##// END OF EJS Templates
controllers: move controllers base class from lib/base to controllers...
Mads Kiilerich -
r8590:4f0de946 default
parent child Browse files
Show More
@@ -112,7 +112,7 b' following list, modules may only depend '
112 everything and has a huge dependency chain, so it should not be used for
112 everything and has a huge dependency chain, so it should not be used for
113 anything else. TODO.
113 anything else. TODO.
114
114
115 ``controlles/base.py``
115 ``controllers/base.py``
116 The base class of controllers, with lots of model knowledge.
116 The base class of controllers, with lots of model knowledge.
117
117
118 ``lib/auth.py``
118 ``lib/auth.py``
@@ -32,8 +32,8 b' import logging'
32 import re
32 import re
33
33
34 from kallithea.config.middleware.pygrack import make_wsgi_app
34 from kallithea.config.middleware.pygrack import make_wsgi_app
35 from kallithea.controllers import base
35 from kallithea.lib import hooks
36 from kallithea.lib import hooks
36 from kallithea.lib.base import BaseVCSController, get_path_info
37
37
38
38
39 log = logging.getLogger(__name__)
39 log = logging.getLogger(__name__)
@@ -48,13 +48,13 b' cmd_mapping = {'
48 }
48 }
49
49
50
50
51 class SimpleGit(BaseVCSController):
51 class SimpleGit(base.BaseVCSController):
52
52
53 scm_alias = 'git'
53 scm_alias = 'git'
54
54
55 @classmethod
55 @classmethod
56 def parse_request(cls, environ):
56 def parse_request(cls, environ):
57 path_info = get_path_info(environ)
57 path_info = base.get_path_info(environ)
58 m = GIT_PROTO_PAT.match(path_info)
58 m = GIT_PROTO_PAT.match(path_info)
59 if m is None:
59 if m is None:
60 return None
60 return None
@@ -34,7 +34,7 b' import urllib.parse'
34
34
35 import mercurial.hgweb
35 import mercurial.hgweb
36
36
37 from kallithea.lib.base import BaseVCSController, get_path_info
37 from kallithea.controllers import base
38 from kallithea.lib.utils import make_ui
38 from kallithea.lib.utils import make_ui
39 from kallithea.lib.utils2 import safe_bytes
39 from kallithea.lib.utils2 import safe_bytes
40
40
@@ -91,7 +91,7 b' cmd_mapping = {'
91 }
91 }
92
92
93
93
94 class SimpleHg(BaseVCSController):
94 class SimpleHg(base.BaseVCSController):
95
95
96 scm_alias = 'hg'
96 scm_alias = 'hg'
97
97
@@ -100,7 +100,7 b' class SimpleHg(BaseVCSController):'
100 http_accept = environ.get('HTTP_ACCEPT', '')
100 http_accept = environ.get('HTTP_ACCEPT', '')
101 if not http_accept.startswith('application/mercurial'):
101 if not http_accept.startswith('application/mercurial'):
102 return None
102 return None
103 path_info = get_path_info(environ)
103 path_info = base.get_path_info(environ)
104 if not path_info.startswith('/'): # it must!
104 if not path_info.startswith('/'): # it must!
105 return None
105 return None
106
106
@@ -29,7 +29,7 b' Original author and date, and relevant c'
29 import logging
29 import logging
30 import time
30 import time
31
31
32 from kallithea.lib.base import get_ip_addr, get_path_info
32 from kallithea.controllers import base
33
33
34
34
35 log = logging.getLogger(__name__)
35 log = logging.getLogger(__name__)
@@ -91,8 +91,8 b' class RequestWrapper(object):'
91 def __call__(self, environ, start_response):
91 def __call__(self, environ, start_response):
92 meter = Meter(start_response)
92 meter = Meter(start_response)
93 description = "Request from %s for %s" % (
93 description = "Request from %s for %s" % (
94 get_ip_addr(environ),
94 base.get_ip_addr(environ),
95 get_path_info(environ),
95 base.get_path_info(environ),
96 )
96 )
97 log.info("%s received", description)
97 log.info("%s received", description)
98 try:
98 try:
@@ -36,8 +36,8 b' from whoosh import query'
36 from whoosh.qparser.dateparse import DateParserPlugin
36 from whoosh.qparser.dateparse import DateParserPlugin
37 from whoosh.qparser.default import QueryParser
37 from whoosh.qparser.default import QueryParser
38
38
39 from kallithea.controllers import base
39 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
40 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
40 from kallithea.lib.base import BaseController, render
41 from kallithea.lib.indexers import JOURNAL_SCHEMA
41 from kallithea.lib.indexers import JOURNAL_SCHEMA
42 from kallithea.lib.page import Page
42 from kallithea.lib.page import Page
43 from kallithea.lib.utils2 import remove_prefix, remove_suffix, safe_int
43 from kallithea.lib.utils2 import remove_prefix, remove_suffix, safe_int
@@ -118,7 +118,7 b' def _journal_filter(user_log, search_ter'
118 return user_log
118 return user_log
119
119
120
120
121 class AdminController(BaseController):
121 class AdminController(base.BaseController):
122
122
123 @LoginRequired(allow_default_user=True)
123 @LoginRequired(allow_default_user=True)
124 def _before(self, *args, **kwargs):
124 def _before(self, *args, **kwargs):
@@ -142,6 +142,6 b' class AdminController(BaseController):'
142 filter=c.search_term)
142 filter=c.search_term)
143
143
144 if request.environ.get('HTTP_X_PARTIAL_XHR'):
144 if request.environ.get('HTTP_X_PARTIAL_XHR'):
145 return render('admin/admin_log.html')
145 return base.render('admin/admin_log.html')
146
146
147 return render('admin/admin.html')
147 return base.render('admin/admin.html')
@@ -32,9 +32,9 b' from tg import tmpl_context as c'
32 from tg.i18n import ugettext as _
32 from tg.i18n import ugettext as _
33 from webob.exc import HTTPFound
33 from webob.exc import HTTPFound
34
34
35 from kallithea.controllers import base
35 from kallithea.lib import auth_modules, webutils
36 from kallithea.lib import auth_modules, webutils
36 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
37 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
37 from kallithea.lib.base import BaseController, render
38 from kallithea.lib.webutils import url
38 from kallithea.lib.webutils import url
39 from kallithea.model import db, meta
39 from kallithea.model import db, meta
40 from kallithea.model.forms import AuthSettingsForm
40 from kallithea.model.forms import AuthSettingsForm
@@ -43,7 +43,7 b' from kallithea.model.forms import AuthSe'
43 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
44
44
45
45
46 class AuthSettingsController(BaseController):
46 class AuthSettingsController(base.BaseController):
47
47
48 @LoginRequired()
48 @LoginRequired()
49 @HasPermissionAnyDecorator('hg.admin')
49 @HasPermissionAnyDecorator('hg.admin')
@@ -86,7 +86,7 b' class AuthSettingsController(BaseControl'
86
86
87 log.debug('defaults: %s', defaults)
87 log.debug('defaults: %s', defaults)
88 return formencode.htmlfill.render(
88 return formencode.htmlfill.render(
89 render('admin/auth/auth_settings.html'),
89 base.render('admin/auth/auth_settings.html'),
90 defaults=c.defaults,
90 defaults=c.defaults,
91 errors=errors,
91 errors=errors,
92 prefix_error=False,
92 prefix_error=False,
@@ -34,9 +34,9 b' from tg import request'
34 from tg.i18n import ugettext as _
34 from tg.i18n import ugettext as _
35 from webob.exc import HTTPFound
35 from webob.exc import HTTPFound
36
36
37 from kallithea.controllers import base
37 from kallithea.lib import webutils
38 from kallithea.lib import webutils
38 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
39 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
39 from kallithea.lib.base import BaseController, render
40 from kallithea.lib.webutils import url
40 from kallithea.lib.webutils import url
41 from kallithea.model import db, meta
41 from kallithea.model import db, meta
42 from kallithea.model.forms import DefaultsForm
42 from kallithea.model.forms import DefaultsForm
@@ -45,7 +45,7 b' from kallithea.model.forms import Defaul'
45 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
46
46
47
47
48 class DefaultsController(BaseController):
48 class DefaultsController(base.BaseController):
49
49
50 @LoginRequired()
50 @LoginRequired()
51 @HasPermissionAnyDecorator('hg.admin')
51 @HasPermissionAnyDecorator('hg.admin')
@@ -56,7 +56,7 b' class DefaultsController(BaseController)'
56 defaults = db.Setting.get_default_repo_settings()
56 defaults = db.Setting.get_default_repo_settings()
57
57
58 return htmlfill.render(
58 return htmlfill.render(
59 render('admin/defaults/defaults.html'),
59 base.render('admin/defaults/defaults.html'),
60 defaults=defaults,
60 defaults=defaults,
61 encoding="UTF-8",
61 encoding="UTF-8",
62 force_defaults=False
62 force_defaults=False
@@ -77,7 +77,7 b' class DefaultsController(BaseController)'
77 defaults = errors.value
77 defaults = errors.value
78
78
79 return htmlfill.render(
79 return htmlfill.render(
80 render('admin/defaults/defaults.html'),
80 base.render('admin/defaults/defaults.html'),
81 defaults=defaults,
81 defaults=defaults,
82 errors=errors.error_dict or {},
82 errors=errors.error_dict or {},
83 prefix_error=False,
83 prefix_error=False,
@@ -35,9 +35,9 b' from tg import tmpl_context as c'
35 from tg.i18n import ugettext as _
35 from tg.i18n import ugettext as _
36 from webob.exc import HTTPForbidden, HTTPFound, HTTPNotFound
36 from webob.exc import HTTPForbidden, HTTPFound, HTTPNotFound
37
37
38 from kallithea.controllers import base
38 from kallithea.lib import auth, webutils
39 from kallithea.lib import auth, webutils
39 from kallithea.lib.auth import LoginRequired
40 from kallithea.lib.auth import LoginRequired
40 from kallithea.lib.base import BaseController, jsonify, render
41 from kallithea.lib.page import Page
41 from kallithea.lib.page import Page
42 from kallithea.lib.utils2 import safe_int, safe_str, time_to_datetime
42 from kallithea.lib.utils2 import safe_int, safe_str, time_to_datetime
43 from kallithea.lib.vcs.exceptions import NodeNotChangedError, VCSError
43 from kallithea.lib.vcs.exceptions import NodeNotChangedError, VCSError
@@ -50,7 +50,7 b' from kallithea.model.gist import GistMod'
50 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
51
51
52
52
53 class GistsController(BaseController):
53 class GistsController(base.BaseController):
54
54
55 def __load_defaults(self, extra_values=None):
55 def __load_defaults(self, extra_values=None):
56 c.lifetime_values = [
56 c.lifetime_values = [
@@ -102,7 +102,7 b' class GistsController(BaseController):'
102 p = safe_int(request.GET.get('page'), 1)
102 p = safe_int(request.GET.get('page'), 1)
103 c.gists_pager = Page(c.gists, page=p, items_per_page=10,
103 c.gists_pager = Page(c.gists, page=p, items_per_page=10,
104 **url_params)
104 **url_params)
105 return render('admin/gists/index.html')
105 return base.render('admin/gists/index.html')
106
106
107 @LoginRequired()
107 @LoginRequired()
108 def create(self):
108 def create(self):
@@ -134,7 +134,7 b' class GistsController(BaseController):'
134 defaults = errors.value
134 defaults = errors.value
135
135
136 return formencode.htmlfill.render(
136 return formencode.htmlfill.render(
137 render('admin/gists/new.html'),
137 base.render('admin/gists/new.html'),
138 defaults=defaults,
138 defaults=defaults,
139 errors=errors.error_dict or {},
139 errors=errors.error_dict or {},
140 prefix_error=False,
140 prefix_error=False,
@@ -150,7 +150,7 b' class GistsController(BaseController):'
150 @LoginRequired()
150 @LoginRequired()
151 def new(self, format='html'):
151 def new(self, format='html'):
152 self.__load_defaults()
152 self.__load_defaults()
153 return render('admin/gists/new.html')
153 return base.render('admin/gists/new.html')
154
154
155 @LoginRequired()
155 @LoginRequired()
156 def delete(self, gist_id):
156 def delete(self, gist_id):
@@ -186,7 +186,7 b' class GistsController(BaseController):'
186 )
186 )
187 response.content_type = 'text/plain'
187 response.content_type = 'text/plain'
188 return content
188 return content
189 return render('admin/gists/show.html')
189 return base.render('admin/gists/show.html')
190
190
191 @LoginRequired()
191 @LoginRequired()
192 def edit(self, gist_id, format='html'):
192 def edit(self, gist_id, format='html'):
@@ -203,7 +203,7 b' class GistsController(BaseController):'
203 raise HTTPNotFound()
203 raise HTTPNotFound()
204
204
205 self.__load_defaults(extra_values=('0', _('Unmodified')))
205 self.__load_defaults(extra_values=('0', _('Unmodified')))
206 rendered = render('admin/gists/edit.html')
206 rendered = base.render('admin/gists/edit.html')
207
207
208 if request.POST:
208 if request.POST:
209 rpost = request.POST
209 rpost = request.POST
@@ -248,7 +248,7 b' class GistsController(BaseController):'
248 return rendered
248 return rendered
249
249
250 @LoginRequired()
250 @LoginRequired()
251 @jsonify
251 @base.jsonify
252 def check_revision(self, gist_id):
252 def check_revision(self, gist_id):
253 c.gist = db.Gist.get_or_404(gist_id)
253 c.gist = db.Gist.get_or_404(gist_id)
254 last_rev = c.gist.scm_instance.get_changeset()
254 last_rev = c.gist.scm_instance.get_changeset()
@@ -35,9 +35,9 b' from tg import tmpl_context as c'
35 from tg.i18n import ugettext as _
35 from tg.i18n import ugettext as _
36 from webob.exc import HTTPFound
36 from webob.exc import HTTPFound
37
37
38 from kallithea.controllers import base
38 from kallithea.lib import auth_modules, webutils
39 from kallithea.lib import auth_modules, webutils
39 from kallithea.lib.auth import AuthUser, LoginRequired
40 from kallithea.lib.auth import AuthUser, LoginRequired
40 from kallithea.lib.base import BaseController, IfSshEnabled, render
41 from kallithea.lib.utils2 import generate_api_key, safe_int
41 from kallithea.lib.utils2 import generate_api_key, safe_int
42 from kallithea.lib.webutils import url
42 from kallithea.lib.webutils import url
43 from kallithea.model import db, meta
43 from kallithea.model import db, meta
@@ -51,7 +51,7 b' from kallithea.model.user import UserMod'
51 log = logging.getLogger(__name__)
51 log = logging.getLogger(__name__)
52
52
53
53
54 class MyAccountController(BaseController):
54 class MyAccountController(base.BaseController):
55
55
56 @LoginRequired()
56 @LoginRequired()
57 def _before(self, *args, **kwargs):
57 def _before(self, *args, **kwargs):
@@ -116,7 +116,7 b' class MyAccountController(BaseController'
116
116
117 except formencode.Invalid as errors:
117 except formencode.Invalid as errors:
118 return htmlfill.render(
118 return htmlfill.render(
119 render('admin/my_account/my_account.html'),
119 base.render('admin/my_account/my_account.html'),
120 defaults=errors.value,
120 defaults=errors.value,
121 errors=errors.error_dict or {},
121 errors=errors.error_dict or {},
122 prefix_error=False,
122 prefix_error=False,
@@ -129,7 +129,7 b' class MyAccountController(BaseController'
129 if update:
129 if update:
130 raise HTTPFound(location='my_account')
130 raise HTTPFound(location='my_account')
131 return htmlfill.render(
131 return htmlfill.render(
132 render('admin/my_account/my_account.html'),
132 base.render('admin/my_account/my_account.html'),
133 defaults=defaults,
133 defaults=defaults,
134 encoding="UTF-8",
134 encoding="UTF-8",
135 force_defaults=False)
135 force_defaults=False)
@@ -150,7 +150,7 b' class MyAccountController(BaseController'
150 webutils.flash(_("Successfully updated password"), category='success')
150 webutils.flash(_("Successfully updated password"), category='success')
151 except formencode.Invalid as errors:
151 except formencode.Invalid as errors:
152 return htmlfill.render(
152 return htmlfill.render(
153 render('admin/my_account/my_account.html'),
153 base.render('admin/my_account/my_account.html'),
154 defaults=errors.value,
154 defaults=errors.value,
155 errors=errors.error_dict or {},
155 errors=errors.error_dict or {},
156 prefix_error=False,
156 prefix_error=False,
@@ -160,7 +160,7 b' class MyAccountController(BaseController'
160 log.error(traceback.format_exc())
160 log.error(traceback.format_exc())
161 webutils.flash(_('Error occurred during update of user password'),
161 webutils.flash(_('Error occurred during update of user password'),
162 category='error')
162 category='error')
163 return render('admin/my_account/my_account.html')
163 return base.render('admin/my_account/my_account.html')
164
164
165 def my_account_repos(self):
165 def my_account_repos(self):
166 c.active = 'repos'
166 c.active = 'repos'
@@ -168,7 +168,7 b' class MyAccountController(BaseController'
168
168
169 # data used to render the grid
169 # data used to render the grid
170 c.data = self._load_my_repos_data()
170 c.data = self._load_my_repos_data()
171 return render('admin/my_account/my_account.html')
171 return base.render('admin/my_account/my_account.html')
172
172
173 def my_account_watched(self):
173 def my_account_watched(self):
174 c.active = 'watched'
174 c.active = 'watched'
@@ -176,14 +176,14 b' class MyAccountController(BaseController'
176
176
177 # data used to render the grid
177 # data used to render the grid
178 c.data = self._load_my_repos_data(watched=True)
178 c.data = self._load_my_repos_data(watched=True)
179 return render('admin/my_account/my_account.html')
179 return base.render('admin/my_account/my_account.html')
180
180
181 def my_account_perms(self):
181 def my_account_perms(self):
182 c.active = 'perms'
182 c.active = 'perms'
183 self.__load_data()
183 self.__load_data()
184 c.perm_user = AuthUser(user_id=request.authuser.user_id)
184 c.perm_user = AuthUser(user_id=request.authuser.user_id)
185
185
186 return render('admin/my_account/my_account.html')
186 return base.render('admin/my_account/my_account.html')
187
187
188 def my_account_emails(self):
188 def my_account_emails(self):
189 c.active = 'emails'
189 c.active = 'emails'
@@ -191,7 +191,7 b' class MyAccountController(BaseController'
191
191
192 c.user_email_map = db.UserEmailMap.query() \
192 c.user_email_map = db.UserEmailMap.query() \
193 .filter(db.UserEmailMap.user == c.user).all()
193 .filter(db.UserEmailMap.user == c.user).all()
194 return render('admin/my_account/my_account.html')
194 return base.render('admin/my_account/my_account.html')
195
195
196 def my_account_emails_add(self):
196 def my_account_emails_add(self):
197 email = request.POST.get('new_email')
197 email = request.POST.get('new_email')
@@ -231,7 +231,7 b' class MyAccountController(BaseController'
231 c.lifetime_options = [(c.lifetime_values, _("Lifetime"))]
231 c.lifetime_options = [(c.lifetime_values, _("Lifetime"))]
232 c.user_api_keys = ApiKeyModel().get_api_keys(request.authuser.user_id,
232 c.user_api_keys = ApiKeyModel().get_api_keys(request.authuser.user_id,
233 show_expired=show_expired)
233 show_expired=show_expired)
234 return render('admin/my_account/my_account.html')
234 return base.render('admin/my_account/my_account.html')
235
235
236 def my_account_api_keys_add(self):
236 def my_account_api_keys_add(self):
237 lifetime = safe_int(request.POST.get('lifetime'), -1)
237 lifetime = safe_int(request.POST.get('lifetime'), -1)
@@ -255,14 +255,14 b' class MyAccountController(BaseController'
255
255
256 raise HTTPFound(location=url('my_account_api_keys'))
256 raise HTTPFound(location=url('my_account_api_keys'))
257
257
258 @IfSshEnabled
258 @base.IfSshEnabled
259 def my_account_ssh_keys(self):
259 def my_account_ssh_keys(self):
260 c.active = 'ssh_keys'
260 c.active = 'ssh_keys'
261 self.__load_data()
261 self.__load_data()
262 c.user_ssh_keys = SshKeyModel().get_ssh_keys(request.authuser.user_id)
262 c.user_ssh_keys = SshKeyModel().get_ssh_keys(request.authuser.user_id)
263 return render('admin/my_account/my_account.html')
263 return base.render('admin/my_account/my_account.html')
264
264
265 @IfSshEnabled
265 @base.IfSshEnabled
266 def my_account_ssh_keys_add(self):
266 def my_account_ssh_keys_add(self):
267 description = request.POST.get('description')
267 description = request.POST.get('description')
268 public_key = request.POST.get('public_key')
268 public_key = request.POST.get('public_key')
@@ -276,7 +276,7 b' class MyAccountController(BaseController'
276 webutils.flash(e.args[0], category='error')
276 webutils.flash(e.args[0], category='error')
277 raise HTTPFound(location=url('my_account_ssh_keys'))
277 raise HTTPFound(location=url('my_account_ssh_keys'))
278
278
279 @IfSshEnabled
279 @base.IfSshEnabled
280 def my_account_ssh_keys_delete(self):
280 def my_account_ssh_keys_delete(self):
281 fingerprint = request.POST.get('del_public_key_fingerprint')
281 fingerprint = request.POST.get('del_public_key_fingerprint')
282 try:
282 try:
@@ -36,9 +36,9 b' from tg import tmpl_context as c'
36 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
37 from webob.exc import HTTPFound
37 from webob.exc import HTTPFound
38
38
39 from kallithea.controllers import base
39 from kallithea.lib import webutils
40 from kallithea.lib import webutils
40 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
41 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
41 from kallithea.lib.base import BaseController, render
42 from kallithea.lib.webutils import url
42 from kallithea.lib.webutils import url
43 from kallithea.model import db, meta
43 from kallithea.model import db, meta
44 from kallithea.model.forms import DefaultPermissionsForm
44 from kallithea.model.forms import DefaultPermissionsForm
@@ -48,7 +48,7 b' from kallithea.model.permission import P'
48 log = logging.getLogger(__name__)
48 log = logging.getLogger(__name__)
49
49
50
50
51 class PermissionsController(BaseController):
51 class PermissionsController(base.BaseController):
52
52
53 @LoginRequired()
53 @LoginRequired()
54 @HasPermissionAnyDecorator('hg.admin')
54 @HasPermissionAnyDecorator('hg.admin')
@@ -120,7 +120,7 b' class PermissionsController(BaseControll'
120 defaults = errors.value
120 defaults = errors.value
121
121
122 return htmlfill.render(
122 return htmlfill.render(
123 render('admin/permissions/permissions.html'),
123 base.render('admin/permissions/permissions.html'),
124 defaults=defaults,
124 defaults=defaults,
125 errors=errors.error_dict or {},
125 errors=errors.error_dict or {},
126 prefix_error=False,
126 prefix_error=False,
@@ -162,7 +162,7 b' class PermissionsController(BaseControll'
162 defaults['default_fork'] = p.permission.permission_name
162 defaults['default_fork'] = p.permission.permission_name
163
163
164 return htmlfill.render(
164 return htmlfill.render(
165 render('admin/permissions/permissions.html'),
165 base.render('admin/permissions/permissions.html'),
166 defaults=defaults,
166 defaults=defaults,
167 encoding="UTF-8",
167 encoding="UTF-8",
168 force_defaults=False)
168 force_defaults=False)
@@ -173,10 +173,10 b' class PermissionsController(BaseControll'
173 c.user_ip_map = db.UserIpMap.query() \
173 c.user_ip_map = db.UserIpMap.query() \
174 .filter(db.UserIpMap.user == c.user).all()
174 .filter(db.UserIpMap.user == c.user).all()
175
175
176 return render('admin/permissions/permissions.html')
176 return base.render('admin/permissions/permissions.html')
177
177
178 def permission_perms(self):
178 def permission_perms(self):
179 c.active = 'perms'
179 c.active = 'perms'
180 c.user = db.User.get_default_user()
180 c.user = db.User.get_default_user()
181 c.perm_user = AuthUser(dbuser=c.user)
181 c.perm_user = AuthUser(dbuser=c.user)
182 return render('admin/permissions/permissions.html')
182 return base.render('admin/permissions/permissions.html')
@@ -37,9 +37,9 b' from tg.i18n import ungettext'
37 from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
37 from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
38
38
39 import kallithea.lib.helpers as h
39 import kallithea.lib.helpers as h
40 from kallithea.controllers import base
40 from kallithea.lib import webutils
41 from kallithea.lib import webutils
41 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoGroupPermissionLevelDecorator, LoginRequired
42 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoGroupPermissionLevelDecorator, LoginRequired
42 from kallithea.lib.base import BaseController, render
43 from kallithea.lib.utils2 import safe_int
43 from kallithea.lib.utils2 import safe_int
44 from kallithea.lib.webutils import url
44 from kallithea.lib.webutils import url
45 from kallithea.model import db, meta
45 from kallithea.model import db, meta
@@ -52,7 +52,7 b' from kallithea.model.scm import Availabl'
52 log = logging.getLogger(__name__)
52 log = logging.getLogger(__name__)
53
53
54
54
55 class RepoGroupsController(BaseController):
55 class RepoGroupsController(base.BaseController):
56
56
57 @LoginRequired(allow_default_user=True)
57 @LoginRequired(allow_default_user=True)
58 def _before(self, *args, **kwargs):
58 def _before(self, *args, **kwargs):
@@ -132,7 +132,7 b' class RepoGroupsController(BaseControlle'
132 "records": repo_groups_data
132 "records": repo_groups_data
133 }
133 }
134
134
135 return render('admin/repo_groups/repo_groups.html')
135 return base.render('admin/repo_groups/repo_groups.html')
136
136
137 def create(self):
137 def create(self):
138 self.__load_defaults()
138 self.__load_defaults()
@@ -154,7 +154,7 b' class RepoGroupsController(BaseControlle'
154 # TODO: in future action_logger(, '', '', '')
154 # TODO: in future action_logger(, '', '', '')
155 except formencode.Invalid as errors:
155 except formencode.Invalid as errors:
156 return htmlfill.render(
156 return htmlfill.render(
157 render('admin/repo_groups/repo_group_add.html'),
157 base.render('admin/repo_groups/repo_group_add.html'),
158 defaults=errors.value,
158 defaults=errors.value,
159 errors=errors.error_dict or {},
159 errors=errors.error_dict or {},
160 prefix_error=False,
160 prefix_error=False,
@@ -190,7 +190,7 b' class RepoGroupsController(BaseControlle'
190
190
191 self.__load_defaults()
191 self.__load_defaults()
192 return htmlfill.render(
192 return htmlfill.render(
193 render('admin/repo_groups/repo_group_add.html'),
193 base.render('admin/repo_groups/repo_group_add.html'),
194 defaults={'parent_group_id': parent_group_id},
194 defaults={'parent_group_id': parent_group_id},
195 errors={},
195 errors={},
196 prefix_error=False,
196 prefix_error=False,
@@ -230,7 +230,7 b' class RepoGroupsController(BaseControlle'
230 except formencode.Invalid as errors:
230 except formencode.Invalid as errors:
231 c.active = 'settings'
231 c.active = 'settings'
232 return htmlfill.render(
232 return htmlfill.render(
233 render('admin/repo_groups/repo_group_edit.html'),
233 base.render('admin/repo_groups/repo_group_edit.html'),
234 defaults=errors.value,
234 defaults=errors.value,
235 errors=errors.error_dict or {},
235 errors=errors.error_dict or {},
236 prefix_error=False,
236 prefix_error=False,
@@ -298,7 +298,7 b' class RepoGroupsController(BaseControlle'
298 repo_groups_list=repo_groups_list,
298 repo_groups_list=repo_groups_list,
299 short_name=True)
299 short_name=True)
300
300
301 return render('admin/repo_groups/repo_group_show.html')
301 return base.render('admin/repo_groups/repo_group_show.html')
302
302
303 @HasRepoGroupPermissionLevelDecorator('admin')
303 @HasRepoGroupPermissionLevelDecorator('admin')
304 def edit(self, group_name):
304 def edit(self, group_name):
@@ -310,7 +310,7 b' class RepoGroupsController(BaseControlle'
310 defaults = self.__load_data(c.repo_group.group_id)
310 defaults = self.__load_data(c.repo_group.group_id)
311
311
312 return htmlfill.render(
312 return htmlfill.render(
313 render('admin/repo_groups/repo_group_edit.html'),
313 base.render('admin/repo_groups/repo_group_edit.html'),
314 defaults=defaults,
314 defaults=defaults,
315 encoding="UTF-8",
315 encoding="UTF-8",
316 force_defaults=False
316 force_defaults=False
@@ -321,7 +321,7 b' class RepoGroupsController(BaseControlle'
321 c.active = 'advanced'
321 c.active = 'advanced'
322 c.repo_group = db.RepoGroup.guess_instance(group_name)
322 c.repo_group = db.RepoGroup.guess_instance(group_name)
323
323
324 return render('admin/repo_groups/repo_group_edit.html')
324 return base.render('admin/repo_groups/repo_group_edit.html')
325
325
326 @HasRepoGroupPermissionLevelDecorator('admin')
326 @HasRepoGroupPermissionLevelDecorator('admin')
327 def edit_repo_group_perms(self, group_name):
327 def edit_repo_group_perms(self, group_name):
@@ -331,7 +331,7 b' class RepoGroupsController(BaseControlle'
331 defaults = self.__load_data(c.repo_group.group_id)
331 defaults = self.__load_data(c.repo_group.group_id)
332
332
333 return htmlfill.render(
333 return htmlfill.render(
334 render('admin/repo_groups/repo_group_edit.html'),
334 base.render('admin/repo_groups/repo_group_edit.html'),
335 defaults=defaults,
335 defaults=defaults,
336 encoding="UTF-8",
336 encoding="UTF-8",
337 force_defaults=False
337 force_defaults=False
@@ -36,9 +36,9 b' from tg.i18n import ugettext as _'
36 from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
36 from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
37
37
38 import kallithea
38 import kallithea
39 from kallithea.controllers import base
39 from kallithea.lib import webutils
40 from kallithea.lib import webutils
40 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired, NotAnonymous
41 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired, NotAnonymous
41 from kallithea.lib.base import BaseRepoController, jsonify, render
42 from kallithea.lib.exceptions import AttachedForksError
42 from kallithea.lib.exceptions import AttachedForksError
43 from kallithea.lib.utils2 import safe_int
43 from kallithea.lib.utils2 import safe_int
44 from kallithea.lib.vcs import RepositoryError
44 from kallithea.lib.vcs import RepositoryError
@@ -52,7 +52,7 b' from kallithea.model.scm import Availabl'
52 log = logging.getLogger(__name__)
52 log = logging.getLogger(__name__)
53
53
54
54
55 class ReposController(BaseRepoController):
55 class ReposController(base.BaseRepoController):
56
56
57 @LoginRequired(allow_default_user=True)
57 @LoginRequired(allow_default_user=True)
58 def _before(self, *args, **kwargs):
58 def _before(self, *args, **kwargs):
@@ -93,7 +93,7 b' class ReposController(BaseRepoController'
93 # data used to render the grid
93 # data used to render the grid
94 c.data = repos_data
94 c.data = repos_data
95
95
96 return render('admin/repos/repos.html')
96 return base.render('admin/repos/repos.html')
97
97
98 @NotAnonymous()
98 @NotAnonymous()
99 def create(self):
99 def create(self):
@@ -106,7 +106,7 b' class ReposController(BaseRepoController'
106 except formencode.Invalid as errors:
106 except formencode.Invalid as errors:
107 log.info(errors)
107 log.info(errors)
108 return htmlfill.render(
108 return htmlfill.render(
109 render('admin/repos/repo_add.html'),
109 base.render('admin/repos/repo_add.html'),
110 defaults=errors.value,
110 defaults=errors.value,
111 errors=errors.error_dict or {},
111 errors=errors.error_dict or {},
112 prefix_error=False,
112 prefix_error=False,
@@ -148,7 +148,7 b' class ReposController(BaseRepoController'
148 defaults.update({'repo_group': parent_group})
148 defaults.update({'repo_group': parent_group})
149
149
150 return htmlfill.render(
150 return htmlfill.render(
151 render('admin/repos/repo_add.html'),
151 base.render('admin/repos/repo_add.html'),
152 defaults=defaults,
152 defaults=defaults,
153 errors={},
153 errors={},
154 prefix_error=False,
154 prefix_error=False,
@@ -161,10 +161,10 b' class ReposController(BaseRepoController'
161 c.task_id = request.GET.get('task_id')
161 c.task_id = request.GET.get('task_id')
162 if not c.repo:
162 if not c.repo:
163 raise HTTPNotFound()
163 raise HTTPNotFound()
164 return render('admin/repos/repo_creating.html')
164 return base.render('admin/repos/repo_creating.html')
165
165
166 @LoginRequired()
166 @LoginRequired()
167 @jsonify
167 @base.jsonify
168 def repo_check(self, repo_name):
168 def repo_check(self, repo_name):
169 c.repo = repo_name
169 c.repo = repo_name
170 task_id = request.GET.get('task_id')
170 task_id = request.GET.get('task_id')
@@ -230,7 +230,7 b' class ReposController(BaseRepoController'
230 defaults = self.__load_data()
230 defaults = self.__load_data()
231 defaults.update(errors.value)
231 defaults.update(errors.value)
232 return htmlfill.render(
232 return htmlfill.render(
233 render('admin/repos/repo_edit.html'),
233 base.render('admin/repos/repo_edit.html'),
234 defaults=defaults,
234 defaults=defaults,
235 errors=errors.error_dict or {},
235 errors=errors.error_dict or {},
236 prefix_error=False,
236 prefix_error=False,
@@ -286,7 +286,7 b' class ReposController(BaseRepoController'
286 .filter(db.RepositoryField.repository == c.repo_info).all()
286 .filter(db.RepositoryField.repository == c.repo_info).all()
287 c.active = 'settings'
287 c.active = 'settings'
288 return htmlfill.render(
288 return htmlfill.render(
289 render('admin/repos/repo_edit.html'),
289 base.render('admin/repos/repo_edit.html'),
290 defaults=defaults,
290 defaults=defaults,
291 encoding="UTF-8",
291 encoding="UTF-8",
292 force_defaults=False)
292 force_defaults=False)
@@ -298,7 +298,7 b' class ReposController(BaseRepoController'
298 defaults = RepoModel()._get_defaults(repo_name)
298 defaults = RepoModel()._get_defaults(repo_name)
299
299
300 return htmlfill.render(
300 return htmlfill.render(
301 render('admin/repos/repo_edit.html'),
301 base.render('admin/repos/repo_edit.html'),
302 defaults=defaults,
302 defaults=defaults,
303 encoding="UTF-8",
303 encoding="UTF-8",
304 force_defaults=False)
304 force_defaults=False)
@@ -355,7 +355,7 b' class ReposController(BaseRepoController'
355 if request.POST:
355 if request.POST:
356
356
357 raise HTTPFound(location=url('repo_edit_fields'))
357 raise HTTPFound(location=url('repo_edit_fields'))
358 return render('admin/repos/repo_edit.html')
358 return base.render('admin/repos/repo_edit.html')
359
359
360 @HasRepoPermissionLevelDecorator('admin')
360 @HasRepoPermissionLevelDecorator('admin')
361 def create_repo_field(self, repo_name):
361 def create_repo_field(self, repo_name):
@@ -413,7 +413,7 b' class ReposController(BaseRepoController'
413 if request.POST:
413 if request.POST:
414 raise HTTPFound(location=url('repo_edit_advanced'))
414 raise HTTPFound(location=url('repo_edit_advanced'))
415 return htmlfill.render(
415 return htmlfill.render(
416 render('admin/repos/repo_edit.html'),
416 base.render('admin/repos/repo_edit.html'),
417 defaults=defaults,
417 defaults=defaults,
418 encoding="UTF-8",
418 encoding="UTF-8",
419 force_defaults=False)
419 force_defaults=False)
@@ -478,7 +478,7 b' class ReposController(BaseRepoController'
478 webutils.flash(_('An error occurred during pull from remote location'),
478 webutils.flash(_('An error occurred during pull from remote location'),
479 category='error')
479 category='error')
480 raise HTTPFound(location=url('edit_repo_remote', repo_name=c.repo_name))
480 raise HTTPFound(location=url('edit_repo_remote', repo_name=c.repo_name))
481 return render('admin/repos/repo_edit.html')
481 return base.render('admin/repos/repo_edit.html')
482
482
483 @HasRepoPermissionLevelDecorator('admin')
483 @HasRepoPermissionLevelDecorator('admin')
484 def edit_statistics(self, repo_name):
484 def edit_statistics(self, repo_name):
@@ -510,4 +510,4 b' class ReposController(BaseRepoController'
510 category='error')
510 category='error')
511 raise HTTPFound(location=url('edit_repo_statistics', repo_name=c.repo_name))
511 raise HTTPFound(location=url('edit_repo_statistics', repo_name=c.repo_name))
512
512
513 return render('admin/repos/repo_edit.html')
513 return base.render('admin/repos/repo_edit.html')
@@ -36,9 +36,9 b' from tg.i18n import ugettext as _'
36 from webob.exc import HTTPFound
36 from webob.exc import HTTPFound
37
37
38 import kallithea
38 import kallithea
39 from kallithea.controllers import base
39 from kallithea.lib import webutils
40 from kallithea.lib import webutils
40 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
41 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
41 from kallithea.lib.base import BaseController, render
42 from kallithea.lib.utils import repo2db_mapper, set_app_settings
42 from kallithea.lib.utils import repo2db_mapper, set_app_settings
43 from kallithea.lib.utils2 import safe_str
43 from kallithea.lib.utils2 import safe_str
44 from kallithea.lib.vcs import VCSError
44 from kallithea.lib.vcs import VCSError
@@ -52,7 +52,7 b' from kallithea.model.scm import ScmModel'
52 log = logging.getLogger(__name__)
52 log = logging.getLogger(__name__)
53
53
54
54
55 class SettingsController(BaseController):
55 class SettingsController(base.BaseController):
56
56
57 @LoginRequired(allow_default_user=True)
57 @LoginRequired(allow_default_user=True)
58 def _before(self, *args, **kwargs):
58 def _before(self, *args, **kwargs):
@@ -85,7 +85,7 b' class SettingsController(BaseController)'
85 form_result = application_form.to_python(dict(request.POST))
85 form_result = application_form.to_python(dict(request.POST))
86 except formencode.Invalid as errors:
86 except formencode.Invalid as errors:
87 return htmlfill.render(
87 return htmlfill.render(
88 render('admin/settings/settings.html'),
88 base.render('admin/settings/settings.html'),
89 defaults=errors.value,
89 defaults=errors.value,
90 errors=errors.error_dict or {},
90 errors=errors.error_dict or {},
91 prefix_error=False,
91 prefix_error=False,
@@ -124,7 +124,7 b' class SettingsController(BaseController)'
124 defaults.update(self._get_hg_ui_settings())
124 defaults.update(self._get_hg_ui_settings())
125
125
126 return htmlfill.render(
126 return htmlfill.render(
127 render('admin/settings/settings.html'),
127 base.render('admin/settings/settings.html'),
128 defaults=defaults,
128 defaults=defaults,
129 encoding="UTF-8",
129 encoding="UTF-8",
130 force_defaults=False)
130 force_defaults=False)
@@ -172,7 +172,7 b' class SettingsController(BaseController)'
172 defaults.update(self._get_hg_ui_settings())
172 defaults.update(self._get_hg_ui_settings())
173
173
174 return htmlfill.render(
174 return htmlfill.render(
175 render('admin/settings/settings.html'),
175 base.render('admin/settings/settings.html'),
176 defaults=defaults,
176 defaults=defaults,
177 encoding="UTF-8",
177 encoding="UTF-8",
178 force_defaults=False)
178 force_defaults=False)
@@ -186,7 +186,7 b' class SettingsController(BaseController)'
186 form_result = application_form.to_python(dict(request.POST))
186 form_result = application_form.to_python(dict(request.POST))
187 except formencode.Invalid as errors:
187 except formencode.Invalid as errors:
188 return htmlfill.render(
188 return htmlfill.render(
189 render('admin/settings/settings.html'),
189 base.render('admin/settings/settings.html'),
190 defaults=errors.value,
190 defaults=errors.value,
191 errors=errors.error_dict or {},
191 errors=errors.error_dict or {},
192 prefix_error=False,
192 prefix_error=False,
@@ -219,7 +219,7 b' class SettingsController(BaseController)'
219 defaults.update(self._get_hg_ui_settings())
219 defaults.update(self._get_hg_ui_settings())
220
220
221 return htmlfill.render(
221 return htmlfill.render(
222 render('admin/settings/settings.html'),
222 base.render('admin/settings/settings.html'),
223 defaults=defaults,
223 defaults=defaults,
224 encoding="UTF-8",
224 encoding="UTF-8",
225 force_defaults=False)
225 force_defaults=False)
@@ -233,7 +233,7 b' class SettingsController(BaseController)'
233 form_result = application_form.to_python(dict(request.POST))
233 form_result = application_form.to_python(dict(request.POST))
234 except formencode.Invalid as errors:
234 except formencode.Invalid as errors:
235 return htmlfill.render(
235 return htmlfill.render(
236 render('admin/settings/settings.html'),
236 base.render('admin/settings/settings.html'),
237 defaults=errors.value,
237 defaults=errors.value,
238 errors=errors.error_dict or {},
238 errors=errors.error_dict or {},
239 prefix_error=False,
239 prefix_error=False,
@@ -274,7 +274,7 b' class SettingsController(BaseController)'
274 defaults.update(self._get_hg_ui_settings())
274 defaults.update(self._get_hg_ui_settings())
275
275
276 return htmlfill.render(
276 return htmlfill.render(
277 render('admin/settings/settings.html'),
277 base.render('admin/settings/settings.html'),
278 defaults=defaults,
278 defaults=defaults,
279 encoding="UTF-8",
279 encoding="UTF-8",
280 force_defaults=False)
280 force_defaults=False)
@@ -312,7 +312,7 b' class SettingsController(BaseController)'
312 c.ini = kallithea.CONFIG
312 c.ini = kallithea.CONFIG
313
313
314 return htmlfill.render(
314 return htmlfill.render(
315 render('admin/settings/settings.html'),
315 base.render('admin/settings/settings.html'),
316 defaults=defaults,
316 defaults=defaults,
317 encoding="UTF-8",
317 encoding="UTF-8",
318 force_defaults=False)
318 force_defaults=False)
@@ -367,7 +367,7 b' class SettingsController(BaseController)'
367 c.custom_hooks = db.Ui.get_custom_hooks()
367 c.custom_hooks = db.Ui.get_custom_hooks()
368
368
369 return htmlfill.render(
369 return htmlfill.render(
370 render('admin/settings/settings.html'),
370 base.render('admin/settings/settings.html'),
371 defaults=defaults,
371 defaults=defaults,
372 encoding="UTF-8",
372 encoding="UTF-8",
373 force_defaults=False)
373 force_defaults=False)
@@ -386,7 +386,7 b' class SettingsController(BaseController)'
386 defaults.update(self._get_hg_ui_settings())
386 defaults.update(self._get_hg_ui_settings())
387
387
388 return htmlfill.render(
388 return htmlfill.render(
389 render('admin/settings/settings.html'),
389 base.render('admin/settings/settings.html'),
390 defaults=defaults,
390 defaults=defaults,
391 encoding="UTF-8",
391 encoding="UTF-8",
392 force_defaults=False)
392 force_defaults=False)
@@ -404,7 +404,7 b' class SettingsController(BaseController)'
404 setattr(c, key, val)
404 setattr(c, key, val)
405
405
406 return htmlfill.render(
406 return htmlfill.render(
407 render('admin/settings/settings.html'),
407 base.render('admin/settings/settings.html'),
408 defaults=defaults,
408 defaults=defaults,
409 encoding="UTF-8",
409 encoding="UTF-8",
410 force_defaults=False)
410 force_defaults=False)
@@ -38,9 +38,9 b' from tg.i18n import ugettext as _'
38 from webob.exc import HTTPFound, HTTPInternalServerError
38 from webob.exc import HTTPFound, HTTPInternalServerError
39
39
40 import kallithea.lib.helpers as h
40 import kallithea.lib.helpers as h
41 from kallithea.controllers import base
41 from kallithea.lib import webutils
42 from kallithea.lib import webutils
42 from kallithea.lib.auth import HasPermissionAnyDecorator, HasUserGroupPermissionLevelDecorator, LoginRequired
43 from kallithea.lib.auth import HasPermissionAnyDecorator, HasUserGroupPermissionLevelDecorator, LoginRequired
43 from kallithea.lib.base import BaseController, render
44 from kallithea.lib.exceptions import RepoGroupAssignmentError, UserGroupsAssignedException
44 from kallithea.lib.exceptions import RepoGroupAssignmentError, UserGroupsAssignedException
45 from kallithea.lib.utils2 import safe_int, safe_str
45 from kallithea.lib.utils2 import safe_int, safe_str
46 from kallithea.lib.webutils import url
46 from kallithea.lib.webutils import url
@@ -53,7 +53,7 b' from kallithea.model.user_group import U'
53 log = logging.getLogger(__name__)
53 log = logging.getLogger(__name__)
54
54
55
55
56 class UserGroupsController(BaseController):
56 class UserGroupsController(base.BaseController):
57
57
58 @LoginRequired(allow_default_user=True)
58 @LoginRequired(allow_default_user=True)
59 def _before(self, *args, **kwargs):
59 def _before(self, *args, **kwargs):
@@ -113,7 +113,7 b' class UserGroupsController(BaseControlle'
113 "records": user_groups_data
113 "records": user_groups_data
114 }
114 }
115
115
116 return render('admin/user_groups/user_groups.html')
116 return base.render('admin/user_groups/user_groups.html')
117
117
118 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
118 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
119 def create(self):
119 def create(self):
@@ -134,7 +134,7 b' class UserGroupsController(BaseControlle'
134 meta.Session().commit()
134 meta.Session().commit()
135 except formencode.Invalid as errors:
135 except formencode.Invalid as errors:
136 return htmlfill.render(
136 return htmlfill.render(
137 render('admin/user_groups/user_group_add.html'),
137 base.render('admin/user_groups/user_group_add.html'),
138 defaults=errors.value,
138 defaults=errors.value,
139 errors=errors.error_dict or {},
139 errors=errors.error_dict or {},
140 prefix_error=False,
140 prefix_error=False,
@@ -149,7 +149,7 b' class UserGroupsController(BaseControlle'
149
149
150 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
150 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
151 def new(self, format='html'):
151 def new(self, format='html'):
152 return render('admin/user_groups/user_group_add.html')
152 return base.render('admin/user_groups/user_group_add.html')
153
153
154 @HasUserGroupPermissionLevelDecorator('admin')
154 @HasUserGroupPermissionLevelDecorator('admin')
155 def update(self, id):
155 def update(self, id):
@@ -184,7 +184,7 b' class UserGroupsController(BaseControlle'
184 })
184 })
185
185
186 return htmlfill.render(
186 return htmlfill.render(
187 render('admin/user_groups/user_group_edit.html'),
187 base.render('admin/user_groups/user_group_edit.html'),
188 defaults=defaults,
188 defaults=defaults,
189 errors=e,
189 errors=e,
190 prefix_error=False,
190 prefix_error=False,
@@ -221,7 +221,7 b' class UserGroupsController(BaseControlle'
221 defaults = self.__load_defaults(id)
221 defaults = self.__load_defaults(id)
222
222
223 return htmlfill.render(
223 return htmlfill.render(
224 render('admin/user_groups/user_group_edit.html'),
224 base.render('admin/user_groups/user_group_edit.html'),
225 defaults=defaults,
225 defaults=defaults,
226 encoding="UTF-8",
226 encoding="UTF-8",
227 force_defaults=False
227 force_defaults=False
@@ -243,7 +243,7 b' class UserGroupsController(BaseControlle'
243 p.permission.permission_name})
243 p.permission.permission_name})
244
244
245 return htmlfill.render(
245 return htmlfill.render(
246 render('admin/user_groups/user_group_edit.html'),
246 base.render('admin/user_groups/user_group_edit.html'),
247 defaults=defaults,
247 defaults=defaults,
248 encoding="UTF-8",
248 encoding="UTF-8",
249 force_defaults=False
249 force_defaults=False
@@ -344,7 +344,7 b' class UserGroupsController(BaseControlle'
344 })
344 })
345
345
346 return htmlfill.render(
346 return htmlfill.render(
347 render('admin/user_groups/user_group_edit.html'),
347 base.render('admin/user_groups/user_group_edit.html'),
348 defaults=defaults,
348 defaults=defaults,
349 encoding="UTF-8",
349 encoding="UTF-8",
350 force_defaults=False
350 force_defaults=False
@@ -394,7 +394,7 b' class UserGroupsController(BaseControlle'
394 c.active = 'advanced'
394 c.active = 'advanced'
395 c.group_members_obj = sorted((x.user for x in c.user_group.members),
395 c.group_members_obj = sorted((x.user for x in c.user_group.members),
396 key=lambda u: u.username.lower())
396 key=lambda u: u.username.lower())
397 return render('admin/user_groups/user_group_edit.html')
397 return base.render('admin/user_groups/user_group_edit.html')
398
398
399 @HasUserGroupPermissionLevelDecorator('admin')
399 @HasUserGroupPermissionLevelDecorator('admin')
400 def edit_members(self, id):
400 def edit_members(self, id):
@@ -404,4 +404,4 b' class UserGroupsController(BaseControlle'
404 key=lambda u: u.username.lower())
404 key=lambda u: u.username.lower())
405
405
406 c.group_members = [(x.user_id, x.username) for x in c.group_members_obj]
406 c.group_members = [(x.user_id, x.username) for x in c.group_members_obj]
407 return render('admin/user_groups/user_group_edit.html')
407 return base.render('admin/user_groups/user_group_edit.html')
@@ -38,9 +38,9 b' from webob.exc import HTTPFound, HTTPNot'
38
38
39 import kallithea
39 import kallithea
40 import kallithea.lib.helpers as h
40 import kallithea.lib.helpers as h
41 from kallithea.controllers import base
41 from kallithea.lib import auth_modules, webutils
42 from kallithea.lib import auth_modules, webutils
42 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
43 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
43 from kallithea.lib.base import BaseController, IfSshEnabled, render
44 from kallithea.lib.exceptions import DefaultUserException, UserCreationError, UserOwnsReposException
44 from kallithea.lib.exceptions import DefaultUserException, UserCreationError, UserOwnsReposException
45 from kallithea.lib.utils2 import datetime_to_time, fmt_date, generate_api_key, safe_int
45 from kallithea.lib.utils2 import datetime_to_time, fmt_date, generate_api_key, safe_int
46 from kallithea.lib.webutils import url
46 from kallithea.lib.webutils import url
@@ -54,7 +54,7 b' from kallithea.model.user import UserMod'
54 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
55
55
56
56
57 class UsersController(BaseController):
57 class UsersController(base.BaseController):
58
58
59 @LoginRequired()
59 @LoginRequired()
60 @HasPermissionAnyDecorator('hg.admin')
60 @HasPermissionAnyDecorator('hg.admin')
@@ -103,7 +103,7 b' class UsersController(BaseController):'
103 "records": users_data
103 "records": users_data
104 }
104 }
105
105
106 return render('admin/users/users.html')
106 return base.render('admin/users/users.html')
107
107
108 def create(self):
108 def create(self):
109 c.default_extern_type = db.User.DEFAULT_AUTH_TYPE
109 c.default_extern_type = db.User.DEFAULT_AUTH_TYPE
@@ -120,7 +120,7 b' class UsersController(BaseController):'
120 meta.Session().commit()
120 meta.Session().commit()
121 except formencode.Invalid as errors:
121 except formencode.Invalid as errors:
122 return htmlfill.render(
122 return htmlfill.render(
123 render('admin/users/user_add.html'),
123 base.render('admin/users/user_add.html'),
124 defaults=errors.value,
124 defaults=errors.value,
125 errors=errors.error_dict or {},
125 errors=errors.error_dict or {},
126 prefix_error=False,
126 prefix_error=False,
@@ -137,7 +137,7 b' class UsersController(BaseController):'
137 def new(self, format='html'):
137 def new(self, format='html'):
138 c.default_extern_type = db.User.DEFAULT_AUTH_TYPE
138 c.default_extern_type = db.User.DEFAULT_AUTH_TYPE
139 c.default_extern_name = ''
139 c.default_extern_name = ''
140 return render('admin/users/user_add.html')
140 return base.render('admin/users/user_add.html')
141
141
142 def update(self, id):
142 def update(self, id):
143 user_model = UserModel()
143 user_model = UserModel()
@@ -208,7 +208,7 b' class UsersController(BaseController):'
208 c.perm_user = AuthUser(dbuser=user)
208 c.perm_user = AuthUser(dbuser=user)
209 managed_fields = auth_modules.get_managed_fields(user)
209 managed_fields = auth_modules.get_managed_fields(user)
210 c.readonly = lambda n: 'readonly' if n in managed_fields else None
210 c.readonly = lambda n: 'readonly' if n in managed_fields else None
211 return render('admin/users/user_edit.html')
211 return base.render('admin/users/user_edit.html')
212
212
213 def edit(self, id, format='html'):
213 def edit(self, id, format='html'):
214 user = self._get_user_or_raise_if_default(id)
214 user = self._get_user_or_raise_if_default(id)
@@ -234,7 +234,7 b' class UsersController(BaseController):'
234 'fork_repo_perm': umodel.has_perm(c.user, 'hg.fork.repository'),
234 'fork_repo_perm': umodel.has_perm(c.user, 'hg.fork.repository'),
235 })
235 })
236 return htmlfill.render(
236 return htmlfill.render(
237 render('admin/users/user_edit.html'),
237 base.render('admin/users/user_edit.html'),
238 defaults=defaults,
238 defaults=defaults,
239 encoding="UTF-8",
239 encoding="UTF-8",
240 force_defaults=False)
240 force_defaults=False)
@@ -255,7 +255,7 b' class UsersController(BaseController):'
255 show_expired=show_expired)
255 show_expired=show_expired)
256 defaults = c.user.get_dict()
256 defaults = c.user.get_dict()
257 return htmlfill.render(
257 return htmlfill.render(
258 render('admin/users/user_edit.html'),
258 base.render('admin/users/user_edit.html'),
259 defaults=defaults,
259 defaults=defaults,
260 encoding="UTF-8",
260 encoding="UTF-8",
261 force_defaults=False)
261 force_defaults=False)
@@ -302,7 +302,7 b' class UsersController(BaseController):'
302 'fork_repo_perm': umodel.has_perm(c.user, 'hg.fork.repository'),
302 'fork_repo_perm': umodel.has_perm(c.user, 'hg.fork.repository'),
303 })
303 })
304 return htmlfill.render(
304 return htmlfill.render(
305 render('admin/users/user_edit.html'),
305 base.render('admin/users/user_edit.html'),
306 defaults=defaults,
306 defaults=defaults,
307 encoding="UTF-8",
307 encoding="UTF-8",
308 force_defaults=False)
308 force_defaults=False)
@@ -350,7 +350,7 b' class UsersController(BaseController):'
350
350
351 defaults = c.user.get_dict()
351 defaults = c.user.get_dict()
352 return htmlfill.render(
352 return htmlfill.render(
353 render('admin/users/user_edit.html'),
353 base.render('admin/users/user_edit.html'),
354 defaults=defaults,
354 defaults=defaults,
355 encoding="UTF-8",
355 encoding="UTF-8",
356 force_defaults=False)
356 force_defaults=False)
@@ -393,7 +393,7 b' class UsersController(BaseController):'
393
393
394 defaults = c.user.get_dict()
394 defaults = c.user.get_dict()
395 return htmlfill.render(
395 return htmlfill.render(
396 render('admin/users/user_edit.html'),
396 base.render('admin/users/user_edit.html'),
397 defaults=defaults,
397 defaults=defaults,
398 encoding="UTF-8",
398 encoding="UTF-8",
399 force_defaults=False)
399 force_defaults=False)
@@ -429,19 +429,19 b' class UsersController(BaseController):'
429 raise HTTPFound(location=url('admin_permissions_ips'))
429 raise HTTPFound(location=url('admin_permissions_ips'))
430 raise HTTPFound(location=url('edit_user_ips', id=id))
430 raise HTTPFound(location=url('edit_user_ips', id=id))
431
431
432 @IfSshEnabled
432 @base.IfSshEnabled
433 def edit_ssh_keys(self, id):
433 def edit_ssh_keys(self, id):
434 c.user = self._get_user_or_raise_if_default(id)
434 c.user = self._get_user_or_raise_if_default(id)
435 c.active = 'ssh_keys'
435 c.active = 'ssh_keys'
436 c.user_ssh_keys = SshKeyModel().get_ssh_keys(c.user.user_id)
436 c.user_ssh_keys = SshKeyModel().get_ssh_keys(c.user.user_id)
437 defaults = c.user.get_dict()
437 defaults = c.user.get_dict()
438 return htmlfill.render(
438 return htmlfill.render(
439 render('admin/users/user_edit.html'),
439 base.render('admin/users/user_edit.html'),
440 defaults=defaults,
440 defaults=defaults,
441 encoding="UTF-8",
441 encoding="UTF-8",
442 force_defaults=False)
442 force_defaults=False)
443
443
444 @IfSshEnabled
444 @base.IfSshEnabled
445 def ssh_keys_add(self, id):
445 def ssh_keys_add(self, id):
446 c.user = self._get_user_or_raise_if_default(id)
446 c.user = self._get_user_or_raise_if_default(id)
447
447
@@ -457,7 +457,7 b' class UsersController(BaseController):'
457 webutils.flash(e.args[0], category='error')
457 webutils.flash(e.args[0], category='error')
458 raise HTTPFound(location=url('edit_user_ssh_keys', id=c.user.user_id))
458 raise HTTPFound(location=url('edit_user_ssh_keys', id=c.user.user_id))
459
459
460 @IfSshEnabled
460 @base.IfSshEnabled
461 def ssh_keys_delete(self, id):
461 def ssh_keys_delete(self, id):
462 c.user = self._get_user_or_raise_if_default(id)
462 c.user = self._get_user_or_raise_if_default(id)
463
463
@@ -35,9 +35,9 b' import types'
35 from tg import Response, TGController, request, response
35 from tg import Response, TGController, request, response
36 from webob.exc import HTTPError, HTTPException
36 from webob.exc import HTTPError, HTTPException
37
37
38 from kallithea.controllers import base
38 from kallithea.lib import ext_json
39 from kallithea.lib import ext_json
39 from kallithea.lib.auth import AuthUser
40 from kallithea.lib.auth import AuthUser
40 from kallithea.lib.base import get_ip_addr, get_path_info
41 from kallithea.lib.utils2 import ascii_bytes
41 from kallithea.lib.utils2 import ascii_bytes
42 from kallithea.model import db
42 from kallithea.model import db
43
43
@@ -99,7 +99,7 b' class JSONRPCController(TGController):'
99
99
100 environ = state.request.environ
100 environ = state.request.environ
101 start = time.time()
101 start = time.time()
102 ip_addr = get_ip_addr(environ)
102 ip_addr = base.get_ip_addr(environ)
103 self._req_id = None
103 self._req_id = None
104 if 'CONTENT_LENGTH' not in environ:
104 if 'CONTENT_LENGTH' not in environ:
105 log.debug("No Content-Length")
105 log.debug("No Content-Length")
@@ -204,8 +204,8 b' class JSONRPCController(TGController):'
204 self._rpc_args['environ'] = environ
204 self._rpc_args['environ'] = environ
205
205
206 log.info('IP: %s Request to %s time: %.3fs' % (
206 log.info('IP: %s Request to %s time: %.3fs' % (
207 get_ip_addr(environ),
207 base.get_ip_addr(environ),
208 get_path_info(environ), time.time() - start)
208 base.get_path_info(environ), time.time() - start)
209 )
209 )
210
210
211 state.set_action(self._rpc_call, [])
211 state.set_action(self._rpc_call, [])
@@ -13,8 +13,8 b''
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 """
15 """
16 kallithea.lib.base
16 kallithea.controllers.base
17 ~~~~~~~~~~~~~~~~~~
17 ~~~~~~~~~~~~~~~~~~~~~~~~~~
18
18
19 The base Controller API
19 The base Controller API
20 Provides the BaseController class for subclassing. And usage in different
20 Provides the BaseController class for subclassing. And usage in different
@@ -33,9 +33,9 b' from tg import tmpl_context as c'
33 from tg.i18n import ugettext as _
33 from tg.i18n import ugettext as _
34 from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
34 from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
35
35
36 from kallithea.controllers import base
36 from kallithea.lib import webutils
37 from kallithea.lib import webutils
37 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
38 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
38 from kallithea.lib.base import BaseRepoController, render
39 from kallithea.lib.graphmod import graph_data
39 from kallithea.lib.graphmod import graph_data
40 from kallithea.lib.page import Page
40 from kallithea.lib.page import Page
41 from kallithea.lib.utils2 import safe_int
41 from kallithea.lib.utils2 import safe_int
@@ -46,7 +46,7 b' from kallithea.lib.webutils import url'
46 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
47
47
48
48
49 class ChangelogController(BaseRepoController):
49 class ChangelogController(base.BaseRepoController):
50
50
51 def _before(self, *args, **kwargs):
51 def _before(self, *args, **kwargs):
52 super(ChangelogController, self)._before(*args, **kwargs)
52 super(ChangelogController, self)._before(*args, **kwargs)
@@ -146,12 +146,12 b' class ChangelogController(BaseRepoContro'
146
146
147 c.revision = revision # requested revision ref
147 c.revision = revision # requested revision ref
148 c.first_revision = c.cs_pagination[0] # pagination is never empty here!
148 c.first_revision = c.cs_pagination[0] # pagination is never empty here!
149 return render('changelog/changelog.html')
149 return base.render('changelog/changelog.html')
150
150
151 @LoginRequired(allow_default_user=True)
151 @LoginRequired(allow_default_user=True)
152 @HasRepoPermissionLevelDecorator('read')
152 @HasRepoPermissionLevelDecorator('read')
153 def changelog_details(self, cs):
153 def changelog_details(self, cs):
154 if request.environ.get('HTTP_X_PARTIAL_XHR'):
154 if request.environ.get('HTTP_X_PARTIAL_XHR'):
155 c.cs = c.db_repo_scm_instance.get_changeset(cs)
155 c.cs = c.db_repo_scm_instance.get_changeset(cs)
156 return render('changelog/changelog_details.html')
156 return base.render('changelog/changelog_details.html')
157 raise HTTPNotFound()
157 raise HTTPNotFound()
@@ -36,9 +36,9 b' from tg.i18n import ugettext as _'
36 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPNotFound
36 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPNotFound
37
37
38 import kallithea.lib.helpers as h
38 import kallithea.lib.helpers as h
39 from kallithea.controllers import base
39 from kallithea.lib import auth, diffs, webutils
40 from kallithea.lib import auth, diffs, webutils
40 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
41 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
41 from kallithea.lib.base import BaseRepoController, jsonify, render
42 from kallithea.lib.graphmod import graph_data
42 from kallithea.lib.graphmod import graph_data
43 from kallithea.lib.utils2 import ascii_str, safe_str
43 from kallithea.lib.utils2 import ascii_str, safe_str
44 from kallithea.lib.vcs.backends.base import EmptyChangeset
44 from kallithea.lib.vcs.backends.base import EmptyChangeset
@@ -148,7 +148,7 b' def create_cs_pr_comment(repo_name, revi'
148 c.comment = comment
148 c.comment = comment
149 data.update(comment.get_dict())
149 data.update(comment.get_dict())
150 data.update({'rendered_text':
150 data.update({'rendered_text':
151 render('changeset/changeset_comment_block.html')})
151 base.render('changeset/changeset_comment_block.html')})
152
152
153 return data
153 return data
154
154
@@ -170,7 +170,7 b' def delete_cs_pr_comment(repo_name, comm'
170 else:
170 else:
171 raise HTTPForbidden()
171 raise HTTPForbidden()
172
172
173 class ChangesetController(BaseRepoController):
173 class ChangesetController(base.BaseRepoController):
174
174
175 def _before(self, *args, **kwargs):
175 def _before(self, *args, **kwargs):
176 super(ChangesetController, self)._before(*args, **kwargs)
176 super(ChangesetController, self)._before(*args, **kwargs)
@@ -285,19 +285,19 b' class ChangesetController(BaseRepoContro'
285 elif method == 'patch':
285 elif method == 'patch':
286 response.content_type = 'text/plain'
286 response.content_type = 'text/plain'
287 c.diff = safe_str(raw_diff)
287 c.diff = safe_str(raw_diff)
288 return render('changeset/patch_changeset.html')
288 return base.render('changeset/patch_changeset.html')
289 elif method == 'raw':
289 elif method == 'raw':
290 response.content_type = 'text/plain'
290 response.content_type = 'text/plain'
291 return raw_diff
291 return raw_diff
292 elif method == 'show':
292 elif method == 'show':
293 if len(c.cs_ranges) == 1:
293 if len(c.cs_ranges) == 1:
294 return render('changeset/changeset.html')
294 return base.render('changeset/changeset.html')
295 else:
295 else:
296 c.cs_ranges_org = None
296 c.cs_ranges_org = None
297 c.cs_comments = {}
297 c.cs_comments = {}
298 revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
298 revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
299 c.jsdata = graph_data(c.db_repo_scm_instance, revs)
299 c.jsdata = graph_data(c.db_repo_scm_instance, revs)
300 return render('changeset/changeset_range.html')
300 return base.render('changeset/changeset_range.html')
301
301
302 @LoginRequired(allow_default_user=True)
302 @LoginRequired(allow_default_user=True)
303 @HasRepoPermissionLevelDecorator('read')
303 @HasRepoPermissionLevelDecorator('read')
@@ -321,19 +321,19 b' class ChangesetController(BaseRepoContro'
321
321
322 @LoginRequired()
322 @LoginRequired()
323 @HasRepoPermissionLevelDecorator('read')
323 @HasRepoPermissionLevelDecorator('read')
324 @jsonify
324 @base.jsonify
325 def comment(self, repo_name, revision):
325 def comment(self, repo_name, revision):
326 return create_cs_pr_comment(repo_name, revision=revision)
326 return create_cs_pr_comment(repo_name, revision=revision)
327
327
328 @LoginRequired()
328 @LoginRequired()
329 @HasRepoPermissionLevelDecorator('read')
329 @HasRepoPermissionLevelDecorator('read')
330 @jsonify
330 @base.jsonify
331 def delete_comment(self, repo_name, comment_id):
331 def delete_comment(self, repo_name, comment_id):
332 return delete_cs_pr_comment(repo_name, comment_id)
332 return delete_cs_pr_comment(repo_name, comment_id)
333
333
334 @LoginRequired(allow_default_user=True)
334 @LoginRequired(allow_default_user=True)
335 @HasRepoPermissionLevelDecorator('read')
335 @HasRepoPermissionLevelDecorator('read')
336 @jsonify
336 @base.jsonify
337 def changeset_info(self, repo_name, revision):
337 def changeset_info(self, repo_name, revision):
338 if request.is_xhr:
338 if request.is_xhr:
339 try:
339 try:
@@ -345,7 +345,7 b' class ChangesetController(BaseRepoContro'
345
345
346 @LoginRequired(allow_default_user=True)
346 @LoginRequired(allow_default_user=True)
347 @HasRepoPermissionLevelDecorator('read')
347 @HasRepoPermissionLevelDecorator('read')
348 @jsonify
348 @base.jsonify
349 def changeset_children(self, repo_name, revision):
349 def changeset_children(self, repo_name, revision):
350 if request.is_xhr:
350 if request.is_xhr:
351 changeset = c.db_repo_scm_instance.get_changeset(revision)
351 changeset = c.db_repo_scm_instance.get_changeset(revision)
@@ -358,7 +358,7 b' class ChangesetController(BaseRepoContro'
358
358
359 @LoginRequired(allow_default_user=True)
359 @LoginRequired(allow_default_user=True)
360 @HasRepoPermissionLevelDecorator('read')
360 @HasRepoPermissionLevelDecorator('read')
361 @jsonify
361 @base.jsonify
362 def changeset_parents(self, repo_name, revision):
362 def changeset_parents(self, repo_name, revision):
363 if request.is_xhr:
363 if request.is_xhr:
364 changeset = c.db_repo_scm_instance.get_changeset(revision)
364 changeset = c.db_repo_scm_instance.get_changeset(revision)
@@ -35,9 +35,9 b' from tg.i18n import ugettext as _'
35 from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
35 from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
36
36
37 import kallithea.lib.helpers as h
37 import kallithea.lib.helpers as h
38 from kallithea.controllers import base
38 from kallithea.lib import diffs, webutils
39 from kallithea.lib import diffs, webutils
39 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
40 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
40 from kallithea.lib.base import BaseRepoController, render
41 from kallithea.lib.graphmod import graph_data
41 from kallithea.lib.graphmod import graph_data
42 from kallithea.lib.webutils import url
42 from kallithea.lib.webutils import url
43 from kallithea.model import db
43 from kallithea.model import db
@@ -46,7 +46,7 b' from kallithea.model import db'
46 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
47
47
48
48
49 class CompareController(BaseRepoController):
49 class CompareController(base.BaseRepoController):
50
50
51 def _before(self, *args, **kwargs):
51 def _before(self, *args, **kwargs):
52 super(CompareController, self)._before(*args, **kwargs)
52 super(CompareController, self)._before(*args, **kwargs)
@@ -76,7 +76,7 b' class CompareController(BaseRepoControll'
76 def index(self, repo_name):
76 def index(self, repo_name):
77 c.compare_home = True
77 c.compare_home = True
78 c.a_ref_name = c.cs_ref_name = None
78 c.a_ref_name = c.cs_ref_name = None
79 return render('compare/compare_diff.html')
79 return base.render('compare/compare_diff.html')
80
80
81 @LoginRequired(allow_default_user=True)
81 @LoginRequired(allow_default_user=True)
82 @HasRepoPermissionLevelDecorator('read')
82 @HasRepoPermissionLevelDecorator('read')
@@ -129,7 +129,7 b' class CompareController(BaseRepoControll'
129 c.jsdata = graph_data(c.cs_repo.scm_instance, revs)
129 c.jsdata = graph_data(c.cs_repo.scm_instance, revs)
130
130
131 if partial:
131 if partial:
132 return render('compare/compare_cs.html')
132 return base.render('compare/compare_cs.html')
133
133
134 org_repo = c.a_repo
134 org_repo = c.a_repo
135 other_repo = c.cs_repo
135 other_repo = c.cs_repo
@@ -185,4 +185,4 b' class CompareController(BaseRepoControll'
185 html_diff = diffs.as_html(parsed_lines=[f])
185 html_diff = diffs.as_html(parsed_lines=[f])
186 c.file_diff_data.append((fid, None, f['operation'], f['old_filename'], filename, html_diff, st))
186 c.file_diff_data.append((fid, None, f['operation'], f['old_filename'], filename, html_diff, st))
187
187
188 return render('compare/compare_diff.html')
188 return base.render('compare/compare_diff.html')
@@ -32,13 +32,13 b' from tg import config, expose, request'
32 from tg import tmpl_context as c
32 from tg import tmpl_context as c
33 from tg.i18n import ugettext as _
33 from tg.i18n import ugettext as _
34
34
35 from kallithea.lib.base import BaseController
35 from kallithea.controllers import base
36
36
37
37
38 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
39
39
40
40
41 class ErrorController(BaseController):
41 class ErrorController(base.BaseController):
42 """Generates error documents as and when they are required.
42 """Generates error documents as and when they are required.
43
43
44 The errorpage middleware renders /error/document when error
44 The errorpage middleware renders /error/document when error
@@ -35,9 +35,9 b' from tg.i18n import ugettext as _'
35
35
36 import kallithea
36 import kallithea
37 import kallithea.lib.helpers as h
37 import kallithea.lib.helpers as h
38 from kallithea.controllers import base
38 from kallithea.lib import feeds, webutils
39 from kallithea.lib import feeds, webutils
39 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
40 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
40 from kallithea.lib.base import BaseRepoController
41 from kallithea.lib.diffs import DiffProcessor
41 from kallithea.lib.diffs import DiffProcessor
42 from kallithea.lib.utils2 import asbool, fmt_date, safe_int, safe_str, shorter
42 from kallithea.lib.utils2 import asbool, fmt_date, safe_int, safe_str, shorter
43
43
@@ -45,7 +45,7 b' from kallithea.lib.utils2 import asbool,'
45 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
46
46
47
47
48 class FeedController(BaseRepoController):
48 class FeedController(base.BaseRepoController):
49
49
50 @LoginRequired(allow_default_user=True)
50 @LoginRequired(allow_default_user=True)
51 @HasRepoPermissionLevelDecorator('read')
51 @HasRepoPermissionLevelDecorator('read')
@@ -40,9 +40,9 b' from webob.exc import HTTPFound, HTTPNot'
40
40
41 import kallithea
41 import kallithea
42 import kallithea.lib.helpers as h
42 import kallithea.lib.helpers as h
43 from kallithea.controllers import base
43 from kallithea.lib import diffs, webutils
44 from kallithea.lib import diffs, webutils
44 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
45 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
45 from kallithea.lib.base import BaseRepoController, jsonify, render
46 from kallithea.lib.exceptions import NonRelativePathError
46 from kallithea.lib.exceptions import NonRelativePathError
47 from kallithea.lib.utils2 import asbool, convert_line_endings, detect_mode, safe_str
47 from kallithea.lib.utils2 import asbool, convert_line_endings, detect_mode, safe_str
48 from kallithea.lib.vcs.backends.base import EmptyChangeset
48 from kallithea.lib.vcs.backends.base import EmptyChangeset
@@ -60,7 +60,7 b' from kallithea.model.scm import ScmModel'
60 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
61
61
62
62
63 class FilesController(BaseRepoController):
63 class FilesController(base.BaseRepoController):
64
64
65 def _before(self, *args, **kwargs):
65 def _before(self, *args, **kwargs):
66 super(FilesController, self)._before(*args, **kwargs)
66 super(FilesController, self)._before(*args, **kwargs)
@@ -179,7 +179,7 b' class FilesController(BaseRepoController'
179 raise HTTPNotFound()
179 raise HTTPNotFound()
180
180
181 if request.environ.get('HTTP_X_PARTIAL_XHR'):
181 if request.environ.get('HTTP_X_PARTIAL_XHR'):
182 return render('files/files_ypjax.html')
182 return base.render('files/files_ypjax.html')
183
183
184 # TODO: tags and bookmarks?
184 # TODO: tags and bookmarks?
185 c.revision_options = [(c.changeset.raw_id,
185 c.revision_options = [(c.changeset.raw_id,
@@ -190,11 +190,11 b' class FilesController(BaseRepoController'
190 c.revision_options += [('-', '-')] + \
190 c.revision_options += [('-', '-')] + \
191 [(n, prefix + b) for b, n in c.db_repo_scm_instance.closed_branches.items()]
191 [(n, prefix + b) for b, n in c.db_repo_scm_instance.closed_branches.items()]
192
192
193 return render('files/files.html')
193 return base.render('files/files.html')
194
194
195 @LoginRequired(allow_default_user=True)
195 @LoginRequired(allow_default_user=True)
196 @HasRepoPermissionLevelDecorator('read')
196 @HasRepoPermissionLevelDecorator('read')
197 @jsonify
197 @base.jsonify
198 def history(self, repo_name, revision, f_path):
198 def history(self, repo_name, revision, f_path):
199 changeset = self.__get_cs(revision)
199 changeset = self.__get_cs(revision)
200 _file = changeset.get_node(f_path)
200 _file = changeset.get_node(f_path)
@@ -224,7 +224,7 b' class FilesController(BaseRepoController'
224 c.authors = []
224 c.authors = []
225 for a in set([x.author for x in _hist]):
225 for a in set([x.author for x in _hist]):
226 c.authors.append((author_email(a), h.person(a)))
226 c.authors.append((author_email(a), h.person(a)))
227 return render('files/files_history_box.html')
227 return base.render('files/files_history_box.html')
228
228
229 @LoginRequired(allow_default_user=True)
229 @LoginRequired(allow_default_user=True)
230 @HasRepoPermissionLevelDecorator('read')
230 @HasRepoPermissionLevelDecorator('read')
@@ -335,7 +335,7 b' class FilesController(BaseRepoController'
335 raise HTTPFound(location=url('changeset_home',
335 raise HTTPFound(location=url('changeset_home',
336 repo_name=c.repo_name, revision='tip'))
336 repo_name=c.repo_name, revision='tip'))
337
337
338 return render('files/files_delete.html')
338 return base.render('files/files_delete.html')
339
339
340 @LoginRequired()
340 @LoginRequired()
341 @HasRepoPermissionLevelDecorator('write')
341 @HasRepoPermissionLevelDecorator('write')
@@ -393,7 +393,7 b' class FilesController(BaseRepoController'
393 raise HTTPFound(location=url('changeset_home',
393 raise HTTPFound(location=url('changeset_home',
394 repo_name=c.repo_name, revision='tip'))
394 repo_name=c.repo_name, revision='tip'))
395
395
396 return render('files/files_edit.html')
396 return base.render('files/files_edit.html')
397
397
398 @LoginRequired()
398 @LoginRequired()
399 @HasRepoPermissionLevelDecorator('write')
399 @HasRepoPermissionLevelDecorator('write')
@@ -468,7 +468,7 b' class FilesController(BaseRepoController'
468 raise HTTPFound(location=url('changeset_home',
468 raise HTTPFound(location=url('changeset_home',
469 repo_name=c.repo_name, revision='tip'))
469 repo_name=c.repo_name, revision='tip'))
470
470
471 return render('files/files_add.html')
471 return base.render('files/files_add.html')
472
472
473 @LoginRequired(allow_default_user=True)
473 @LoginRequired(allow_default_user=True)
474 @HasRepoPermissionLevelDecorator('read')
474 @HasRepoPermissionLevelDecorator('read')
@@ -645,7 +645,7 b' class FilesController(BaseRepoController'
645 ignore_whitespace=ignore_whitespace_diff,
645 ignore_whitespace=ignore_whitespace_diff,
646 line_context=diff_context_size)
646 line_context=diff_context_size)
647 c.file_diff_data = [(fid, fid, op, a_path, node2.path, diff, st)]
647 c.file_diff_data = [(fid, fid, op, a_path, node2.path, diff, st)]
648 return render('files/file_diff.html')
648 return base.render('files/file_diff.html')
649
649
650 @LoginRequired(allow_default_user=True)
650 @LoginRequired(allow_default_user=True)
651 @HasRepoPermissionLevelDecorator('read')
651 @HasRepoPermissionLevelDecorator('read')
@@ -693,7 +693,7 b' class FilesController(BaseRepoController'
693 c.cs1 = c.changeset_1
693 c.cs1 = c.changeset_1
694 c.cs2 = c.changeset_2
694 c.cs2 = c.changeset_2
695
695
696 return render('files/diff_2way.html')
696 return base.render('files/diff_2way.html')
697
697
698 def _get_node_history(self, cs, f_path, changesets=None):
698 def _get_node_history(self, cs, f_path, changesets=None):
699 """
699 """
@@ -736,7 +736,7 b' class FilesController(BaseRepoController'
736
736
737 @LoginRequired(allow_default_user=True)
737 @LoginRequired(allow_default_user=True)
738 @HasRepoPermissionLevelDecorator('read')
738 @HasRepoPermissionLevelDecorator('read')
739 @jsonify
739 @base.jsonify
740 def nodelist(self, repo_name, revision, f_path):
740 def nodelist(self, repo_name, revision, f_path):
741 if request.environ.get('HTTP_X_PARTIAL_XHR'):
741 if request.environ.get('HTTP_X_PARTIAL_XHR'):
742 cs = self.__get_cs(revision)
742 cs = self.__get_cs(revision)
@@ -30,8 +30,8 b' import logging'
30 from tg import request
30 from tg import request
31 from tg import tmpl_context as c
31 from tg import tmpl_context as c
32
32
33 from kallithea.controllers import base
33 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
34 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
34 from kallithea.lib.base import BaseRepoController, render
35 from kallithea.lib.page import Page
35 from kallithea.lib.page import Page
36 from kallithea.lib.utils2 import safe_int
36 from kallithea.lib.utils2 import safe_int
37 from kallithea.model import db
37 from kallithea.model import db
@@ -40,7 +40,7 b' from kallithea.model import db'
40 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
41
41
42
42
43 class FollowersController(BaseRepoController):
43 class FollowersController(base.BaseRepoController):
44
44
45 @LoginRequired(allow_default_user=True)
45 @LoginRequired(allow_default_user=True)
46 @HasRepoPermissionLevelDecorator('read')
46 @HasRepoPermissionLevelDecorator('read')
@@ -52,6 +52,6 b' class FollowersController(BaseRepoContro'
52 c.followers_pager = Page(d, page=p, items_per_page=20)
52 c.followers_pager = Page(d, page=p, items_per_page=20)
53
53
54 if request.environ.get('HTTP_X_PARTIAL_XHR'):
54 if request.environ.get('HTTP_X_PARTIAL_XHR'):
55 return render('/followers/followers_data.html')
55 return base.render('/followers/followers_data.html')
56
56
57 return render('/followers/followers.html')
57 return base.render('/followers/followers.html')
@@ -36,9 +36,9 b' from tg.i18n import ugettext as _'
36 from webob.exc import HTTPFound, HTTPNotFound
36 from webob.exc import HTTPFound, HTTPNotFound
37
37
38 import kallithea
38 import kallithea
39 from kallithea.controllers import base
39 from kallithea.lib import webutils
40 from kallithea.lib import webutils
40 from kallithea.lib.auth import HasPermissionAnyDecorator, HasRepoPermissionLevel, HasRepoPermissionLevelDecorator, LoginRequired
41 from kallithea.lib.auth import HasPermissionAnyDecorator, HasRepoPermissionLevel, HasRepoPermissionLevelDecorator, LoginRequired
41 from kallithea.lib.base import BaseRepoController, render
42 from kallithea.lib.page import Page
42 from kallithea.lib.page import Page
43 from kallithea.lib.utils2 import safe_int
43 from kallithea.lib.utils2 import safe_int
44 from kallithea.model import db
44 from kallithea.model import db
@@ -50,7 +50,7 b' from kallithea.model.scm import Availabl'
50 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
51
51
52
52
53 class ForksController(BaseRepoController):
53 class ForksController(base.BaseRepoController):
54
54
55 def __load_defaults(self):
55 def __load_defaults(self):
56 c.repo_groups = AvailableRepoGroupChoices('write')
56 c.repo_groups = AvailableRepoGroupChoices('write')
@@ -113,9 +113,9 b' class ForksController(BaseRepoController'
113 c.forks_pager = Page(d, page=p, items_per_page=20)
113 c.forks_pager = Page(d, page=p, items_per_page=20)
114
114
115 if request.environ.get('HTTP_X_PARTIAL_XHR'):
115 if request.environ.get('HTTP_X_PARTIAL_XHR'):
116 return render('/forks/forks_data.html')
116 return base.render('/forks/forks_data.html')
117
117
118 return render('/forks/forks.html')
118 return base.render('/forks/forks.html')
119
119
120 @LoginRequired()
120 @LoginRequired()
121 @HasPermissionAnyDecorator('hg.admin', 'hg.fork.repository')
121 @HasPermissionAnyDecorator('hg.admin', 'hg.fork.repository')
@@ -128,7 +128,7 b' class ForksController(BaseRepoController'
128 defaults = self.__load_data()
128 defaults = self.__load_data()
129
129
130 return htmlfill.render(
130 return htmlfill.render(
131 render('forks/fork.html'),
131 base.render('forks/fork.html'),
132 defaults=defaults,
132 defaults=defaults,
133 encoding="UTF-8",
133 encoding="UTF-8",
134 force_defaults=False)
134 force_defaults=False)
@@ -157,7 +157,7 b' class ForksController(BaseRepoController'
157 task_id = task.task_id
157 task_id = task.task_id
158 except formencode.Invalid as errors:
158 except formencode.Invalid as errors:
159 return htmlfill.render(
159 return htmlfill.render(
160 render('forks/fork.html'),
160 base.render('forks/fork.html'),
161 defaults=errors.value,
161 defaults=errors.value,
162 errors=errors.error_dict or {},
162 errors=errors.error_dict or {},
163 prefix_error=False,
163 prefix_error=False,
@@ -35,8 +35,8 b' from tg.i18n import ugettext as _'
35 from webob.exc import HTTPBadRequest
35 from webob.exc import HTTPBadRequest
36
36
37 import kallithea.lib.helpers as h
37 import kallithea.lib.helpers as h
38 from kallithea.controllers import base
38 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
39 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
39 from kallithea.lib.base import BaseController, jsonify, render
40 from kallithea.lib.utils2 import safe_str
40 from kallithea.lib.utils2 import safe_str
41 from kallithea.model import db
41 from kallithea.model import db
42 from kallithea.model.repo import RepoModel
42 from kallithea.model.repo import RepoModel
@@ -46,10 +46,10 b' from kallithea.model.scm import UserGrou'
46 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
47
47
48
48
49 class HomeController(BaseController):
49 class HomeController(base.BaseController):
50
50
51 def about(self):
51 def about(self):
52 return render('/about.html')
52 return base.render('/about.html')
53
53
54 @LoginRequired(allow_default_user=True)
54 @LoginRequired(allow_default_user=True)
55 def index(self):
55 def index(self):
@@ -62,10 +62,10 b' class HomeController(BaseController):'
62 repo_groups_list=repo_groups_list,
62 repo_groups_list=repo_groups_list,
63 short_name=True)
63 short_name=True)
64
64
65 return render('/index.html')
65 return base.render('/index.html')
66
66
67 @LoginRequired(allow_default_user=True)
67 @LoginRequired(allow_default_user=True)
68 @jsonify
68 @base.jsonify
69 def repo_switcher_data(self):
69 def repo_switcher_data(self):
70 if request.is_xhr:
70 if request.is_xhr:
71 all_repos = db.Repository.query(sorted=True).all()
71 all_repos = db.Repository.query(sorted=True).all()
@@ -109,7 +109,7 b' class HomeController(BaseController):'
109
109
110 @LoginRequired(allow_default_user=True)
110 @LoginRequired(allow_default_user=True)
111 @HasRepoPermissionLevelDecorator('read')
111 @HasRepoPermissionLevelDecorator('read')
112 @jsonify
112 @base.jsonify
113 def repo_refs_data(self, repo_name):
113 def repo_refs_data(self, repo_name):
114 repo = db.Repository.get_by_repo_name(repo_name).scm_instance
114 repo = db.Repository.get_by_repo_name(repo_name).scm_instance
115 res = []
115 res = []
@@ -144,7 +144,7 b' class HomeController(BaseController):'
144 return data
144 return data
145
145
146 @LoginRequired()
146 @LoginRequired()
147 @jsonify
147 @base.jsonify
148 def users_and_groups_data(self):
148 def users_and_groups_data(self):
149 """
149 """
150 Returns 'results' with a list of users and user groups.
150 Returns 'results' with a list of users and user groups.
@@ -37,10 +37,10 b' from tg.i18n import ugettext as _'
37 from webob.exc import HTTPBadRequest
37 from webob.exc import HTTPBadRequest
38
38
39 import kallithea.lib.helpers as h
39 import kallithea.lib.helpers as h
40 from kallithea.controllers import base
40 from kallithea.controllers.admin.admin import _journal_filter
41 from kallithea.controllers.admin.admin import _journal_filter
41 from kallithea.lib import feeds, webutils
42 from kallithea.lib import feeds, webutils
42 from kallithea.lib.auth import LoginRequired
43 from kallithea.lib.auth import LoginRequired
43 from kallithea.lib.base import BaseController, render
44 from kallithea.lib.page import Page
44 from kallithea.lib.page import Page
45 from kallithea.lib.utils2 import AttributeDict, safe_int
45 from kallithea.lib.utils2 import AttributeDict, safe_int
46 from kallithea.model import db, meta
46 from kallithea.model import db, meta
@@ -55,7 +55,7 b' ttl = "5"'
55 feed_nr = 20
55 feed_nr = 20
56
56
57
57
58 class JournalController(BaseController):
58 class JournalController(base.BaseController):
59
59
60 def _before(self, *args, **kwargs):
60 def _before(self, *args, **kwargs):
61 super(JournalController, self)._before(*args, **kwargs)
61 super(JournalController, self)._before(*args, **kwargs)
@@ -178,7 +178,7 b' class JournalController(BaseController):'
178 c.journal_day_aggregate = self._get_daily_aggregate(c.journal_pager)
178 c.journal_day_aggregate = self._get_daily_aggregate(c.journal_pager)
179
179
180 if request.environ.get('HTTP_X_PARTIAL_XHR'):
180 if request.environ.get('HTTP_X_PARTIAL_XHR'):
181 return render('journal/journal_data.html')
181 return base.render('journal/journal_data.html')
182
182
183 repos_list = db.Repository.query(sorted=True) \
183 repos_list = db.Repository.query(sorted=True) \
184 .filter_by(owner_id=request.authuser.user_id).all()
184 .filter_by(owner_id=request.authuser.user_id).all()
@@ -187,7 +187,7 b' class JournalController(BaseController):'
187 # data used to render the grid
187 # data used to render the grid
188 c.data = repos_data
188 c.data = repos_data
189
189
190 return render('journal/journal.html')
190 return base.render('journal/journal.html')
191
191
192 @LoginRequired()
192 @LoginRequired()
193 def journal_atom(self):
193 def journal_atom(self):
@@ -250,9 +250,9 b' class JournalController(BaseController):'
250 c.journal_day_aggregate = self._get_daily_aggregate(c.journal_pager)
250 c.journal_day_aggregate = self._get_daily_aggregate(c.journal_pager)
251
251
252 if request.environ.get('HTTP_X_PARTIAL_XHR'):
252 if request.environ.get('HTTP_X_PARTIAL_XHR'):
253 return render('journal/journal_data.html')
253 return base.render('journal/journal_data.html')
254
254
255 return render('journal/public_journal.html')
255 return base.render('journal/public_journal.html')
256
256
257 @LoginRequired(allow_default_user=True)
257 @LoginRequired(allow_default_user=True)
258 def public_journal_atom(self):
258 def public_journal_atom(self):
@@ -36,9 +36,9 b' from tg import tmpl_context as c'
36 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
37 from webob.exc import HTTPBadRequest, HTTPFound
37 from webob.exc import HTTPBadRequest, HTTPFound
38
38
39 from kallithea.controllers import base
39 from kallithea.lib import webutils
40 from kallithea.lib import webutils
40 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator
41 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator
41 from kallithea.lib.base import BaseController, log_in_user, render
42 from kallithea.lib.exceptions import UserCreationError
42 from kallithea.lib.exceptions import UserCreationError
43 from kallithea.lib.recaptcha import submit
43 from kallithea.lib.recaptcha import submit
44 from kallithea.lib.webutils import url
44 from kallithea.lib.webutils import url
@@ -50,7 +50,7 b' from kallithea.model.user import UserMod'
50 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
51
51
52
52
53 class LoginController(BaseController):
53 class LoginController(base.BaseController):
54
54
55 def _validate_came_from(self, came_from,
55 def _validate_came_from(self, came_from,
56 _re=re.compile(r"/(?!/)[-!#$%&'()*+,./:;=?@_~0-9A-Za-z]*$")):
56 _re=re.compile(r"/(?!/)[-!#$%&'()*+,./:;=?@_~0-9A-Za-z]*$")):
@@ -89,7 +89,7 b' class LoginController(BaseController):'
89 # remove password from filling in form again
89 # remove password from filling in form again
90 defaults.pop('password', None)
90 defaults.pop('password', None)
91 return htmlfill.render(
91 return htmlfill.render(
92 render('/login.html'),
92 base.render('/login.html'),
93 defaults=errors.value,
93 defaults=errors.value,
94 errors=errors.error_dict or {},
94 errors=errors.error_dict or {},
95 prefix_error=False,
95 prefix_error=False,
@@ -103,7 +103,7 b' class LoginController(BaseController):'
103 webutils.flash(e, 'error')
103 webutils.flash(e, 'error')
104 else:
104 else:
105 # login_form already validated the password - now set the session cookie accordingly
105 # login_form already validated the password - now set the session cookie accordingly
106 auth_user = log_in_user(user, c.form_result['remember'], is_external_auth=False, ip_addr=request.ip_addr)
106 auth_user = base.log_in_user(user, c.form_result['remember'], is_external_auth=False, ip_addr=request.ip_addr)
107 if auth_user:
107 if auth_user:
108 raise HTTPFound(location=c.came_from)
108 raise HTTPFound(location=c.came_from)
109 webutils.flash(_('Authentication failed.'), 'error')
109 webutils.flash(_('Authentication failed.'), 'error')
@@ -113,7 +113,7 b' class LoginController(BaseController):'
113 raise HTTPFound(location=c.came_from)
113 raise HTTPFound(location=c.came_from)
114 # continue to show login to default user
114 # continue to show login to default user
115
115
116 return render('/login.html')
116 return base.render('/login.html')
117
117
118 @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate',
118 @HasPermissionAnyDecorator('hg.admin', 'hg.register.auto_activate',
119 'hg.register.manual_activate')
119 'hg.register.manual_activate')
@@ -151,7 +151,7 b' class LoginController(BaseController):'
151
151
152 except formencode.Invalid as errors:
152 except formencode.Invalid as errors:
153 return htmlfill.render(
153 return htmlfill.render(
154 render('/register.html'),
154 base.render('/register.html'),
155 defaults=errors.value,
155 defaults=errors.value,
156 errors=errors.error_dict or {},
156 errors=errors.error_dict or {},
157 prefix_error=False,
157 prefix_error=False,
@@ -164,7 +164,7 b' class LoginController(BaseController):'
164 # Exception itself
164 # Exception itself
165 webutils.flash(e, 'error')
165 webutils.flash(e, 'error')
166
166
167 return render('/register.html')
167 return base.render('/register.html')
168
168
169 def password_reset(self):
169 def password_reset(self):
170 settings = db.Setting.get_app_settings()
170 settings = db.Setting.get_app_settings()
@@ -193,14 +193,14 b' class LoginController(BaseController):'
193
193
194 except formencode.Invalid as errors:
194 except formencode.Invalid as errors:
195 return htmlfill.render(
195 return htmlfill.render(
196 render('/password_reset.html'),
196 base.render('/password_reset.html'),
197 defaults=errors.value,
197 defaults=errors.value,
198 errors=errors.error_dict or {},
198 errors=errors.error_dict or {},
199 prefix_error=False,
199 prefix_error=False,
200 encoding="UTF-8",
200 encoding="UTF-8",
201 force_defaults=False)
201 force_defaults=False)
202
202
203 return render('/password_reset.html')
203 return base.render('/password_reset.html')
204
204
205 def password_reset_confirmation(self):
205 def password_reset_confirmation(self):
206 # This controller handles both GET and POST requests, though we
206 # This controller handles both GET and POST requests, though we
@@ -213,14 +213,14 b' class LoginController(BaseController):'
213 c.timestamp = request.params.get('timestamp') or ''
213 c.timestamp = request.params.get('timestamp') or ''
214 c.token = request.params.get('token') or ''
214 c.token = request.params.get('token') or ''
215 if not request.POST:
215 if not request.POST:
216 return render('/password_reset_confirmation.html')
216 return base.render('/password_reset_confirmation.html')
217
217
218 form = PasswordResetConfirmationForm()()
218 form = PasswordResetConfirmationForm()()
219 try:
219 try:
220 form_result = form.to_python(dict(request.POST))
220 form_result = form.to_python(dict(request.POST))
221 except formencode.Invalid as errors:
221 except formencode.Invalid as errors:
222 return htmlfill.render(
222 return htmlfill.render(
223 render('/password_reset_confirmation.html'),
223 base.render('/password_reset_confirmation.html'),
224 defaults=errors.value,
224 defaults=errors.value,
225 errors=errors.error_dict or {},
225 errors=errors.error_dict or {},
226 prefix_error=False,
226 prefix_error=False,
@@ -232,7 +232,7 b' class LoginController(BaseController):'
232 form_result['token'],
232 form_result['token'],
233 ):
233 ):
234 return htmlfill.render(
234 return htmlfill.render(
235 render('/password_reset_confirmation.html'),
235 base.render('/password_reset_confirmation.html'),
236 defaults=form_result,
236 defaults=form_result,
237 errors={'token': _('Invalid password reset token')},
237 errors={'token': _('Invalid password reset token')},
238 prefix_error=False,
238 prefix_error=False,
@@ -36,10 +36,10 b' from tg.i18n import ugettext as _'
36 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
36 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
37
37
38 import kallithea.lib.helpers as h
38 import kallithea.lib.helpers as h
39 from kallithea.controllers import base
39 from kallithea.controllers.changeset import create_cs_pr_comment, delete_cs_pr_comment
40 from kallithea.controllers.changeset import create_cs_pr_comment, delete_cs_pr_comment
40 from kallithea.lib import auth, diffs, webutils
41 from kallithea.lib import auth, diffs, webutils
41 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
42 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
42 from kallithea.lib.base import BaseRepoController, jsonify, render
43 from kallithea.lib.graphmod import graph_data
43 from kallithea.lib.graphmod import graph_data
44 from kallithea.lib.page import Page
44 from kallithea.lib.page import Page
45 from kallithea.lib.utils2 import ascii_bytes, safe_bytes, safe_int
45 from kallithea.lib.utils2 import ascii_bytes, safe_bytes, safe_int
@@ -69,7 +69,7 b' def _get_reviewer(user_id):'
69 return user
69 return user
70
70
71
71
72 class PullrequestsController(BaseRepoController):
72 class PullrequestsController(base.BaseRepoController):
73
73
74 def _get_repo_refs(self, repo, rev=None, branch=None, branch_rev=None):
74 def _get_repo_refs(self, repo, rev=None, branch=None, branch_rev=None):
75 """return a structure with scm repo's interesting changesets, suitable for
75 """return a structure with scm repo's interesting changesets, suitable for
@@ -211,7 +211,7 b' class PullrequestsController(BaseRepoCon'
211
211
212 c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=100, **url_params)
212 c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=100, **url_params)
213
213
214 return render('/pullrequests/pullrequest_show_all.html')
214 return base.render('/pullrequests/pullrequest_show_all.html')
215
215
216 @LoginRequired()
216 @LoginRequired()
217 def show_my(self):
217 def show_my(self):
@@ -236,7 +236,7 b' class PullrequestsController(BaseRepoCon'
236 else:
236 else:
237 c.participate_in_pull_requests_todo.append(pr)
237 c.participate_in_pull_requests_todo.append(pr)
238
238
239 return render('/pullrequests/pullrequest_show_my.html')
239 return base.render('/pullrequests/pullrequest_show_my.html')
240
240
241 @LoginRequired()
241 @LoginRequired()
242 @HasRepoPermissionLevelDecorator('read')
242 @HasRepoPermissionLevelDecorator('read')
@@ -291,11 +291,11 b' class PullrequestsController(BaseRepoCon'
291 for fork in org_repo.forks:
291 for fork in org_repo.forks:
292 c.a_repos.append((fork.repo_name, fork.repo_name))
292 c.a_repos.append((fork.repo_name, fork.repo_name))
293
293
294 return render('/pullrequests/pullrequest.html')
294 return base.render('/pullrequests/pullrequest.html')
295
295
296 @LoginRequired()
296 @LoginRequired()
297 @HasRepoPermissionLevelDecorator('read')
297 @HasRepoPermissionLevelDecorator('read')
298 @jsonify
298 @base.jsonify
299 def repo_info(self, repo_name):
299 def repo_info(self, repo_name):
300 repo = c.db_repo
300 repo = c.db_repo
301 refs, selected_ref = self._get_repo_refs(repo.scm_instance)
301 refs, selected_ref = self._get_repo_refs(repo.scm_instance)
@@ -432,7 +432,7 b' class PullrequestsController(BaseRepoCon'
432
432
433 @LoginRequired()
433 @LoginRequired()
434 @HasRepoPermissionLevelDecorator('read')
434 @HasRepoPermissionLevelDecorator('read')
435 @jsonify
435 @base.jsonify
436 def delete(self, repo_name, pull_request_id):
436 def delete(self, repo_name, pull_request_id):
437 pull_request = db.PullRequest.get_or_404(pull_request_id)
437 pull_request = db.PullRequest.get_or_404(pull_request_id)
438 # only owner can delete it !
438 # only owner can delete it !
@@ -620,11 +620,11 b' class PullrequestsController(BaseRepoCon'
620
620
621 c.is_ajax_preview = False
621 c.is_ajax_preview = False
622 c.ancestors = None # [c.a_rev] ... but that is shown in an other way
622 c.ancestors = None # [c.a_rev] ... but that is shown in an other way
623 return render('/pullrequests/pullrequest_show.html')
623 return base.render('/pullrequests/pullrequest_show.html')
624
624
625 @LoginRequired()
625 @LoginRequired()
626 @HasRepoPermissionLevelDecorator('read')
626 @HasRepoPermissionLevelDecorator('read')
627 @jsonify
627 @base.jsonify
628 def comment(self, repo_name, pull_request_id):
628 def comment(self, repo_name, pull_request_id):
629 pull_request = db.PullRequest.get_or_404(pull_request_id)
629 pull_request = db.PullRequest.get_or_404(pull_request_id)
630 allowed_to_change_status = self._is_allowed_to_change_status(pull_request)
630 allowed_to_change_status = self._is_allowed_to_change_status(pull_request)
@@ -633,6 +633,6 b' class PullrequestsController(BaseRepoCon'
633
633
634 @LoginRequired()
634 @LoginRequired()
635 @HasRepoPermissionLevelDecorator('read')
635 @HasRepoPermissionLevelDecorator('read')
636 @jsonify
636 @base.jsonify
637 def delete_comment(self, repo_name, comment_id):
637 def delete_comment(self, repo_name, comment_id):
638 return delete_cs_pr_comment(repo_name, comment_id)
638 return delete_cs_pr_comment(repo_name, comment_id)
@@ -14,9 +14,9 b''
14 from tg import config
14 from tg import config
15 from tgext.routes import RoutedController
15 from tgext.routes import RoutedController
16
16
17 from kallithea.controllers import base
17 from kallithea.controllers.error import ErrorController
18 from kallithea.controllers.error import ErrorController
18 from kallithea.controllers.routing import make_map
19 from kallithea.controllers.routing import make_map
19 from kallithea.lib.base import BaseController
20
20
21
21
22 # This is the main Kallithea entry point; TurboGears will forward all requests
22 # This is the main Kallithea entry point; TurboGears will forward all requests
@@ -26,7 +26,7 b' from kallithea.lib.base import BaseContr'
26 # The mapper is configured using routes defined in routing.py. This use of the
26 # The mapper is configured using routes defined in routing.py. This use of the
27 # 'mapper' attribute is a feature of tgext.routes, which is activated by
27 # 'mapper' attribute is a feature of tgext.routes, which is activated by
28 # inheriting from its RoutedController class.
28 # inheriting from its RoutedController class.
29 class RootController(RoutedController, BaseController):
29 class RootController(RoutedController, base.BaseController):
30
30
31 def __init__(self):
31 def __init__(self):
32 self.mapper = make_map(config)
32 self.mapper = make_map(config)
@@ -35,8 +35,8 b' from whoosh.index import EmptyIndexError'
35 from whoosh.qparser import QueryParser, QueryParserError
35 from whoosh.qparser import QueryParser, QueryParserError
36 from whoosh.query import Phrase, Prefix
36 from whoosh.query import Phrase, Prefix
37
37
38 from kallithea.controllers import base
38 from kallithea.lib.auth import LoginRequired
39 from kallithea.lib.auth import LoginRequired
39 from kallithea.lib.base import BaseRepoController, render
40 from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA, WhooshResultWrapper
40 from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA, WhooshResultWrapper
41 from kallithea.lib.page import Page
41 from kallithea.lib.page import Page
42 from kallithea.lib.utils2 import safe_int
42 from kallithea.lib.utils2 import safe_int
@@ -46,7 +46,7 b' from kallithea.model.repo import RepoMod'
46 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
47
47
48
48
49 class SearchController(BaseRepoController):
49 class SearchController(base.BaseRepoController):
50
50
51 @LoginRequired(allow_default_user=True)
51 @LoginRequired(allow_default_user=True)
52 def index(self, repo_name=None):
52 def index(self, repo_name=None):
@@ -139,4 +139,4 b' class SearchController(BaseRepoControlle'
139 c.runtime = _('An error occurred during search operation.')
139 c.runtime = _('An error occurred during search operation.')
140
140
141 # Return a rendered template
141 # Return a rendered template
142 return render('/search/search.html')
142 return base.render('/search/search.html')
@@ -38,9 +38,9 b' from tg import tmpl_context as c'
38 from tg.i18n import ugettext as _
38 from tg.i18n import ugettext as _
39 from webob.exc import HTTPBadRequest
39 from webob.exc import HTTPBadRequest
40
40
41 from kallithea.controllers import base
41 from kallithea.lib import ext_json, webutils
42 from kallithea.lib import ext_json, webutils
42 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
43 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
43 from kallithea.lib.base import BaseRepoController, jsonify, render
44 from kallithea.lib.conf import ALL_EXTS, ALL_READMES, LANGUAGES_EXTENSIONS_MAP
44 from kallithea.lib.conf import ALL_EXTS, ALL_READMES, LANGUAGES_EXTENSIONS_MAP
45 from kallithea.lib.markup_renderer import MarkupRenderer
45 from kallithea.lib.markup_renderer import MarkupRenderer
46 from kallithea.lib.page import Page
46 from kallithea.lib.page import Page
@@ -58,7 +58,7 b" README_FILES = [''.join([x[0][0], x[1][0"
58 key=lambda y:y[0][1] + y[1][1])]
58 key=lambda y:y[0][1] + y[1][1])]
59
59
60
60
61 class SummaryController(BaseRepoController):
61 class SummaryController(base.BaseRepoController):
62
62
63 def __get_readme_data(self, db_repo):
63 def __get_readme_data(self, db_repo):
64 repo_name = db_repo.repo_name
64 repo_name = db_repo.repo_name
@@ -148,11 +148,11 b' class SummaryController(BaseRepoControll'
148 c.enable_downloads = c.db_repo.enable_downloads
148 c.enable_downloads = c.db_repo.enable_downloads
149 c.readme_data, c.readme_file = \
149 c.readme_data, c.readme_file = \
150 self.__get_readme_data(c.db_repo)
150 self.__get_readme_data(c.db_repo)
151 return render('summary/summary.html')
151 return base.render('summary/summary.html')
152
152
153 @LoginRequired()
153 @LoginRequired()
154 @HasRepoPermissionLevelDecorator('read')
154 @HasRepoPermissionLevelDecorator('read')
155 @jsonify
155 @base.jsonify
156 def repo_size(self, repo_name):
156 def repo_size(self, repo_name):
157 if request.is_xhr:
157 if request.is_xhr:
158 return c.db_repo._repo_size()
158 return c.db_repo._repo_size()
@@ -209,4 +209,4 b' class SummaryController(BaseRepoControll'
209
209
210 recurse_limit = 500 # don't recurse more than 500 times when parsing
210 recurse_limit = 500 # don't recurse more than 500 times when parsing
211 async_tasks.get_commits_stats(c.db_repo.repo_name, ts_min_y, ts_max_y, recurse_limit)
211 async_tasks.get_commits_stats(c.db_repo.repo_name, ts_min_y, ts_max_y, recurse_limit)
212 return render('summary/statistics.html')
212 return base.render('summary/statistics.html')
@@ -131,10 +131,10 b' conftest'
131
131
132 normal_modules = set('''
132 normal_modules = set('''
133 kallithea
133 kallithea
134 kallithea.controllers.base
134 kallithea.lib
135 kallithea.lib
135 kallithea.lib.auth
136 kallithea.lib.auth
136 kallithea.lib.auth_modules
137 kallithea.lib.auth_modules
137 kallithea.lib.base
138 kallithea.lib.celerylib
138 kallithea.lib.celerylib
139 kallithea.lib.db_manage
139 kallithea.lib.db_manage
140 kallithea.lib.helpers
140 kallithea.lib.helpers
General Comments 0
You need to be logged in to leave comments. Login now