Commits

Zhang Huangbin  committed b6a71de

Improve domain profile page. Sync templates.

  • Participants
  • Parent commits 1bc0bc6

Comments (0)

Files changed (13)

File controllers/ldap/domain.py

     @base.protected
     def GET(self, domain):
         domain = web.safestr(domain.split('/', 1)[0])
-        if domain is '' or domain is None:
+        if domain != '' and domain is not None and \
+            profile_type in ['general', 'admins', 'services', 'bcc', 'quotas', 'backupmx', 'advanced', ]:
+
+            domain = web.safestr(domain)
+            profile = domainLib.profile(domain)
+
+            if profile:
+                allDomains = domainLib.list(attrs=['domainName'])
+                allAdmins = adminLib.list()
+                domainAdmins = domainLib.admins(domain)
+
+                return render.domain_profile(
+                        cur_domain=domain,
+                        allDomains=allDomains,
+                        profile=profile,
+                        profile_type=profile_type,
+                        admins=allAdmins,
+                        # We need only mail address of domain admins.
+                        domainAdmins=domainAdmins[0][1].get('domainAdmin', []),
+                        )
+            else:
+                web.seeother('/domains?msg=NO_SUCH_DOMAIN')
+        else:
             web.seeother('/domains?msg=NO_SUCH_DOMAIN')
 
-        domain = web.safestr(domain)
-        profile = domainLib.profile(domain)
-        allAdmins = adminLib.list()
-        domainAdmins = domainLib.admins(domain)
-        
-        if profile:
-            return render.domain_profile(
-                    domain=domain,
-                    profile=profile,
-                    admins=allAdmins,
-                    # We need only mail address of domain admins.
-                    domainAdmins=domainAdmins[0][1].get('domainAdmin', []),
-                    )
-        else:
-            return render.domains(msg='NO_SUCH_DOMAIN')
-
     @base.protected
     def POST(self, domain):
         i = web.input(enabledService=[])

File controllers/ldap/urls.py

 
         # Domain related.
         '/domains',                         'controllers.ldap.domain.list',
+        '/profile/domain/(general)/(.*\..*)',         'controllers.ldap.domain.profile',
+        '/profile/domain/(services)/(.*\..*)',         'controllers.ldap.domain.profile',
+        '/profile/domain/(admins)/(.*\..*)',         'controllers.ldap.domain.profile',
+        '/profile/domain/(quotas)/(.*\..*)',         'controllers.ldap.domain.profile',
+        '/profile/domain/(backupmx)/(.*\..*)',         'controllers.ldap.domain.profile',
+        '/profile/domain/(bcc)/(.*\..*)',         'controllers.ldap.domain.profile',
+        '/profile/domain/(advanced)/(.*\..*)',         'controllers.ldap.domain.profile',
         '/profile/domain/(.*\..*)',         'controllers.ldap.domain.profile',
         '/create/domain',                   'controllers.ldap.domain.create',
         '/delete/domain',                   'controllers.ldap.domain.delete',

File controllers/ldap/user.py

 
 # Author: Zhang Huangbin <michaelbibby (at) gmail.com>
 
-import sys
+import types, sys
 import web
 from web import render
 from web import iredconfig as cfg
     @base.protected
     def GET(self, domain=''):
         domain = web.safestr(domain.split('/', 1)[0])
-
-        allDomains = domainLib.list()
+        allDomains = domainLib.list(attrs=['domainName'])
 
         if domain == '' or domain is None:
-            return render.users(allDomains=allDomains)
+            #return render.users(allDomains=allDomains)
 
-        users = userLib.list(domain=domain)
-        if users is not False:
-            return render.users(
-                    users=users, cur_domain=domain,
-                    allDomains=allDomains,
-                    msg=None,
-                    )
+            # List users if only one domain available.
+            if isinstance(allDomains, types.ListType) is True and len(allDomains) == 1:
+                cur_domain = str(allDomains[0][1]['domainName'][0])
+                users = userLib.list(domain=cur_domain)
+                if users is not False:
+                    return render.users(
+                            users=users, cur_domain=domain,
+                            allDomains=allDomains,
+                            msg=None,
+                            )
+                else:
+                    web.seeother('/domains?msg=NO_SUCH_DOMAIN')
+            elif isinstance(allDomains, types.ListType) is True and len(allDomains) == 0:
+                return render.users(msg='NO_DOMAIN_AVAILABLE')
+            else:
+                web.seeother('/domains?msg=NO_SUCH_DOMAIN')
         else:
-            web.seeother('/domains?msg=NO_SUCH_DOMAIN')
+            users = userLib.list(domain=domain)
+            if users is not False:
+                return render.users(
+                        users=users, cur_domain=domain,
+                        allDomains=allDomains,
+                        msg=None,
+                        )
+            else:
+                web.seeother('/domains?msg=NO_SUCH_DOMAIN')
 
     @base.protected
     def POST(self, domain):
         email = web.safestr(email)
 
         if len(email.split('@', 1)) == 2 and \
-                profile_type in ['general', 'groups', 'services', 'forwarding', 'bcc', 'password', 'advanced']:
+                profile_type in ['general', 'nicknames', 'groups', 'services', 'forwarding', 'bcc', 'password', 'advanced',]:
             domain = email.split('@', 1)[1]
             userdn = ldaputils.convEmailToUserDN(email)
 
         dn = ldaputils.convEmailToUserDN(username + '@' + domain)
         result = userLib.add(dn, ldif)
         if result is True:
-            web.seeother('/users/' + domain)
+            web.seeother('/profile/user/general/' + username + '@' + domain)
         elif result == 'ALREADY_EXISTS':
             web.seeother('/users/' + domain + '?msg=ALREADY_EXISTS')
         else:

File docs/INSTALL.rhel

         bind_dn = cn=vmailadmin,dc=iredmail,dc=org
         bind_pw = passwd
 
+    - Make settings.ini not world-readable:
+
+        # chmod -w settings.ini
+
 *) Visit below url in your web browser for test:
 
     http://your_server_ip_address/iredadmin/

File libs/ldaplib/domain.py

 
     # List all domains.
     def list(self, attrs=attrs.DOMAIN_SEARCH_ATTRS):
-        return self.get_all_domains(attrs)
+        allDomains = self.get_all_domains(attrs)
+        allDomains.sort()
+        return allDomains
 
     # Delete domain.
     def delete(self, domainName=[]):

File libs/ldaplib/iredldif.py

 
     if cn is not None and cn != '':
         ldif += [('cn', [cn.encode('utf-8')])]
+    else:
+        ldif += [('cn', [username])]
 
     return ldif

File static/default/css/iredadmin.css

 
 #brd-visit #welcome span a.active {
     text-decoration: none;
+    font-weight: bold;
     }
 
 #brd-visit #visit-links {

File templates/default/ldap/domain_create.html

 {% block js_tablesorter %}{% endblock %}
 
 {% block title %}{{ _('Add new mail domain') }}{% endblock title %}
+{% block submenu %}{% endblock submenu %}
 
 {% block main %}
 <div class="main-subhead">

File templates/default/ldap/domain_profile.html

+{# cur_domain, allDomains, profile_type, #}
 {% extends "layout.html" %}
 
 {% from "macros.html" import
 {% block title %}{{ _('Edit domain profile.') }}{% endblock %}
 
 {% block id_welcome %}
-<span class="float_right">{{ _('View/Update domain profile:') }} <a href="{{homepath |e}}/profile/domain/{{domain}}">{{domain}}</a></strong></span>
+<span><a href="{{ctx.homepath}}/profile/domain/general/{{cur_domain}}" {% if profile_type == "general" %}class="active"{%endif%}>General</a>&nbsp;</span>
+{% if session.get('domainGlobalAdmin') == 'yes' %}
+    <span><a href="{{ctx.homepath}}/profile/domain/admins/{{cur_domain}}" {% if profile_type == "admins" %}class="active"{%endif%}>Admins</a>&nbsp;</span>
+    <span><a href="{{ctx.homepath}}/profile/domain/services/{{cur_domain}}" {% if profile_type == "services" %}class="active"{%endif%}>Service control</a>&nbsp;</span>
+    <span><a href="{{ctx.homepath}}/profile/domain/bcc/{{cur_domain}}" {%if profile_type == 'bcc'%}class="active"{%endif%}>BCC control</a>&nbsp;</span>
+    <span><a href="{{ctx.homepath}}/profile/domain/quotas/{{cur_domain}}" {%if profile_type == 'quotas'%}class="active"{%endif%}>Quotas</a>&nbsp;</span>
+    <span><a href="{{ctx.homepath}}/profile/domain/backupmx/{{cur_domain}}" {%if profile_type == 'backupmx'%}class="active"{%endif%}>Backup MX</a>&nbsp;</span>
+    <span><a href="{{ctx.homepath}}/profile/domain/advanced/{{cur_domain}}" {%if profile_type == 'advanced'%}class="active"{%endif%}>Advanced settings</a>&nbsp;</span>
+{% endif %}
 {% endblock id_welcome %}
 
 {# Domain profile. #}
 {% block main %}
-<div id="brd-visit" class="gen-content">
-    <p><span>{{ _('Domain profile.') }}</span></p>
-</div>
-
-{# Domain profile. #}
 {% set p = profile[0] %}
 {% set dn = p[0] %}
 {% set entries = p[1] %}
 
 {% set createTimestamp = entries.get('createTimestamp', ['--------------'])[0] %}
 
-<form class="frm-form" method="post" method="{{ctx.homepath}}/user/edit">
+<form class="frm-form" method="post" method="{{ctx.homepath}}/profile/domain/{{cur_domain}}">
 <div class="main-content main-frm">
+    <div class="profile ct-group data-group vcard">
         <div class="ct-set data-set set1">
             <div class="ct-box data-box">
                 <ul class="data-list">
-                    <input type="hidden" name="domainName" value="{{domain}}" />
-                    <li><span><strong>{{ _('Domain name:') }}</strong> {{domain}}</span></li>
+                    <input type="hidden" name="domainName" value="{{cur_domain}}" />
+                    <li><span><strong>{{ _('Domain name:') }}</strong>
+                        <span>
+                            <select id="domainSelect" name="domainName" onchange="listAccountsUnderDomain(this, baseurl='{{ctx.homepath}}/profile/domain/general/');">
+                                {% for d in allDomains %}
+                                <option value="{{d[1].domainName[0]}}" {% if cur_domain == d[1].domainName[0] %}selected{%endif%}>{{d[1].domainName[0]}}</option>
+                                {% endfor %}
+                                </select>
+                            </span></span></li>
                     <li><span><strong>{{ _('Company/Organization:') }}</strong> {{cn}}</span></li>
                     <li><span><strong>{{ _('Created Date:') }}</strong> {{createTimestamp[:4]}}.{{createTimestamp[4:6]}}.{{createTimestamp[6:8]}} {{createTimestamp[8:10]}}:{{createTimestamp[10:12]}}:{{createTimestamp[12:14]}}</span></li>
-                </ul>
+                    </ul>
+                </div>
             </div>
         </div>
 

File templates/default/ldap/domains.html

                         {% if session.get('domainGlobalAdmin') == 'yes' %}
                         <input type="checkbox" name="domainName" value="{{domain}}"/>
                         {% endif %}
-                        <a href="{{ctx.homepath}}/profile/domain/{{domain}}" alt="{{_('Edit')}}" title="{{ _('Edit domain profile.') }}">{{domain}}</a>
+                        <a href="{{ctx.homepath}}/profile/domain/general/{{domain}}" alt="{{_('Edit')}}" title="{{ _('Edit domain profile.') }}">{{domain}}</a>
                     </span>
                     <span class="float_right">{{ set_account_status_img(accountStatus) }}</span>
                 </td>

File templates/default/ldap/layout.html

             | <a href="http://code.google.com/p/iredmail/">iRedMail Project</a>
             {% if session.get('domainGlobalAdmin') == 'yes' %}
                 | <a href="mailto:michaelbibby@gmail.com">{{ _('Get support') }}</a>
+                | <a href="#">{{ _('Check new version') }}</a>
             {% else %}
                 | <a href="mailto:{{session.get('webmaster')}}">{{ _('Get support') }}</a>
             {% endif %}

File templates/default/ldap/macros.html

     <input type="hidden" name="{{ name }}" value="{{ value }}">
 {%- endmacro %}
 
-{% macro display_cn(value='', accountType='domain') -%}
-    <fieldset class="frm-group">
-        <div class="sf-set">
+{% macro display_cn(value='', accountType='domain', firstitem='yes') -%}
+    <fieldset class="frm-group {% if firstitem == 'yes' %}group1{% endif %}">
+        <div class="sf-set {% if firstitem == 'yes' %}set1{% endif %}">
             <div class="sf-box text">
                 <label><span>
                 {% if accountType == 'domain' %}

File templates/default/ldap/user_profile.html

                 <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 />
+                        <input type="text" name="telephoneNumber_{{loop.index}}" value="{{phone}}" size="25" /><br />
                     {% endfor %}
                 </span>
             </div>