fixes and updates to registration
This commit is contained in:
parent
ace50ee568
commit
bcb59fd7a0
@ -1,5 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/index.css" />
|
<link rel="stylesheet" type="text/css" href="/static/css/index.css" />
|
||||||
<script src="/static/htmx.min.js"></script>
|
<script src="/static/htmx.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
@ -25,7 +26,7 @@
|
|||||||
<input id="name" name="name" aria-label="Name" class="appearance-none block w-full mt-1 px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="Name Surname" />
|
<input id="name" name="name" aria-label="Name" class="appearance-none block w-full mt-1 px-3 py-3 border border-gray-300 text-base leading-6 rounded-md placeholder-gray-500 shadow-sm focus:outline-none focus:placeholder-gray-400 focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:flex-1" placeholder="Name Surname" />
|
||||||
</div>
|
</div>
|
||||||
<div class="md:ml-2">
|
<div class="md:ml-2">
|
||||||
<label for="company_website" class="block text-sm font-medium leading-5 text-gray-700">Organization Website</label>
|
<label for="company_website" class="mt-1 lg:mt-0 block text-sm font-medium leading-5 text-gray-700">Organization Website</label>
|
||||||
<div class="mt-1 relative rounded-md shadow-sm">
|
<div class="mt-1 relative rounded-md shadow-sm">
|
||||||
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||||
<span class="text-gray-500 sm:text-base sm:leading-5">
|
<span class="text-gray-500 sm:text-base sm:leading-5">
|
||||||
|
4
templates/full.html
Normal file
4
templates/full.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<div class="relative pt-6 pb-8 text-red-600 font-medium">
|
||||||
|
Unfortunately the capacity for this event is filled.
|
||||||
|
We will send you an email if there is more space available.
|
||||||
|
</div>
|
@ -1,15 +0,0 @@
|
|||||||
<div class="ticket_container">
|
|
||||||
<div>
|
|
||||||
<h1>Ourworld ICTC Event</h1>
|
|
||||||
<p></p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,24 +0,0 @@
|
|||||||
<div class="ticket_container">
|
|
||||||
<div>
|
|
||||||
<h1>Ourworld ICTC Event</h1>
|
|
||||||
<p>running rice valley hide speech roof accident full involved wide rather order good hidden horse home graph did model perhaps worry volume collect put</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h2>Sponsors</h2>
|
|
||||||
<div></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex">
|
|
||||||
<div>
|
|
||||||
<h2>Register</h2>
|
|
||||||
<p>dangerous shadow exclaimed stopped sale easy find add ago cold hard satisfied bent month sing frighten will flag shorter cage period doing successful husband</p>
|
|
||||||
</div>
|
|
||||||
<img src="qrs/qr_$slug" alt="QR Code">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
<div></div>
|
|
43
ticket.v
43
ticket.v
@ -3,33 +3,7 @@ module main
|
|||||||
import vweb
|
import vweb
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
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('<div>') or { panic('Failed to write <div> 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('</div>') or {
|
|
||||||
panic('Failed to write </div> to index.html file: $err')
|
|
||||||
}
|
|
||||||
index_file.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
vweb.Context
|
vweb.Context
|
||||||
@ -43,7 +17,6 @@ pub fn new_app() &App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
run_before()
|
|
||||||
mut app := new_app()
|
mut app := new_app()
|
||||||
vweb.run(app, 8000)
|
vweb.run(app, 8000)
|
||||||
}
|
}
|
||||||
@ -59,24 +32,36 @@ pub struct Registration {
|
|||||||
org_website string
|
org_website string
|
||||||
plus_one string
|
plus_one string
|
||||||
receive_communication string
|
receive_communication string
|
||||||
|
timestamp time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut app App) exists() vweb.Result {
|
pub fn (mut app App) exists() vweb.Result {
|
||||||
return $vweb.html()
|
return $vweb.html()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (mut app App) full() vweb.Result {
|
||||||
|
return $vweb.html()
|
||||||
|
}
|
||||||
|
|
||||||
['/register'; post]
|
['/register'; post]
|
||||||
pub fn (mut app App) register(name string, email string, org_website string, plus_one string, receive_communication string) vweb.Result {
|
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 {
|
registration := Registration {
|
||||||
name: name,
|
name: name,
|
||||||
email: email,
|
email: email,
|
||||||
org_website: org_website,
|
org_website: org_website,
|
||||||
plus_one: plus_one,
|
plus_one: plus_one,
|
||||||
receive_communication: receive_communication,
|
receive_communication: receive_communication,
|
||||||
|
timestamp: time.now()
|
||||||
}
|
}
|
||||||
path := 'registrations/${email}.txt'
|
path := 'registrations/${email}.txt'
|
||||||
if os.exists(path) { return app.exists()}
|
if os.exists(path) { return app.exists()}
|
||||||
os.write_file(path, json.encode(registration)) or {println('error')}
|
os.write_file(path, json.encode(registration)) or {println('error')}
|
||||||
|
if files.len > 200 {
|
||||||
|
return app.full()
|
||||||
|
}
|
||||||
return $vweb.html()
|
return $vweb.html()
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user