~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-12 03:33:38 UTC
  • Revision ID: matt.giuca@gmail.com-20100212033338-z5sc1gh7ea3y30vx
Tutors can now (once again) edit worksheets.
database: Created a new capability, 'edit_worksheets', which is set for tutors
    and above.
    The 'edit' capability for worksheets is now derived from the
    'edit_worksheets' capability in the offering, rather than 'edit'.
All checks to do with creating or editing worksheets (in general, not specific
ones) check 'edit_worksheets'. Checks specific to a worksheet still check the
'edit' capability, on the worksheet itself.

Show diffs side-by-side

added added

removed removed

Lines of Context:
377
377
            enrolment = self.get_enrolment(user)
378
378
            if enrolment or user.admin:
379
379
                perms.add('view')
 
380
            if (enrolment and enrolment.role in (u'tutor', u'lecturer')) \
 
381
               or user.admin:
 
382
                perms.add('edit_worksheets')
380
383
            if (enrolment and enrolment.role in (u'lecturer')) or user.admin:
381
 
                perms.add('edit')
 
384
                perms.add('edit')           # Can edit projects & details
382
385
                perms.add('enrol')          # Can see enrolment screen at all
383
386
                perms.add('enrol_student')  # Can enrol students
384
387
                perms.add('enrol_tutor')    # Can enrol tutors
925
928
            WorksheetExercise.worksheet == self).remove()
926
929
 
927
930
    def get_permissions(self, user):
928
 
        return self.offering.get_permissions(user)
 
931
        # Almost the same permissions as for the offering itself
 
932
        perms = self.offering.get_permissions(user)
 
933
        # However, "edit" permission is derived from the "edit_worksheets"
 
934
        # permission of the offering
 
935
        if 'edit_worksheets' in perms:
 
936
            perms.add('edit')
 
937
        else:
 
938
            perms.discard('edit')
 
939
        return perms
929
940
 
930
941
    def get_xml(self):
931
942
        """Returns the xml of this worksheet, converts from rst if required."""