fixes and updates to registration

This commit is contained in:
timurgordon 2022-10-26 08:53:38 +03:00
parent ace50ee568
commit bcb59fd7a0
6 changed files with 20 additions and 70 deletions

View File

@ -1,5 +1,6 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/static/css/index.css" />
<script src="/static/htmx.min.js"></script>
</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" />
</div>
<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="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">

4
templates/full.html Normal file
View 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>

View File

@ -1,15 +0,0 @@
<div class="ticket_container">
<div>
<h1>Ourworld ICTC Event</h1>
<p></p>
</div>
<div>
</div>
<div>
</div>
<div>
</div>
</div>

View File

@ -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>

View File

@ -1 +0,0 @@
<div></div>

View File

@ -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('<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()
}
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()
}