Пример #1
0
 def post(self, request, *args, **kwargs):
     if (self.blog.check_can_change_settings(self.membership) or
             Blog.can_be_moderated_by(self.request.user)):
         return super(EditBlogView, self).post(request, *args, **kwargs)
     else:
         messages.error(self.request, _('You can\'t perform this action'))
         return HttpResponseRedirect(self.get_success_url(self.blog))
Пример #2
0
 def post(self, request, *args, **kwargs):
     self.object = self.get_object()
     if self.object.blog is not None:
         membership = self.object.blog.check_membership(request.user)
     else:
         membership = None
     if (request.user == self.object.author or
             Blog.check_can_delete_posts(membership) or
             self.request.user.has_perm('collective_blog.delete_post')):
         return super(DeletePostView, self).post(request, *args, **kwargs)
     else:
         messages.error(self.request, _('You can\'t perform this action'))
         return HttpResponseRedirect(self.get_success_url())
Пример #3
0
    def get_context_data(self, **kwargs):
        context = super(BlogView, self).get_context_data(**kwargs)
        context['is_banned'] = self.blog.is_banned(self.membership)
        context['can_join'] = self.blog.check_can_join(self.request.user)
        context['colors'] = Membership.COLORS
        context['current_color'] = self.membership.color if self.membership else ''
        context['members'] = Membership.objects.filter(blog=self.blog).exclude(role__in=['L', 'LB']).count()
        context['posts'] = Post.objects.filter(blog=self.blog, is_draft=False).count()
        context['is_moderator'] = Blog.can_be_moderated_by(self.request.user)

        if self.membership and self.membership.role in ['O', 'A'] and self.membership.can_accept_new_users():
            context['pending'] = Membership.objects.filter(role='W', blog=self.blog).count()

        return context
Пример #4
0
 def get_context_data(self, **kwargs):
     context = super(EditBlogView, self).get_context_data(**kwargs)
     context['is_moderator'] = Blog.can_be_moderated_by(self.request.user)
     return context