]> git.openstreetmap.org Git - osqa.git/commitdiff
Some extra admin stuff and applied a patch from Ekalinin on OSQA 95.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 14 May 2010 14:00:15 +0000 (14:00 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 14 May 2010 14:00:15 +0000 (14:00 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@271 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/settings/forms.py
forum/skins/default/media/js/osqa.admin.js
forum/skins/default/media/style/djstyle_admin.css
forum/skins/default/templates/header.html
forum/skins/default/templates/users/users.html
forum/urls.py
forum/views/admin.py
settings.py

index 15bbef669413603f9f3a9447f6a3a28e87e95831..a1876837acaaa47dfeec88195852e8b6b76045c3 100644 (file)
@@ -38,6 +38,12 @@ class SettingsSetForm(forms.Form):
 
         self.set = set
 
+    def as_table(self):
+        return self._html_output(
+                u'<tr><th>%(label)s' + ('<br /><a class="fieldtool context" href="#">%s</a><span class="sep">|</span><a class="fieldtool default" href="#">%s</a></th>' % (
+                    _('context'), _('default'))) + u'<td>%(errors)s%(field)s%(help_text)s</td>',
+                u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%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 += """
-            <div>
+            <div class="string-list-input">
                 <input type="text" name="%(name)s" value="%(value)s" />
                 <button class="string_list_widget_button">-</button>
             </div>
index ce0fc79e89a5935eb46a11e69ad0ac895493992b..634f4c8fcfb8694739e24bf54e28b5f69c36f9be 100644 (file)
@@ -3,8 +3,8 @@ $(function() {
         $but = $(this);\r
 \r
         if ($but.is('.add')) {\r
-            $new = $("<div style=\"display: none\">" +\r
-                    "<input type=\"text\" name=\"" + $but.attr('name') + "\" value=\"\" />" +\r
+            $new = $("<div style=\"display: none;\">" +\r
+                    "<input style=\"width: 600px;\" type=\"text\" name=\"" + $but.attr('name') + "\" value=\"\" />" +\r
                     "<button class=\"string_list_widget_button\">-</button>" +\r
                     "</div>");\r
 \r
@@ -18,4 +18,27 @@ $(function() {
 \r
         return false;\r
     })\r
+\r
+    $('.fieldtool').each(function() {\r
+        var $link = $(this);\r
+        var $input = $link.parent().parent().find('input, textarea');\r
+        var name = $input.attr('name')\r
+\r
+        if ($link.is('.context')) {\r
+            $link.click(function() {\r
+                var $contextbox = $('<input type="text" value="' + name + '" />');\r
+                $link.replaceWith($contextbox);\r
+            });\r
+        } else if ($link.is('.default')) {\r
+            if ($input.length == 1 && ($input.is('[type=text]') || $input.is('textarea'))) {\r
+                $link.click(function() {\r
+                    $.post(name + '/', function(data) {\r
+                        $input.val(data);\r
+                    });\r
+                });\r
+            } else {\r
+                $link.attr('href', name + '/');\r
+            }\r
+        }\r
+    });\r
 });
\ No newline at end of file
index 5afe22e7977ccba448b134600f552f2e53e0aceb..87fe341d6b029025f8a53504e700bfc7257f3191 100644 (file)
@@ -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;
+}
index c53604ca3afe559be2486688c745d1a6116805b5..64056b61d15658bef3e9339218b3fc38b44d7c58 100644 (file)
@@ -8,7 +8,7 @@
                     {% if request.user.is_superuser %}
                         <a href="{% url admin_index %}">{% trans "administration" %}</a>   
                     {% endif %}
-                    <a href="{% url user_profile id=request.user.id,slug=request.user.username|slugify %}">{{ request.user.username }}</a> {% get_score_badge request.user %} 
+                    <a href="{{ request.user.get_profile_url }}">{{ request.user.username }}</a> {% get_score_badge request.user %} 
                     <a href="{% url logout %}">{% trans "logout" %}</a>
                 {% else %}
                     <a href="{% url auth_signin %}">{% trans "login" %}</a>
index f24b60a10769c9dc22b9b9609e58de3280427ec7..cc4daebe12c7855d059ee111a96801b51a17b769 100644 (file)
@@ -47,8 +47,8 @@
                     
                     <div class="user">
                         <ul>
-                                <li class="thumb"><a href="/users/{{ user.id }}/{{ user.username|slugify }}/">{% gravatar user 32 %}</a></li>
-                                <li><a href="/users/{{ user.id }}/{{ user.username|slugify }}/">{{user.username}}</a></li>
+                                <li class="thumb"><a href=" {{ user.get_profile_url }} ">{% gravatar user 32 %}</a></li>
+                                <li><a href=" {{ user.get_profile_url }} ">{{ user.get_profile_link }}</a></li> 
                                 <li>{% get_score_badge user %}</li>
                             </ul>
                     </div>
index 0d471276e279774644c9c487a64f12aeab10c40a..52336e312692e0f052c7435ec57f7c42c6053d49 100644 (file)
@@ -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<set_name>\w+)/$' % _('admin/'), app.admin.settings_set, name="admin_set"),
+    url(r'^%s(?P<set_name>\w+)/(?P<var_name>\w+)/$' % _('admin/'), app.admin.get_default, name="admin_default"),
 
     url(r'^feeds/rss/$', RssLastestQuestionsFeed, name="latest_questions_feed"),
 )
index dd1f3f5a4a472c30a1b6f6587a1c4d6f2ef7b662..d277954b7b278989e1937b1a27e7d48cf338e612 100644 (file)
@@ -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]
index a7c589300508523648a62fe07d68b59b85765799..7b9e1f0f432ed6821051afade6fbbad30d7bdbbd 100644 (file)
@@ -71,7 +71,7 @@ INSTALLED_APPS = [
     'forum',
 ]
 
-if DEBUG:
+if DEBUG and False:
     try:
         import debug_toolbar
         MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')