From 56e536a441b0cb4d30e629e582cef5a0e8dda384 Mon Sep 17 00:00:00 2001 From: jordan Date: Tue, 19 Apr 2011 15:59:02 +0000 Subject: [PATCH] creating the site key setting that wraps the OSQA installation key, also creating the function that generates that site key, the format of that key is abcd-1234-efgh-t3st and it is unique for every installation, has to be kept private git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@991 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum_modules/updater/base.py | 6 ++++++ forum_modules/updater/settings.py | 18 ++++++++++++++++++ forum_modules/updater/urls.py | 9 +++++++++ forum_modules/updater/views.py | 6 ++++++ 4 files changed, 39 insertions(+) create mode 100644 forum_modules/updater/base.py create mode 100644 forum_modules/updater/settings.py diff --git a/forum_modules/updater/base.py b/forum_modules/updater/base.py new file mode 100644 index 0000000..74d37e5 --- /dev/null +++ b/forum_modules/updater/base.py @@ -0,0 +1,6 @@ +import string +import random + +def generate_installation_key(): + gen = lambda length: "".join( [random.choice(string.digits+string.letters) for i in xrange(length)]) + return '%s-%s-%s-%s' % (gen(4), gen(4), gen(4), gen(4)) \ No newline at end of file diff --git a/forum_modules/updater/settings.py b/forum_modules/updater/settings.py new file mode 100644 index 0000000..3faa290 --- /dev/null +++ b/forum_modules/updater/settings.py @@ -0,0 +1,18 @@ +from forum.settings.base import Setting, SettingSet +from django.utils.translation import ugettext_lazy as _ + +from base import generate_installation_key + +UPDATER_SET = SettingSet('updater', _('Updater Settings'), _("OSQA Update Checker Settings."), 100) + +CHECK_FOR_UPDATES = Setting('CHECK_FOR_UPDATES', True, UPDATER_SET, dict( +label = "Check for updates", +help_text = _(""" +Use the OSQA update server recieve notifications about the latest updates. +"""), +required=False)) + +SITE_KEY = Setting('SITE_KEY', generate_installation_key()) + +# Update server. Do not edit. +UPDATE_SERVER_URL = 'http://192.168.0.102:8008' \ No newline at end of file diff --git a/forum_modules/updater/urls.py b/forum_modules/updater/urls.py index e69de29..300a589 100644 --- a/forum_modules/updater/urls.py +++ b/forum_modules/updater/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls.defaults import * +from django.views.generic.simple import direct_to_template +from django.utils.translation import ugettext as _ + +from views import updater_index + +urlpatterns = patterns('', + url(r'^%s%s$' % (_('admin/'), _('updater/')), updater_index, name='updater_index'), +) diff --git a/forum_modules/updater/views.py b/forum_modules/updater/views.py index e69de29..33b13b2 100644 --- a/forum_modules/updater/views.py +++ b/forum_modules/updater/views.py @@ -0,0 +1,6 @@ +from django.http import HttpResponse +from base import generate_installation_key +from settings import SITE_KEY + +def updater_index(request): + return HttpResponse(str(SITE_KEY)) -- 2.39.5