139
139
Offering.id == Enrolment.offering_id,
140
140
Subject.id == Offering.subject_id).config(distinct=True)
142
# TODO: Invitations should be listed too?
143
def get_groups(self, offering=None):
145
ProjectGroupMembership.user_id == self.id,
146
ProjectGroup.id == ProjectGroupMembership.project_group_id,
150
ProjectSet.offering_id == offering.id,
151
ProjectGroup.project_set_id == ProjectSet.id,
153
return Store.of(self).find(ProjectGroup, *preds)
157
return self.get_groups()
143
160
def active_enrolments(self):
144
161
'''A sanely ordered list of the user's active enrolments.'''
226
243
def __repr__(self):
227
244
return "<%s %r in %r>" % (type(self).__name__, self.user,
247
class ProjectSet(Storm):
248
__storm_table__ = "project_set"
250
id = Int(name="projectsetid", primary=True)
251
offering_id = Int(name="offeringid")
252
offering = Reference(offering_id, Offering.id)
253
max_students_per_group = Int()
255
__init__ = _kwarg_init
258
return "<%s %d in %r>" % (type(self).__name__, self.id,
261
class Project(Storm):
262
__storm_table__ = "project"
264
id = Int(name="projectid", primary=True)
267
project_set_id = Int(name="projectsetid")
268
project_set = Reference(project_set_id, ProjectSet.id)
269
deadline = DateTime()
271
__init__ = _kwarg_init
274
return "<%s '%s' in %r>" % (type(self).__name__, self.synopsis,
275
self.project_set.offering)
277
class ProjectGroup(Storm):
278
__storm_table__ = "project_group"
280
id = Int(name="groupid", primary=True)
281
name = Unicode(name="groupnm")
282
project_set_id = Int(name="projectsetid")
283
project_set = Reference(project_set_id, ProjectSet.id)
285
created_by_id = Int(name="createdby")
286
created_by = Reference(created_by_id, User.id)
289
__init__ = _kwarg_init
292
return "<%s %s in %r>" % (type(self).__name__, self.name,
293
self.project_set.offering)
295
class ProjectGroupMembership(Storm):
296
__storm_table__ = "group_member"
297
__storm_primary__ = "user_id", "project_group_id"
299
user_id = Int(name="loginid")
300
user = Reference(user_id, User.id)
301
project_group_id = Int(name="groupid")
302
project_group = Reference(project_group_id, ProjectGroup.id)
304
__init__ = _kwarg_init
307
return "<%s %r in %r>" % (type(self).__name__, self.user,