Commits

Zhang Huangbin  committed f502aa4

Re-design user profile page.

  • Participants
  • Parent commits 04502a2

Comments (0)

Files changed (7)

File controllers/ldap/urls.py

         # /domain.ltd/users
         '/users',                           'controllers.ldap.user.list',
         '/users/(.*\..*)',                  'controllers.ldap.user.list',
+        '/profile/user/(general)/(.*@.*\..*)',        'controllers.ldap.user.profile',
+        '/profile/user/(groups)/(.*@.*\..*)',        'controllers.ldap.user.profile',
+        '/profile/user/(services)/(.*@.*\..*)',        'controllers.ldap.user.profile',
+        '/profile/user/(forwarding)/(.*@.*\..*)',        'controllers.ldap.user.profile',
+        '/profile/user/(bcc)/(.*@.*\..*)',        'controllers.ldap.user.profile',
+        '/profile/user/(password)/(.*@.*\..*)',        'controllers.ldap.user.profile',
+        '/profile/user/(advanced)/(.*@.*\..*)',        'controllers.ldap.user.profile',
         '/profile/user/(.*@.*\..*)',        'controllers.ldap.user.profile',
         '/create/user/(.*\..*)',            'controllers.ldap.user.create',
         '/create/user',                     'controllers.ldap.user.create',

File controllers/ldap/user.py

 
 class profile(dbinit):
     @base.protected
-    def GET(self, email):
-        #i = web.input()
+    def GET(self, profile_type, email):
         email = web.safestr(email)
 
-        if len(email.split('@', 1)) == 2:
+        if len(email.split('@', 1)) == 2 and \
+                profile_type in ['general', 'groups', 'services', 'forwarding', 'bcc', 'password', 'advanced']:
             domain = email.split('@', 1)[1]
             userdn = ldaputils.convEmailToUserDN(email)
 
             if userdn:
                 profile = userLib.profile(dn=userdn)
-                return render.user_profile(user_profile=profile)
+                return render.user_profile(
+                        profile_type=profile_type,
+                        mail=email,
+                        user_profile=profile,
+                        )
             else:
                 web.seeother('/domains')
         else:

File static/default/css/iredadmin.css

     float: left;
     }
 
+#brd-visit #welcome span a.active {
+    text-decoration: none;
+    }
+
 #brd-visit #visit-links {
     text-align: right;
     float: right;

File static/default/css/iredadmin_cs.css

     }
 
 
-.brd .required label em, .brd #req-msg em, .brd .warn strong, .brd .important strong {
+.brd .required label em, .brd .required legend em, .brd #req-msg em, .brd .warn strong, .brd .important strong {
     color: #b42000;
     }
 

File templates/default/ldap/macros.html

     </fieldset>
 {%- endmacro %}
 
-{% macro display_reset_password(oldpw='', newpw='', confirmpw='', show_oldpw='no', show_confirmpw='yes') -%}
-    <fieldset class="frm-group">
+{% macro display_reset_password(oldpw='', newpw='', confirmpw='', show_oldpw='no', show_confirmpw='yes', firstitem='yes',) -%}
+    <fieldset class="frm-group {%if firstitem == 'yes' %}group1{%endif%}">
         <legend class="group-legend"><strong>Required information</strong></legend>
         {% if show_oldpw == 'yes' %}
-        <div class="sf-set">
+        <div class="sf-set {%if firstitem == 'yes' %}set1{%endif%}">
             <div class="sf-box text required">
                 <label for="oldpw"><span>{{ _('Old password') }} <em>{{ _('(Required)') }}</em></span></label><br />
                 <span class="fld-input"><input type="password" id="oldpw" name="oldpw" size="35" value="{{oldpw}}"/></span><br />

File templates/default/ldap/user_profile.html

 {% extends "layout.html" %}
 
-{% from "macros.html" import display_account_status, %}
+{% from "macros.html" import
+        display_account_status,
+        display_reset_password,
+        %}
 
 {% block title %}{{ _('Edit user profile') }}{% endblock %}
 
 
 {# Show profile categories #}
 {% block id_welcome %}
-<span><a href="#">General</a>&nbsp;</span>
-<span><a href="#">Reset password</a>&nbsp;</span>
+<span><a href="{{ctx.homepath}}/profile/user/general/{{mail}}" {% if profile_type == "general" %}class="active"{%endif%}>General</a>&nbsp;</span>
+<span><a href="{{ctx.homepath}}/profile/user/password/{{mail}}" {%if profile_type == 'password'%}class="active"{%endif%}>Reset password</a>&nbsp;</span>
+<span><a href="{{ctx.homepath}}/profile/user/advanced/{{mail}}" {%if profile_type == 'advanced'%}class="active"{%endif%}>Advanced settings</a>&nbsp;</span>
 {% endblock id_welcome %}
 
 {% block main %}
 {% set entries = user[1] %}
 {% set cn = entries.get('cn', [''])[0].decode('utf-8') %}
 {% set mail = entries.get('mail')[0] %}
-{% set username, domain = mail.split('@') %}
+{% set username, domain = mail.split('@', 1) %}
 {% set employeeNumber = entries.get('employeeNumber', [''])[0] %}
 {% set jpegPhoto = entries.get('jpegPhoto', [''])[0] %}
-{% set accountStatus = entries.get('accountStatus', ['disabled'])[0] %}
-{% set mailQuota = entries.get('mailQuota', [0])[0] %}
-{% set memberOfGroup = entries.get('memberOfGroup', []) %}
-{% set homeDirectory = entries.get('homeDirectory', ['/home/vmail'])[0] %}
-{% set mailMessageStore = entries.get('mailMessageStore', [domain + '/' + username + '/'])[0] %}
-{% set enabledService = entries.get('enabledService', ['']) %}
-{% set mailForwardingAddress = entries.get('mailForwardingAddress', ['']) %}
-{% set userRecipientBccAddress = entries.get('userRecipientBccAddress', [''])[0] %}
-{% set userSenderBccAddress = entries.get('userSenderBccAddress', [''])[0] %}
 {% set createTimestamp = entries.get('createTimestamp', ['--------------'])[0] %}
 
-<form class="frm-form" method="post" method="{{ctx.homepath}}/user/edit">
-<div class="main-content main-frm">
+{% if profile_type == 'general' %}
+    {% set telephoneNumber = entries.get('telephoneNumber', ['']) %}
+    {% set accountStatus = entries.get('accountStatus', ['disabled'])[0] %}
+    {% set mailQuota = entries.get('mailQuota', [0])[0] %}
+{% elif profile_type == 'advanced' %}
+    {% set mailMessageStore = entries.get('mailMessageStore', [domain + '/' + username + '/'])[0] %}
+    {% set homeDirectory = entries.get('homeDirectory', ['/home/vmail'])[0] %}
+{% endif %}
+
+<form class="frm-form" method="post" action="{{ctx.homepath}}/user/{{profile_type}}/{{mail}}">
+<div class="main-frm">
     <div class="profile ct-group data-group vcard">
         <div class="ct-set data-set set1">
             <div class="ct-box data-box">
         </div>
     </div>
 
-    {# Modify #}
-        <fieldset class="frm-group group1">
-            <legend class="group-legend"><strong>{{ _('Name') }}</strong></legend>
-            <div class="sf-set set1">
-                <div class="sf-box text">
-                    <label><span>{{ _('Username') }}</span></label>
-                    <span class="fld-input"><input type="text" name="cn" value="{{cn}}" size="25" /></span>
-                </div>
-                <div class="sf-box text">
-                    <label><span>{{ _('Mail address') }}</span>{% if session.get('domainGlobalAdmin') == 'yes' %}<small>{{ _("Warning: Change mail address won't cause mailbox location changed.") }}</small>{%endif%}</label>
-                    <span class="fld-input"><input type="text" name="mail" value="{{username}}" size="25" />@{{domain}}</span>
-                </div>
+    {% if profile_type == 'general' %}
+    <fieldset class="frm-group group1">
+        <legend class="group-legend"><strong>{{ _('Name') }}</strong></legend>
+        <div class="sf-set set1">
+            <div class="sf-box text">
+                <label><span>{{ _('Username') }}</span></label>
+                <span class="fld-input"><input type="text" name="cn" value="{{cn}}" size="25" /></span>
+            </div>
+            <div class="sf-box text">
+                <label><span>{{ _('Mail address') }}</span>{% if session.get('domainGlobalAdmin') == 'yes' %}<small>{{ _("Warning: Change mail address won't cause mailbox location changed.") }}</small>{%endif%}</label>
+                <span class="fld-input"><input type="text" name="mail" value="{{username}}" size="25" />@{{domain}}</span>
+            </div>
 
-                <div class="sf-box text">
-                    <label><span>{{ _('Mail quota (in MB)') }}</span></label>
-                    <span class="fld-input"><input type="text" name="mailQuota" value="" size="15" /> {{_('Current quota:') }} {% if mailQuota == '0' %}{{ _('Unlimited') }}{%else%}{{mailQuota |filesizeformat}}{%endif%}</span>
-                </div>
+            <div class="sf-box text">
+                <label><span>{{ _('Mail quota (in MB)') }}</span></label>
+                <span class="fld-input"><input type="text" name="mailQuota" value="" size="15" /> {{_('Current quota:') }} {% if mailQuota == '0' %}{{ _('Unlimited') }}{%else%}{{mailQuota |filesizeformat}}{%endif%}</span>
             </div>
-        </fieldset>
+        </div>
+    </fieldset>
 
-        {{ display_account_status(accountStatus) }}
+    <fieldset class="frm-group">
+        <legend class="group-legend"><strong>{{ _('Telephone Number') }}</strong></legend>
+        <div class="sf-set">
+            <div class="sf-box text">
+                <label><span>{{ _('Telephone Number') }}</span></label>
+                <span class="fld-input">
+                    {% for phone in telephoneNumber %}
+                        <input type="text" name="telephoneNumber_{{loop.index}}" title="{{ _('Telephone Number')}} #{{loop.index}}" value="{{phone}}" /><br />
+                    {% endfor %}
+                </span>
+            </div>
+        </div>
+    </fieldset>
+
+    {{ display_account_status(accountStatus) }}
+    {% endif %}
 </table>
 
     <div class="frm-buttons">

File templates/default/ldap/users.html

                     <td>
                         <span class="float_left">
                             <input type="checkbox" name="mail" value="{{mail}}" />
-                            <a href="{{ctx.homepath}}/profile/user/{{mail}}" title="{{ _('Edit user profile.') }}">{{ entries.get('cn', [''])[0].decode('utf-8') }}</a>
+                            <a href="{{ctx.homepath}}/profile/user/general/{{mail}}" title="{{ _('Edit user profile.') }}">{{ entries.get('cn', [''])[0].decode('utf-8') }}</a>
                         </span>
                         <span class="float_right">{{ set_account_status_img(accountStatus) }}</span>
                     </td>