Exemple #1
0
    def make_form(self):
        initial_data = {'title': self.thread.title, 'post': self.post.original}

        if self.mode == EDIT:
            is_first_post = self.post.id == self.thread.first_post_id
            if is_first_post and can_edit_thread(self.user, self.thread):
                FormType = ThreadForm
            else:
                FormType = ReplyForm
        elif self.mode == START:
            FormType = ThreadForm
        else:
            FormType = ReplyForm

        if FormType == ThreadForm:
            if self.request.method == 'POST':
                form = FormType(
                    self.thread, self.post, self.request, self.request.POST)
            else:
                form = FormType(
                    self.thread, self.post, self.request, initial=initial_data)
        else:
            if self.request.method == 'POST':
                form = FormType(
                    self.post, self.request, self.request.POST)
            else:
                form = FormType(
                    self.post, self.request, initial=initial_data)

        form.post_editor = Editor(form['post'], has_preview=True)
        return form
Exemple #2
0
    def make_form(self):
        initial_data = {'title': self.thread.title, 'post': self.post.original}

        if self.mode == EDIT:
            is_first_post = self.post.id == self.thread.first_post_id
            if is_first_post and can_edit_thread(self.user, self.thread):
                FormType = ThreadForm
            else:
                FormType = ReplyForm
        elif self.mode == START:
            FormType = ThreadForm
        else:
            FormType = ReplyForm

        if FormType == ThreadForm:
            if self.request.method == 'POST':
                form = FormType(self.thread, self.post, self.request,
                                self.request.POST)
            else:
                form = FormType(self.thread,
                                self.post,
                                self.request,
                                initial=initial_data)
        else:
            if self.request.method == 'POST':
                form = FormType(self.post, self.request, self.request.POST)
            else:
                form = FormType(self.post, self.request, initial=initial_data)

        form.post_editor = Editor(form['post'], has_preview=True)
        return form
Exemple #3
0
    def use_this_middleware(self):
        if self.forum.labels and self.forum.acl['can_change_threads_labels']:
            self.label_id = self.thread.label_id

            if self.mode == START:
                return True

            if self.mode == EDIT and can_edit_thread(self.user, self.thread):
                return True

        return False
Exemple #4
0
    def use_this_middleware(self):
        if self.forum.labels and self.forum.acl['can_change_threads_labels']:
            self.label_id = self.thread.label_id

            if self.mode == START:
                return True

            if self.mode == EDIT and can_edit_thread(self.user, self.thread):
                return True

        return False