##// END OF EJS Templates
Added info about attachments
Added info about attachments

File last commit:

r730:447bb8d7 2.0-dev
r840:78400567 decentral
Show More
post_admin.py
60 lines | 1.9 KiB | text/x-python | PythonLexer
neko259
Added post admin page with tags edit capability
r566 from django.shortcuts import render, get_object_or_404, 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 PERMISSION_MODERATE,\
get_settings_manager
neko259
Added post admin page with tags edit capability
r566 from boards.views.base import BaseBoardView
from boards.views.mixins import DispatcherMixin
from boards.models.post import Post
from boards.models.tag import Tag
from boards.forms import AddTagForm, PlainErrorList
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
neko259
Added post admin page with tags edit capability
r566 class PostAdminView(BaseBoardView, DispatcherMixin):
def get(self, request, post_id, form=None):
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
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 if not settings_manager.has_permission(PERMISSION_MODERATE):
neko259
Added post admin page with tags edit capability
r566 redirect('index')
post = get_object_or_404(Post, id=post_id)
if not form:
dispatch_result = self.dispatch_method(request, post)
if dispatch_result:
return dispatch_result
form = AddTagForm()
context = self.get_context_data(request=request)
context['post'] = post
context['tag_form'] = form
return render(request, 'boards/post_admin.html', context)
def post(self, request, post_id):
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
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 if not settings_manager.has_permission(PERMISSION_MODERATE):
neko259
Added post admin page with tags edit capability
r566 redirect('index')
post = get_object_or_404(Post, id=post_id)
return self.dispatch_method(request, post)
def delete_tag(self, request, post):
tag_name = request.GET['tag']
tag = get_object_or_404(Tag, name=tag_name)
post.remove_tag(tag)
return redirect('post_admin', post.id)
def add_tag(self, request, post):
form = AddTagForm(request.POST, error_class=PlainErrorList)
if form.is_valid():
tag_name = form.cleaned_data['tag']
tag, created = Tag.objects.get_or_create(name=tag_name)
post.add_tag(tag)
return redirect('post_admin', post.id)
else:
return self.get(request, post.id, form)