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

« back to all changes in this revision

Viewing changes to ivle/database.py

  • Committer: Matt Giuca
  • Date: 2010-03-05 07:03:27 UTC
  • Revision ID: matt.giuca@gmail.com-20100305070327-nj2bs3owz1kngkmy
ivle.webapp.admin.subject: Abstracted code to generate Subversion URL into the database. User and ProjectGroup objects now have a get_svn_url method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import hashlib
27
27
import datetime
28
28
import os
 
29
import urlparse
29
30
 
30
31
from storm.locals import create_database, Store, Int, Unicode, DateTime, \
31
32
                         Reference, ReferenceSet, Bool, Storm, Desc
229
230
        """Find a user in a store by login name."""
230
231
        return store.find(cls, cls.login == unicode(login)).one()
231
232
 
 
233
    def get_svn_url(self, config):
 
234
        """Get the subversion repository URL for this user or group."""
 
235
        path = 'users/%s' % self.login
 
236
        return urlparse.urljoin(config['urls']['svn_addr'], path)
 
237
 
232
238
    def get_permissions(self, user, config):
233
239
        """Determine privileges held by a user over this object.
234
240
 
725
731
            Semester.id == Offering.semester_id,
726
732
            (not active_only) or (Semester.state == u'current'))
727
733
 
 
734
    def get_svn_url(self, config):
 
735
        """Get the subversion repository URL for this user or group."""
 
736
        path = 'groups/%s_%s_%s_%s' % (
 
737
                self.project_set.offering.subject.short_name,
 
738
                self.project_set.offering.semester.year,
 
739
                self.project_set.offering.semester.semester,
 
740
                self.name
 
741
                )
 
742
        return urlparse.urljoin(config['urls']['svn_addr'], path)
728
743
 
729
744
    def get_permissions(self, user, config):
730
745
        if user.admin or user in self.members: