From 3b5c6ac1b27189ff017910816324420cb3b2cec6 Mon Sep 17 00:00:00 2001
From: RaNaN <Mast3rRaNaN@hotmail.de>
Date: Thu, 21 Jul 2011 13:01:24 +0200
Subject: show updates on webif

---
 module/plugins/hooks/UpdateManager.py  |  3 +++
 module/web/pyload_app.py               | 17 ++++++++++++++---
 module/web/templates/default/base.html | 16 +++++++++++++++-
 3 files changed, 32 insertions(+), 4 deletions(-)

(limited to 'module')

diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index 7f4d57947..705ed8eca 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -80,6 +80,9 @@ class UpdateManager(Hook):
     def checkPlugins(self):
         """ checks for plugins updates"""
 
+        # plugins were already updated
+        if self.info["plugins"]: return
+
         try:
             updates = getURL("http://get.pyload.org/plugins/check/")
         except:
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py
index 7492114ca..35203ad7b 100644
--- a/module/web/pyload_app.py
+++ b/module/web/pyload_app.py
@@ -45,16 +45,27 @@ def pre_processor():
     user = parse_userdata(s)
     perms = parse_permissions(s)
     status = {}
-    if user["is_authenticated"]:
-        status = PYLOAD.statusServer()
     captcha = False
+    update = False
+    plugins = False
     if user["is_authenticated"]:
+        status = PYLOAD.statusServer()
+        info = PYLOAD.getInfoByPlugin("UpdateManager")
         captcha = PYLOAD.isCaptchaWaiting()
+
+        # check if update check is available
+        if info:
+            if info["pyload"] == "True": update = True
+            if info["plugins"] == "True": plugins = True
+
+
     return {"user": user,
             'status': status,
             'captcha': captcha,
             'perms': perms,
-            'url': request.url}
+            'url': request.url,
+            'update': update,
+            'plugins': plugins}
 
 
 def base(messages):
diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html
index c247a7dc8..5b6854525 100644
--- a/module/web/templates/default/base.html
+++ b/module/web/templates/default/base.html
@@ -181,12 +181,26 @@ function AddBox(){
 
         {% if user.is_authenticated %}
 
+
+{% if update %}
+<span>
+<span style="font-weight: bold; margin: 0 2px 0 2px;">{{_("pyLoad Update available!")}}</span>
+</span>
+{% endif %}
+
+
+{% if plugins %}
+<span>
+<span style="font-weight: bold; margin: 0 2px 0 2px;">{{_("Plugins updated, please restart!")}}</span>
+</span>
+{% endif %}
+
 <span id="cap_info" style="display: {% if captcha %}inline{%else%}none{% endif %}">
 <img src="/media/default/img/images.png" alt="Captcha:" style="vertical-align:middle; margin:2px" />
 <span style="font-weight: bold; cursor: pointer; margin-right: 2px;">{{_("Captcha waiting")}}</span>
 </span>
 
-<img src="/media/default/img/head-login.png" alt="User:" style="vertical-align:middle; margin:2px" /><span style="padding-right: 2px;">{{user.name}}</span>
+    <img src="/media/default/img/head-login.png" alt="User:" style="vertical-align:middle; margin:2px" /><span style="padding-right: 2px;">{{user.name}}</span>
 	<ul id="user-actions">
 		<li><a href="/logout"  class="action logout" rel="nofollow">{{_("Logout")}}</a></li>
 		{% if user.is_admin %}
-- 
cgit v1.2.3