76
76
ctx['semesters'].append((semester, offerings))
79
def format_submission_principal(user, principal):
80
"""Render a list of users to fit in the offering project listing.
82
Given a user and a list of submitters, returns 'solo' if the
83
only submitter is the user, or a string of the form
84
'with A, B and C' if there are any other submitters.
86
If submitters is None, we assume that the list of members could
87
not be determined, so we just return 'group'.
95
display_names = sorted(
96
member.display_name for member in principal.members
97
if member is not user)
99
if len(display_names) == 0:
100
return 'solo (%s)' % principal.name
101
elif len(display_names) == 1:
102
return 'with %s (%s)' % (display_names[0], principal.name)
103
elif len(display_names) > 5:
104
return 'with %d others (%s)' % (len(display_names), principal.name)
106
return 'with %s and %s (%s)' % (', '.join(display_names[:-1]),
107
display_names[-1], principal.name)
110
78
class OfferingView(XHTMLView):
111
79
"""The home page of an offering."""
112
80
template = 'templates/offering.html'
119
87
ctx['context'] = self.context
121
89
ctx['permissions'] = self.context.get_permissions(req.user)
122
ctx['format_submission_principal'] = format_submission_principal
90
ctx['format_submission_principal'] = util.format_submission_principal
123
91
ctx['format_datetime'] = ivle.date.make_date_nice
124
92
ctx['format_datetime_short'] = ivle.date.format_datetime_for_paragraph
125
93
ctx['OfferingEdit'] = OfferingEdit