##// END OF EJS Templates
Fixes #18, removing user, who owns some repositories
marcink -
r376:7fbf8144 default
parent child Browse files
Show More
@@ -24,6 +24,7 b' admin controller for pylons'
24 """
24 """
25 from formencode import htmlfill
25 from formencode import htmlfill
26 from operator import itemgetter
26 from operator import itemgetter
27 from paste.httpexceptions import HTTPInternalServerError
27 from pylons import request, response, session, tmpl_context as c, url
28 from pylons import request, response, session, tmpl_context as c, url
28 from pylons.controllers.util import abort, redirect
29 from pylons.controllers.util import abort, redirect
29 from pylons.i18n.translation import _
30 from pylons.i18n.translation import _
@@ -31,13 +32,13 b' from pylons_app.lib import helpers as h'
31 from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator
32 from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator
32 from pylons_app.lib.base import BaseController, render
33 from pylons_app.lib.base import BaseController, render
33 from pylons_app.lib.utils import invalidate_cache
34 from pylons_app.lib.utils import invalidate_cache
35 from pylons_app.model.db import User
34 from pylons_app.model.forms import RepoForm
36 from pylons_app.model.forms import RepoForm
35 from pylons_app.model.hg_model import HgModel
37 from pylons_app.model.hg_model import HgModel
36 from pylons_app.model.repo_model import RepoModel
38 from pylons_app.model.repo_model import RepoModel
37 import formencode
39 import formencode
38 import logging
40 import logging
39 import traceback
41 import traceback
40 from paste.httpexceptions import HTTPInternalServerError
41
42
42 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
43
44
@@ -196,7 +197,13 b' class ReposController(BaseController):'
196
197
197 return redirect(url('repos'))
198 return redirect(url('repos'))
198 defaults = c.repo_info.__dict__
199 defaults = c.repo_info.__dict__
199 defaults.update({'user':c.repo_info.user.username})
200 if c.repo_info.user:
201 defaults.update({'user':c.repo_info.user.username})
202 else:
203 replacement_user = self.sa.query(User)\
204 .filter(User.admin == True).first().username
205 defaults.update({'user':replacement_user})
206
200 c.users_array = repo_model.get_users_js()
207 c.users_array = repo_model.get_users_js()
201
208
202 for p in c.repo_info.repo2perm:
209 for p in c.repo_info.repo2perm:
@@ -28,7 +28,7 b' from mercurial.hgweb.hgwebdir_mod import'
28 from pylons.i18n.translation import _
28 from pylons.i18n.translation import _
29 from pylons_app.lib.auth import HasRepoPermissionAny
29 from pylons_app.lib.auth import HasRepoPermissionAny
30 from pylons_app.model import meta
30 from pylons_app.model import meta
31 from pylons_app.model.db import Repository
31 from pylons_app.model.db import Repository, User
32 from sqlalchemy.orm import joinedload
32 from sqlalchemy.orm import joinedload
33 from vcs.exceptions import RepositoryError, VCSError
33 from vcs.exceptions import RepositoryError, VCSError
34 import logging
34 import logging
@@ -134,7 +134,11 b' class HgModel(object):'
134 log.info('Adding db instance to cached list')
134 log.info('Adding db instance to cached list')
135 repos_list[name].dbrepo = dbrepo
135 repos_list[name].dbrepo = dbrepo
136 repos_list[name].description = dbrepo.description
136 repos_list[name].description = dbrepo.description
137 repos_list[name].contact = dbrepo.user.full_contact
137 if dbrepo.user:
138 repos_list[name].contact = dbrepo.user.full_contact
139 else:
140 repos_list[name].contact = sa.query(User)\
141 .filter(User.admin == True).first().full_contact
138 except OSError:
142 except OSError:
139 continue
143 continue
140 meta.Session.remove()
144 meta.Session.remove()
General Comments 0
You need to be logged in to leave comments. Login now