From a25bf3a9c94021424fb0a22e467102adc080e327 Mon Sep 17 00:00:00 2001 From: "Troll (Hermes Agent)" Date: Tue, 4 Aug 2026 17:17:57 +0000 Subject: [PATCH] Add admin Pricing page with fixed and custom items --- app.py | 46 ++++++++++++++ templates/admin/dashboard.html | 3 +- templates/admin/pricing.html | 108 +++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 templates/admin/pricing.html diff --git a/app.py b/app.py index dc83d69..3230861 100644 --- a/app.py +++ b/app.py @@ -801,6 +801,52 @@ def admin_sales(): return render_template('admin/sales.html', sales=sales, statuses=STATUS_LABELS) +@app.route('/admin/pricing', methods=['GET', 'POST']) +def admin_pricing(): + """ + Pricing configuration page. + Fixed items: one_song, both_songs, wav_per_song, stems_per_song. + Plus up to 5 custom name/price pairs. + """ + redir = require_admin() + if redir: + return redir + + fixed_keys = ['one_song', 'both_songs', 'wav_per_song', 'stems_per_song'] + custom_count = 5 + + cfg = load_booth_settings() + if 'pricing' not in cfg: + cfg['pricing'] = {} + + if request.method == 'POST': + pricing = {} + for key in fixed_keys: + pricing[key] = request.form.get(key, '').strip() + for i in range(1, custom_count + 1): + name = request.form.get(f'custom_name_{i}', '').strip() + price = request.form.get(f'custom_price_{i}', '').strip() + if name: + pricing[f'custom_{i}'] = {'name': name, 'price': price} + else: + pricing[f'custom_{i}'] = None + cfg['pricing'] = pricing + save_booth_settings(cfg) + flash('Pricing saved.', 'success') + return redirect(url_for('admin_pricing')) + + pricing = cfg.get('pricing', {}) + fixed = {key: pricing.get(key, '') for key in fixed_keys} + customs = [] + for i in range(1, custom_count + 1): + entry = pricing.get(f'custom_{i}') + customs.append({ + 'name': entry.get('name', '') if isinstance(entry, dict) else '', + 'price': entry.get('price', '') if isinstance(entry, dict) else '' + }) + return render_template('admin/pricing.html', fixed=fixed, customs=customs) + + @app.route('/admin/request/', methods=['GET', 'POST']) def admin_request(rid): """ diff --git a/templates/admin/dashboard.html b/templates/admin/dashboard.html index 63bdbda..d3624f0 100644 --- a/templates/admin/dashboard.html +++ b/templates/admin/dashboard.html @@ -110,8 +110,9 @@
- +
+ Pricing Sales Settings Log out diff --git a/templates/admin/pricing.html b/templates/admin/pricing.html new file mode 100644 index 0000000..97dba3b --- /dev/null +++ b/templates/admin/pricing.html @@ -0,0 +1,108 @@ + + + + + + Pricing — Admin + + + +
+ + +

Pricing

+ + {% with messages = get_flashed_messages(with_categories=true) %} + {% for category, message in messages %} +
{{ message }}
+ {% endfor %} + {% endwith %} + +
+

Standard Items

+

Leave blank to hide a price. Enter numbers only or include currency symbols as you prefer.

+ + + + + + + + + + + + + +

Custom Items

+ {% for c in customs %} +
+
+ + +
+
+ + +
+
+ {% endfor %} + + +
+
+ +