Show More
@@ -7,6 +7,7 b' from django.http.response import HttpRes' | |||
|
7 | 7 | from django.template import RequestContext |
|
8 | 8 | from django.shortcuts import render, redirect, get_object_or_404 |
|
9 | 9 | from django.utils import timezone |
|
10 | from django.db import transaction | |
|
10 | 11 | |
|
11 | 12 | from boards import forms |
|
12 | 13 | import boards |
@@ -61,6 +62,7 b' def index(request, page=0):' | |||
|
61 | 62 | context) |
|
62 | 63 | |
|
63 | 64 | |
|
65 | @transaction.commit_on_success | |
|
64 | 66 | def _new_post(request, form, thread_id=boards.models.NO_PARENT): |
|
65 | 67 | """Add a new post (in thread or as a reply).""" |
|
66 | 68 | |
@@ -226,22 +228,23 b' def settings(request):' | |||
|
226 | 228 | is_moderator = user.is_moderator() |
|
227 | 229 | |
|
228 | 230 | if request.method == 'POST': |
|
229 | if is_moderator: | |
|
230 | form = ModeratorSettingsForm(request.POST, | |
|
231 | error_class=PlainErrorList) | |
|
232 | else: | |
|
233 | form = SettingsForm(request.POST, error_class=PlainErrorList) | |
|
231 | with transaction.commit_on_success(): | |
|
232 | if is_moderator: | |
|
233 | form = ModeratorSettingsForm(request.POST, | |
|
234 | error_class=PlainErrorList) | |
|
235 | else: | |
|
236 | form = SettingsForm(request.POST, error_class=PlainErrorList) | |
|
234 | 237 | |
|
235 |
|
|
|
236 |
|
|
|
238 | if form.is_valid(): | |
|
239 | selected_theme = form.cleaned_data['theme'] | |
|
237 | 240 | |
|
238 |
|
|
|
241 | user.save_setting('theme', selected_theme) | |
|
239 | 242 | |
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 | if is_moderator: | |
|
244 | moderate = form.cleaned_data['moderate'] | |
|
245 | user.save_setting(SETTING_MODERATE, moderate) | |
|
243 | 246 | |
|
244 |
|
|
|
247 | return redirect(settings) | |
|
245 | 248 | else: |
|
246 | 249 | selected_theme = _get_theme(request) |
|
247 | 250 | |
@@ -288,6 +291,7 b' def authors(request):' | |||
|
288 | 291 | return render(request, 'boards/authors.html', context) |
|
289 | 292 | |
|
290 | 293 | |
|
294 | @transaction.commit_on_success | |
|
291 | 295 | def delete(request, post_id): |
|
292 | 296 | """Delete post""" |
|
293 | 297 | |
@@ -304,6 +308,7 b' def delete(request, post_id):' | |||
|
304 | 308 | return redirect(thread, post_id=post.thread.id) |
|
305 | 309 | |
|
306 | 310 | |
|
311 | @transaction.commit_on_success | |
|
307 | 312 | def ban(request, post_id): |
|
308 | 313 | """Ban user""" |
|
309 | 314 | |
@@ -331,6 +336,7 b' def page_404(request):' | |||
|
331 | 336 | return render(request, 'boards/404.html', context) |
|
332 | 337 | |
|
333 | 338 | |
|
339 | @transaction.commit_on_success | |
|
334 | 340 | def tag_subscribe(request, tag_name): |
|
335 | 341 | """Add tag to favorites""" |
|
336 | 342 | |
@@ -343,6 +349,7 b' def tag_subscribe(request, tag_name):' | |||
|
343 | 349 | return _redirect_to_next(request) |
|
344 | 350 | |
|
345 | 351 | |
|
352 | @transaction.commit_on_success | |
|
346 | 353 | def tag_unsubscribe(request, tag_name): |
|
347 | 354 | """Remove tag from favorites""" |
|
348 | 355 |
@@ -111,7 +111,6 b' MIDDLEWARE_CLASSES = (' | |||
|
111 | 111 | 'django.contrib.sessions.middleware.SessionMiddleware', |
|
112 | 112 | 'django.middleware.locale.LocaleMiddleware', |
|
113 | 113 | 'django.middleware.common.CommonMiddleware', |
|
114 | 'django.middleware.transaction.TransactionMiddleware', | |
|
115 | 114 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
|
116 | 115 | 'django.contrib.messages.middleware.MessageMiddleware', |
|
117 | 116 | 'boards.middlewares.BanMiddleware', |
General Comments 0
You need to be logged in to leave comments.
Login now