From 8b2fff67c684c5350cdc41ebe201300a6b5fbe8c Mon Sep 17 00:00:00 2001 From: jordan Date: Sat, 23 Apr 2011 16:29:40 +0000 Subject: [PATCH] adding download update messages functionality, AJAX button git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@998 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum_modules/updater/templates/index.html | 27 +++++++++++++++++++--- forum_modules/updater/views.py | 14 +++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/forum_modules/updater/templates/index.html b/forum_modules/updater/templates/index.html index 04f20af..aed0d01 100644 --- a/forum_modules/updater/templates/index.html +++ b/forum_modules/updater/templates/index.html @@ -1,14 +1,34 @@ {% extends basetemplate %} -{% load i18n %} +{% load i18n extra_tags %} {% block adminjs %} {{ block.super }} + + + @@ -23,6 +43,7 @@ $(function() { {% block admincontent %} -{% trans "Check for Updates" %} +{% trans "Check for Updates" %} +
{% endblock %} diff --git a/forum_modules/updater/views.py b/forum_modules/updater/views.py index 3066074..5d68e57 100644 --- a/forum_modules/updater/views.py +++ b/forum_modules/updater/views.py @@ -4,6 +4,8 @@ import bz2 import urllib2, urllib import binascii +from xml.dom.minidom import parse, parseString + from django import VERSION as DJANGO_VERSION from django.http import HttpResponse from django.utils.translation import ugettext as _ @@ -75,5 +77,13 @@ def updater_check(request): except urllib2.HTTPError, error: content = error.read() - json = simplejson.dumps({}) - return HttpResponse(content, mimetype='text/html') \ No newline at end of file + # Read the messages from the Update Server + messages_xml_url = '%s%s' % (UPDATE_SERVER_URL, '/messages/xml/') + messages_request = urllib2.Request(messages_xml_url, headers=headers) + messages_response = urllib2.urlopen(messages_request) + messages_xml = messages_response.read() + + messages_dom = parseString(messages_xml) + messages_count = len(messages_dom.getElementsByTagName('message')) + + return HttpResponse(_('%d update messages have been downloaded') % messages_count, mimetype='text/html') \ No newline at end of file -- 2.45.1