-
Notifications
You must be signed in to change notification settings - Fork 2
/
import_demo.py
executable file
·255 lines (218 loc) · 7.16 KB
/
import_demo.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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/usr/bin/env python
import os
import sys
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'penncfa.settings.development'
application = get_wsgi_application()
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from app.models import (FreeResponseQuestion, FollowupQuestion, CFAUser, EligibilityQuestion, FunderConstraint,
CommonFreeResponseQuestion, CommonFollowupQuestion)
from penncfa.settings.development import TEST_EMAIL
QUESTIONS = [
{
'q': ("Is your event primarily a speaker event (i.e., "
"over 50% speaking)?"),
'ys': ['connaissance'],
'ns': ['tchange']
},
{
'q': ("Is your event primarily a performance event (i.e., over 50% "
"performance, not including speaking)?"),
'ys': [],
'ns': []
},
{
'q': "Is alcohol served at your event?",
'ys': [],
'ns': ['spectrum', 'connaissance', 'fullyplanned', 'icf', 'faithfund',
'tchange', 'uacontingency']
},
{
'q': "Is your event a fundraiser for your group?", # TODO: Differentiate?
'ys': [],
'ns': ['spectrum', 'connaissance', 'fullyplanned', 'icf', 'tchange']
},
{
'q': "Is your event a closed event?",
'ys': [],
'ns': ['spectrum', 'icf', 'faithfund', 'tchange']
},
{
'q': ("Does your event involve multiple student organizations and "
"undergraduate communities?"),
'ys': ['icf', 'tchange'],
'ns': []
},
{
'q': ("Does this event does transport students via a private "
"transport service?"),
'ys': [],
'ns': ['tchange']
},
{
'q': "Are all your groups University-recognized?",
'ys': ['icf'],
'ns': []
},
]
COMMON_QS = [
("What are the goals and mission of your event and how do the "
"relate to the missions of all groups involved?"),
("Describe in detail the nature of your event and the timeline for "
"its completion."),
("Please list three past events held by the collaborating "
"organizations and describe their outcomes."),
("How do you plan to publicize this event?"),
]
COMMON_FOLLOWUP_QS = [
("How did your event go?"),
("Did your advisor attend?"),
("Why was it a success?")
]
REQUESTERS = [
'philo',
'testrequester1',
'testrequester2',
'testrequester3',
]
FUNDERS = [
{
'name': 'SPEC-TRUM',
'un': 'spectrum',
'desc': 'Host events serving multitude of minority interests on campus.',
'qs': [],
'fqs': []
},
{
'name': 'SPEC Connaissance',
'un': 'connaissance',
'desc': 'Bring awesome speakers.',
'qs': [],
'fqs': []
},
{
'name': 'SPEC Fully Planned',
'un': 'fullyplanned',
'desc': ('Fund events that are ready to go but need financial '
'assistance to be viable.'),
'qs': [],
'fqs': [
('SPEC has a followup.')
]
},
{
'name': 'Intercultural Fund',
'un': 'icf',
'desc': ('Fund events where at least one group sponsoring event '
'must be 5B.'),
'qs': [
('Please list which of the 5B groups are involved in your '
'event (i.e., APSC, Lambda, PCUW, UMOJA, and/or UMC).'),
("How does your event fulfill the mission of the "
"Intercultural Fund?"),
],
'fqs': [
('ICF has a followup.')
]
},
{
'name': 'Faith Fund',
'un': 'faithfund',
'desc': ('Promote and support faith-based events that are '
'educational in nature and not exclusive'),
'qs': [],
'fqs': []
},
{
'name': 'T-Change',
'un': 'tchange',
'desc': ('Fund collaborative events that promote interaction among '
'disparate audiences.'),
'qs': [
("The Vice-Provost of University Life (VPUL) charges "
"Tangible Change with funding unique events that bring "
"together disparate and/or diverse undergraduate "
"communities. Explain how your event meets this criterion. "
"(Up to 300 words.)"),
("Please detail the nature of collaboration between your "
"event's collaborating groups. (Up to 200 words.)"),
("Please list the past 3 major events hosted by your "
"event's collaborating organizations.")
],
'fqs': [
('Tchange has some change for you')
]
},
{
'name': 'UA Contingency',
'un': 'uacontingency',
'desc': ('Fund events that need funding and have exhausted their other '
'alternatives.'),
'qs': [],
'fqs': []
}
]
def add_funder(name, un, desc, qs, fqs):
"""Add a funder and their attendant questions."""
# User and CFAUser
user = User.objects.create_user(
username=un,
password=un,
email=TEST_EMAIL)
user.first_name = name[:30]
profile = user.profile
profile.user_type = 'F'
profile.mission_statement = desc
profile.osa_email = TEST_EMAIL
profile.save()
# Questions
for q in qs:
FreeResponseQuestion.objects.create(funder=profile, question=q)
for fq in fqs:
FollowupQuestion.objects.create(funder=profile, question=fq)
def add_requester(un):
"""Import a dummy requester."""
User.objects.create_user(username=un, email=TEST_EMAIL, password=un)
def import_users():
"""Import all the funders described above."""
CFAUser.objects.all().delete()
User.objects.filter(is_staff=False).delete()
FreeResponseQuestion.objects.all().delete()
# Import funders
for funder in FUNDERS:
add_funder(**funder)
# Import requesters
for requester in REQUESTERS:
add_requester(requester)
def import_questions():
"""Import the common and eligibility questions. Should be run after
import_funders."""
EligibilityQuestion.objects.all().delete()
FunderConstraint.objects.all().delete()
for question in QUESTIONS:
q = EligibilityQuestion.objects.create(question=question['q'])
for y in question['ys']:
FunderConstraint.objects.create(
funder=User.objects.get(username=y).profile,
question=q, answer='Y')
for n in question['ns']:
FunderConstraint.objects.create(
funder=User.objects.get(username=n).profile,
question=q, answer='N')
CommonFreeResponseQuestion.objects.all().delete()
for common_q in COMMON_QS:
CommonFreeResponseQuestion.objects.create(question=common_q)
for common_followup_q in COMMON_FOLLOWUP_QS:
CommonFollowupQuestion.objects.create(question=common_followup_q)
def import_sites():
Site.objects.create(
domain='http://localhost:8000//',
name='The Common Funding App')
def import_all():
import_users()
import_questions()
import_sites()
return 0
if __name__ == '__main__':
sys.exit(import_all())