-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprograms.py
More file actions
executable file
·29 lines (24 loc) · 852 Bytes
/
programs.py
File metadata and controls
executable file
·29 lines (24 loc) · 852 Bytes
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
from ..everything import *
def getAllPrograms ():
# This returns the program table
progQ = (Programs.select()
.order_by(+Programs.abbreviation)) # + is short for Sort ascending
if progQ.exists():
return progQ.select()
else:
return None
@app.route ("/urcpp/v1/programs/getAll", methods = ["POST"])
def programs_getAll ():
if username != authUser(request.environ):
return { "response": cfg["response"]["badUsername"] }
progs = getAllPrograms()
if progs:
response = { "response" : "OK" }
dicts = map(m2d, progs)
app.logger.info("Programs: {0}".format(dicts))
response['programs'] = dicts
return jsonify(response)
else:
response = { "response": cfg["response"]["noResults"],
"details": "No results found for all programs." }
return jsonify(response)