231
231
"""Find a user in a store by login name."""
232
232
return store.find(cls, cls.login == unicode(login)).one()
234
def get_svn_url(self, config, req):
234
def get_svn_url(self, config):
235
235
"""Get the subversion repository URL for this user or group."""
236
login = req.user.login
237
url = urlparse.urlsplit(config['urls']['svn_addr'])
238
url = urlparse.urlunsplit(url[:1] + (login+'@'+url[1],) + url[2:])
236
url = config['urls']['svn_addr']
239
237
path = 'users/%s' % self.login
240
238
return urlparse.urljoin(url, path)
735
733
Semester.id == Offering.semester_id,
736
734
(not active_only) or (Semester.state == u'current'))
738
def get_svn_url(self, config, req):
736
def get_svn_url(self, config):
739
737
"""Get the subversion repository URL for this user or group."""
740
login = req.user.login
741
url = urlparse.urlsplit(config['urls']['svn_addr'])
742
url = urlparse.urlunsplit(url[:1] + (login+'@'+url[1],) + url[2:])
738
url = config['urls']['svn_addr']
743
739
path = 'groups/%s_%s_%s_%s' % (
744
740
self.project_set.offering.subject.short_name,
745
741
self.project_set.offering.semester.year,
912
908
return "/files/%s/%s/%s?r=%d" % (user.login,
913
909
self.assessed.checkout_location, submitpath, self.revision)
915
def get_svn_url(self, req):
911
def get_svn_url(self, config):
916
912
"""Get subversion URL for this submission"""
917
913
princ = self.assessed.principal
918
base = princ.get_svn_url(req.config, req)
914
base = princ.get_svn_url(config)
919
915
if self.path.startswith(os.sep):
920
916
return os.path.join(base,
921
917
urllib.quote(self.path[1:].encode('utf-8')))
923
919
return os.path.join(base, urllib.quote(self.path.encode('utf-8')))
925
def get_svn_checkout_command(self, req):
926
svn_url = self.get_svn_url(req)
927
return "svn export -r%d '%s'"%(self.revision, svn_url)
921
def get_svn_export_command(self, req):
922
"""Returns a Unix shell command to export a submission"""
923
svn_url = self.get_svn_url(req.config)
924
username = (req.user.login if req.user.login.isalnum() else
925
"'%s'"%req.user.login)
926
export_dir = self.assessed.principal.short_name
927
return "svn export --username %s -r%d '%s' %s"%(req.user.login,
928
self.revision, svn_url, export_dir)
930
931
def test_and_normalise_path(path):