Show More
@@ -32,7 +32,7 b' from pylons_app.lib.auth import LoginReq' | |||||
32 | HasPermissionAnyDecorator |
|
32 | HasPermissionAnyDecorator | |
33 | from pylons_app.lib.base import BaseController, render |
|
33 | from pylons_app.lib.base import BaseController, render | |
34 | from pylons_app.lib.utils import repo2db_mapper, invalidate_cache, \ |
|
34 | from pylons_app.lib.utils import repo2db_mapper, invalidate_cache, \ | |
35 | set_hg_app_config |
|
35 | set_hg_app_config, get_hg_settings | |
36 | from pylons_app.model.db import User, UserLog, HgAppSettings |
|
36 | from pylons_app.model.db import User, UserLog, HgAppSettings | |
37 | from pylons_app.model.forms import UserForm, ApplicationSettingsForm |
|
37 | from pylons_app.model.forms import UserForm, ApplicationSettingsForm | |
38 | from pylons_app.model.hg_model import HgModel |
|
38 | from pylons_app.model.hg_model import HgModel | |
@@ -64,8 +64,8 b' class SettingsController(BaseController)' | |||||
64 | """GET /admin/settings: All items in the collection""" |
|
64 | """GET /admin/settings: All items in the collection""" | |
65 | # url('admin_settings') |
|
65 | # url('admin_settings') | |
66 |
|
66 | |||
67 | hgsettings = self.sa.query(HgAppSettings).scalar() |
|
67 | defaults = get_hg_settings() | |
68 | defaults = hgsettings.__dict__ if hgsettings else {} |
|
68 | ||
69 | return htmlfill.render( |
|
69 | return htmlfill.render( | |
70 | render('admin/settings/settings.html'), |
|
70 | render('admin/settings/settings.html'), | |
71 | defaults=defaults, |
|
71 | defaults=defaults, | |
@@ -106,15 +106,17 b' class SettingsController(BaseController)' | |||||
106 | application_form = ApplicationSettingsForm()() |
|
106 | application_form = ApplicationSettingsForm()() | |
107 | try: |
|
107 | try: | |
108 | form_result = application_form.to_python(dict(request.POST)) |
|
108 | form_result = application_form.to_python(dict(request.POST)) | |
109 | title = form_result['app_title'] |
|
|||
110 | realm = form_result['app_auth_realm'] |
|
|||
111 |
|
109 | |||
112 | try: |
|
110 | try: | |
113 |
hgsettings = self.sa.query(HgAppSettings). |
|
111 | hgsettings1 = self.sa.query(HgAppSettings).filter(HgAppSettings.app_settings_name == 'title').one() | |
114 |
hgsettings.app_ |
|
112 | hgsettings1.app_settings_value = form_result['hg_app_title'] | |
115 | hgsettings.app_title = title |
|
|||
116 |
|
113 | |||
117 | self.sa.add(hgsettings) |
|
114 | hgsettings2 = self.sa.query(HgAppSettings).filter(HgAppSettings.app_settings_name == 'realm').one() | |
|
115 | hgsettings2.app_settings_value = form_result['hg_app_realm'] | |||
|
116 | ||||
|
117 | ||||
|
118 | self.sa.add(hgsettings1) | |||
|
119 | self.sa.add(hgsettings2) | |||
118 | self.sa.commit() |
|
120 | self.sa.commit() | |
119 | set_hg_app_config(config) |
|
121 | set_hg_app_config(config) | |
120 | h.flash(_('Updated application settings'), |
|
122 | h.flash(_('Updated application settings'), | |
@@ -122,7 +124,7 b' class SettingsController(BaseController)' | |||||
122 |
|
124 | |||
123 | except: |
|
125 | except: | |
124 | log.error(traceback.format_exc()) |
|
126 | log.error(traceback.format_exc()) | |
125 |
h.flash(_('error occured during |
|
127 | h.flash(_('error occured during updating application settings'), | |
126 | category='error') |
|
128 | category='error') | |
127 |
|
129 | |||
128 | self.sa.rollback() |
|
130 | self.sa.rollback() |
@@ -17,6 +17,11 b'' | |||||
17 | # along with this program; if not, write to the Free Software |
|
17 | # along with this program; if not, write to the Free Software | |
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
19 | # MA 02110-1301, USA. |
|
19 | # MA 02110-1301, USA. | |
|
20 | """ | |||
|
21 | Created on April 4, 2010 | |||
|
22 | ||||
|
23 | @author: marcink | |||
|
24 | """ | |||
20 | from beaker.cache import cache_region |
|
25 | from beaker.cache import cache_region | |
21 | from pylons import config, session, url, request |
|
26 | from pylons import config, session, url, request | |
22 | from pylons.controllers.util import abort, redirect |
|
27 | from pylons.controllers.util import abort, redirect | |
@@ -28,11 +33,6 b' from sqlalchemy.orm.exc import NoResultF' | |||||
28 | import crypt |
|
33 | import crypt | |
29 | from decorator import decorator |
|
34 | from decorator import decorator | |
30 | import logging |
|
35 | import logging | |
31 | """ |
|
|||
32 | Created on April 4, 2010 |
|
|||
33 |
|
||||
34 | @author: marcink |
|
|||
35 | """ |
|
|||
36 |
|
36 | |||
37 | log = logging.getLogger(__name__) |
|
37 | log = logging.getLogger(__name__) | |
38 |
|
38 | |||
@@ -186,7 +186,6 b' def get_user(session):' | |||||
186 | user = fill_perms(user) |
|
186 | user = fill_perms(user) | |
187 | session['hg_app_user'] = user |
|
187 | session['hg_app_user'] = user | |
188 | session.save() |
|
188 | session.save() | |
189 | print user.permissions |
|
|||
190 | return user |
|
189 | return user | |
191 |
|
190 | |||
192 | #=============================================================================== |
|
191 | #=============================================================================== |
@@ -16,7 +16,7 b' class BaseController(WSGIController):' | |||||
16 |
|
16 | |||
17 | def __before__(self): |
|
17 | def __before__(self): | |
18 | c.hg_app_version = __version__ |
|
18 | c.hg_app_version = __version__ | |
19 |
c.hg_app_name = config['hg_app_ |
|
19 | c.hg_app_name = config['hg_app_title'] | |
20 | c.repo_name = get_repo_slug(request) |
|
20 | c.repo_name = get_repo_slug(request) | |
21 | c.cached_repo_list = _get_repos_cached() |
|
21 | c.cached_repo_list = _get_repos_cached() | |
22 | c.repo_switcher_list = _get_repos_switcher_cached(c.cached_repo_list) |
|
22 | c.repo_switcher_list = _get_repos_switcher_cached(c.cached_repo_list) |
@@ -121,9 +121,14 b' class DbManage(object):' | |||||
121 | paths.ui_value = os.path.join(path, '*') |
|
121 | paths.ui_value = os.path.join(path, '*') | |
122 |
|
122 | |||
123 |
|
123 | |||
124 | hgsettings = HgAppSettings() |
|
124 | hgsettings1 = HgAppSettings() | |
125 | hgsettings.app_auth_realm = 'hg-app authentication' |
|
125 | ||
126 |
hgsettings.app_ |
|
126 | hgsettings1.app_settings_name = 'realm' | |
|
127 | hgsettings1.app_settings_value = 'hg-app authentication' | |||
|
128 | ||||
|
129 | hgsettings2 = HgAppSettings() | |||
|
130 | hgsettings2.app_settings_name = 'title' | |||
|
131 | hgsettings2.app_settings_value = 'hg-app' | |||
127 |
|
132 | |||
128 | try: |
|
133 | try: | |
129 | #self.sa.add(hooks) |
|
134 | #self.sa.add(hooks) | |
@@ -132,7 +137,8 b' class DbManage(object):' | |||||
132 | self.sa.add(web3) |
|
137 | self.sa.add(web3) | |
133 | self.sa.add(web4) |
|
138 | self.sa.add(web4) | |
134 | self.sa.add(paths) |
|
139 | self.sa.add(paths) | |
135 | self.sa.add(hgsettings) |
|
140 | self.sa.add(hgsettings1) | |
|
141 | self.sa.add(hgsettings2) | |||
136 | self.sa.commit() |
|
142 | self.sa.commit() | |
137 | except: |
|
143 | except: | |
138 | self.sa.rollback() |
|
144 | self.sa.rollback() |
@@ -63,7 +63,7 b' class SimpleHg(object):' | |||||
63 | #=================================================================== |
|
63 | #=================================================================== | |
64 | username = REMOTE_USER(environ) |
|
64 | username = REMOTE_USER(environ) | |
65 | if not username: |
|
65 | if not username: | |
66 |
self.authenticate.realm = self.config['hg_app_ |
|
66 | self.authenticate.realm = self.config['hg_app_realm'] | |
67 | result = self.authenticate(environ) |
|
67 | result = self.authenticate(environ) | |
68 | if isinstance(result, str): |
|
68 | if isinstance(result, str): | |
69 | AUTH_TYPE.update(environ, 'basic') |
|
69 | AUTH_TYPE.update(environ, 'basic') |
@@ -100,13 +100,17 b' def get_hg_ui_cached():' | |||||
100 | def get_hg_settings(): |
|
100 | def get_hg_settings(): | |
101 | try: |
|
101 | try: | |
102 | sa = meta.Session |
|
102 | sa = meta.Session | |
103 |
ret = sa.query(HgAppSettings). |
|
103 | ret = sa.query(HgAppSettings).all() | |
104 | finally: |
|
104 | finally: | |
105 | meta.Session.remove() |
|
105 | meta.Session.remove() | |
106 |
|
106 | |||
107 | if not ret: |
|
107 | if not ret: | |
108 | raise Exception('Could not get application settings !') |
|
108 | raise Exception('Could not get application settings !') | |
109 | return ret |
|
109 | settings = {} | |
|
110 | for each in ret: | |||
|
111 | settings['hg_app_' + each.app_settings_name] = each.app_settings_value | |||
|
112 | ||||
|
113 | return settings | |||
110 |
|
114 | |||
111 | def make_ui(read_from='file', path=None, checkpaths=True): |
|
115 | def make_ui(read_from='file', path=None, checkpaths=True): | |
112 | """ |
|
116 | """ | |
@@ -155,8 +159,9 b" def make_ui(read_from='file', path=None," | |||||
155 |
|
159 | |||
156 | def set_hg_app_config(config): |
|
160 | def set_hg_app_config(config): | |
157 | hgsettings = get_hg_settings() |
|
161 | hgsettings = get_hg_settings() | |
158 | config['hg_app_auth_realm'] = hgsettings.app_auth_realm |
|
162 | ||
159 | config['hg_app_name'] = hgsettings.app_title |
|
163 | for k, v in hgsettings.items(): | |
|
164 | config[k] = v | |||
160 |
|
165 | |||
161 | def invalidate_cache(name, *args): |
|
166 | def invalidate_cache(name, *args): | |
162 | """Invalidates given name cache""" |
|
167 | """Invalidates given name cache""" |
@@ -5,10 +5,10 b' from vcs.utils.lazy import LazyProperty' | |||||
5 |
|
5 | |||
6 | class HgAppSettings(Base): |
|
6 | class HgAppSettings(Base): | |
7 | __tablename__ = 'hg_app_settings' |
|
7 | __tablename__ = 'hg_app_settings' | |
8 | __table_args__ = {'useexisting':True} |
|
8 | __table_args__ = (UniqueConstraint('app_settings_name'), {'useexisting':True}) | |
9 | app_settings_id = Column("app_settings_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) |
|
9 | app_settings_id = Column("app_settings_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True) | |
10 |
app_ |
|
10 | app_settings_name = Column("app_settings_name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
11 |
app_ |
|
11 | app_settings_value = Column("app_settings_value", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
12 |
|
12 | |||
13 | class HgAppUi(Base): |
|
13 | class HgAppUi(Base): | |
14 | __tablename__ = 'hg_app_ui' |
|
14 | __tablename__ = 'hg_app_ui' |
@@ -297,8 +297,8 b' def ApplicationSettingsForm():' | |||||
297 | class _ApplicationSettingsForm(formencode.Schema): |
|
297 | class _ApplicationSettingsForm(formencode.Schema): | |
298 | allow_extra_fields = True |
|
298 | allow_extra_fields = True | |
299 | filter_extra_fields = False |
|
299 | filter_extra_fields = False | |
300 | app_title = UnicodeString(strip=True, min=3, not_empty=True) |
|
300 | hg_app_title = UnicodeString(strip=True, min=3, not_empty=True) | |
301 |
app |
|
301 | hg_app_realm = UnicodeString(strip=True, min=3, not_empty=True) | |
302 |
|
302 | |||
303 | return _ApplicationSettingsForm |
|
303 | return _ApplicationSettingsForm | |
304 |
|
304 |
@@ -5,8 +5,6 b'' | |||||
5 | ${_('Settings administration')} |
|
5 | ${_('Settings administration')} | |
6 | </%def> |
|
6 | </%def> | |
7 |
|
7 | |||
8 |
|
||||
9 |
|
||||
10 | <%def name="breadcrumbs_links()"> |
|
8 | <%def name="breadcrumbs_links()"> | |
11 | ${h.link_to(_('Admin'),h.url('admin_home'))} » ${_('Settings')} |
|
9 | ${h.link_to(_('Admin'),h.url('admin_home'))} » ${_('Settings')} | |
12 | </%def> |
|
10 | </%def> | |
@@ -30,7 +28,7 b'' | |||||
30 | <div class="fields"> |
|
28 | <div class="fields"> | |
31 | <div class="field"> |
|
29 | <div class="field"> | |
32 | <div class="label label-checkbox"> |
|
30 | <div class="label label-checkbox"> | |
33 |
<label for=" |
|
31 | <label for="destroy">${_('rescan option')}:</label> | |
34 | </div> |
|
32 | </div> | |
35 | <div class="checkboxes"> |
|
33 | <div class="checkboxes"> | |
36 | <div class="checkbox"> |
|
34 | <div class="checkbox"> | |
@@ -60,7 +58,7 b'' | |||||
60 | <label for="input-small">${_('Application name')}:</label> |
|
58 | <label for="input-small">${_('Application name')}:</label> | |
61 | </div> |
|
59 | </div> | |
62 | <div class="input"> |
|
60 | <div class="input"> | |
63 | ${h.text('app_title',size=30)} |
|
61 | ${h.text('hg_app_title',size=30)} | |
64 | </div> |
|
62 | </div> | |
65 | </div> |
|
63 | </div> | |
66 |
|
64 | |||
@@ -69,7 +67,7 b'' | |||||
69 | <label for="input-small">${_('Realm text')}:</label> |
|
67 | <label for="input-small">${_('Realm text')}:</label> | |
70 | </div> |
|
68 | </div> | |
71 | <div class="input"> |
|
69 | <div class="input"> | |
72 |
${h.text('app |
|
70 | ${h.text('hg_app_realm',size=30)} | |
73 | </div> |
|
71 | </div> | |
74 | </div> |
|
72 | </div> | |
75 |
|
73 |
General Comments 0
You need to be logged in to leave comments.
Login now