~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-07-21 04:12:30 UTC
  • Revision ID: matt.giuca@gmail.com-20100721041230-hlrn2q3fx2uvaprd
ivle.webapp.admin.user: Fixed call to req.user.get_svn_url (now takes 1 argument, as of r1810).
Fixes Internal server error on Settings page (since r1810).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import urllib
28
28
import urlparse
29
29
import cgi
 
30
import datetime
30
31
 
31
32
from storm.locals import Desc, Store
32
33
import genshi
39
40
                                    DateTimeValidator)
40
41
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
41
42
from ivle.webapp.base.xhtml import XHTMLView
 
43
from ivle.webapp.base.text import TextView
42
44
from ivle.webapp.errors import BadRequest
43
45
from ivle.webapp import ApplicationRoot
44
46
 
735
737
    permission = "view_project_submissions"
736
738
    tab = 'subjects'
737
739
 
738
 
    def build_subversion_url(self, config, submission):
739
 
        princ = submission.assessed.principal
740
 
 
741
 
        return os.path.join(princ.get_svn_url(config),
742
 
                            submission.path[1:] if
743
 
                                submission.path.startswith(os.sep) else
744
 
                                submission.path)
745
 
 
746
740
    def populate(self, req, ctx):
747
741
        self.plugin_styles[Plugin] = ["project.css"]
748
742
 
752
746
        ctx['EnrolView'] = EnrolView
753
747
        ctx['format_datetime'] = ivle.date.make_date_nice
754
748
        ctx['format_datetime_short'] = ivle.date.format_datetime_for_paragraph
755
 
        ctx['build_subversion_url'] = self.build_subversion_url
756
749
        ctx['project'] = self.context
757
750
        ctx['user'] = req.user
758
751
        ctx['ProjectEdit'] = ProjectEdit
759
752
        ctx['ProjectDelete'] = ProjectDelete
 
753
        ctx['ProjectExport'] = ProjectBashExportView
 
754
 
 
755
class ProjectBashExportView(TextView):
 
756
    """Produce a Bash script for exporting projects"""
 
757
    template = "templates/project-export.sh"
 
758
    content_type = "text/x-sh"
 
759
    permission = "view_project_submissions"
 
760
 
 
761
    def populate(self, req, ctx):
 
762
        ctx['req'] = req
 
763
        ctx['permissions'] = self.context.get_permissions(req.user,req.config)
 
764
        ctx['format_datetime'] = ivle.date.make_date_nice
 
765
        ctx['format_datetime_short'] = ivle.date.format_datetime_for_paragraph
 
766
        ctx['project'] = self.context
 
767
        ctx['user'] = req.user
 
768
        ctx['now'] = datetime.datetime.now()
 
769
        ctx['format_datetime'] = ivle.date.make_date_nice
 
770
        ctx['format_datetime_short'] = ivle.date.format_datetime_for_paragraph
760
771
 
761
772
class ProjectUniquenessValidator(formencode.FancyValidator):
762
773
    """A FormEncode validator that checks that a project short_name is unique
957
968
             (Project, '+index', ProjectView),
958
969
             (Project, '+edit', ProjectEdit),
959
970
             (Project, '+delete', ProjectDelete),
 
971
             (Project, ('+export', 'project-export.sh'),
 
972
                ProjectBashExportView),
960
973
             ]
961
974
 
962
975
    breadcrumbs = {Subject: SubjectBreadcrumb,