Skip to content

Commit

Permalink
Merge pull request #25 from lnbits/add_image_banner
Browse files Browse the repository at this point in the history
allow for an image banner
  • Loading branch information
arcbtc authored Feb 17, 2024
2 parents 07d2f59 + 38951a7 commit 4f5fe80
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
5 changes: 3 additions & 2 deletions crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,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,
Expand Down
7 changes: 7 additions & 0 deletions migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
2 changes: 2 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions templates/events/display.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% extends "public.html" %} {% block page %}
<div class="row q-col-gutter-md justify-center">
<div class="col-12 col-md-7 col-lg-6 q-gutter-y-md">
<q-card class="q-pa-lg">
<q-card>
<q-img v-if="banner" :src="banner" transition="slide-up"></q-img>
<q-card-section class="q-pa-none">
<h3 class="q-my-none">{{ event_name }}</h3>
<h3 class="q-my-none q-pa-lg">{{ event_name }}</h3>
<br />
<div v-html="formatDescription"></div>
<br />
Expand Down Expand Up @@ -125,6 +126,7 @@ <h5 class="q-mt-none">Buy Ticket</h5>
async created() {
this.info = '{{ event_info | tojson }}'
this.info = this.info.substring(1, this.info.length - 1)
this.banner = JSON.parse('{{ event_banner | tojson |safe }}')
await this.purgeUnpaidTickets()
},
computed: {
Expand Down
12 changes: 10 additions & 2 deletions templates/events/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ <h6 class="text-subtitle1 q-my-none">
label="Info about the event"
hint="Markdown supported"
></q-input>
<div class="row">
<q-input
filled
dense
v-model.trim="formDialog.data.banner"
type="url"
label="Image URL"
hint="Optional banner image to display on the event page"
></q-input>
<div class="row q-mt-lg">
<div class="col-4">Ticket closing date</div>
<div class="col-8">
<q-input
Expand Down Expand Up @@ -334,6 +342,7 @@ <h6 class="text-subtitle1 q-my-none">
{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',
Expand Down Expand Up @@ -449,7 +458,6 @@ <h6 class="text-subtitle1 q-my-none">
exportticketsCSV: function () {
LNbits.utils.exportCSV(this.ticketsTable.columns, this.tickets)
},

getEvents: function () {
var self = this

Expand Down
1 change: 1 addition & 0 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)

Expand Down

0 comments on commit 4f5fe80

Please sign in to comment.