Commits

Zhang Huangbin committed 2bcb036

Add ability to check new version.

  • Participants
  • Parent commits 7b0d72b

Comments (0)

Files changed (6)

File controllers/ldap/basic.py

 # Author: Zhang Huangbin <michaelbibby (at) gmail.com>
 
 import web, sys
-from libs import iredutils
+from libs import __version__, __url_iredadmin_lastest__, iredutils
 from libs.ldaplib import core, auth, domain, ldaputils
 from controllers.ldap import base
 
 class dashboard:
     @base.protected
     def GET(self):
-        return render.dashboard()
+        from socket import gethostname
+        import os
+        return render.dashboard(
+                version=__version__,
+                hostname=gethostname(),
+                uptime=iredutils.getServerUptime(),
+                loadavg=os.getloadavg(),
+                )
+
+class checknew:
+    @base.check_global_admin
+    @base.protected
+    def GET(self):
+        import urllib2
+        try:
+            f = urllib2.urlopen(__url_iredadmin_lastest__)
+            info = f.read().strip().split('\n')[:3]
+        except Exception, e:
+            info = (None, str(e))
+        return render.checknew(version=__version__, info=info,)
 
 class dbinit:
     def __init__(self):

File libs/__init__.py

-__version__ = '0.1'
+__version__ = 0.1
 __author__ = 'Zhang Huangbin'
 __author_mail__ = 'michaelbibby@gmail.com'
+__url_iredadmin_lastest__ = 'http://www.iredmail.org/iredadmin_ose_lastest'

File templates/default/ldap/admins.html

 
         <div class="frm-buttons">
             <span class="submit">
-                <input type="checkbox" id="checkall" />{{ _('Select all') }}
+                <input type="checkbox" id="checkall" />{{ _('Select/Unselect all') }}
                 <input type="submit" value="{{ _('Delete') }}" onclick="return confirm('{{ _('Are you sure want to delete selected account(s)?') }}');" }}" />
             </span>
         </div>

File templates/default/ldap/checknew.html

+{# version, #}
+{% extends "layout.html" %}
+
+{% block js %}{% endblock js %}
+{% block js_tablesorter %}{% endblock %}
+{% block jquery_docoment_ready %} {% endblock %}
+{% block title %} {{ _('Dashboard') }} {% endblock %}
+{% block submenu %}{% endblock submenu %}
+
+{% block main %}
+
+<div class="main-frm">
+    <div class="main-subhead">
+        <h2 class="hn">{{ _('Check new version') }}</h2>
+    </div>
+
+    <div class="ct-group">
+        <div class="ct-set group-item1">
+            <div class="ct-box">
+                <h3 class="ct-legend hn"><span>{{ _('Current iRedAdmin version') }}</span></h3>
+                <p><span class="fld-input">{{ version }}</span></p>
+            </div>
+            <div class="ct-box">
+                {% if info[0] is not sameas none %}
+                    {% if info[0] |float > version |float %}
+                    <h3 class="ct-legend hn"><span><strong>{{ _('New version available') }}</strong></span></h3>
+                    <ul class="data-list">
+                        <li><span>{{ info[0] |float }}</span></li>
+                        <li><span><a href="{{ info[1] }}">{{ _('ChangeLog') }}</a></span></li>
+                        <li><span><a href="{{ info[2] }}">{{ _('Download') }}</a></span></li>
+                    </ul>
+                    {% else %}
+                    <h3 class="ct-legend hn"><span>{{ _('No new version available') }}</span></h3>
+                    {% endif %}
+                {% else %}
+                    <h3 clss="ct-legend hn"><span>{{ _('Error while check new version') }}</span></h3>
+                    <p><span>{{ info[1] }}</span></p>
+                {% endif %}
+            </div>
+        </div>
+    </div>
+</div>
+
+{% endblock main %}

File templates/default/ldap/domains.html

     {% if session.get('domainGlobalAdmin') == 'yes' %}
         <div class="frm-buttons">
             <span class="submit">
-                <input type="checkbox" id="checkall" />{{ _('Select all') }}
+                <input type="checkbox" id="checkall" />{{ _('Select/Unselect all') }}
                 <input type="submit" value="{{ _('Delete') }}" onclick="return confirm('{{ _('Are you sure want to delete selected domain(s) and accounts under it?') }}');" }}" />
             </span>
         </div>

File templates/default/ldap/users.html

 
     <div class="frm-buttons">
         <span class="submit">
-            <input type="checkbox" id="checkall" />{{ _('Select all') }}
+            <input type="checkbox" id="checkall" />{{ _('Select/Unselect all') }}
             <input type="submit" value="{{ _('Delete') }}" onclick="return confirm('{{ _('Are you sure want to delete selected account(s)?') }}');" }}" />
         </span>
     </div>