Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
9ec1afb
feat(labels): the bazaar decides whether labels carry the seller number
Garaz08 Nov 2, 2026
67db16a
fix(events): address everywhere, drafts that stay out of the way, pag…
Garaz08 Nov 2, 2026
7117367
feat(labels): universal labels for many small items, start place on t…
Garaz08 Nov 2, 2026
c1d3f01
feat(events): universal labels by default for kids and clothing bazaars
Garaz08 Nov 2, 2026
d00c820
feat(demo): seed universal labels, QR-only labels and venue addresses
Garaz08 Nov 2, 2026
66fc794
feat(marketing): explain universal labels on the public pages
Garaz08 Nov 2, 2026
89d84a4
feat(account): country selector in the profile and the join wizard
Garaz08 Nov 3, 2026
db944e8
Merge remote-tracking branch 'origin/development' into feat/universal…
Garaz08 Nov 4, 2026
a3c4edc
feat(labels): one QR component, lasting sort marks without the seller…
Garaz08 Nov 4, 2026
71d1f1a
test(account): find the digital ID by the role of the QR code
Garaz08 Nov 4, 2026
6f333c9
feat(labels): random sorting codes, cut lines and a framed mark
Garaz08 Nov 4, 2026
bbe353e
feat(labels): sellers and the team print a label for the basket
Garaz08 Nov 4, 2026
18385e0
feat(labels): basket label in the seller's intake details, letters mo…
Garaz08 Nov 4, 2026
dd56a5d
Merge remote-tracking branch 'origin/development' into feat/universal…
Garaz08 Nov 4, 2026
b4fc4c1
feat(labels): the team exports the labels of all sellers of a bazaar
Garaz08 Nov 4, 2026
c94a061
test(labels): the batch test no longer builds 1200 labels
Garaz08 Nov 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/migrations/0017_user_sort_code.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- A number that stays with a seller across all bazaars. Universal labels print it as a
-- digit, symbols and colors (src/shared/sortCode.ts), so they can be reused. Numbers are
-- not given out again, also after an account is deleted.
ALTER TABLE users ADD COLUMN sort_code integer GENERATED BY DEFAULT AS IDENTITY UNIQUE;
13 changes: 13 additions & 0 deletions backend/migrations/0018_user_country_code.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Profile countries were free text; now they are ISO 3166-1 alpha-2 codes like those of events.
-- Other values stay as they are and keep being shown as typed. Snapshots of sellers keep what
-- was true when they were taken.
UPDATE users SET country = CASE
WHEN lower(trim(country)) IN ('de', 'd', 'deu', 'ger', 'brd', 'deutschland', 'germany') THEN 'DE'
-- translate: lower() leaves Ö alone in databases with the C locale
WHEN translate(lower(trim(country)), 'Ö', 'ö') IN ('at', 'a', 'aut', 'österreich', 'oesterreich', 'austria') THEN 'AT'
WHEN lower(trim(country)) IN ('ch', 'che', 'schweiz', 'switzerland', 'suisse', 'svizzera') THEN 'CH'
WHEN lower(trim(country)) IN ('li', 'lie', 'liechtenstein') THEN 'LI'
WHEN lower(trim(country)) IN ('lu', 'lux', 'luxemburg', 'luxembourg') THEN 'LU'
ELSE country
END
WHERE country IS NOT NULL;
32 changes: 32 additions & 0 deletions backend/migrations/0020_sort_code_for_sellers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- Sorting codes are for sellers. A buyer without items must not use up one of the codes
-- that need no extra letter, so a code is given with the first item or bazaar. Codes are
-- never given out again, not even after an account is deleted: printed labels may still
-- carry them.
ALTER TABLE users ALTER COLUMN sort_code DROP IDENTITY;
ALTER TABLE users ALTER COLUMN sort_code DROP NOT NULL;
UPDATE users SET sort_code = NULL;

CREATE SEQUENCE users_sort_code_seq OWNED BY users.sort_code;

WITH sellers AS (
SELECT id FROM users u
WHERE EXISTS (SELECT 1 FROM products p WHERE p.vendor_id = u.id)
OR EXISTS (SELECT 1 FROM event_sellers s WHERE s.user_id = u.id)
ORDER BY created_at, id
), numbered AS (
SELECT id, nextval('users_sort_code_seq')::integer AS code FROM sellers
)
UPDATE users u SET sort_code = n.code FROM numbered n WHERE n.id = u.id;

CREATE FUNCTION give_sort_code() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
UPDATE users SET sort_code = nextval('users_sort_code_seq')
WHERE id = (to_jsonb(NEW) ->> TG_ARGV[0])::uuid AND sort_code IS NULL;
RETURN NULL;
END;
$$;

CREATE TRIGGER products_give_sort_code AFTER INSERT OR UPDATE OF vendor_id ON products
FOR EACH ROW EXECUTE FUNCTION give_sort_code('vendor_id');
CREATE TRIGGER event_sellers_give_sort_code AFTER INSERT ON event_sellers
FOR EACH ROW EXECUTE FUNCTION give_sort_code('user_id');
46 changes: 46 additions & 0 deletions backend/migrations/0021_random_sort_codes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- A code must not tell when an account was made, and a new bazaar must not start at 00 00:
-- codes are drawn at random. A code without a letter is drawn while one is easy to find,
-- then one with the next letter (see src/shared/sortCode.ts). Codes stay unique and are
-- never given out again. No labels were printed with the numbers before.
CREATE FUNCTION assign_sort_code(seller uuid) RETURNS void LANGUAGE plpgsql AS $$
DECLARE
patterns CONSTANT integer := 100000;
tries_per_letter CONSTANT integer := 20;
letter integer := 0;
candidate integer;
BEGIN
LOOP
FOR try IN 1..tries_per_letter LOOP
candidate := letter * patterns + floor(random() * patterns)::integer;
BEGIN
UPDATE users SET sort_code = candidate WHERE id = seller AND sort_code IS NULL;
RETURN;
EXCEPTION WHEN unique_violation THEN
NULL; -- Taken: draw again
END;
END LOOP;
letter := letter + 1;
END LOOP;
END;
$$;

CREATE OR REPLACE FUNCTION give_sort_code() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
PERFORM assign_sort_code((to_jsonb(NEW) ->> TG_ARGV[0])::uuid);
RETURN NULL;
END;
$$;

DO $$
DECLARE
seller uuid;
BEGIN
CREATE TEMP TABLE sellers ON COMMIT DROP AS SELECT id FROM users WHERE sort_code IS NOT NULL;
UPDATE users SET sort_code = NULL;
FOR seller IN SELECT id FROM sellers LOOP
PERFORM assign_sort_code(seller);
END LOOP;
END;
$$;

DROP SEQUENCE users_sort_code_seq;
6 changes: 3 additions & 3 deletions backend/src/demo/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ pub fn city(locale: Locale, index: usize) -> City {
City {
zip: "89073",
name: "Ulm",
country: "Deutschland",
country: "DE",
},
City {
zip: "89231",
name: "Neu-Ulm",
country: "Deutschland",
country: "DE",
},
City {
zip: "89077",
name: "Ulm",
country: "Deutschland",
country: "DE",
},
];
const EN: [City; 3] = [
Expand Down
2 changes: 1 addition & 1 deletion backend/src/demo/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ pub async fn insert_users(seeder: &Seeder, ctx: &mut Ctx) -> AppResult<CoreUsers
),
zip_code: Some(seeder.text(t("89073", "OX1 2JD"))),
city: Some(seeder.text(t("Ulm", "Oxford"))),
country: Some(seeder.text(t("Deutschland", "United Kingdom"))),
country: Some(seeder.text(t("DE", "United Kingdom"))),
..UserSpec::simple("seller@bazarpro.de", "Demo Seller")
},
)
Expand Down
54 changes: 50 additions & 4 deletions backend/src/demo/extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,21 @@ struct Demo<'a> {
single: bool,
}

/// Address of the venue. Empty parts in English: the address form knows no British towns,
/// those demos keep it all in the location, as older events do.
struct Venue {
street: Text,
postal_code: Text,
city: Text,
country: &'static str,
}

struct EventPlan {
organizer: Uuid,
title: Text,
description: Text,
location: Text,
address: Option<Venue>,
contact: &'static str,
services: &'static [&'static str],
visibility: &'static str,
Expand Down Expand Up @@ -239,6 +249,14 @@ impl Demo<'_> {
"commission": plan.commission,
"features": plan.features,
});
if let Some(venue) = &plan.address {
args["address"] = json!({
"street": self.text(venue.street),
"postalCode": self.text(venue.postal_code),
"city": self.text(venue.city),
"country": venue.country,
});
}
if let Some(cover) = self.seeder.image(plan.cover) {
args["coverImage"] = json!(cover);
}
Expand Down Expand Up @@ -659,9 +677,15 @@ async fn kids_bazaar(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Second-hand bazaar for children's clothes, toys, books and prams. Run by the parents' council, 15 % go to the nursery. With a cake buffet!\n\nDrop-off the day before, unsold items can be picked up from 3 pm.",
),
location: t(
"Kita Sonnenschein, Turnraum, Lindenstraße 4, Ulm",
"Kita Sonnenschein, Turnraum",
"Sunshine Nursery, gym, 4 Linden Street, Oxford",
),
address: Some(Venue {
street: t("Lindenstraße 4", ""),
postal_code: t("89073", ""),
city: t("Ulm", ""),
country: "DE",
}),
contact: "elternbeirat@example.org",
services: &["Imbiss", "Getränke"],
visibility: "public",
Expand All @@ -678,6 +702,7 @@ async fn kids_bazaar(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"minimumPrice": true,
"questions": true,
"labelFormat": "small",
"labelMark": "universal",
"intakeFee": 0.5,
"privateSellersOnly": true,
"fixedSellerData": true,
Expand Down Expand Up @@ -948,9 +973,15 @@ async fn ski_bazaar(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Used skis, snowboards, boots, helmets and winter clothing. Our instructors help you choose, and the waxing service is on site.\n\nSellers register with the access code from the club newsletter.",
),
location: t(
"Mehrzweckhalle Blaustein, Am Sportplatz 2",
"Mehrzweckhalle Blaustein",
"Blue Valley sports hall, 2 Sports Ground Road",
),
address: Some(Venue {
street: t("Am Sportplatz 2", ""),
postal_code: t("89134", ""),
city: t("Blaustein", ""),
country: "DE",
}),
contact: "skibasar@example.org",
services: &["Parkplatz", "Skiservice", "Getränke"],
visibility: "public",
Expand Down Expand Up @@ -1096,9 +1127,15 @@ async fn flea_market(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Flea market in the courtyard of the community centre: household goods, furniture, electronics, bikes and clothes. Coffee and waffles from the neighbourhood café.",
),
location: t(
"Stadtteiltreff Südstadt, Gartenweg 12",
"Stadtteiltreff Südstadt",
"Southside community centre, 12 Garden Lane",
),
address: Some(Venue {
street: t("Gartenweg 12", ""),
postal_code: t("89077", ""),
city: t("Ulm", ""),
country: "DE",
}),
contact: "suedstadt@example.org",
services: &["Gastronomie"],
visibility: "public",
Expand All @@ -1114,6 +1151,8 @@ async fn flea_market(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"priceOffers": true,
"minimumPrice": true,
"questions": true,
// Only the QR code: sellers bring the labels of their last flea market
"labelMark": "none",
}),
},
true,
Expand Down Expand Up @@ -1290,6 +1329,12 @@ async fn book_market(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()>
"Second-hand books for a good cause: novels, non-fiction and children's books. Proceeds go to reading programmes.",
),
location: t("Stadtbibliothek, Foyer", "City library, foyer"),
address: Some(Venue {
street: t("Kirchstraße 12", "Kirchstraße 12"),
postal_code: t("6900", "6900"),
city: t("Bregenz", "Bregenz"),
country: "AT",
}),
contact: "bibliothek@example.org",
services: &["Getränke"],
visibility: "public",
Expand Down Expand Up @@ -1354,6 +1399,7 @@ async fn other_events(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()
title,
description,
location,
address: None,
contact: "kontakt@example.org",
services: &[],
visibility: "public",
Expand Down Expand Up @@ -1431,7 +1477,7 @@ async fn other_events(demo: &mut Demo<'_>, people: &People) -> anyhow::Result<()
vendor_limit: Some(3),
visibility: "logged-in",
categories: &[Cat::Clothing, Cat::Shoes],
features: json!({ "discounts": false, "labelFormat": "small" }),
features: json!({ "discounts": false, "labelFormat": "small", "labelMark": "universal" }),
..plan(
sabine,
t("Kleiderbasar Gemeindehaus", "Parish Hall Clothes Sale"),
Expand Down
11 changes: 11 additions & 0 deletions backend/src/modules/event_roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use uuid::Uuid;

use super::access::is_platform_admin;
use super::docs::{self, User};
use super::features::label_mark;
use super::labels::seller_sort_code;
use super::sales::{self, IntakeFee};
use super::seller_records::{keeps_seller_record, with_snapshot};
use crate::error::{AppError, AppResult};
Expand Down Expand Up @@ -257,6 +259,8 @@ pub struct VendorWithCalculations {
pub is_helper: bool,
/// Seller number of this event; missing for sellers from before numbers existed
pub seller_number: Option<i32>,
/// The seller's lasting code, on bazaars with universal labels
pub sort_code: Option<i32>,
/// Bazaars with fixedSellerData: name and address are recorded (first item accepted).
/// Before, the team checks them against the ID card and the seller may still correct them.
pub details_recorded: Option<bool>,
Expand Down Expand Up @@ -304,6 +308,7 @@ pub async fn load_vendors_with_calculations(
let users = docs::users(ctx.conn(), &vendor_ids).await?;
let over = event.end_date < Utc::now();
let keeps_record = keeps_seller_record(&event);
let universal = label_mark(&event) == "universal";
for vendor in vendor_ids {
let Some(mut user) = users.iter().find(|user| user.id == vendor).cloned() else {
continue;
Expand All @@ -328,6 +333,11 @@ pub async fn load_vendors_with_calculations(
seller.as_ref(),
accepted.get(&vendor).copied().unwrap_or(0),
);
let sort_code = if universal {
seller_sort_code(ctx, vendor).await?
} else {
None
};
vendors.push(VendorWithCalculations {
user,
total_revenue,
Expand All @@ -344,6 +354,7 @@ pub async fn load_vendors_with_calculations(
.is_some_and(|seller| seller.seller_snapshot.is_some())
}),
seller_number: seller.and_then(|seller| seller.number),
sort_code,
});
}
Ok(vendors)
Expand Down
22 changes: 21 additions & 1 deletion backend/src/modules/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const SERVICES: [&str; 5] = [
];
const VISIBILITIES: [&str; 3] = ["public", "logged-in", "approved"];
const LABEL_FORMATS: [&str; 2] = ["standard", "small"];
const LABEL_MARKS: [&str; 2] = ["universal", "none"];
/// What viewers outside the team see instead of the access code
const HIDDEN_ACCESS_CODE: &str = "••••";

Expand Down Expand Up @@ -672,6 +673,7 @@ struct FeaturesArgs {
max_items_per_seller: Option<f64>,
label_format: Option<String>,
price_on_label: Option<bool>,
label_mark: Option<String>,
intake_fee: Option<f64>,
private_sellers_only: Option<bool>,
fixed_seller_data: Option<bool>,
Expand Down Expand Up @@ -717,6 +719,11 @@ fn sanitize_features(features: FeaturesArgs, previous: Option<&Value>) -> AppRes
{
return Err(invalid("labelFormat"));
}
if let Some(mark) = &features.label_mark
&& !LABEL_MARKS.contains(&mark.as_str())
{
return Err(invalid("labelMark"));
}
let previous_bool = |key: &str| previous.and_then(|p| p.get(key)).and_then(Value::as_bool);
let required_fields: Option<Vec<String>> = match features.required_fields {
Some(fields) => fields,
Expand Down Expand Up @@ -795,6 +802,18 @@ fn sanitize_features(features: FeaturesArgs, previous: Option<&Value>) -> AppRes
"priceOnLabel",
json!(features.price_on_label.unwrap_or(false)),
);
put(
"labelMark",
json!(
features
.label_mark
.or_else(|| previous
.and_then(|p| p.get("labelMark"))
.and_then(Value::as_str)
.map(str::to_owned))
.unwrap_or_else(|| "number".to_owned())
),
);
put(
"intakeFee",
json!(sanitize_intake_fee(features.intake_fee)?),
Expand Down Expand Up @@ -1600,7 +1619,7 @@ mod tests {
intake_fee: Some(0.555),
..FeaturesArgs::default()
},
Some(&json!({ "fixedSellerData": true })),
Some(&json!({ "fixedSellerData": true, "labelMark": "universal" })),
)
.unwrap();
assert_eq!(stored["discounts"], false);
Expand All @@ -1609,6 +1628,7 @@ mod tests {
assert_eq!(stored["intakeFee"], 0.56);
// Not sent by an older client: kept
assert_eq!(stored["fixedSellerData"], true);
assert_eq!(stored["labelMark"], "universal");
assert_eq!(stored["labelFormat"], "standard");
}

Expand Down
Loading
Loading