~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/subject.py

  • Committer: Matt Giuca
  • Date: 2010-02-11 07:39:15 UTC
  • Revision ID: matt.giuca@gmail.com-20100211073915-rirq98zg3sanvf09
Submit view: The projects list is now identical (except for radio buttons) to the view on the subjects page. It is much clearer and contains more info. The code is somewhat different, because it's a table, not a list, so I didn't abstract it. Moved a function out of subject.py to ivle.util, as it is shared by both views.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
            if len(offerings):
76
76
                ctx['semesters'].append((semester, offerings))
77
77
 
78
 
 
79
 
def format_submission_principal(user, principal):
80
 
    """Render a list of users to fit in the offering project listing.
81
 
 
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.
85
 
 
86
 
    If submitters is None, we assume that the list of members could
87
 
    not be determined, so we just return 'group'.
88
 
    """
89
 
    if principal is None:
90
 
        return 'group'
91
 
 
92
 
    if principal is user:
93
 
        return 'solo'
94
 
 
95
 
    display_names = sorted(
96
 
        member.display_name for member in principal.members
97
 
        if member is not user)
98
 
 
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)
105
 
    else:
106
 
        return 'with %s and %s (%s)' % (', '.join(display_names[:-1]),
107
 
                                        display_names[-1], principal.name)
108
 
 
109
 
 
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
120
88
        ctx['req'] = req
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