From: hernani Date: Fri, 14 May 2010 14:00:15 +0000 (+0000) Subject: Some extra admin stuff and applied a patch from Ekalinin on OSQA 95. X-Git-Tag: live~859 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/c5240df75267cc1201c0e4673c34cc25149698e4 Some extra admin stuff and applied a patch from Ekalinin on OSQA 95. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@271 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/settings/forms.py b/forum/settings/forms.py index 15bbef6..a187683 100644 --- a/forum/settings/forms.py +++ b/forum/settings/forms.py @@ -38,6 +38,12 @@ class SettingsSetForm(forms.Form): self.set = set + def as_table(self): + return self._html_output( + u'%(label)s' + ('
%s|%s' % ( + _('context'), _('default'))) + u'%(errors)s%(field)s%(help_text)s', + u'%s', '', u'
%s', False) + def save(self): for setting in self.set: setting.set_value(self.cleaned_data[setting.name]) @@ -76,7 +82,7 @@ class StringListWidget(forms.Widget): ret = "" for s in value: ret += """ -
+
diff --git a/forum/skins/default/media/js/osqa.admin.js b/forum/skins/default/media/js/osqa.admin.js index ce0fc79..634f4c8 100644 --- a/forum/skins/default/media/js/osqa.admin.js +++ b/forum/skins/default/media/js/osqa.admin.js @@ -3,8 +3,8 @@ $(function() { $but = $(this); if ($but.is('.add')) { - $new = $("
" + - "" + + $new = $("
" + + "" + "" + "
"); @@ -18,4 +18,27 @@ $(function() { return false; }) + + $('.fieldtool').each(function() { + var $link = $(this); + var $input = $link.parent().parent().find('input, textarea'); + var name = $input.attr('name') + + if ($link.is('.context')) { + $link.click(function() { + var $contextbox = $(''); + $link.replaceWith($contextbox); + }); + } else if ($link.is('.default')) { + if ($input.length == 1 && ($input.is('[type=text]') || $input.is('textarea'))) { + $link.click(function() { + $.post(name + '/', function(data) { + $input.val(data); + }); + }); + } else { + $link.attr('href', name + '/'); + } + } + }); }); \ No newline at end of file diff --git a/forum/skins/default/media/style/djstyle_admin.css b/forum/skins/default/media/style/djstyle_admin.css index 5afe22e..87fe341 100644 --- a/forum/skins/default/media/style/djstyle_admin.css +++ b/forum/skins/default/media/style/djstyle_admin.css @@ -10,6 +10,40 @@ input.longstring { white-space: nowrap; } -#admin_form tr td { - width: 100%; -} \ No newline at end of file +#admin_form tr th a { + font-size: 80%; +} + +#admin_form tr th .sep { + font-size: 80%; + margin-left: 6px; + margin-right: 6px; +} + +#admin_form tr td:first-of-type { + width: 100%; +} + +.string-list-input { + vertical-align: middle; +} + +.string-list-input input { + width: 600px; + margin: 0px; +} + +.string_list_widget_button { + background:url("../img/admin/nav-bg.gif") repeat-x scroll center bottom #dcdcdc; + border-color:#DDDDDD #AAAAAA #AAAAAA #DDDDDD; + border-style:solid; + border-width:1px; + color:black; + height: 20px; + width: 20px; +} + +.string_list_widget_button.add { + position: relative; + left: 612px; +} diff --git a/forum/skins/default/templates/header.html b/forum/skins/default/templates/header.html index c53604c..64056b6 100644 --- a/forum/skins/default/templates/header.html +++ b/forum/skins/default/templates/header.html @@ -8,7 +8,7 @@ {% if request.user.is_superuser %} {% trans "administration" %} {% endif %} - {{ request.user.username }} {% get_score_badge request.user %} + {{ request.user.username }} {% get_score_badge request.user %} {% trans "logout" %} {% else %} {% trans "login" %} diff --git a/forum/skins/default/templates/users/users.html b/forum/skins/default/templates/users/users.html index f24b60a..cc4daeb 100644 --- a/forum/skins/default/templates/users/users.html +++ b/forum/skins/default/templates/users/users.html @@ -47,8 +47,8 @@ diff --git a/forum/urls.py b/forum/urls.py index 0d47127..52336e3 100644 --- a/forum/urls.py +++ b/forum/urls.py @@ -134,6 +134,7 @@ urlpatterns += patterns('', url(r'^%s%s$' % (_('admin/'), _('go_bootstrap/')), app.admin.go_bootstrap, name="admin_go_bootstrap"), url(r'^%s%s$' % (_('admin/'), _('go_defaults/')), app.admin.go_defaults, name="admin_go_defaults"), url(r'^%s(?P\w+)/$' % _('admin/'), app.admin.settings_set, name="admin_set"), + url(r'^%s(?P\w+)/(?P\w+)/$' % _('admin/'), app.admin.get_default, name="admin_default"), url(r'^feeds/rss/$', RssLastestQuestionsFeed, name="latest_questions_feed"), ) diff --git a/forum/views/admin.py b/forum/views/admin.py index dd1f3f5..d277954 100644 --- a/forum/views/admin.py +++ b/forum/views/admin.py @@ -114,7 +114,7 @@ def settings_set(request, set_name): if set_name in ('minrep', 'badges', 'repgain'): settings.SETTINGS_PACK.set_value("custom") - return HttpResponseRedirect(reverse('admin_set', args=[set_name])) + return HttpResponseRedirect(reverse('admin_set', args=[set_name])) else: form = SettingsSetForm(set) @@ -123,6 +123,21 @@ def settings_set(request, set_name): 'markdown': set.markdown, } +@super_user_required +def get_default(request, set_name, var_name): + set = Setting.sets.get(set_name, None) + if set is None: raise Http404 + + setting = dict([(s.name, s) for s in set]).get(var_name, None) + if setting is None: raise Http404 + + setting.to_default() + + if request.is_ajax(): + return HttpResponse(setting.default) + else: + return HttpResponseRedirect(reverse('admin_set', kwargs={'set_name': set_name})) + def get_recent_activity(): return Action.objects.order_by('-action_date')[0:30] diff --git a/settings.py b/settings.py index a7c5893..7b9e1f0 100644 --- a/settings.py +++ b/settings.py @@ -71,7 +71,7 @@ INSTALLED_APPS = [ 'forum', ] -if DEBUG: +if DEBUG and False: try: import debug_toolbar MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')