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

« back to all changes in this revision

Viewing changes to ivle/database.py

  • Committer: William Grant
  • Date: 2009-02-27 03:55:15 UTC
  • Revision ID: grantw@unimelb.edu.au-20090227035515-u5nwfrbed8qu9sbl
Offerings now give 'view' only to user enrolled in them. 'edit' is granted
to their tutors and lecturers.

Worksheet(Exercise)s and their views now delegate to and use Offering's
permissions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
290
290
    def get_permissions(self, user):
291
291
        perms = set()
292
292
        if user is not None:
293
 
            perms.add('view')
294
 
            if user.admin:
 
293
            enrolment = self.get_enrolment(user)
 
294
            if enrolment or user.admin:
 
295
                perms.add('view')
 
296
            if (enrolment and enrolment.role in (u'tutor', u'lecturer')) \
 
297
               or user.admin:
295
298
                perms.add('edit')
296
299
        return perms
297
300
 
511
514
        return "<%s %s in %s>" % (type(self).__name__, self.exercise.name,
512
515
                                  self.worksheet.identifier)
513
516
 
 
517
    def get_permissions(self, user):
 
518
        return self.worksheet.get_permissions(user)
 
519
 
514
520
class ExerciseSave(Storm):
515
521
    """
516
522
    Represents a potential solution to an exercise that a user has submitted