annotate pylons_app/controllers/admin/settings.py @ 350:664a5b8c551a

Added application settings, are now customizable from database fixed all instances of sqlachemy to be removed() after execution.
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 14 Jul 2010 18:31:06 +0200
parents e8fc875467bd
children 339d1368c10d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 #!/usr/bin/env python
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 # encoding: utf-8
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 # settings controller for pylons
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
5
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 # This program is free software; you can redistribute it and/or
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # modify it under the terms of the GNU General Public License
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # as published by the Free Software Foundation; version 2
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # of the License or (at your opinion) any later version of the license.
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 #
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # GNU General Public License for more details.
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 #
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 # along with this program; if not, write to the Free Software
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # MA 02110-1301, USA.
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 """
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 Created on July 14, 2010
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 settings controller for pylons
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 @author: marcink
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 """
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 from formencode import htmlfill
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
26 from pylons import request, session, tmpl_context as c, url, app_globals as g, \
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
27 config
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 from pylons.controllers.util import abort, redirect
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 from pylons.i18n.translation import _
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 from pylons_app.lib import helpers as h
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 from pylons_app.lib.base import BaseController, render
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
33 from pylons_app.lib.utils import repo2db_mapper, invalidate_cache, \
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
34 set_hg_app_config
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
35 from pylons_app.model.db import User, UserLog, HgAppSettings
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
36 from pylons_app.model.forms import UserForm, ApplicationSettingsForm
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
37 from pylons_app.model.hg_model import HgModel
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 from pylons_app.model.user_model import UserModel
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 import formencode
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 import logging
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
41 import traceback
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
42
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 log = logging.getLogger(__name__)
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 class SettingsController(BaseController):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 """REST Controller styled on the Atom Publishing Protocol"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 # To properly map this controller, ensure your config/routing.py
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 # file has a resource setup:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 # map.resource('setting', 'settings', controller='admin/settings',
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 # path_prefix='/admin', name_prefix='admin_')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 @LoginRequired()
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 #@HasPermissionAllDecorator('hg.admin')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 def __before__(self):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 c.admin_user = session.get('admin_user')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 c.admin_username = session.get('admin_username')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 super(SettingsController, self).__before__()
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 def index(self, format='html'):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 """GET /admin/settings: All items in the collection"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 # url('admin_settings')
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
64
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
65 hgsettings = self.sa.query(HgAppSettings).scalar()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
66 defaults = hgsettings.__dict__ if hgsettings else {}
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
67 return htmlfill.render(
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
68 render('admin/settings/settings.html'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
69 defaults=defaults,
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
70 encoding="UTF-8",
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
71 force_defaults=False
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
72 )
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 def create(self):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 """POST /admin/settings: Create a new item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 # url('admin_settings')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 def new(self, format='html'):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 """GET /admin/settings/new: Form to create a new item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 # url('admin_new_setting')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 def update(self, id):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 """PUT /admin/settings/id: Update an existing item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 # Forms posted to this method should contain a hidden field:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 # <input type="hidden" name="_method" value="PUT" />
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 # Or using helpers:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 # h.form(url('admin_setting', id=ID),
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 # method='put')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 # url('admin_setting', id=ID)
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
90 if id == 'mapping':
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
91 rm_obsolete = request.POST.get('destroy', False)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
92 log.debug('Rescanning directories with destroy=%s', rm_obsolete)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
93
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
94 initial = HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
95 repo2db_mapper(initial, rm_obsolete)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
96 invalidate_cache('cached_repo_list')
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
97
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
98 if id == 'global':
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
99
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
100 application_form = ApplicationSettingsForm()()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
101 try:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
102 form_result = application_form.to_python(dict(request.POST))
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
103 title = form_result['app_title']
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
104 realm = form_result['app_auth_realm']
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
105
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
106 try:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
107 hgsettings = self.sa.query(HgAppSettings).get(1)
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
108 hgsettings.app_auth_realm = realm
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
109 hgsettings.app_title = title
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
110
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
111 self.sa.add(hgsettings)
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
112 self.sa.commit()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
113 set_hg_app_config(config)
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
114 h.flash(_('Updated application settings'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
115 category='success')
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
116
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
117 except:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
118 log.error(traceback.format_exc())
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
119 h.flash(_('error occured during chaning application settings'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
120 category='error')
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
121
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
122 self.sa.rollback()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
123
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
124
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
125 except formencode.Invalid as errors:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
126 c.form_errors = errors.error_dict
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
127 return htmlfill.render(
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
128 render('admin/settings/settings.html'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
129 defaults=errors.value,
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
130 encoding="UTF-8")
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
131
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
132
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
133
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
134
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
135
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
136
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
137
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
138 return redirect(url('admin_settings'))
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
139
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
140
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
141
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
142
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
143
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
144 def delete(self, id):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145 """DELETE /admin/settings/id: Delete an existing item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
146 # Forms posted to this method should contain a hidden field:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
147 # <input type="hidden" name="_method" value="DELETE" />
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148 # Or using helpers:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149 # h.form(url('admin_setting', id=ID),
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 # method='delete')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
151 # url('admin_setting', id=ID)
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
152
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
153 def show(self, id, format='html'):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
154 """GET /admin/settings/id: Show a specific item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
155 # url('admin_setting', id=ID)
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
157 def edit(self, id, format='html'):
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
158 """GET /admin/settings/id/edit: Form to edit an existing item"""
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
159 # url('admin_edit_setting', id=ID)