-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
78 lines (70 loc) · 3.57 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from flask import Flask, render_template, flash, request, redirect, url_for
from wtforms import Form, TextField, TextAreaField, DateField, SelectField, validators, StringField, SubmitField, BooleanField
from wtforms_components import TimeField, IntegerField
from ticketing import submit_walkin_ticket, submit_print_refund
# config
DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
app.config['SECRET_KEY'] = 'secret_key'
class WalkInTicket(Form):
name = TextField('Name:', validators=[validators.required()])
net_id = TextField('NetID:', validators=[validators.required()])
service = SelectField('Service:', validators=[validators.required()],
choices=[("Device Configuration", "Device Configuration"),
("Ethernet Request", "Ethernet Request"),
("Printing", "Printing"),
("Accounts", "Accounts"),
("Other", "Other")])
comments = TextField('Additional Comments:')
class PrintRefund(Form):
name = TextField('Name:', validators=[validators.required()])
net_id = TextField('NetID:', validators=[validators.required()])
student_id = TextField('Student ID:', validators=[validators.required()])
date_of_print = DateField('Date of Print:', format='%m/%d/%Y')
time_of_print = TimeField('Time of Print:', validators=[validators.required()])
printer_name = TextField('Printer Name:', validators=[validators.required()])
file_name = TextField('File Name:', validators=[validators.required()])
num_pages = IntegerField('Number of Pages:', validators=[validators.NumberRange(min=1)])
plot_attached = SelectField('Is the bad plot attached?:',
choices=[("Yes", "Yes"),
("No", "No")])
header_attached = SelectField('Is the header attached?:',
choices=[("Yes", "Yes"),
("No", "No")])
converted_to_pdf = SelectField('Did you convert to a PDF?:',
choices=[("Yes", "Yes"),
("No", "No")])
downsampled = SelectField('Did you downsample before printing?:',
choices=[("Yes", "Yes"),
("No", "No")])
explanation = TextAreaField('Explanation:')
@app.route("/walkin", methods=['GET', 'POST'])
def walkin():
form = WalkInTicket(request.form)
if request.method == 'POST':
if form.validate():
flash('Thanks for your response, ' + request.form['name'].split(" ")[0], 'success')
submit_walkin_ticket(request.form)
return redirect(url_for('walkin'))
else:
print form.errors
flash('Please fill out all fields.', 'danger')
return render_template('walkin_ticket.html', form=form)
@app.route("/print_refund", methods=['GET', 'POST'])
def print_refund():
form = PrintRefund(request.form)
print form.errors
if request.method == 'POST':
print request.form
if form.validate():
flash('Thanks for your response, ' + request.form['name'].split(" ")[0], 'success')
submit_print_refund(request.form)
return redirect(url_for('print_refund'))
else:
print form.errors
flash('Please fill out all fields.', 'danger')
return render_template('print_refund.html', form=form)
if __name__ == "__main__":
app.secret_key = '0011223344556677'
app.run()