-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
executable file
·177 lines (147 loc) · 6.34 KB
/
models.py
File metadata and controls
executable file
·177 lines (147 loc) · 6.34 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import datetime
from peewee import *
import os
# Create a database
from api.config import load_config
here = os.path.dirname(__file__)
cfg = load_config(os.path.join(here, 'config.yaml'))
dynamicDB = MySQLDatabase(cfg['db']['name'], host=cfg['db']['host'], user=cfg['db']['user'], passwd=cfg['db']['password'])
class DynamicModel (Model):
class Meta:
database = dynamicDB
# To see the databases, do this:
# sqlite_web -p $PORT -H $IP -x data/test.sqlite
######################################################
# STATIC MODELS
######################################################
class LDAPFaculty (DynamicModel):
fID = PrimaryKeyField()
username = CharField(unique = True)
bnumber = TextField()
lastname = TextField()
firstname = TextField()
isChair = BooleanField(default=False)
isCommitteeMember = BooleanField(default=False)
def is_active(self):
"""All user will be active"""
return True
def get_id(self):
return str(self.fID)
def is_authenticated(self):
"""Return True if the user is authenticated"""
return True
def is_anonymous(self):
return False
def __repr__(self):
return '{0} {1}'.format(self.firstname, self.lastname)
class LDAPStudents (DynamicModel):
username = PrimaryKeyField()
bnumber = TextField()
lastname = TextField()
firstname = TextField()
class Programs (DynamicModel):
pID = PrimaryKeyField()
name = TextField()
abbreviation = TextField()
######################################################
# DYNAMIC MODELS
######################################################
class Budget (DynamicModel):
bID = PrimaryKeyField()
facultyStipend = IntegerField(default=0)
facultyStipendDesc = TextField(default = "")
miles = IntegerField(default=0)
milesDesc = TextField(default = "")
otherTravel = IntegerField(default=0)
otherTravelDesc = TextField(default = "")
equipment = IntegerField(default=0)
equipmentDesc = TextField(default = "")
materials = IntegerField(default=0)
materialsDesc = TextField(default = "")
other = IntegerField(default=0)
otherDesc = TextField(default = "")
class PreSurvey (DynamicModel):
psID = PrimaryKeyField()
class PostSurvey (DynamicModel):
psID = PrimaryKeyField()
class Parameters (DynamicModel):
pID = PrimaryKeyField()
year = IntegerField(unique=True)
appOpenDate = DateTimeField()
appCloseDate = DateTimeField()
ProposalAcceptanceDate = DateTimeField()
AllSubmissionsClosedDate = DateTimeField()
mileageRate = FloatField() # Or Double?
laborRate = FloatField() # Or Double?
isCurrentParameter = BooleanField(default=False)
IRBchair_id = ForeignKeyField(LDAPFaculty, to_field = "username")
currentchair_id = ForeignKeyField(LDAPFaculty, to_field = "username")
staffsupport_id = ForeignKeyField(LDAPFaculty, to_field = "username")
class Projects (DynamicModel):
pID = PrimaryKeyField()
title = TextField()
budgetID = ForeignKeyField(Budget, related_name = 'budget')
duration = IntegerField()
startDate = DateTimeField()
endDate = DateTimeField()
year = ForeignKeyField(Parameters, to_field = "year")
# Like the vitae; the file is in a folder.
# /year/projid/title.pdf
#proposal = BlobField()
hasCommunityPartner = BooleanField(default = False)
isServiceToCommunity = BooleanField(default = False)
humanSubjects = BooleanField(null = True)
# Like the vitae
# /year/projid/irb.something
# irb = BlobField()
numberStudents = IntegerField(default = 1)
# Stati are in the config under the key
# projectstatus: ... it is a list.
status = TextField(default = cfg["projectStatus"]["Incomplete"])
createdDate = DateTimeField(default = datetime.datetime.now)
class URCPPStudents (DynamicModel):
sID = PrimaryKeyField()
username = ForeignKeyField(LDAPStudents)
# We need to insert empty rows when we create the students.
preSurveyID = ForeignKeyField(PreSurvey)
postSurveyID = ForeignKeyField(PostSurvey)
projectID = ForeignKeyField(Projects)
class URCPPFaculty (DynamicModel):
fID = PrimaryKeyField()
pID = ForeignKeyField(Projects, db_column="pid_id", related_name = "project")
username = ForeignKeyField(LDAPFaculty, to_field = "username")
# We will always name these ourselves, and
# choose where they go. It is in our config[] YAML.
# Something like...
# /year/projid/username.pdf
# vitae = BlobField()
yearsFunded = TextField( default = "" )
relatedFunding = TextField( default = "" )
programID = ForeignKeyField(Programs, default = 0)
class Collaborators (DynamicModel):
cID = PrimaryKeyField()
pID = ForeignKeyField(Projects, related_name = "collaborators")
username = ForeignKeyField(LDAPFaculty, to_field = "username")
yearsFunded = TextField( default = "" )
class Voting (DynamicModel):
vID = PrimaryKeyField()
committeeID = ForeignKeyField(LDAPFaculty, to_field = "username")
projectID = ForeignKeyField(Projects)
studentLearning = FloatField(null = True)
studentAccessibility = FloatField(null = True)
qualityOfResearch = FloatField(null = True)
studentDevelopment = FloatField(null = True)
facultyDevelopment = FloatField(null = True)
development = FloatField(null = True)
collaborative = FloatField(null = True)
interaction = FloatField(null = True)
communication = FloatField(null = True)
scholarlySignificance = FloatField(null = True)
proposalQuality = FloatField(null = True)
budget = FloatField(null = True)
timeline = FloatField(null = True)
comments = TextField(null = True)
class EmailTemplates (DynamicModel):
eID = PrimaryKeyField()
Body = TextField(null = True)
Subject = TextField(null = True)