Show More
@@ -45,7 +45,7 b' class AdminController(BaseController):' | |||||
45 | @HasPermissionAllDecorator('hg.admin') |
|
45 | @HasPermissionAllDecorator('hg.admin') | |
46 | def index(self): |
|
46 | def index(self): | |
47 |
|
47 | |||
48 |
users_log = |
|
48 | users_log = UserLog.query()\ | |
49 | .options(joinedload(UserLog.user))\ |
|
49 | .options(joinedload(UserLog.user))\ | |
50 | .options(joinedload(UserLog.repository))\ |
|
50 | .options(joinedload(UserLog.repository))\ | |
51 | .order_by(UserLog.action_date.desc()) |
|
51 | .order_by(UserLog.action_date.desc()) |
@@ -40,6 +40,7 b' from rhodecode.lib.auth import LoginRequ' | |||||
40 | from rhodecode.lib.exceptions import LdapImportError |
|
40 | from rhodecode.lib.exceptions import LdapImportError | |
41 | from rhodecode.model.forms import LdapSettingsForm |
|
41 | from rhodecode.model.forms import LdapSettingsForm | |
42 | from rhodecode.model.db import RhodeCodeSetting |
|
42 | from rhodecode.model.db import RhodeCodeSetting | |
|
43 | from rhodecode.model.meta import Session | |||
43 |
|
44 | |||
44 | log = logging.getLogger(__name__) |
|
45 | log = logging.getLogger(__name__) | |
45 |
|
46 | |||
@@ -119,9 +120,9 b' class LdapSettingsController(BaseControl' | |||||
119 | v = ldap_active |
|
120 | v = ldap_active | |
120 | setting = RhodeCodeSetting.get_by_name(k) |
|
121 | setting = RhodeCodeSetting.get_by_name(k) | |
121 | setting.app_settings_value = v |
|
122 | setting.app_settings_value = v | |
122 |
|
|
123 | Session().add(setting) | |
123 |
|
124 | |||
124 |
|
|
125 | Session().commit() | |
125 | h.flash(_('Ldap settings updated successfully'), |
|
126 | h.flash(_('Ldap settings updated successfully'), | |
126 | category='success') |
|
127 | category='success') | |
127 | if not ldap_active: |
|
128 | if not ldap_active: |
@@ -83,7 +83,7 b' class NotificationsController(BaseContro' | |||||
83 | # mark all read |
|
83 | # mark all read | |
84 | nm.mark_all_read_for_user(self.rhodecode_user.user_id, |
|
84 | nm.mark_all_read_for_user(self.rhodecode_user.user_id, | |
85 | filter_=request.GET.getall('type')) |
|
85 | filter_=request.GET.getall('type')) | |
86 | Session.commit() |
|
86 | Session().commit() | |
87 | c.user = self.rhodecode_user |
|
87 | c.user = self.rhodecode_user | |
88 | notif = nm.get_for_user(self.rhodecode_user.user_id, |
|
88 | notif = nm.get_for_user(self.rhodecode_user.user_id, | |
89 | filter_=request.GET.getall('type')) |
|
89 | filter_=request.GET.getall('type')) | |
@@ -112,7 +112,7 b' class NotificationsController(BaseContro' | |||||
112 | == c.rhodecode_user.user_id) |
|
112 | == c.rhodecode_user.user_id) | |
113 | if h.HasPermissionAny('hg.admin')() or owner: |
|
113 | if h.HasPermissionAny('hg.admin')() or owner: | |
114 | NotificationModel().mark_read(c.rhodecode_user.user_id, no) |
|
114 | NotificationModel().mark_read(c.rhodecode_user.user_id, no) | |
115 | Session.commit() |
|
115 | Session().commit() | |
116 | return 'ok' |
|
116 | return 'ok' | |
117 | except Exception: |
|
117 | except Exception: | |
118 | Session.rollback() |
|
118 | Session.rollback() | |
@@ -134,7 +134,7 b' class NotificationsController(BaseContro' | |||||
134 | == c.rhodecode_user.user_id) |
|
134 | == c.rhodecode_user.user_id) | |
135 | if h.HasPermissionAny('hg.admin')() or owner: |
|
135 | if h.HasPermissionAny('hg.admin')() or owner: | |
136 | NotificationModel().delete(c.rhodecode_user.user_id, no) |
|
136 | NotificationModel().delete(c.rhodecode_user.user_id, no) | |
137 | Session.commit() |
|
137 | Session().commit() | |
138 | return 'ok' |
|
138 | return 'ok' | |
139 | except Exception: |
|
139 | except Exception: | |
140 | Session.rollback() |
|
140 | Session.rollback() | |
@@ -158,7 +158,7 b' class NotificationsController(BaseContro' | |||||
158 | if unotification: |
|
158 | if unotification: | |
159 | if unotification.read is False: |
|
159 | if unotification.read is False: | |
160 | unotification.mark_as_read() |
|
160 | unotification.mark_as_read() | |
161 | Session.commit() |
|
161 | Session().commit() | |
162 | c.notification = no |
|
162 | c.notification = no | |
163 |
|
163 | |||
164 | return render('admin/notifications/show_notification.html') |
|
164 | return render('admin/notifications/show_notification.html') |
@@ -102,7 +102,7 b' class PermissionsController(BaseControll' | |||||
102 | form_result = _form.to_python(dict(request.POST)) |
|
102 | form_result = _form.to_python(dict(request.POST)) | |
103 | form_result.update({'perm_user_name': id}) |
|
103 | form_result.update({'perm_user_name': id}) | |
104 | permission_model.update(form_result) |
|
104 | permission_model.update(form_result) | |
105 | Session.commit() |
|
105 | Session().commit() | |
106 | h.flash(_('Default permissions updated successfully'), |
|
106 | h.flash(_('Default permissions updated successfully'), | |
107 | category='success') |
|
107 | category='success') | |
108 |
|
108 |
@@ -167,7 +167,7 b' class ReposController(BaseController):' | |||||
167 | action_logger(self.rhodecode_user, 'admin_created_repo', |
|
167 | action_logger(self.rhodecode_user, 'admin_created_repo', | |
168 | form_result['repo_name_full'], self.ip_addr, |
|
168 | form_result['repo_name_full'], self.ip_addr, | |
169 | self.sa) |
|
169 | self.sa) | |
170 | Session.commit() |
|
170 | Session().commit() | |
171 | except formencode.Invalid, errors: |
|
171 | except formencode.Invalid, errors: | |
172 |
|
172 | |||
173 | c.new_repo = errors.value['repo_name'] |
|
173 | c.new_repo = errors.value['repo_name'] | |
@@ -229,7 +229,7 b' class ReposController(BaseController):' | |||||
229 | changed_name = repo.repo_name |
|
229 | changed_name = repo.repo_name | |
230 | action_logger(self.rhodecode_user, 'admin_updated_repo', |
|
230 | action_logger(self.rhodecode_user, 'admin_updated_repo', | |
231 | changed_name, self.ip_addr, self.sa) |
|
231 | changed_name, self.ip_addr, self.sa) | |
232 | Session.commit() |
|
232 | Session().commit() | |
233 | except formencode.Invalid, errors: |
|
233 | except formencode.Invalid, errors: | |
234 | defaults = self.__load_data(repo_name) |
|
234 | defaults = self.__load_data(repo_name) | |
235 | defaults.update(errors.value) |
|
235 | defaults.update(errors.value) | |
@@ -273,7 +273,7 b' class ReposController(BaseController):' | |||||
273 | repo_model.delete(repo) |
|
273 | repo_model.delete(repo) | |
274 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
274 | invalidate_cache('get_repo_cached_%s' % repo_name) | |
275 | h.flash(_('deleted repository %s') % repo_name, category='success') |
|
275 | h.flash(_('deleted repository %s') % repo_name, category='success') | |
276 | Session.commit() |
|
276 | Session().commit() | |
277 | except IntegrityError, e: |
|
277 | except IntegrityError, e: | |
278 | if e.message.find('repositories_fork_id_fkey') != -1: |
|
278 | if e.message.find('repositories_fork_id_fkey') != -1: | |
279 | log.error(traceback.format_exc()) |
|
279 | log.error(traceback.format_exc()) | |
@@ -303,7 +303,7 b' class ReposController(BaseController):' | |||||
303 | try: |
|
303 | try: | |
304 | RepoModel().revoke_user_permission(repo=repo_name, |
|
304 | RepoModel().revoke_user_permission(repo=repo_name, | |
305 | user=request.POST['user_id']) |
|
305 | user=request.POST['user_id']) | |
306 | Session.commit() |
|
306 | Session().commit() | |
307 | except Exception: |
|
307 | except Exception: | |
308 | log.error(traceback.format_exc()) |
|
308 | log.error(traceback.format_exc()) | |
309 | h.flash(_('An error occurred during deletion of repository user'), |
|
309 | h.flash(_('An error occurred during deletion of repository user'), | |
@@ -322,7 +322,7 b' class ReposController(BaseController):' | |||||
322 | RepoModel().revoke_users_group_permission( |
|
322 | RepoModel().revoke_users_group_permission( | |
323 | repo=repo_name, group_name=request.POST['users_group_id'] |
|
323 | repo=repo_name, group_name=request.POST['users_group_id'] | |
324 | ) |
|
324 | ) | |
325 | Session.commit() |
|
325 | Session().commit() | |
326 | except Exception: |
|
326 | except Exception: | |
327 | log.error(traceback.format_exc()) |
|
327 | log.error(traceback.format_exc()) | |
328 | h.flash(_('An error occurred during deletion of repository' |
|
328 | h.flash(_('An error occurred during deletion of repository' | |
@@ -340,7 +340,7 b' class ReposController(BaseController):' | |||||
340 |
|
340 | |||
341 | try: |
|
341 | try: | |
342 | RepoModel().delete_stats(repo_name) |
|
342 | RepoModel().delete_stats(repo_name) | |
343 | Session.commit() |
|
343 | Session().commit() | |
344 | except Exception, e: |
|
344 | except Exception, e: | |
345 | h.flash(_('An error occurred during deletion of repository stats'), |
|
345 | h.flash(_('An error occurred during deletion of repository stats'), | |
346 | category='error') |
|
346 | category='error') | |
@@ -356,7 +356,7 b' class ReposController(BaseController):' | |||||
356 |
|
356 | |||
357 | try: |
|
357 | try: | |
358 | ScmModel().mark_for_invalidation(repo_name) |
|
358 | ScmModel().mark_for_invalidation(repo_name) | |
359 | Session.commit() |
|
359 | Session().commit() | |
360 | except Exception, e: |
|
360 | except Exception, e: | |
361 | h.flash(_('An error occurred during cache invalidation'), |
|
361 | h.flash(_('An error occurred during cache invalidation'), | |
362 | category='error') |
|
362 | category='error') | |
@@ -380,7 +380,7 b' class ReposController(BaseController):' | |||||
380 | self.scm_model.toggle_following_repo(repo_id, user_id) |
|
380 | self.scm_model.toggle_following_repo(repo_id, user_id) | |
381 | h.flash(_('Updated repository visibility in public journal'), |
|
381 | h.flash(_('Updated repository visibility in public journal'), | |
382 | category='success') |
|
382 | category='success') | |
383 | Session.commit() |
|
383 | Session().commit() | |
384 | except: |
|
384 | except: | |
385 | h.flash(_('An error occurred during setting this' |
|
385 | h.flash(_('An error occurred during setting this' | |
386 | ' repository in public journal'), |
|
386 | ' repository in public journal'), |
@@ -115,7 +115,7 b' class ReposGroupsController(BaseControll' | |||||
115 | group_description=form_result['group_description'], |
|
115 | group_description=form_result['group_description'], | |
116 | parent=form_result['group_parent_id'] |
|
116 | parent=form_result['group_parent_id'] | |
117 | ) |
|
117 | ) | |
118 | Session.commit() |
|
118 | Session().commit() | |
119 | h.flash(_('created repos group %s') \ |
|
119 | h.flash(_('created repos group %s') \ | |
120 | % form_result['group_name'], category='success') |
|
120 | % form_result['group_name'], category='success') | |
121 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
121 | #TODO: in futureaction_logger(, '', '', '', self.sa) | |
@@ -162,7 +162,7 b' class ReposGroupsController(BaseControll' | |||||
162 | try: |
|
162 | try: | |
163 | form_result = repos_group_form.to_python(dict(request.POST)) |
|
163 | form_result = repos_group_form.to_python(dict(request.POST)) | |
164 | ReposGroupModel().update(id, form_result) |
|
164 | ReposGroupModel().update(id, form_result) | |
165 | Session.commit() |
|
165 | Session().commit() | |
166 | h.flash(_('updated repos group %s') \ |
|
166 | h.flash(_('updated repos group %s') \ | |
167 | % form_result['group_name'], category='success') |
|
167 | % form_result['group_name'], category='success') | |
168 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
168 | #TODO: in futureaction_logger(, '', '', '', self.sa) | |
@@ -201,7 +201,7 b' class ReposGroupsController(BaseControll' | |||||
201 |
|
201 | |||
202 | try: |
|
202 | try: | |
203 | ReposGroupModel().delete(id) |
|
203 | ReposGroupModel().delete(id) | |
204 | Session.commit() |
|
204 | Session().commit() | |
205 | h.flash(_('removed repos group %s') % gr.group_name, category='success') |
|
205 | h.flash(_('removed repos group %s') % gr.group_name, category='success') | |
206 | #TODO: in future action_logger(, '', '', '', self.sa) |
|
206 | #TODO: in future action_logger(, '', '', '', self.sa) | |
207 | except IntegrityError, e: |
|
207 | except IntegrityError, e: | |
@@ -234,7 +234,7 b' class ReposGroupsController(BaseControll' | |||||
234 | ReposGroupModel().revoke_user_permission( |
|
234 | ReposGroupModel().revoke_user_permission( | |
235 | repos_group=group_name, user=request.POST['user_id'] |
|
235 | repos_group=group_name, user=request.POST['user_id'] | |
236 | ) |
|
236 | ) | |
237 | Session.commit() |
|
237 | Session().commit() | |
238 | except Exception: |
|
238 | except Exception: | |
239 | log.error(traceback.format_exc()) |
|
239 | log.error(traceback.format_exc()) | |
240 | h.flash(_('An error occurred during deletion of group user'), |
|
240 | h.flash(_('An error occurred during deletion of group user'), | |
@@ -254,7 +254,7 b' class ReposGroupsController(BaseControll' | |||||
254 | repos_group=group_name, |
|
254 | repos_group=group_name, | |
255 | group_name=request.POST['users_group_id'] |
|
255 | group_name=request.POST['users_group_id'] | |
256 | ) |
|
256 | ) | |
257 | Session.commit() |
|
257 | Session().commit() | |
258 | except Exception: |
|
258 | except Exception: | |
259 | log.error(traceback.format_exc()) |
|
259 | log.error(traceback.format_exc()) | |
260 | h.flash(_('An error occurred during deletion of group' |
|
260 | h.flash(_('An error occurred during deletion of group' | |
@@ -291,7 +291,7 b' class ReposGroupsController(BaseControll' | |||||
291 |
|
291 | |||
292 | c.repo_cnt = 0 |
|
292 | c.repo_cnt = 0 | |
293 |
|
293 | |||
294 |
c.groups = |
|
294 | c.groups = RepoGroup.query().order_by(RepoGroup.group_name)\ | |
295 | .filter(RepoGroup.group_parent_id == id).all() |
|
295 | .filter(RepoGroup.group_parent_id == id).all() | |
296 |
|
296 | |||
297 | return render('admin/repos_groups/repos_groups.html') |
|
297 | return render('admin/repos_groups/repos_groups.html') |
@@ -51,8 +51,6 b' from rhodecode.model.user import UserMod' | |||||
51 | from rhodecode.model.db import User |
|
51 | from rhodecode.model.db import User | |
52 | from rhodecode.model.notification import EmailNotificationModel |
|
52 | from rhodecode.model.notification import EmailNotificationModel | |
53 | from rhodecode.model.meta import Session |
|
53 | from rhodecode.model.meta import Session | |
54 | from pylons.decorators import jsonify |
|
|||
55 | from rhodecode.model.pull_request import PullRequestModel |
|
|||
56 |
|
54 | |||
57 | log = logging.getLogger(__name__) |
|
55 | log = logging.getLogger(__name__) | |
58 |
|
56 | |||
@@ -109,6 +107,7 b' class SettingsController(BaseController)' | |||||
109 | # h.form(url('admin_setting', setting_id=ID), |
|
107 | # h.form(url('admin_setting', setting_id=ID), | |
110 | # method='put') |
|
108 | # method='put') | |
111 | # url('admin_setting', setting_id=ID) |
|
109 | # url('admin_setting', setting_id=ID) | |
|
110 | ||||
112 | if setting_id == 'mapping': |
|
111 | if setting_id == 'mapping': | |
113 | rm_obsolete = request.POST.get('destroy', False) |
|
112 | rm_obsolete = request.POST.get('destroy', False) | |
114 | log.debug('Rescanning directories with destroy=%s' % rm_obsolete) |
|
113 | log.debug('Rescanning directories with destroy=%s' % rm_obsolete) | |
@@ -121,123 +120,115 b' class SettingsController(BaseController)' | |||||
121 |
|
120 | |||
122 | h.flash(_('Repositories successfully' |
|
121 | h.flash(_('Repositories successfully' | |
123 | ' rescanned added: %s,removed: %s') % (added, removed), |
|
122 | ' rescanned added: %s,removed: %s') % (added, removed), | |
124 | category='success') |
|
123 | category='success') | |
125 |
|
124 | |||
126 | if setting_id == 'whoosh': |
|
125 | if setting_id == 'whoosh': | |
127 | repo_location = self.get_hg_ui_settings()['paths_root_path'] |
|
126 | repo_location = self.get_hg_ui_settings()['paths_root_path'] | |
128 | full_index = request.POST.get('full_index', False) |
|
127 | full_index = request.POST.get('full_index', False) | |
129 | run_task(tasks.whoosh_index, repo_location, full_index) |
|
128 | run_task(tasks.whoosh_index, repo_location, full_index) | |
|
129 | h.flash(_('Whoosh reindex task scheduled'), category='success') | |||
130 |
|
130 | |||
131 | h.flash(_('Whoosh reindex task scheduled'), category='success') |
|
|||
132 | if setting_id == 'global': |
|
131 | if setting_id == 'global': | |
133 |
|
132 | |||
134 | application_form = ApplicationSettingsForm()() |
|
133 | application_form = ApplicationSettingsForm()() | |
135 | try: |
|
134 | try: | |
136 | form_result = application_form.to_python(dict(request.POST)) |
|
135 | form_result = application_form.to_python(dict(request.POST)) | |
137 |
|
136 | except formencode.Invalid, errors: | ||
138 |
|
|
137 | return htmlfill.render( | |
139 |
|
|
138 | render('admin/settings/settings.html'), | |
140 | hgsettings1.app_settings_value = \ |
|
139 | defaults=errors.value, | |
141 | form_result['rhodecode_title'] |
|
140 | errors=errors.error_dict or {}, | |
|
141 | prefix_error=False, | |||
|
142 | encoding="UTF-8" | |||
|
143 | ) | |||
142 |
|
144 | |||
143 | hgsettings2 = RhodeCodeSetting.get_by_name('realm') |
|
145 | try: | |
144 | hgsettings2.app_settings_value = \ |
|
146 | sett1 = RhodeCodeSetting.get_by_name('title') | |
145 |
|
|
147 | sett1.app_settings_value = form_result['rhodecode_title'] | |
|
148 | Session().add(sett1) | |||
146 |
|
149 | |||
147 |
|
|
150 | sett2 = RhodeCodeSetting.get_by_name('realm') | |
148 |
|
|
151 | sett2.app_settings_value = form_result['rhodecode_realm'] | |
149 | form_result['rhodecode_ga_code'] |
|
152 | Session().add(sett2) | |
150 |
|
153 | |||
151 | self.sa.add(hgsettings1) |
|
154 | sett3 = RhodeCodeSetting.get_by_name('ga_code') | |
152 | self.sa.add(hgsettings2) |
|
155 | sett3.app_settings_value = form_result['rhodecode_ga_code'] | |
153 |
|
|
156 | Session().add(sett3) | |
154 | self.sa.commit() |
|
157 | ||
155 | set_rhodecode_config(config) |
|
158 | Session().commit() | |
156 | h.flash(_('Updated application settings'), |
|
159 | set_rhodecode_config(config) | |
157 |
|
|
160 | h.flash(_('Updated application settings'), category='success') | |
158 |
|
161 | |||
159 |
|
|
162 | except Exception: | |
160 |
|
|
163 | log.error(traceback.format_exc()) | |
161 |
|
|
164 | h.flash(_('error occurred during updating ' | |
162 |
|
|
165 | 'application settings'), | |
163 |
|
|
166 | category='error') | |
164 |
|
167 | |||
165 | self.sa.rollback() |
|
168 | if setting_id == 'vcs': | |
166 |
|
169 | application_form = ApplicationUiSettingsForm()() | ||
|
170 | try: | |||
|
171 | form_result = application_form.to_python(dict(request.POST)) | |||
167 | except formencode.Invalid, errors: |
|
172 | except formencode.Invalid, errors: | |
168 | return htmlfill.render( |
|
173 | return htmlfill.render( | |
169 | render('admin/settings/settings.html'), |
|
174 | render('admin/settings/settings.html'), | |
170 | defaults=errors.value, |
|
175 | defaults=errors.value, | |
171 | errors=errors.error_dict or {}, |
|
176 | errors=errors.error_dict or {}, | |
172 | prefix_error=False, |
|
177 | prefix_error=False, | |
173 |
encoding="UTF-8" |
|
178 | encoding="UTF-8" | |
|
179 | ) | |||
174 |
|
180 | |||
175 | if setting_id == 'mercurial': |
|
|||
176 | application_form = ApplicationUiSettingsForm()() |
|
|||
177 | try: |
|
181 | try: | |
178 | form_result = application_form.to_python(dict(request.POST)) |
|
|||
179 | # fix namespaces for hooks |
|
182 | # fix namespaces for hooks | |
180 | _f = lambda s: s.replace('.', '_') |
|
183 | _f = lambda s: s.replace('.', '_') | |
181 | try: |
|
|||
182 |
|
184 | |||
183 |
|
|
185 | sett1 = RhodeCodeUi.query()\ | |
184 | .filter(RhodeCodeUi.ui_key == 'push_ssl').one() |
|
186 | .filter(RhodeCodeUi.ui_key == 'push_ssl').one() | |
185 |
|
|
187 | sett1.ui_value = form_result['web_push_ssl'] | |
186 |
|
188 | |||
187 |
|
|
189 | sett2 = RhodeCodeUi.query()\ | |
188 | .filter(RhodeCodeUi.ui_key == '/').one() |
|
190 | .filter(RhodeCodeUi.ui_key == '/').one() | |
189 |
|
|
191 | sett2.ui_value = form_result['paths_root_path'] | |
190 |
|
192 | |||
191 |
|
|
193 | #HOOKS | |
192 |
|
|
194 | sett3 = RhodeCodeUi.query()\ | |
193 | .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_UPDATE)\ |
|
195 | .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_UPDATE)\ | |
194 | .one() |
|
196 | .one() | |
195 |
|
|
197 | sett3.ui_active = bool(form_result[_f('hooks_%s' % | |
196 |
|
|
198 | RhodeCodeUi.HOOK_UPDATE)]) | |
197 |
|
199 | |||
198 |
|
|
200 | sett4 = RhodeCodeUi.query()\ | |
199 | .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_REPO_SIZE)\ |
|
201 | .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_REPO_SIZE)\ | |
200 | .one() |
|
202 | .one() | |
201 |
|
|
203 | sett4.ui_active = bool(form_result[_f('hooks_%s' % | |
202 |
|
|
204 | RhodeCodeUi.HOOK_REPO_SIZE)]) | |
203 |
|
||||
204 | hgsettings5 = self.sa.query(RhodeCodeUi)\ |
|
|||
205 | .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_PUSH)\ |
|
|||
206 | .one() |
|
|||
207 | hgsettings5.ui_active = bool(form_result[_f('hooks_%s' % |
|
|||
208 | RhodeCodeUi.HOOK_PUSH)]) |
|
|||
209 |
|
205 | |||
210 |
|
|
206 | sett5 = RhodeCodeUi.query()\ | |
211 |
.filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_PU |
|
207 | .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_PUSH)\ | |
212 | .one() |
|
208 | .one() | |
213 |
|
|
209 | sett5.ui_active = bool(form_result[_f('hooks_%s' % | |
214 |
|
|
210 | RhodeCodeUi.HOOK_PUSH)]) | |
215 |
|
211 | |||
216 | self.sa.add(hgsettings1) |
|
212 | sett6 = RhodeCodeUi.query()\ | |
217 | self.sa.add(hgsettings2) |
|
213 | .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_PULL)\ | |
218 |
|
|
214 | .one() | |
219 | self.sa.add(hgsettings4) |
|
215 | sett6.ui_active = bool(form_result[_f('hooks_%s' % | |
220 | self.sa.add(hgsettings5) |
|
216 | RhodeCodeUi.HOOK_PULL)]) | |
221 | self.sa.add(hgsettings6) |
|
|||
222 | self.sa.commit() |
|
|||
223 |
|
217 | |||
224 | h.flash(_('Updated mercurial settings'), |
|
218 | Session().add(sett1) | |
225 | category='success') |
|
219 | Session().add(sett2) | |
226 |
|
220 | Session().add(sett3) | ||
227 |
|
|
221 | Session().add(sett4) | |
228 | log.error(traceback.format_exc()) |
|
222 | Session().add(sett5) | |
229 | h.flash(_('error occurred during updating ' |
|
223 | Session().add(sett6) | |
230 | 'application settings'), category='error') |
|
224 | Session().commit() | |
231 |
|
225 | |||
232 | self.sa.rollback() |
|
226 | h.flash(_('Updated mercurial settings'), category='success') | |
233 |
|
227 | |||
234 | except formencode.Invalid, errors: |
|
228 | except Exception: | |
235 | return htmlfill.render( |
|
229 | log.error(traceback.format_exc()) | |
236 | render('admin/settings/settings.html'), |
|
230 | h.flash(_('error occurred during updating ' | |
237 | defaults=errors.value, |
|
231 | 'application settings'), category='error') | |
238 | errors=errors.error_dict or {}, |
|
|||
239 | prefix_error=False, |
|
|||
240 | encoding="UTF-8") |
|
|||
241 |
|
232 | |||
242 | if setting_id == 'hooks': |
|
233 | if setting_id == 'hooks': | |
243 | ui_key = request.POST.get('new_hook_ui_key') |
|
234 | ui_key = request.POST.get('new_hook_ui_key') | |
@@ -259,8 +250,8 b' class SettingsController(BaseController)' | |||||
259 |
|
250 | |||
260 | if update: |
|
251 | if update: | |
261 | h.flash(_('Updated hooks'), category='success') |
|
252 | h.flash(_('Updated hooks'), category='success') | |
262 |
|
|
253 | Session().commit() | |
263 | except: |
|
254 | except Exception: | |
264 | log.error(traceback.format_exc()) |
|
255 | log.error(traceback.format_exc()) | |
265 | h.flash(_('error occurred during hook creation'), |
|
256 | h.flash(_('error occurred during hook creation'), | |
266 | category='error') |
|
257 | category='error') | |
@@ -296,7 +287,7 b' class SettingsController(BaseController)' | |||||
296 | if setting_id == 'hooks': |
|
287 | if setting_id == 'hooks': | |
297 | hook_id = request.POST.get('hook_id') |
|
288 | hook_id = request.POST.get('hook_id') | |
298 | RhodeCodeUi.delete(hook_id) |
|
289 | RhodeCodeUi.delete(hook_id) | |
299 |
|
|
290 | Session().commit() | |
300 |
|
291 | |||
301 | @HasPermissionAllDecorator('hg.admin') |
|
292 | @HasPermissionAllDecorator('hg.admin') | |
302 | def show(self, setting_id, format='html'): |
|
293 | def show(self, setting_id, format='html'): | |
@@ -329,7 +320,7 b' class SettingsController(BaseController)' | |||||
329 | # url('admin_settings_my_account') |
|
320 | # url('admin_settings_my_account') | |
330 |
|
321 | |||
331 | c.user = User.get(self.rhodecode_user.user_id) |
|
322 | c.user = User.get(self.rhodecode_user.user_id) | |
332 |
all_repos = |
|
323 | all_repos = Session().query(Repository)\ | |
333 | .filter(Repository.user_id == c.user.user_id)\ |
|
324 | .filter(Repository.user_id == c.user.user_id)\ | |
334 | .order_by(func.lower(Repository.repo_name)).all() |
|
325 | .order_by(func.lower(Repository.repo_name)).all() | |
335 |
|
326 | |||
@@ -369,7 +360,7 b' class SettingsController(BaseController)' | |||||
369 | UserModel().update_my_account(uid, form_result) |
|
360 | UserModel().update_my_account(uid, form_result) | |
370 | h.flash(_('Your account was updated successfully'), |
|
361 | h.flash(_('Your account was updated successfully'), | |
371 | category='success') |
|
362 | category='success') | |
372 | Session.commit() |
|
363 | Session().commit() | |
373 | except formencode.Invalid, errors: |
|
364 | except formencode.Invalid, errors: | |
374 | c.user = User.get(self.rhodecode_user.user_id) |
|
365 | c.user = User.get(self.rhodecode_user.user_id) | |
375 |
|
366 | |||
@@ -386,10 +377,10 b' class SettingsController(BaseController)' | |||||
386 | % form_result.get('username'), category='error') |
|
377 | % form_result.get('username'), category='error') | |
387 |
|
378 | |||
388 | return redirect(url('my_account')) |
|
379 | return redirect(url('my_account')) | |
389 |
|
380 | |||
390 | @NotAnonymous() |
|
381 | @NotAnonymous() | |
391 | def my_account_my_repos(self): |
|
382 | def my_account_my_repos(self): | |
392 |
all_repos = |
|
383 | all_repos = Session().query(Repository)\ | |
393 | .filter(Repository.user_id == self.rhodecode_user.user_id)\ |
|
384 | .filter(Repository.user_id == self.rhodecode_user.user_id)\ | |
394 | .order_by(func.lower(Repository.repo_name))\ |
|
385 | .order_by(func.lower(Repository.repo_name))\ | |
395 | .all() |
|
386 | .all() | |
@@ -425,7 +416,7 b' class SettingsController(BaseController)' | |||||
425 |
|
416 | |||
426 | @NotAnonymous() |
|
417 | @NotAnonymous() | |
427 | def get_hg_ui_settings(self): |
|
418 | def get_hg_ui_settings(self): | |
428 |
ret = |
|
419 | ret = RhodeCodeUi.query().all() | |
429 |
|
420 | |||
430 | if not ret: |
|
421 | if not ret: | |
431 | raise Exception('Could not get application ui settings !') |
|
422 | raise Exception('Could not get application ui settings !') |
@@ -126,7 +126,7 b' class UsersController(BaseController):' | |||||
126 | None, self.ip_addr, self.sa) |
|
126 | None, self.ip_addr, self.sa) | |
127 | h.flash(_('created user %s') % usr, |
|
127 | h.flash(_('created user %s') % usr, | |
128 | category='success') |
|
128 | category='success') | |
129 | Session.commit() |
|
129 | Session().commit() | |
130 | except formencode.Invalid, errors: |
|
130 | except formencode.Invalid, errors: | |
131 | return htmlfill.render( |
|
131 | return htmlfill.render( | |
132 | render('admin/users/user_add.html'), |
|
132 | render('admin/users/user_add.html'), | |
@@ -166,7 +166,7 b' class UsersController(BaseController):' | |||||
166 | action_logger(self.rhodecode_user, 'admin_updated_user:%s' % usr, |
|
166 | action_logger(self.rhodecode_user, 'admin_updated_user:%s' % usr, | |
167 | None, self.ip_addr, self.sa) |
|
167 | None, self.ip_addr, self.sa) | |
168 | h.flash(_('User updated successfully'), category='success') |
|
168 | h.flash(_('User updated successfully'), category='success') | |
169 | Session.commit() |
|
169 | Session().commit() | |
170 | except formencode.Invalid, errors: |
|
170 | except formencode.Invalid, errors: | |
171 | c.user_email_map = UserEmailMap.query()\ |
|
171 | c.user_email_map = UserEmailMap.query()\ | |
172 | .filter(UserEmailMap.user == c.user).all() |
|
172 | .filter(UserEmailMap.user == c.user).all() | |
@@ -198,7 +198,7 b' class UsersController(BaseController):' | |||||
198 | user_model = UserModel() |
|
198 | user_model = UserModel() | |
199 | try: |
|
199 | try: | |
200 | user_model.delete(id) |
|
200 | user_model.delete(id) | |
201 | Session.commit() |
|
201 | Session().commit() | |
202 | h.flash(_('successfully deleted user'), category='success') |
|
202 | h.flash(_('successfully deleted user'), category='success') | |
203 | except (UserOwnsReposException, DefaultUserException), e: |
|
203 | except (UserOwnsReposException, DefaultUserException), e: | |
204 | h.flash(e, category='warning') |
|
204 | h.flash(e, category='warning') | |
@@ -252,7 +252,7 b' class UsersController(BaseController):' | |||||
252 | user_model.grant_perm(id, perm) |
|
252 | user_model.grant_perm(id, perm) | |
253 | h.flash(_("Granted 'repository create' permission to user"), |
|
253 | h.flash(_("Granted 'repository create' permission to user"), | |
254 | category='success') |
|
254 | category='success') | |
255 | Session.commit() |
|
255 | Session().commit() | |
256 | else: |
|
256 | else: | |
257 | perm = Permission.get_by_key('hg.create.repository') |
|
257 | perm = Permission.get_by_key('hg.create.repository') | |
258 | user_model.revoke_perm(id, perm) |
|
258 | user_model.revoke_perm(id, perm) | |
@@ -261,7 +261,7 b' class UsersController(BaseController):' | |||||
261 | user_model.grant_perm(id, perm) |
|
261 | user_model.grant_perm(id, perm) | |
262 | h.flash(_("Revoked 'repository create' permission to user"), |
|
262 | h.flash(_("Revoked 'repository create' permission to user"), | |
263 | category='success') |
|
263 | category='success') | |
264 | Session.commit() |
|
264 | Session().commit() | |
265 | return redirect(url('edit_user', id=id)) |
|
265 | return redirect(url('edit_user', id=id)) | |
266 |
|
266 | |||
267 | def add_email(self, id): |
|
267 | def add_email(self, id): | |
@@ -274,7 +274,7 b' class UsersController(BaseController):' | |||||
274 |
|
274 | |||
275 | try: |
|
275 | try: | |
276 | user_model.add_extra_email(id, email) |
|
276 | user_model.add_extra_email(id, email) | |
277 | Session.commit() |
|
277 | Session().commit() | |
278 | h.flash(_("Added email %s to user") % email, category='success') |
|
278 | h.flash(_("Added email %s to user") % email, category='success') | |
279 | except formencode.Invalid, error: |
|
279 | except formencode.Invalid, error: | |
280 | msg = error.error_dict['email'] |
|
280 | msg = error.error_dict['email'] | |
@@ -290,6 +290,6 b' class UsersController(BaseController):' | |||||
290 | # url('user_emails_delete', id=ID, method='delete') |
|
290 | # url('user_emails_delete', id=ID, method='delete') | |
291 | user_model = UserModel() |
|
291 | user_model = UserModel() | |
292 | user_model.delete_extra_email(id, request.POST.get('del_email')) |
|
292 | user_model.delete_extra_email(id, request.POST.get('del_email')) | |
293 | Session.commit() |
|
293 | Session().commit() | |
294 | h.flash(_("Removed email from user"), category='success') |
|
294 | h.flash(_("Removed email from user"), category='success') | |
295 | return redirect(url('edit_user', id=id)) |
|
295 | return redirect(url('edit_user', id=id)) |
@@ -65,7 +65,7 b' class UsersGroupsController(BaseControll' | |||||
65 | def index(self, format='html'): |
|
65 | def index(self, format='html'): | |
66 | """GET /users_groups: All items in the collection""" |
|
66 | """GET /users_groups: All items in the collection""" | |
67 | # url('users_groups') |
|
67 | # url('users_groups') | |
68 |
c.users_groups_list = |
|
68 | c.users_groups_list = UsersGroup().query().all() | |
69 | return render('admin/users_groups/users_groups.html') |
|
69 | return render('admin/users_groups/users_groups.html') | |
70 |
|
70 | |||
71 | def create(self): |
|
71 | def create(self): | |
@@ -82,7 +82,7 b' class UsersGroupsController(BaseControll' | |||||
82 | 'admin_created_users_group:%s' % gr, |
|
82 | 'admin_created_users_group:%s' % gr, | |
83 | None, self.ip_addr, self.sa) |
|
83 | None, self.ip_addr, self.sa) | |
84 | h.flash(_('created users group %s') % gr, category='success') |
|
84 | h.flash(_('created users group %s') % gr, category='success') | |
85 | Session.commit() |
|
85 | Session().commit() | |
86 | except formencode.Invalid, errors: |
|
86 | except formencode.Invalid, errors: | |
87 | return htmlfill.render( |
|
87 | return htmlfill.render( | |
88 | render('admin/users_groups/users_group_add.html'), |
|
88 | render('admin/users_groups/users_group_add.html'), | |
@@ -117,7 +117,7 b' class UsersGroupsController(BaseControll' | |||||
117 | c.group_members_obj] |
|
117 | c.group_members_obj] | |
118 |
|
118 | |||
119 | c.available_members = [(x.user_id, x.username) for x in |
|
119 | c.available_members = [(x.user_id, x.username) for x in | |
120 |
|
|
120 | User.query().all()] | |
121 |
|
121 | |||
122 | available_members = [safe_unicode(x[0]) for x in c.available_members] |
|
122 | available_members = [safe_unicode(x[0]) for x in c.available_members] | |
123 |
|
123 | |||
@@ -133,7 +133,7 b' class UsersGroupsController(BaseControll' | |||||
133 | 'admin_updated_users_group:%s' % gr, |
|
133 | 'admin_updated_users_group:%s' % gr, | |
134 | None, self.ip_addr, self.sa) |
|
134 | None, self.ip_addr, self.sa) | |
135 | h.flash(_('updated users group %s') % gr, category='success') |
|
135 | h.flash(_('updated users group %s') % gr, category='success') | |
136 | Session.commit() |
|
136 | Session().commit() | |
137 | except formencode.Invalid, errors: |
|
137 | except formencode.Invalid, errors: | |
138 | e = errors.error_dict or {} |
|
138 | e = errors.error_dict or {} | |
139 |
|
139 | |||
@@ -165,7 +165,7 b' class UsersGroupsController(BaseControll' | |||||
165 |
|
165 | |||
166 | try: |
|
166 | try: | |
167 | UsersGroupModel().delete(id) |
|
167 | UsersGroupModel().delete(id) | |
168 | Session.commit() |
|
168 | Session().commit() | |
169 | h.flash(_('successfully deleted users group'), category='success') |
|
169 | h.flash(_('successfully deleted users group'), category='success') | |
170 | except UsersGroupsAssignedException, e: |
|
170 | except UsersGroupsAssignedException, e: | |
171 | h.flash(e, category='error') |
|
171 | h.flash(e, category='error') | |
@@ -183,7 +183,7 b' class UsersGroupsController(BaseControll' | |||||
183 | """GET /users_groups/id/edit: Form to edit an existing item""" |
|
183 | """GET /users_groups/id/edit: Form to edit an existing item""" | |
184 | # url('edit_users_group', id=ID) |
|
184 | # url('edit_users_group', id=ID) | |
185 |
|
185 | |||
186 |
c.users_group = |
|
186 | c.users_group = UsersGroup.get(id) | |
187 | if not c.users_group: |
|
187 | if not c.users_group: | |
188 | return redirect(url('users_groups')) |
|
188 | return redirect(url('users_groups')) | |
189 |
|
189 | |||
@@ -192,7 +192,7 b' class UsersGroupsController(BaseControll' | |||||
192 | c.group_members = [(x.user_id, x.username) for x in |
|
192 | c.group_members = [(x.user_id, x.username) for x in | |
193 | c.group_members_obj] |
|
193 | c.group_members_obj] | |
194 | c.available_members = [(x.user_id, x.username) for x in |
|
194 | c.available_members = [(x.user_id, x.username) for x in | |
195 |
|
|
195 | User.query().all()] | |
196 | defaults = c.users_group.get_dict() |
|
196 | defaults = c.users_group.get_dict() | |
197 | perm = Permission.get_by_key('hg.create.repository') |
|
197 | perm = Permission.get_by_key('hg.create.repository') | |
198 | defaults.update({'create_repo_perm': |
|
198 | defaults.update({'create_repo_perm': | |
@@ -219,7 +219,7 b' class UsersGroupsController(BaseControll' | |||||
219 | h.flash(_("Granted 'repository create' permission to user"), |
|
219 | h.flash(_("Granted 'repository create' permission to user"), | |
220 | category='success') |
|
220 | category='success') | |
221 |
|
221 | |||
222 | Session.commit() |
|
222 | Session().commit() | |
223 | else: |
|
223 | else: | |
224 | perm = Permission.get_by_key('hg.create.repository') |
|
224 | perm = Permission.get_by_key('hg.create.repository') | |
225 | UsersGroupModel().revoke_perm(id, perm) |
|
225 | UsersGroupModel().revoke_perm(id, perm) | |
@@ -228,5 +228,5 b' class UsersGroupsController(BaseControll' | |||||
228 | UsersGroupModel().grant_perm(id, perm) |
|
228 | UsersGroupModel().grant_perm(id, perm) | |
229 | h.flash(_("Revoked 'repository create' permission to user"), |
|
229 | h.flash(_("Revoked 'repository create' permission to user"), | |
230 | category='success') |
|
230 | category='success') | |
231 | Session.commit() |
|
231 | Session().commit() | |
232 | return redirect(url('edit_users_group', id=id)) |
|
232 | return redirect(url('edit_users_group', id=id)) |
@@ -59,7 +59,7 b' class DbManage(object):' | |||||
59 | def init_db(self): |
|
59 | def init_db(self): | |
60 | engine = create_engine(self.dburi, echo=self.log_sql) |
|
60 | engine = create_engine(self.dburi, echo=self.log_sql) | |
61 | init_model(engine) |
|
61 | init_model(engine) | |
62 | self.sa = meta.Session |
|
62 | self.sa = meta.Session() | |
63 |
|
63 | |||
64 | def create_tables(self, override=False, defaults={}): |
|
64 | def create_tables(self, override=False, defaults={}): | |
65 | """ |
|
65 | """ | |
@@ -445,18 +445,25 b' class DbManage(object):' | |||||
445 | paths.ui_key = '/' |
|
445 | paths.ui_key = '/' | |
446 | paths.ui_value = path |
|
446 | paths.ui_value = path | |
447 |
|
447 | |||
448 |
|
|
448 | sett1 = RhodeCodeSetting('realm', 'RhodeCode authentication') | |
449 |
|
|
449 | sett2 = RhodeCodeSetting('title', 'RhodeCode') | |
450 |
|
|
450 | sett3 = RhodeCodeSetting('ga_code', '') | |
|
451 | ||||
|
452 | sett4 = RhodeCodeSetting('show_public_icon', True) | |||
|
453 | sett5 = RhodeCodeSetting('show_private_icon', True) | |||
|
454 | sett6 = RhodeCodeSetting('stylify_metatags', False) | |||
451 |
|
455 | |||
452 | self.sa.add(web1) |
|
456 | self.sa.add(web1) | |
453 | self.sa.add(web2) |
|
457 | self.sa.add(web2) | |
454 | self.sa.add(web3) |
|
458 | self.sa.add(web3) | |
455 | self.sa.add(web4) |
|
459 | self.sa.add(web4) | |
456 | self.sa.add(paths) |
|
460 | self.sa.add(paths) | |
457 |
self.sa.add( |
|
461 | self.sa.add(sett1) | |
458 |
self.sa.add( |
|
462 | self.sa.add(sett2) | |
459 |
self.sa.add( |
|
463 | self.sa.add(sett3) | |
|
464 | self.sa.add(sett4) | |||
|
465 | self.sa.add(sett5) | |||
|
466 | self.sa.add(sett6) | |||
460 |
|
467 | |||
461 | self.create_ldap_options() |
|
468 | self.create_ldap_options() | |
462 |
|
469 |
@@ -115,8 +115,8 b'' | |||||
115 | </div> |
|
115 | </div> | |
116 | ${h.end_form()} |
|
116 | ${h.end_form()} | |
117 |
|
117 | |||
118 |
<h3>${_(' |
|
118 | <h3>${_('VCS settings')}</h3> | |
119 |
${h.form(url('admin_setting', setting_id=' |
|
119 | ${h.form(url('admin_setting', setting_id='vcs'),method='put')} | |
120 | <div class="form"> |
|
120 | <div class="form"> | |
121 | <!-- fields --> |
|
121 | <!-- fields --> | |
122 |
|
122 |
General Comments 0
You need to be logged in to leave comments.
Login now