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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-05-14 02:30:46 UTC
  • mfrom: (1165.3.86 submissions-admin)
  • Revision ID: grantw@unimelb.edu.au-20090514023046-ujf6ay6rf6iioz9s
Merge submissions-admin.

Offering staff can now administer projects and view their projects'
submissions. A tool is also provided to create archives of each submission.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# A sample / testing application for IVLE.
24
24
 
25
25
import os
 
26
import os.path
26
27
import urllib
 
28
import urlparse
27
29
import cgi
28
30
 
29
31
from storm.locals import Desc
168
170
        self.plugin_styles[Plugin] = ["project.css"]
169
171
        self.plugin_scripts[Plugin] = ["project.js"]
170
172
        ctx['offering'] = self.context
171
 
        ctx['subject'] = self.context.subject.short_name
172
 
        ctx['year'] = self.context.semester.year
173
 
        ctx['semester'] = self.context.semester.semester
174
 
 
175
173
        ctx['projectsets'] = []
176
174
 
177
175
        #Open the projectset Fragment, and render it for inclusion
187
185
        for projectset in self.context.project_sets:
188
186
            settmpl = loader.load(set_fragment)
189
187
            setCtx = Context()
190
 
            setCtx['group_size'] = projectset.max_students_per_group
191
 
            setCtx['projectset_id'] = projectset.id
 
188
            setCtx['projectset'] = projectset
192
189
            setCtx['new_project_url'] = self.new_project_url(projectset)
193
190
            setCtx['projects'] = []
194
191
 
223
220
        if self.context is None:
224
221
            raise NotFound()
225
222
 
 
223
    def build_subversion_url(self, svnroot, submission):
 
224
        princ = submission.assessed.principal
 
225
 
 
226
        if isinstance(princ, User):
 
227
            path = 'users/%s' % princ.login
 
228
        else:
 
229
            path = 'groups/%s_%s_%s_%s' % (
 
230
                    princ.project_set.offering.subject.short_name,
 
231
                    princ.project_set.offering.semester.year,
 
232
                    princ.project_set.offering.semester.semester,
 
233
                    princ.name
 
234
                    )
 
235
        return urlparse.urljoin(
 
236
                    svnroot,
 
237
                    os.path.join(path, submission.path[1:] if
 
238
                                       submission.path.startswith(os.sep) else
 
239
                                       submission.path))
 
240
 
226
241
    def populate(self, req, ctx):
 
242
        self.plugin_styles[Plugin] = ["project.css"]
 
243
 
227
244
        ctx['format_datetime_short'] = ivle.date.format_datetime_for_paragraph
228
 
 
 
245
        ctx['build_subversion_url'] = self.build_subversion_url
 
246
        ctx['svn_addr'] = req.config['urls']['svn_addr']
229
247
        ctx['project'] = self.context
230
 
        ctx['assesseds'] = self.context.assesseds
231
 
 
232
 
        ctx['submissions'] = []
233
 
        for assessed in self.context.assesseds:
234
 
            if assessed.submissions.count() > 0:
235
 
                ctx['submissions'].append(
236
 
                        assessed.submissions.order_by(ProjectSubmission.date_submitted)[-1])
237
 
 
 
248
        ctx['user'] = req.user
238
249
 
239
250
class Plugin(ViewPlugin, MediaPlugin):
240
251
    urls = [