~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-22 06:05:32 UTC
  • Revision ID: matt.giuca@gmail.com-20100322060532-5365361xrx9mh32v
Changed database.py get_svn_url to take a req; include the req.user.login in the Subversion URL. This allows you to check out repositories without separately supplying the IVLE URL (as Subversion won't ask for a username by default). Also removed --username= from the lecturer project view, as it's redundant now. This fixes Launchpad bug #543936.

Show diffs side-by-side

added added

removed removed

Lines of Context:
230
230
        """Find a user in a store by login name."""
231
231
        return store.find(cls, cls.login == unicode(login)).one()
232
232
 
233
 
    def get_svn_url(self, config):
 
233
    def get_svn_url(self, config, req):
234
234
        """Get the subversion repository URL for this user or group."""
 
235
        login = req.user.login
 
236
        url = urlparse.urlsplit(config['urls']['svn_addr'])
 
237
        url = urlparse.urlunsplit(url[:1] + (login+'@'+url[1],) + url[2:])
235
238
        path = 'users/%s' % self.login
236
 
        return urlparse.urljoin(config['urls']['svn_addr'], path)
 
239
        return urlparse.urljoin(url, path)
237
240
 
238
241
    def get_permissions(self, user, config):
239
242
        """Determine privileges held by a user over this object.
731
734
            Semester.id == Offering.semester_id,
732
735
            (not active_only) or (Semester.state == u'current'))
733
736
 
734
 
    def get_svn_url(self, config):
 
737
    def get_svn_url(self, config, req):
735
738
        """Get the subversion repository URL for this user or group."""
 
739
        login = req.user.login
 
740
        url = urlparse.urlsplit(config['urls']['svn_addr'])
 
741
        url = urlparse.urlunsplit(url[:1] + (login+'@'+url[1],) + url[2:])
736
742
        path = 'groups/%s_%s_%s_%s' % (
737
743
                self.project_set.offering.subject.short_name,
738
744
                self.project_set.offering.semester.year,
739
745
                self.project_set.offering.semester.semester,
740
746
                self.name
741
747
                )
742
 
        return urlparse.urljoin(config['urls']['svn_addr'], path)
 
748
        return urlparse.urljoin(url, path)
743
749
 
744
750
    def get_permissions(self, user, config):
745
751
        if user.admin or user in self.members: