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

« back to all changes in this revision

Viewing changes to ivle/database.py

  • Committer: Matt Giuca
  • Date: 2010-02-11 08:58:01 UTC
  • Revision ID: matt.giuca@gmail.com-20100211085801-l6w2v24qn4ub9yiv
Subject page: Added Verify links on the subject pages to any projects with
existing submissions. This simply links to the path/revision which was
submitted.
database.py: Added Assessed.checkout_location and
    ProjectSubmission.get_verify_url to assist with this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
719
719
    def principal(self):
720
720
        return self.project_group or self.user
721
721
 
 
722
    @property
 
723
    def checkout_location(self):
 
724
        """Returns the location of the Subversion workspace for this piece of
 
725
        assessment, relative to each group member's home directory."""
 
726
        subjectname = self.project.project_set.offering.subject.short_name
 
727
        if self.is_group:
 
728
            checkout_dir_name = self.principal.short_name
 
729
        else:
 
730
            checkout_dir_name = "mywork"
 
731
        return subjectname + "/" + checkout_dir_name
 
732
 
722
733
    @classmethod
723
734
    def get(cls, store, principal, project):
724
735
        """Find or create an Assessed for the given user or group and project.
784
795
    submitter = Reference(submitter_id, User.id)
785
796
    date_submitted = DateTime()
786
797
 
 
798
    def get_verify_url(self, user):
 
799
        """Get the URL for verifying this submission, within the account of
 
800
        the given user."""
 
801
        # If this is a solo project, then self.path will be prefixed with the
 
802
        # subject name. Remove the first path segment.
 
803
        submitpath = self.path[1:] if self.path[:1] == '/' else self.path
 
804
        if not self.assessed.is_group:
 
805
            if '/' in submitpath:
 
806
                submitpath = submitpath.split('/', 1)[1]
 
807
            else:
 
808
                submitpath = ''
 
809
        return "/files/%s/%s/%s?r=%d" % (user.login,
 
810
            self.assessed.checkout_location, submitpath, self.revision)
787
811
 
788
812
# WORKSHEETS AND EXERCISES #
789
813