You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/06/13 20:34:44 UTC
[02/17] git commit: [#7436] ticket:599 Move password change & upload
key forms from theme provider
[#7436] ticket:599 Move password change & upload key forms from theme provider
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/0141660d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0141660d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0141660d
Branch: refs/heads/db/7406
Commit: 0141660d1478b1c5719bb60f3a346ca4287ff52d
Parents: cc69dc3
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jun 6 11:04:52 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Jun 12 19:38:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 6 +++++-
Allura/allura/lib/plugin.py | 22 +++-------------------
Allura/allura/templates/user_prefs.html | 8 ++++----
3 files changed, 12 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/0141660d/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 4d137c3..7e96cf0 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -49,6 +49,8 @@ log = logging.getLogger(__name__)
class F(object):
login_form = LoginForm()
+ password_change_form = forms.PasswordChangeForm(action='/auth/preferences/change_password')
+ upload_key_form = forms.UploadKeyForm(action='/auth/preferences/upload_sshkey')
recover_password_change_form = forms.PasswordChangeBase()
forgotten_password_form = ForgottenPasswordForm()
subscription_form = SubscriptionForm()
@@ -339,6 +341,8 @@ class PreferencesController(BaseController):
@with_trailing_slash
@expose('jinja:allura:templates/user_prefs.html')
def index(self, **kw):
+ c.password_change_form = F.password_change_form
+ c.upload_key_form = F.upload_key_form
provider = plugin.AuthenticationProvider.get(request)
menu = provider.account_navigation()
return dict(menu=menu)
@@ -390,7 +394,7 @@ class PreferencesController(BaseController):
@require_post()
@validate(V.NullValidator(), error_handler=index)
def change_password(self, **kw):
- kw = g.theme.password_change_form.to_python(kw, None)
+ kw = F.password_change_form.to_python(kw, None)
ap = plugin.AuthenticationProvider.get(request)
try:
ap.set_password(c.user, kw['oldpw'], kw['pw'])
http://git-wip-us.apache.org/repos/asf/allura/blob/0141660d/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index a8fec7a..6a70cdf 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -169,7 +169,7 @@ class AuthenticationProvider(object):
:rtype: None
:raises: AssertionError with user message, upon any error
'''
- raise NotImplemented, 'upload_sshkey'
+ raise NotImplementedError, 'upload_sshkey'
def account_navigation(self):
return [
@@ -218,7 +218,7 @@ class AuthenticationProvider(object):
raise NotImplementedError, 'user_by_project_shortname'
def update_notifications(self, user):
- raise NotImplemented, 'update_notifications'
+ raise NotImplementedError, 'update_notifications'
def user_registration_date(self, user):
'''
@@ -355,7 +355,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
def upload_sshkey(self, username, pubkey):
if not asbool(config.get('auth.ldap.use_schroot', True)):
- raise NotImplemented, 'SSH keys are not supported'
+ raise NotImplementedError, 'SSH keys are not supported'
argv = ('schroot -d / -c %s -u root /ldap-userconfig.py upload %s' % (
config['auth.ldap.schroot_name'], username)).split() + [pubkey]
@@ -805,14 +805,6 @@ class ThemeProvider(object):
os.path.join('nf', name)))
@LazyProperty
- def password_change_form(self):
- '''
- :return: None, or an easywidgets Form to render on the user preferences page
- '''
- from allura.lib.widgets.forms import PasswordChangeForm
- return PasswordChangeForm(action='/auth/preferences/change_password')
-
- @LazyProperty
def personal_data_form(self):
'''
:return: None, or an easywidgets Form to render on the user preferences page
@@ -956,14 +948,6 @@ class ThemeProvider(object):
from allura.lib.widgets.forms import RemoveSkillForm
return RemoveSkillForm(action='/auth/user_info/skills/remove_skill')
- @LazyProperty
- def upload_key_form(self):
- '''
- :return: None, or an easywidgets Form to render on the user preferences page
- '''
- from allura.lib.widgets.forms import UploadKeyForm
- return UploadKeyForm(action='/auth/preferences/upload_sshkey')
-
@property
def master(self):
return self.master_template
http://git-wip-us.apache.org/repos/asf/allura/blob/0141660d/Allura/allura/templates/user_prefs.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/user_prefs.html b/Allura/allura/templates/user_prefs.html
index e4b766d..3e7a0d7 100644
--- a/Allura/allura/templates/user_prefs.html
+++ b/Allura/allura/templates/user_prefs.html
@@ -103,17 +103,17 @@
{% endif %} {# allow_edit_prefs #}
{% endblock edit_prefs_form %}
- {% if g.theme.password_change_form %}
+ {% if c.password_change_form %}
<fieldset>
<legend>Change Password</legend>
- {{ g.theme.password_change_form.display() }}
+ {{ c.password_change_form.display() }}
</fieldset>
{% endif %}
- {% if g.theme.upload_key_form %}
+ {% if c.upload_key_form %}
<fieldset>
<legend>Upload ssh public key</legend>
- {{ g.theme.upload_key_form.display() }}
+ {{ c.upload_key_form.display() }}
</fieldset>
{% endif %}