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])
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>
$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
\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
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;
+}
{% 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>
<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>
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"),
)
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)
'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]
'forum',
]
-if DEBUG:
+if DEBUG and False:
try:
import debug_toolbar
MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')