-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtesting.py
More file actions
106 lines (79 loc) · 2.71 KB
/
testing.py
File metadata and controls
106 lines (79 loc) · 2.71 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import os
import urllib
import sys
import datetime
from datetime import timedelta
from google.appengine.api import users
from google.appengine.ext import ndb
from handlers import BaseRequestHandler, AuthHandler
import jinja2
from models import *
JINJA_ENVIRONMENT = jinja2.Environment(loader=jinja2.FileSystemLoader(os.getcwd()))
class CreateTestData(BaseRequestHandler):
def get(self):
"""put code in here to load the test data"""
# First check if user is signed in and if not redirect to sign-in page
if self.logged_in:
user=self.current_user
try:
e=Events(
event_name = "Marlow",
event_date = datetime.date(2015,8,20),
event_desc = "The last chance to excel before Henley").put()
s=Stages(
event_id = e,
stage_index = 0,
label = "start").put()
s=Stages(
event_id = e,
stage_index = 1,
label = "stop").put()
c=Crews(
event_id = e,
crew_number = 123,
crew_name = "Eton College RC",
pic_file = "etn.gif",
crew_type = "Coxed Quad 4x+",
rower_count = 4,
cox = True).put()
c2=Crews(
event_id = e,
crew_number = 124,
crew_name = "Bedford Modern RC",
pic_file = "bms.gif",
crew_type = "Coxed Quad 4x+",
rower_count = 4,
cox = True).put()
except:
message = sys.exc_info()[0]
raise
self.response.write("data loaded")
else:
user=""
template_values = {}
template = JINJA_ENVIRONMENT.get_template('templates/rcn_login.html')
self.response.write(template.render(template_values))
return
class ConvertData(BaseRequestHandler):
def get(self):
"""This code converts old databases to the new format with a stages section"""
# First check if user is signed in and if not redirect to sign-in page
if self.logged_in:
user=self.current_user
event_list = list()
event_list = Events.query().fetch()
#read each event and add stages start and stop to them
for e in event_list:
s1=Stages(event_id = e.key,
stage_index = 0,
label = "start").put()
s2=Stages(event_id = e.key,
stage_index = 1,
label = "stop").put()
self.response.write("stages added")
else:
user=""
template_values = {}
template = JINJA_ENVIRONMENT.get_template('templates/rcn_login.html')
self.response.write(template.render(template_values))
return