Esempio n. 1
0
    def get_context_data(self, **kwargs):
        ctx = super(TopicView, self).get_context_data(**kwargs)
        ctx.update(get_intial_home_data(self.request))
        if self.request.user.is_authenticated():
            self.request.user.is_moderator = self.request.user.is_superuser or (self.request.user in self.topic.forum.moderators.all())
            self.request.user.is_subscribed = self.request.user in self.topic.subscribers.all()
            if perms.may_post_as_admin(self.request.user):
                ctx['form'] = AdminPostForm(initial={'login': self.request.user.username}, topic=self.topic)
            else:
                ctx['form'] = PostForm(topic=self.topic)
            self.mark_read(self.request, self.topic)
        elif defaults.PYBB_ENABLE_ANONYMOUS_POST:
            ctx['form'] = PostForm(topic=self.topic)
        else:
            ctx['form'] = None
        if defaults.PYBB_ATTACHMENT_ENABLE:
            aformset = AttachmentFormSet()
            ctx['aformset'] = aformset
        if defaults.PYBB_FREEZE_FIRST_POST:
            ctx['first_post'] = self.topic.head
        else:
            ctx['first_post'] = None
        ctx['topic'] = self.topic

        if self.request.user.is_authenticated() and self.topic.poll_type != Topic.POLL_TYPE_NONE and \
           pybb_topic_poll_not_voted(self.topic, self.request.user):
            ctx['poll_form'] = PollForm(self.topic)

        return ctx
Esempio n. 2
0
 def get_context_data(self, **kwargs):
     ctx = super(IndexView, self).get_context_data(**kwargs)
     ctx.update(get_intial_home_data(self.request))
     categories = ctx['categories']
     for category in categories:
         category.forums_accessed = perms.filter_forums(self.request.user, category.forums.all())
     ctx['categories'] = categories
     return ctx
Esempio n. 3
0
 def get_context_data(self, **kwargs):
     ctx = super(CategoryView, self).get_context_data(**kwargs)
     ctx.update(get_intial_home_data(self.request))
     ctx['category'].forums_accessed = perms.filter_forums(self.request.user, ctx['category'].forums.all())
     ctx['categories'] = [ctx['category']]
     return ctx
Esempio n. 4
0
 def get_context_data(self, **kwargs):
     ctx = super(ForumView, self).get_context_data(**kwargs)
     ctx.update(get_intial_home_data(self.request))
     ctx['forum'] = self.forum
     return ctx