fix #179 open/close action worked incorrect
This commit is contained in:
parent
a4ed45cbd9
commit
998f9d4bc4
3 changed files with 18 additions and 12 deletions
|
@ -204,14 +204,14 @@
|
|||
<dd><a href="{% url djangobb:delete_posts topic.id %}">{% trans "Delete multiple posts" %}</a></dd>
|
||||
<dd><a href="{% url djangobb:move_topic %}?topic_id={{ topic.id }}">{% trans "Move topic" %}</a></dd>
|
||||
{% if topic.closed %}
|
||||
<dd><a href="{% url djangobb:open_close_topic topic.id %}">{% trans "Open topic" %}</a></dd>
|
||||
<dd><a href="{% url djangobb:open_close_topic topic.id 'o' %}">{% trans "Open topic" %}</a></dd>
|
||||
{% else %}
|
||||
<dd><a href="{% url djangobb:open_close_topic topic.id %}">{% trans "Close topic" %}</a></dd>
|
||||
<dd><a href="{% url djangobb:open_close_topic topic.id 'c' %}">{% trans "Close topic" %}</a></dd>
|
||||
{% endif %}
|
||||
{% if topic.sticky %}
|
||||
<dd><a href="{% url djangobb:stick_unstick_topic topic.id %}">{% trans "Unstick topic" %}</a></dd></dl>
|
||||
<dd><a href="{% url djangobb:stick_unstick_topic topic.id 'u' %}">{% trans "Unstick topic" %}</a></dd></dl>
|
||||
{% else %}
|
||||
<dd><a href="{% url djangobb:stick_unstick_topic topic.id %}">{% trans "Stick topic" %}</a></dd></dl>
|
||||
<dd><a href="{% url djangobb:stick_unstick_topic topic.id 's' %}">{% trans "Stick topic" %}</a></dd></dl>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</dl>
|
||||
|
|
|
@ -25,8 +25,8 @@ urlpatterns = patterns('',
|
|||
{'topic_id': None}, name='add_topic'),
|
||||
url('^topic/(?P<topic_id>\d+)/delete_posts/$', forum_views.delete_posts, name='delete_posts'),
|
||||
url('^topic/move/$', forum_views.move_topic, name='move_topic'),
|
||||
url('^topic/(?P<topic_id>\d+)/stick_unstick/$', forum_views.stick_unstick_topic, name='stick_unstick_topic'),
|
||||
url('^topic/(?P<topic_id>\d+)/open_close/$', forum_views.open_close_topic, name='open_close_topic'),
|
||||
url('^topic/(?P<topic_id>\d+)/stick_unstick/(?P<action>[s|u])/$', forum_views.stick_unstick_topic, name='stick_unstick_topic'),
|
||||
url('^topic/(?P<topic_id>\d+)/open_close/(?P<action>[c|o])/$', forum_views.open_close_topic, name='open_close_topic'),
|
||||
|
||||
# Post
|
||||
url('^topic/(?P<topic_id>\d+)/post/add/$', forum_views.add_post,
|
||||
|
|
|
@ -93,11 +93,11 @@ def moderate(request, forum_id):
|
|||
return HttpResponseRedirect(reverse('djangobb:index'))
|
||||
elif 'open_topics' in request.POST:
|
||||
for topic_id in topic_ids:
|
||||
open_close_topic(request, topic_id)
|
||||
open_close_topic(request, topic_id, 'o')
|
||||
return HttpResponseRedirect(reverse('djangobb:index'))
|
||||
elif 'close_topics' in request.POST:
|
||||
for topic_id in topic_ids:
|
||||
open_close_topic(request, topic_id)
|
||||
open_close_topic(request, topic_id, 'c')
|
||||
return HttpResponseRedirect(reverse('djangobb:index'))
|
||||
|
||||
return {'forum': forum,
|
||||
|
@ -674,11 +674,14 @@ def move_topic(request):
|
|||
|
||||
@login_required
|
||||
@transaction.commit_on_success
|
||||
def stick_unstick_topic(request, topic_id):
|
||||
def stick_unstick_topic(request, topic_id, action):
|
||||
|
||||
topic = get_object_or_404(Topic, pk=topic_id)
|
||||
if forum_moderated_by(topic, request.user):
|
||||
topic.sticky = not topic.sticky
|
||||
if action == 's':
|
||||
topic.sticky = True
|
||||
elif action == 'u':
|
||||
topic.sticky = False
|
||||
topic.save()
|
||||
return HttpResponseRedirect(topic.get_absolute_url())
|
||||
|
||||
|
@ -714,11 +717,14 @@ def delete_post(request, post_id):
|
|||
|
||||
@login_required
|
||||
@transaction.commit_on_success
|
||||
def open_close_topic(request, topic_id):
|
||||
def open_close_topic(request, topic_id, action):
|
||||
|
||||
topic = get_object_or_404(Topic, pk=topic_id)
|
||||
if forum_moderated_by(topic, request.user):
|
||||
topic.closed = not topic.closed
|
||||
if action == 'c':
|
||||
topic.closed = True
|
||||
elif action == 'o':
|
||||
topic.closed = False
|
||||
topic.save()
|
||||
return HttpResponseRedirect(topic.get_absolute_url())
|
||||
|
||||
|
|
Reference in a new issue