##// END OF EJS Templates
Better interface for the thread admin tags list
Better interface for the thread admin tags list

File last commit:

r919:84a3726d default
r921:eeea6bf9 default
Show More
settings.py
41 lines | 1.2 KiB | text/x-python | PythonLexer
neko259
Made settings view class-based
r547 from django.db import transaction
from django.shortcuts import render, redirect
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 from boards.abstracts.settingsmanager import get_settings_manager
neko259
Code cleanup part 2
r722 from boards.views.base import BaseBoardView, CONTEXT_FORM
neko259
Added login and logout for moderators
r729 from boards.forms import SettingsForm, PlainErrorList
neko259
Made settings view class-based
r547
neko259
Views refactoring
r900 FORM_THEME = 'theme'
neko259
Fixed hidden tags list in the settings
r733 CONTEXT_HIDDEN_TAGS = 'hidden_tags'
neko259
Minor style fixes to view classes. Fixed ban view
r561
neko259
Made settings view class-based
r547 class SettingsView(BaseBoardView):
def get(self, request):
neko259
Fixed tag threads view
r919 params = self.get_context_data()
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(request)
neko259
Made settings view class-based
r547
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728 selected_theme = settings_manager.get_theme()
neko259
Made settings view class-based
r547
neko259
Views refactoring
r900 form = SettingsForm(initial={FORM_THEME: selected_theme},
neko259
Added login and logout for moderators
r729 error_class=PlainErrorList)
neko259
Made settings view class-based
r547
neko259
Fixed tag threads view
r919 params[CONTEXT_FORM] = form
params[CONTEXT_HIDDEN_TAGS] = settings_manager.get_hidden_tags()
neko259
Made settings view class-based
r547
neko259
Updates to support django 1.7
r872 # TODO Use dict here
neko259
Fixed tag threads view
r919 return render(request, 'boards/settings.html', params)
neko259
Made settings view class-based
r547
def post(self, request):
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(request)
neko259
Made settings view class-based
r547
with transaction.atomic():
neko259
Added login and logout for moderators
r729 form = SettingsForm(request.POST, error_class=PlainErrorList)
neko259
Made settings view class-based
r547
if form.is_valid():
neko259
Views refactoring
r900 selected_theme = form.cleaned_data[FORM_THEME]
neko259
Made settings view class-based
r547
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728 settings_manager.set_theme(selected_theme)
neko259
Made settings view class-based
r547
return redirect('settings')