From bcb59fd7a015fafca0b1647b5dc4a3fbc49b4df8 Mon Sep 17 00:00:00 2001 From: timurgordon Date: Wed, 26 Oct 2022 08:53:38 +0300 Subject: [PATCH] fixes and updates to registration --- index.html | 3 ++- templates/full.html | 4 ++++ templates/ticket_back.html | 15 ------------- templates/ticket_front.html | 24 --------------------- templates/tickets.html | 1 - ticket.v | 43 ++++++++++++------------------------- 6 files changed, 20 insertions(+), 70 deletions(-) create mode 100644 templates/full.html delete mode 100644 templates/ticket_back.html delete mode 100644 templates/ticket_front.html delete mode 100644 templates/tickets.html diff --git a/index.html b/index.html index aa2247b..2960597 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,6 @@ + @@ -25,7 +26,7 @@
- +
diff --git a/templates/full.html b/templates/full.html new file mode 100644 index 0000000..17db251 --- /dev/null +++ b/templates/full.html @@ -0,0 +1,4 @@ +
+ Unfortunately the capacity for this event is filled. + We will send you an email if there is more space available. +
diff --git a/templates/ticket_back.html b/templates/ticket_back.html deleted file mode 100644 index 6ef690d..0000000 --- a/templates/ticket_back.html +++ /dev/null @@ -1,15 +0,0 @@ -
-
-

Ourworld ICTC Event

-

-
-
- -
-
- -
-
- -
-
\ No newline at end of file diff --git a/templates/ticket_front.html b/templates/ticket_front.html deleted file mode 100644 index 1c04abf..0000000 --- a/templates/ticket_front.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
-

Ourworld ICTC Event

-

running rice valley hide speech roof accident full involved wide rather order good hidden horse home graph did model perhaps worry volume collect put

-
- -
-

Sponsors

-
-
- -
-
-

Register

-

dangerous shadow exclaimed stopped sale easy find add ago cold hard satisfied bent month sing frighten will flag shorter cage period doing successful husband

-
- QR Code -
-
- -
-
- - diff --git a/templates/tickets.html b/templates/tickets.html deleted file mode 100644 index 281c686..0000000 --- a/templates/tickets.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/ticket.v b/ticket.v index 83bcb66..f4c2a86 100644 --- a/ticket.v +++ b/ticket.v @@ -3,33 +3,7 @@ module main import vweb import os import json - -pub fn ticket_front(qr string) string { - slug := qr.all_after_last('_') - return $tmpl('templates/ticket_front.html') -} - -pub fn run_before() { - - mut qr_paths := os.walk_ext('qrs', 'png') - mut html := '' - os.rm('templates/tickets.html') or { panic(err) } - mut index_file := os.create('templates/tickets.html') or { - panic('Failed to create index.html file: $err') - } - println('debug:${typeof(index_file)}') - println('debug: ${ticket_front('test')}') - index_file.write_string('
') or { panic('Failed to write
to index.html file: $err') } - for qr in qr_paths { - index_file.write_string(ticket_front(qr)) or { - panic('Failed to write qr: $qr to index.html file: $err') - } - } - index_file.write_string('
') or { - panic('Failed to write
to index.html file: $err') - } - index_file.close() -} +import time pub struct App { vweb.Context @@ -43,7 +17,6 @@ pub fn new_app() &App { } pub fn main() { - run_before() mut app := new_app() vweb.run(app, 8000) } @@ -59,24 +32,36 @@ pub struct Registration { org_website string plus_one string receive_communication string + timestamp time.Time } pub fn (mut app App) exists() vweb.Result { return $vweb.html() } +pub fn (mut app App) full() vweb.Result { + return $vweb.html() +} + ['/register'; post] pub fn (mut app App) register(name string, email string, org_website string, plus_one string, receive_communication string) vweb.Result { - println(app.req.data) + files := os.ls('registrations') or { [] } + // if files.len > 1000 { + // return full() + // } registration := Registration { name: name, email: email, org_website: org_website, plus_one: plus_one, receive_communication: receive_communication, + timestamp: time.now() } path := 'registrations/${email}.txt' if os.exists(path) { return app.exists()} os.write_file(path, json.encode(registration)) or {println('error')} + if files.len > 200 { + return app.full() + } return $vweb.html() } \ No newline at end of file