mirror of
https://github.com/lnbits/lnbits.git
synced 2025-08-02 23:12:34 +02:00
Working events extension
This commit is contained in:
@@ -1,11 +1,3 @@
|
|||||||
<h1>Example Extension</h1>
|
<h1>Events</h1>
|
||||||
<h2>*tagline*</h2>
|
<h2>Events: Sell and register event tickets</h2>
|
||||||
This is an example extension to help you organise and build you own.
|
Events alows you to make a wave of tickets for an event, each ticket is in the form of a unqiue QRcode, which the user presents at registration. Events comes with a shareable ticket scanner, which can be used to register attendees.
|
||||||
|
|
||||||
Try to include an image
|
|
||||||
<img src="https://i.imgur.com/9i4xcQB.png">
|
|
||||||
|
|
||||||
|
|
||||||
<h2>If your extension has API endpoints, include useful ones here</h2>
|
|
||||||
|
|
||||||
<code>curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"example"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY"</code>
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Events",
|
"name": "Events",
|
||||||
"short_description": "Sell/register event tickets",
|
"short_description": "Sell and register event tickets",
|
||||||
"icon": "local_activity",
|
"icon": "local_activity",
|
||||||
"contributors": ["benarc"]
|
"contributors": ["benarc"]
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ from .models import Tickets, Events
|
|||||||
#######TICKETS########
|
#######TICKETS########
|
||||||
|
|
||||||
|
|
||||||
def create_ticket(wallet: str, event: str, name: str, email: str) -> Tickets:
|
def create_ticket(wallet: str, event: str, name: str, email: str) -> Tickets:
|
||||||
with open_ext_db("events") as db:
|
with open_ext_db("events") as db:
|
||||||
eventdata = get_event(event)
|
eventdata = get_event(event)
|
||||||
sold = eventdata.sold + 1
|
sold = eventdata.sold + 1
|
||||||
@@ -78,6 +78,7 @@ def update_event(event_id: str, **kwargs) -> Events:
|
|||||||
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
|
q = ", ".join([f"{field[0]} = ?" for field in kwargs.items()])
|
||||||
with open_ext_db("events") as db:
|
with open_ext_db("events") as db:
|
||||||
db.execute(f"UPDATE events SET {q} WHERE id = ?", (*kwargs.values(), event_id))
|
db.execute(f"UPDATE events SET {q} WHERE id = ?", (*kwargs.values(), event_id))
|
||||||
|
|
||||||
row = db.fetchone("SELECT * FROM events WHERE id = ?", (event_id,))
|
row = db.fetchone("SELECT * FROM events WHERE id = ?", (event_id,))
|
||||||
|
|
||||||
return Events(**row) if row else None
|
return Events(**row) if row else None
|
||||||
|
@@ -7,21 +7,11 @@
|
|||||||
>
|
>
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<h5 class="text-subtitle1 q-my-none">Events: Sell and register tickets for an event</h5>
|
<h5 class="text-subtitle1 q-my-none">Events: Sell and register ticket waves for an event</h5>
|
||||||
<p>Events alows you to make a wave of tickets for an event. Once an attendee has paid for a ticket they get a unqiue code. Events comes with a shareable scanning frontend, so you can register the attendees<br/>
|
<p>Events alows you to make a wave of tickets for an event, each ticket is in the form of a unqiue QRcode, which the user presents at registration. Events comes with a shareable ticket scanner, which can be used to register attendees.<br/>
|
||||||
<small> Created by, <a href="https://github.com/benarc">Ben Arc</a></small></p>
|
<small> Created by, <a href="https://github.com/benarc">Ben Arc</a></small></p>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-expansion-item>
|
|
||||||
<q-expansion-item
|
|
||||||
group="extras"
|
|
||||||
icon="swap_vertical_circle"
|
|
||||||
label="API info"
|
|
||||||
:content-inset-level="0.5"
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
|
@@ -154,6 +154,7 @@
|
|||||||
axios
|
axios
|
||||||
.post('/events/api/v1/tickets/' + self.paymentCheck, {
|
.post('/events/api/v1/tickets/' + self.paymentCheck, {
|
||||||
event: '{{ event_id }}',
|
event: '{{ event_id }}',
|
||||||
|
event_name: '{{ event_name }}',
|
||||||
name: self.formDialog.data.name,
|
name: self.formDialog.data.name,
|
||||||
email: self.formDialog.data.email
|
email: self.formDialog.data.email
|
||||||
})
|
})
|
||||||
|
@@ -84,6 +84,7 @@
|
|||||||
type="text/css"
|
type="text/css"
|
||||||
href="{{ url_for('static', filename='vendor/vue-qrcode-reader@2.2.0/vue-qrcode-reader.min.css') }}"
|
href="{{ url_for('static', filename='vendor/vue-qrcode-reader@2.2.0/vue-qrcode-reader.min.css') }}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{% endblock %} {% block scripts %}
|
{% endblock %} {% block scripts %}
|
||||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
||||||
{% assets filters='rjsmin', output='__bundle__/core/chart.js',
|
{% assets filters='rjsmin', output='__bundle__/core/chart.js',
|
||||||
@@ -135,6 +136,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
hoverEmail: function (tmp) {
|
||||||
|
this.tickets.data.emailtemp = tmp
|
||||||
|
},
|
||||||
closeCamera: function () {
|
closeCamera: function () {
|
||||||
this.sendCamera.show = false
|
this.sendCamera.show = false
|
||||||
},
|
},
|
||||||
@@ -144,19 +148,21 @@
|
|||||||
decodeQR: function (res) {
|
decodeQR: function (res) {
|
||||||
this.sendCamera.show = false
|
this.sendCamera.show = false
|
||||||
var self = this
|
var self = this
|
||||||
|
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request('GET', '/events/api/v1/register/ticket/' + res)
|
.request('GET', '/events/api/v1/register/ticket/' + res)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
self.$q.notify({
|
||||||
|
type: 'positive',
|
||||||
|
message: 'Registered!'
|
||||||
|
})
|
||||||
self.tickets = response.data.map(function (obj) {
|
self.tickets = response.data.map(function (obj) {
|
||||||
self.$q.notify({
|
|
||||||
timeout: 5,
|
|
||||||
type: 'positive',
|
|
||||||
message: 'Registered!'
|
|
||||||
})
|
|
||||||
return mapEvents(obj)
|
return mapEvents(obj)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
LNbits.utils.notifyApiError(error)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
getEventTickets: function () {
|
getEventTickets: function () {
|
||||||
var self = this
|
var self = this
|
||||||
@@ -171,6 +177,9 @@
|
|||||||
return mapEvents(obj)
|
return mapEvents(obj)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
LNbits.utils.notifyApiError(error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<h3 class="q-my-none">{{ ticket_name }} Ticket</h3>
|
<h3 class="q-my-none">{{ ticket_name }} Ticket</h3>
|
||||||
<br />
|
<br />
|
||||||
<h5 class="q-my-none">
|
<h5 class="q-my-none">
|
||||||
Bookmark or screenshot this page,<br />
|
Bookmark, print or screenshot this page,<br />
|
||||||
and present it for registration!
|
and present it for registration!
|
||||||
</h5>
|
</h5>
|
||||||
<br />
|
<br />
|
||||||
@@ -17,6 +17,10 @@
|
|||||||
:options="{width: 340}"
|
:options="{width: 340}"
|
||||||
class="rounded-borders"
|
class="rounded-borders"
|
||||||
></qrcode>
|
></qrcode>
|
||||||
|
<br />
|
||||||
|
<q-btn @click="printWindow" color="grey" class="q-ml-auto">
|
||||||
|
<q-icon left size="3em" name="print"></q-icon> Print</q-btn
|
||||||
|
>
|
||||||
</center>
|
</center>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
@@ -28,7 +32,15 @@
|
|||||||
Vue.component(VueQrcode.name, VueQrcode)
|
Vue.component(VueQrcode.name, VueQrcode)
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [windowMixin]
|
mixins: [windowMixin],
|
||||||
|
data: function () {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
printWindow: function () {
|
||||||
|
window.print()
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -155,6 +155,15 @@ def api_event_tickets(wallet_id, event_id):
|
|||||||
|
|
||||||
@events_ext.route("/api/v1/register/ticket/<ticket_id>", methods=["GET"])
|
@events_ext.route("/api/v1/register/ticket/<ticket_id>", methods=["GET"])
|
||||||
def api_event_register_ticket(ticket_id):
|
def api_event_register_ticket(ticket_id):
|
||||||
|
|
||||||
|
ticket = get_ticket(ticket_id)
|
||||||
|
|
||||||
|
if not ticket:
|
||||||
|
return jsonify({"message": "Ticket does not exist."}), HTTPStatus.FORBIDDEN
|
||||||
|
|
||||||
|
if ticket.registered == True:
|
||||||
|
return jsonify({"message": "Ticket already registered"}), HTTPStatus.FORBIDDEN
|
||||||
|
|
||||||
|
|
||||||
return jsonify([ticket._asdict() for ticket in reg_ticket(ticket_id)]), HTTPStatus.OK
|
return jsonify([ticket._asdict() for ticket in reg_ticket(ticket_id)]), HTTPStatus.OK
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user