top of page

PAGE UNDER CONSTRUCTION

Requirements for the Bulletin Upload Version 1.0

I am a novice use who has little velo developer experience. Plese provide clear instructions and code for me to cut and paste into the web site.

  1. A page where the bulletin can be uploaded

    1. This page should only be accessible by site members​

    2. When the page is loaded it should produce information about who is using the page (the Wix ID) and their Wix role.

    3. There should be a button to allow the user to select a file to upload.

      1. The file name should be displayed with a correction facility.​

    4. There should be a button which enables the upload.​

    5. Status and error messages should be displayed.

    6. The specified file should be uploaded to a CMS dataset where the <current file> is stored.

    7. The specified file should be added to a second CMS dataset which contains the following information:

      1. Date and time of upload

      2. ID of Uploader

      3. Name of Uploaded file

      4. URL of uploaded file to allow downloads.

  2. I need instructions on how to add a button to an existing page which allows anyone to download the <current file>.

  3. A set of unit tests for all of these functions

  4. A set of complete function tests of the whole suite.

  5. A set of test for each time the Bulleting is uploaded

  6. Please provide an updated set of requirements as they evolve. This should be sufficient to allow me to restart this conversation with Claude if I need to change something later.

  7. Please provide documentation at the end of the process.

Here is the full updated requirements document incorporating everything so far:

BULLETIN UPLOAD SYSTEM — REQUIREMENTS v1.3

CONTEXT

This is a Wix Velo website. The developer is a novice Velo user. All code must be copy-paste ready with clear step-by-step instructions. Web modules (.web.js) are used instead of the deprecated .jsw files. All exported backend functions must have "use server" as the very first line. All page code files must have "use client" as the very first line.

CMS COLLECTIONS

1. CurrentBulletin

Stores exactly one record (the current bulletin).

FieldType

fileNameText

fileUrlURL

uploadedAtDate

uploadedByText

Permissions: Admin and Collaborators only.

2. BulletinHistory

Stores all uploads as a full log. Records are never deleted.

FieldType

fileNameText

fileUrlURL

uploadedAtDate

uploadedByText

Permissions: Admin and Collaborators only.

BACKEND FILE: bulletin.web.js

Location: backend/bulletin.web.js

This file runs securely on the server and is called from page code. It must begin with "use server" as the very first line.

Functions

saveCurrentBulletin(fileName, fileUrl, memberId) Saves the uploaded file as the new current bulletin. Clears all existing records from CurrentBulletin and inserts the new one, ensuring only one record ever exists.

addToHistory(fileName, fileUrl, memberId) Inserts a new record into BulletinHistory. This log is never cleared.

getCurrentBulletin() Returns the current bulletin record (most recent by uploadedAt), or null if none exists.

getBulletinHistory() Returns up to 100 bulletin history records, newest first.

Current Code (v1.0)

js

"use server"; // backend/bulletin.web.js import wixData from 'wix-data'; export async function saveCurrentBulletin(fileName, fileUrl, memberId) { try { const existing = await wixData.query('CurrentBulletin').find(); for (const item of existing.items) { await wixData.remove('CurrentBulletin', item._id); } await wixData.insert('CurrentBulletin', { fileName: fileName, fileUrl: fileUrl, uploadedAt: new Date(), uploadedBy: memberId, }); return { success: true }; } catch (err) { console.error('saveCurrentBulletin error:', err); return { success: false, error: err.message }; } } export async function addToHistory(fileName, fileUrl, memberId) { try { await wixData.insert('BulletinHistory', { fileName: fileName, fileUrl: fileUrl, uploadedAt: new Date(), uploadedBy: memberId, }); return { success: true }; } catch (err) { console.error('addToHistory error:', err); return { success: false, error: err.message }; } } export async function getCurrentBulletin() { try { const result = await wixData .query('CurrentBulletin') .descending('uploadedAt') .limit(1) .find(); return result.items.length > 0 ? result.items[0] : null; } catch (err) { console.error('getCurrentBulletin error:', err); return null; } } export async function getBulletinHistory() { try { const result = await wixData .query('BulletinHistory') .descending('uploadedAt') .limit(100) .find(); return result.items; } catch (err) { console.error('getBulletinHistory error:', err); return []; } }

PAGES REQUIRED

Page 1: Bulletin Upload Page

Access: Members only (site members login required). Non-members are redirected or shown an access denied message.

On page load, display:

  • The current user's Wix member ID

  • The current user's Wix role

Page elements:

  1. A file selector button allowing the user to choose a file to upload.

  2. Display of the selected file name, with the ability to correct/change it before uploading.

  3. An Upload button that triggers the upload process.

  4. A status/message area that displays progress, success, and error messages.

On upload:

  1. The selected file is uploaded to Wix Media.

  2. saveCurrentBulletin() is called to store the file as the current bulletin (replacing any previous record).

  3. addToHistory() is called to add a permanent log entry to BulletinHistory.

  4. Success or failure is reported to the user via the status area.

Page 2: Download Button (added to an existing page)

Access: Open to all visitors (no login required).

Requirements:

  • Clear step-by-step instructions for adding a Download Current Bulletin button to an existing Wix page.

  • On click, the button retrieves the current bulletin URL via getCurrentBulletin() and opens or downloads the file.

  • If no bulletin exists, a suitable message is shown.

TESTING REQUIREMENTS

Unit Tests

A unit test for each individual backend function:

  • saveCurrentBulletin() — verify it clears old records and inserts the new one correctly.

  • addToHistory() — verify a new history record is inserted with correct fields.

  • getCurrentBulletin() — verify it returns the most recent record, or null if empty.

  • getBulletinHistory() — verify it returns records in descending date order.

Full System / Integration Tests

End-to-end tests covering the complete upload flow:

  • User loads upload page → member info is displayed correctly.

  • User selects a file → file name is displayed.

  • User clicks Upload → file uploads, CurrentBulletin is updated, BulletinHistory gains a new entry.

  • Download button on existing page retrieves and opens the correct current file.

Per-Upload Regression Tests

A checklist or test script to run each time a bulletin is uploaded, verifying:

  • CurrentBulletin contains exactly one record after upload.

  • The new record has the correct fileName, fileUrl, uploadedAt, and uploadedBy.

  • BulletinHistory has gained exactly one new record matching the upload.

  • The download button on the public page retrieves the newly uploaded file.

ONGOING REQUIREMENTS

  • All code must be copy-paste ready with clear step-by-step instructions suitable for a novice Velo user.

  • Requirements must be kept up to date as the system evolves, sufficient to restart a conversation with Claude and continue development.

  • Full documentation to be provided at the conclusion of development, covering: system overview, CMS structure, all files and their purpose, how to use the upload page, how to add the download button, and how to run tests.

Version history:

  • v1.0 — Initial requirements stated by developer.

  • v1.2 — CMS collections defined, web module approach established, "use server" / "use client" directives specified.

  • v1.3 — Backend file bulletin.web.js documented with full code. All prior requirements consolidated into this single document.

135 High St, Sawston,

Cambridge CB22 3HJ, UK

01223 832397 / 07754 227468

bottom of page