From ae8930f884ca2bdaf810bd3e110387a1bfbb91a3 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Wed, 31 Jan 2024 13:15:52 +0000 Subject: [PATCH] allow for an image banner --- crud.py | 5 +++-- migrations.py | 7 +++++++ models.py | 2 ++ templates/events/display.html | 6 ++++-- templates/events/index.html | 12 ++++++++++-- views.py | 1 + 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/crud.py b/crud.py index 0d9c25b..ed4857c 100644 --- a/crud.py +++ b/crud.py @@ -92,14 +92,15 @@ async def create_event(data: CreateEvent) -> Event: event_id = urlsafe_short_hash() await db.execute( """ - INSERT INTO events.events (id, wallet, name, info, closing_date, event_start_date, event_end_date, currency, amount_tickets, price_per_ticket, sold) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + INSERT INTO events.events (id, wallet, name, info, banner, closing_date, event_start_date, event_end_date, currency, amount_tickets, price_per_ticket, sold) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( event_id, data.wallet, data.name, data.info, + data.banner, data.closing_date, data.event_start_date, data.event_end_date, diff --git a/migrations.py b/migrations.py index 8052e3f..87a0dd4 100644 --- a/migrations.py +++ b/migrations.py @@ -153,3 +153,10 @@ async def m004_add_currency(db): ) await db.execute("DROP TABLE events.events_old") + + +async def m005_add_image_banner(db): + """ + Add a column to allow an image banner for the event + """ + await db.execute("ALTER TABLE events.events ADD COLUMN banner TEXT;") diff --git a/models.py b/models.py index 2798c12..2b24098 100644 --- a/models.py +++ b/models.py @@ -7,6 +7,7 @@ class CreateEvent(BaseModel): wallet: str name: str info: str + banner: Optional[str] closing_date: str event_start_date: str event_end_date: str @@ -25,6 +26,7 @@ class Event(BaseModel): wallet: str name: str info: str + banner: Optional[str] closing_date: str event_start_date: str event_end_date: str diff --git a/templates/events/display.html b/templates/events/display.html index 60ec944..840d15c 100644 --- a/templates/events/display.html +++ b/templates/events/display.html @@ -1,9 +1,10 @@ {% extends "public.html" %} {% block page %}
- + + -

{{ event_name }}

+

{{ event_name }}



@@ -124,6 +125,7 @@
Buy Ticket
created() { this.info = '{{ event_info | tojson }}' this.info = this.info.substring(1, this.info.length - 1) + this.banner = JSON.parse('{{ event_banner | tojson |safe }}') }, computed: { formatDescription() { diff --git a/templates/events/index.html b/templates/events/index.html index cf3bbba..a5f127d 100644 --- a/templates/events/index.html +++ b/templates/events/index.html @@ -209,7 +209,15 @@
label="Info about the event" hint="Markdown supported" > -
+ +
Ticket closing date
{name: 'id', align: 'left', label: 'ID', field: 'id'}, {name: 'name', align: 'left', label: 'Name', field: 'name'}, {name: 'info', align: 'left', label: 'Info', field: 'info'}, + {name: 'banner', align: 'left', label: 'Banner', field: 'banner'}, { name: 'event_start_date', align: 'left', @@ -447,7 +456,6 @@
exportticketsCSV: function () { LNbits.utils.exportCSV(this.ticketsTable.columns, this.tickets) }, - getEvents: function () { var self = this diff --git a/views.py b/views.py index 4ed5679..082c5a6 100644 --- a/views.py +++ b/views.py @@ -58,6 +58,7 @@ async def display(request: Request, event_id): "event_name": event.name, "event_info": event.info, "event_price": event.price_per_ticket, + "event_banner": event.banner, }, )