Commits

Zhang Huangbin committed a34a416

Remove controllers/ldap/preferences.py, merged into controllers/ldap/admin.py.
mv templates/default/ldap/preferences.html templates/default/ldap/admin_profile.html

Comments (0)

Files changed (4)

controllers/ldap/admin.py

     @base.protected
     def GET(self):
         return render.admin_add()
+
+class profile(dbinit):
+    @base.protected
+    def GET(self):
+        self.langs = prefLib.get_langs()
+
+        return render.admin_profile(
+                cur_lang=self.langs.pop('cur_lang'),
+                langmaps=self.langs.pop('langmaps'),
+                msg=None,
+                )
+
+    @base.protected
+    def POST(self):
+        # Get passwords.
+        i = web.input()
+        result = prefLib.update(i)
+        self.langs = prefLib.get_langs()
+
+        cur_lang = self.langs.pop('cur_lang')
+        if result is True:
+            msg = 'SUCCESS'
+            web.render = iredutils.setRenderLang(web.render, cur_lang, oldlang=session.get('lang'),)
+        else:
+            msg = result
+
+        return render.admin_profile(
+                cur_lang=cur_lang,
+                langmaps=self.langs.pop('langmaps'),
+                msg=msg,
+                )

controllers/ldap/preferences.py

-#!/usr/bin/env python
-# encoding: utf-8
-
-# Author: Zhang Huangbin <michaelbibby (at) gmail.com>
-
-import sys
-import web
-from web import render
-from controllers.ldap import base
-from controllers.ldap.basic import dbinit
-from libs import iredutils
-from libs.ldaplib import preferences
-
-session = web.config.get('_session')
-
-prefLib = preferences.Preferences()
-
-class Preferences:
-    @base.protected
-    def GET(self):
-        self.langs = prefLib.get_langs()
-
-        return render.preferences(
-                cur_lang=self.langs.pop('cur_lang'),
-                langmaps=self.langs.pop('langmaps'),
-                msg=None,
-                )
-
-    @base.protected
-    def POST(self):
-        # Get passwords.
-        i = web.input()
-        result = prefLib.update(i)
-        self.langs = prefLib.get_langs()
-
-        cur_lang = self.langs.pop('cur_lang')
-        if result is True:
-            msg = 'SUCCESS'
-            web.render = iredutils.setRenderLang(web.render, cur_lang, oldlang=session.get('lang'),)
-        else:
-            msg = result
-
-        return render.preferences(
-                cur_lang=cur_lang,
-                langmaps=self.langs.pop('langmaps'),
-                msg=msg,
-                )

templates/default/ldap/admin_profile.html

+{# defined: cur_lang, langmaps #}
+
+{% extends "layout.html" %}
+
+{% block js_tablesorter %}{% endblock %}
+{% block title %}{{ _('Preferences') }}{% endblock %}
+{% block submenu %}{% endblock submenu %}
+
+{% block main %}
+<div class="main-subhead">
+    <h2 class="hn"><span>
+            {% if admin == session.get('username') or admin is not defined %}
+            {{ _('View/Update your preferences.') }}
+            {% else %}
+            {{ _("View/Update %s's preferences.") |format(admin) }}
+            {% endif %}
+    </span></h2>
+</div>
+
+{% if msg is not none %}
+    {% if msg is sameas true %}
+        <div class="main-submenu"><span class="success">{{ _('Changes are saved.') }}</span></div>
+    {% endif %}
+{% endif %}
+
+<div class="frm parted">
+    <form class="frm-form" method="post" action="{{ctx.homepath}}/preferences">
+        <div class="content-head">
+            <h2 class="hn"><span>{{ _('Default language') }}</span></h2>
+        </div>
+
+        <fieldset class="sf-set">
+            <legend><span>{{ _('Default language') }}</span></legend>
+            <div class="sf-box select">
+                <label><span>{{ _('Default language') }}</span></label>
+                <span class="fld-input">
+                    <select name="preferredLanguage">
+                        {% for lang in langmaps %}
+                            <option value="{{lang}}" {% if lang == cur_lang %}selected{%endif%}>{{langmaps[lang]}}</option>
+                        {% endfor %}
+                    </select>
+                </span>
+            </div>
+        </fieldset>
+
+        <div class="content-head">
+            <h2 class="hn"><span>{{ _('Change password') }}</span></h2>
+        </div>
+        <div class="sf-set">
+            <div class="sf-box text">
+                <label><span>{{ _('Current password') }}</span></label><br />
+                <span class="fld-input"><input type="password" id="cur_passwd" name="cur_passwd" size="25" /></span>
+            </div>
+
+            <div class="sf-box text">
+                <label><span>{{ _('New password') }}</span></label><br />
+                <span class="fld-input"><input type="password" name="newpw" size="25" /></span>
+            </div>
+
+            <div class="sf-box text">
+                <label><span>{{ _('Retype new password') }}</span></label><br />
+                <span class="fld-input"><input type="password" name="confirmpw" size="25" /></span>
+            </div>
+        </div>
+
+        <div class="frm-buttons">
+            <span class="submit"><input type="submit" value="{{ _('Save changes') }}" /></span>
+        </div>
+    </form>
+</div>
+{% endblock main %}

templates/default/ldap/preferences.html

-{# defined: cur_lang, langmaps #}
-
-{% extends "layout.html" %}
-
-{% block js_tablesorter %}{% endblock %}
-{% block title %}{{ _('Preferences') }}{% endblock %}
-{% block submenu %}{% endblock submenu %}
-
-{% block main %}
-<div class="main-subhead">
-    <h2 class="hn"><span>
-            {% if admin == session.get('username') or admin is not defined %}
-            {{ _('View/Update your preferences.') }}
-            {% else %}
-            {{ _("View/Update %s's preferences.") |format(admin) }}
-            {% endif %}
-    </span></h2>
-</div>
-
-{% if msg is not none %}
-    {% if msg is sameas true %}
-        <div class="main-submenu"><span class="success">{{ _('Changes are saved.') }}</span></div>
-    {% endif %}
-{% endif %}
-
-<div class="frm parted">
-    <form class="frm-form" method="post" action="{{ctx.homepath}}/preferences">
-        <div class="content-head">
-            <h2 class="hn"><span>{{ _('Default language') }}</span></h2>
-        </div>
-
-        <fieldset class="sf-set">
-            <legend><span>{{ _('Default language') }}</span></legend>
-            <div class="sf-box select">
-                <label><span>{{ _('Default language') }}</span></label>
-                <span class="fld-input">
-                    <select name="preferredLanguage">
-                        {% for lang in langmaps %}
-                            <option value="{{lang}}" {% if lang == cur_lang %}selected{%endif%}>{{langmaps[lang]}}</option>
-                        {% endfor %}
-                    </select>
-                </span>
-            </div>
-        </fieldset>
-
-        <div class="content-head">
-            <h2 class="hn"><span>{{ _('Change password') }}</span></h2>
-        </div>
-        <div class="sf-set">
-            <div class="sf-box text">
-                <label><span>{{ _('Current password') }}</span></label><br />
-                <span class="fld-input"><input type="password" id="cur_passwd" name="cur_passwd" size="25" /></span>
-            </div>
-
-            <div class="sf-box text">
-                <label><span>{{ _('New password') }}</span></label><br />
-                <span class="fld-input"><input type="password" name="newpw" size="25" /></span>
-            </div>
-
-            <div class="sf-box text">
-                <label><span>{{ _('Retype new password') }}</span></label><br />
-                <span class="fld-input"><input type="password" name="confirmpw" size="25" /></span>
-            </div>
-        </div>
-
-        <div class="frm-buttons">
-            <span class="submit"><input type="submit" value="{{ _('Save changes') }}" /></span>
-        </div>
-    </form>
-</div>
-{% endblock main %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.