X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/ae44eb36129b207e217c3dea05e9a5cad2194fd5..dab4b8dda813f3f50df31d6cc73c9ee721c740a6:/forum_modules/updater/base.py?ds=sidebyside diff --git a/forum_modules/updater/base.py b/forum_modules/updater/base.py index 44af2ea..3ccf97d 100644 --- a/forum_modules/updater/base.py +++ b/forum_modules/updater/base.py @@ -14,9 +14,10 @@ import logging from xml.dom.minidom import parse, parseString from forum.models import Question, User -from forum.settings import APP_URL, SVN_REVISION +from forum.settings import APP_URL, SVN_REVISION, APP_TITLE, APP_DESCRIPTION from django import VERSION as DJANGO_VERSION from django.utils import simplejson +from django.utils.html import escape from django.utils.encoding import smart_unicode from django.conf import settings as django_settings from django.utils.translation import ugettext as _ @@ -36,6 +37,18 @@ def get_site_views(): return views +# Gets the active users count since the last visit +def get_active_users(): + users_count = 0 + + try: + if settings.LATEST_UPDATE_DATETIME: + users_count = User.objects.filter(last_login__gt=settings.LATEST_UPDATE_DATETIME).count() + except: + pass + + return users_count + def get_server_name(): url = '%s/' % APP_URL @@ -78,9 +91,11 @@ def check_for_updates(): statistics = """ + + - + @@ -90,9 +105,12 @@ def check_for_updates(): """ % { 'site_key' : settings.SITE_KEY, 'app_url' : APP_URL, + 'app_title' : escape(APP_TITLE.value), + 'app_description' : escape(APP_DESCRIPTION.value), 'svn_revision' : svn_revision, 'site_views' : get_site_views(), 'server_name' : get_server_name(), + 'active_users' : get_active_users(), 'python_version' : ''.join(sys.version.splitlines()), 'django_version' : str(DJANGO_VERSION), 'database' : django_settings.DATABASE_ENGINE, @@ -137,6 +155,10 @@ def check_for_updates(): messages_dom = parseString(messages_xml) messages_count = len(messages_dom.getElementsByTagName('message')) + # Set the latest update datetime to now. + now = datetime.datetime.now() + settings.LATEST_UPDATE_DATETIME.set_value(now) + return _('%d update messages have been downloaded.') % messages_count def update_trigger(): @@ -146,6 +168,4 @@ def update_trigger(): update_status = check_for_updates() logging.error(smart_unicode("Update process has been triggered: %s" % update_status)) - - # Set the latest update datetime to now. settings.LATEST_UPDATE_DATETIME.set_value(now)