925
925
return self.db.query(query).dictresult()
929
def get_groups_by_user(self, login, offeringid=None, dry=False):
931
Get all project groups the student is in, corresponding to a
932
particular subject offering (or all offerings, if omitted).
933
Returns a list of tuples:
934
(int groupid, str groupnm, str group_nick, bool is_member).
935
(Note: If is_member is false, it means they have just been invited to
936
this group, not a member).
938
if offeringid is None:
941
and_projectset_table = ", project_set"
943
AND project_group.projectsetid = project_set.projectsetid
944
AND project_set.offeringid = %s""" % _escape(offeringid)
945
# Union both the groups this user is a member of, and the groups this
946
# user is invited to.
948
SELECT project_group.groupid, groupnm, project_group.nick, True
949
FROM project_group, group_member, login %(and_projectset_table)s
950
WHERE project_group.groupid = group_member.groupid
951
AND group_member.loginid = login.loginid
952
AND login = %(login)s
955
SELECT project_group.groupid, groupnm, project_group.nick, False
956
FROM project_group, group_invitation, login %(and_projectset_table)s
957
WHERE project_group.groupid = group_invitation.groupid
958
AND group_invitation.loginid = login.loginid
959
AND login = %(login)s
961
;""" % {"login": _escape(login), "and_offering": and_offering,
962
"and_projectset_table": and_projectset_table}
965
# Convert 't' -> True, 'f' -> False
966
return [(groupid, groupnm, nick, ismember == 't')
967
for groupid, groupnm, nick, ismember
968
in self.db.query(query).getresult()]
970
927
def get_offering_info(self, projectsetid, dry=False):
971
928
"""Takes information from projectset and returns useful information
972
929
about the subject and semester. Returns as a dictionary.