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

« back to all changes in this revision

Viewing changes to ivle/database.py

  • Committer: William Grant
  • Date: 2010-02-24 12:27:34 UTC
  • mto: This revision was merged to the branch mainline in revision 1698.
  • Revision ID: grantw@unimelb.edu.au-20100224122734-ws4gi771ydr47tgl
Forbid normal users from viewing unpublished worksheets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
999
999
            WorksheetExercise.worksheet == self).remove()
1000
1000
 
1001
1001
    def get_permissions(self, user, config):
1002
 
        # Almost the same permissions as for the offering itself
1003
 
        perms = self.offering.get_permissions(user, config)
1004
 
        # However, "edit" permission is derived from the "edit_worksheets"
1005
 
        # permission of the offering
1006
 
        if 'edit_worksheets' in perms:
 
1002
        offering_perms = self.offering.get_permissions(user, config)
 
1003
 
 
1004
        perms = set()
 
1005
 
 
1006
        # Anybody who can view an offering can view a published
 
1007
        # worksheet.
 
1008
        if 'view' in offering_perms and self.published:
 
1009
            perms.add('view')
 
1010
 
 
1011
        # Any worksheet editors can both view and edit.
 
1012
        if 'edit_worksheets' in offering_perms:
 
1013
            perms.add('view')
1007
1014
            perms.add('edit')
1008
 
        else:
1009
 
            perms.discard('edit')
 
1015
 
1010
1016
        return perms
1011
1017
 
1012
1018
    def get_xml(self):