~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-18 03:57:33 UTC
  • Revision ID: matt.giuca@gmail.com-20100218035733-d4v0iy4hq0wbjas6
ivle.fileservice_lib.listing: Previously assumed any SVN client error meant the directory was not versioned, and silently dropped SVN metadata. Now checks the error message, and for any unexpected errors, raises the exception rather than assuming unversioned. Fixes Launchpad Bug #523592.

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
            Semester.id == Offering.semester_id,
216
216
            (not active_only) or (Semester.state == u'current'),
217
217
            Enrolment.offering_id == Offering.id,
218
 
            Enrolment.user_id == self.id)
 
218
            Enrolment.user_id == self.id,
 
219
            Enrolment.active == True)
219
220
 
220
221
    @staticmethod
221
222
    def hash_password(password):
424
425
        # XXX: Respect extensions.
425
426
        return self.projects.find(Project.deadline > datetime.datetime.now())
426
427
 
 
428
    def clone_worksheets(self, source):
 
429
        """Clone all worksheets from the specified source to this offering."""
 
430
        import ivle.worksheet.utils
 
431
        for worksheet in source.worksheets:
 
432
            newws = Worksheet()
 
433
            newws.seq_no = worksheet.seq_no
 
434
            newws.identifier = worksheet.identifier
 
435
            newws.name = worksheet.name
 
436
            newws.assessable = worksheet.assessable
 
437
            newws.data = worksheet.data
 
438
            newws.format = worksheet.format
 
439
            newws.offering = self
 
440
            Store.of(self).add(newws)
 
441
            ivle.worksheet.utils.update_exerciselist(newws)
 
442
 
 
443
 
427
444
class Enrolment(Storm):
428
445
    """An enrolment of a user in an offering.
429
446
 
455
472
        return "<%s %r in %r>" % (type(self).__name__, self.user,
456
473
                                  self.offering)
457
474
 
 
475
    def get_permissions(self, user, config):
 
476
        # A user can edit any enrolment that they could have created.
 
477
        perms = set()
 
478
        if ('enrol_' + str(self.role)) in self.offering.get_permissions(
 
479
            user, config):
 
480
            perms.add('edit')
 
481
        return perms
 
482
 
 
483
    def delete(self):
 
484
        """Delete this enrolment."""
 
485
        Store.of(self).remove(self)
 
486
 
 
487
 
458
488
# PROJECTS #
459
489
 
460
490
class ProjectSet(Storm):