Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        super(TopicForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('title'),
            Field('subtitle', autocomplete='off'),
            Field('tags'),
            HTML(
                """<div id="topic-suggest" style="display:none;"  url="/rechercher/sujets-similaires/">
  <label>{0}</label>
  <div id="topic-result-container" data-neither="{1}"></div>
</div>""".format(_('Sujets similaires au vôtre :'), _('Aucun résultat'))),
            CommonLayoutEditor(),
        )

        if 'text' in self.initial:
            self.helper.layout.append(
                HTML(
                    "{% include 'misc/hat_choice.html' with edited_message=topic.first_post %}"
                ))
        else:
            self.helper.layout.append(
                HTML("{% include 'misc/hat_choice.html' %}"))
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = "content-wrapper"
        self.helper.form_method = "post"

        self.helper.layout = Layout(
            Field("title"),
            Field("subtitle", autocomplete="off"),
            Field("tags"),
            HTML(
                """<div id="topic-suggest" style="display:none;"  url="/rechercher/sujets-similaires/">
  <label>{}</label>
  <div id="topic-result-container" data-neither="{}"></div>
</div>""".format(_("Sujets similaires au vôtre :"), _("Aucun résultat"))),
            CommonLayoutEditor(),
        )

        if "text" in self.initial:
            self.helper.layout.append(
                HTML(
                    "{% include 'misc/hat_choice.html' with edited_message=topic.first_post %}"
                ))
        else:
            self.helper.layout.append(
                HTML("{% include 'misc/hat_choice.html' %}"))
Esempio n. 3
0
    def __init__(self, tutorial, user, *args, **kwargs):
        super(NoteForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse(
            'zds.tutorial.views.answer') + '?tutorial=' + str(tutorial.pk)
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden('last_note', '{{ last_note_pk }}'),
        )

        if tutorial.antispam(user):
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=u'Vous venez de poster. Merci de patienter '
                    u'au moins 15 minutes entre deux messages consécutifs '
                    u'afin de limiter le flood.',
                    disabled=True)
        elif tutorial.is_locked:
            self.helper['text'].wrap(
                Field,
                placeholder=u'Ce tutoriel est verrouillé.',
                disabled=True
            )
Esempio n. 4
0
    def __init__(self, topic, user, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_method = "post"

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden("last_post", "{{ last_post_pk }}"),
        )

        if "text" in self.initial:
            self.helper.layout.append(
                HTML(
                    "{% include 'misc/hat_choice.html' with edited_message=post %}"
                ))
        else:
            self.helper.layout.append(
                HTML("{% include 'misc/hat_choice.html' %}"))

        if topic.antispam(user):
            if "text" not in self.initial:
                self.helper["text"].wrap(
                    Field,
                    placeholder=_(
                        "Vous venez de poster. Merci de patienter "
                        "au moins 15 minutes entre deux messages consécutifs "
                        "afin de limiter le flood."),
                    disabled=True,
                )
        elif topic.is_locked:
            if "text" not in self.initial:
                self.helper["text"].wrap(
                    Field,
                    placeholder=_("Ce topic est verrouillé."),
                    disabled=True)
Esempio n. 5
0
    def __init__(self, topic, user, *args, **kwargs):
        super(PostForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden('last_post', '{{ last_post_pk }}'),
        )

        if 'text' in self.initial:
            self.helper.layout.append(
                HTML(
                    "{% include 'misc/hat_choice.html' with edited_message=post %}"
                ))
        else:
            self.helper.layout.append(
                HTML("{% include 'misc/hat_choice.html' %}"))

        if topic.antispam(user):
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=_(
                        'Vous venez de poster. Merci de patienter '
                        'au moins 15 minutes entre deux messages consécutifs '
                        'afin de limiter le flood.'),
                    disabled=True)
        elif topic.is_locked:
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=_('Ce topic est verrouillé.'),
                    disabled=True)
Esempio n. 6
0
    def __init__(self, *args, **kwargs):
        super(ExtractForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(Field('title'),
                                    Hidden('last_hash', '{{ last_hash }}'),
                                    CommonLayoutEditor())
Esempio n. 7
0
    def __init__(self, *args, **kwargs):
        super(TopicForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('title'),
            Field('subtitle', autocomplete='off'),
            Field('tags'),
            CommonLayoutEditor(),
        )
Esempio n. 8
0
    def __init__(self, *args, **kwargs):
        super(TopicForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('title', autocomplete='off'),
            HTML('<div id="results" ><table id="tb-results" class="topics-entries"></table></div>'),
            Field('subtitle', autocomplete='off'),
            CommonLayoutEditor(),
        )
Esempio n. 9
0
    def __init__(self, username, *args, **kwargs):
        super(PrivateTopicForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'
        self.username = username

        self.helper.layout = Layout(
            Field('participants', autocomplete='off'),
            Field('title', autocomplete='off'),
            Field('subtitle', autocomplete='off'),
            CommonLayoutEditor(),
        )
Esempio n. 10
0
    def __init__(self, content, reaction, *args, **kwargs):
        """initialize the form, handle antispam GUI
        :param content: the parent content
        :type content: zds.tutorialv2.models.models_database.PublishableContent
        :param reaction: the initial reaction if we edit, ``Ǹone```otherwise
        :type reaction: zds.tutorialv2.models.models_database.ContentReaction
        :param args:
        :param kwargs:
        """

        last_note = kwargs.pop('last_note', 0)

        super(NoteForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse(
            'content:add-reaction') + '?pk={}'.format(content.pk)
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Field('last_note') if not last_note else Hidden(
                'last_note', last_note))

        if reaction is not None:  # we're editing an existing comment
            self.helper.layout.append(
                HTML(
                    "{% include 'misc/hat_choice.html' with edited_message=reaction %}"
                ))
        else:
            self.helper.layout.append(
                HTML("{% include 'misc/hat_choice.html' %}"))

        if content.antispam():
            if not reaction:
                self.helper['text'].wrap(
                    Field,
                    placeholder=_(
                        "Vous avez posté il n'y a pas longtemps. Merci de patienter "
                        'au moins 15 minutes entre deux messages consécutifs '
                        'afin de limiter le flood.'),
                    disabled=True)
        elif content.is_locked:
            self.helper['text'].wrap(
                Field,
                placeholder=_('Ce contenu est verrouillé.'),
                disabled=True)

        if reaction is not None:
            self.initial.setdefault('text', reaction.text)

        self.content = content
Esempio n. 11
0
    def __init__(self, *args, **kwargs):
        super(ArticleForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('title', autocomplete='off'),
            Field('description', autocomplete='off'),
            Field('image'),
            Field('subcategory'),
            Field('licence'),
            CommonLayoutEditor(),
        )
Esempio n. 12
0
    def __init__(self, username, *args, **kwargs):
        super(PrivateTopicForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = "content-wrapper"
        self.helper.form_method = "post"
        self.username = username

        self.helper.layout = Layout(
            Field("participants", autocomplete="off"),
            Field("title", autocomplete="off"),
            Field("subtitle", autocomplete="off"),
            CommonLayoutEditor(),
            HTML("{% include 'misc/hat_choice.html' %}"),
        )
Esempio n. 13
0
    def __init__(self, topic, user, *args, **kwargs):
        super(PrivatePostForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse(
            'zds.mp.views.answer') + '?sujet=' + str(topic.pk)
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden('last_post', '{{ last_post_pk }}'),
        )

        if topic.alone():
            self.helper['text'].wrap(
                Field,
                placeholder=u'Vous êtes seul dans cette conversation, '
                u'vous ne pouvez plus y écrire.',
                disabled=True)
Esempio n. 14
0
    def __init__(self, *args, **kwargs):
        self.user = kwargs.get('user')

        super(TopicForm, self).__init__(*args, **kwargs)

        self.fields['forum'].queryset = Forum.objects.exclude(
            group__in=Group.objects.filter(user=self.user).all())

        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('title', autocomplete='off'),
            Field('subtitle', autocomplete='off'),
            Field('tags'),
            Field('forum'),
            CommonLayoutEditor(),
        )
Esempio n. 15
0
    def __init__(self, topic, *args, **kwargs):
        super(PrivatePostForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('private-posts-new',
                                          args=[topic.pk,
                                                topic.slug()])
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden('last_post', '{{ last_post_pk }}'),
        )

        if topic.alone():
            self.helper['text'].wrap(
                Field,
                placeholder=_(u'Vous êtes seul dans cette conversation, '
                              u'vous ne pouvez plus y écrire.'),
                disabled=True)
Esempio n. 16
0
    def __init__(self, topic, user, *args, **kwargs):
        super(PostForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden('last_post', '{{ last_post_pk }}'),
        )
        if topic.antispam(user):
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=u'Vous venez de poster. Merci de patienter '
                    u'au moins 15 minutes entre deux messages consécutifs '
                    u'afin de limiter le flood.',
                    disabled=True)
        elif topic.is_locked:
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=u'Ce topic est verrouillé.',
                    disabled=True)
Esempio n. 17
0
    def __init__(self, topic, *args, **kwargs):
        super(PrivatePostForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse("private-posts-new",
                                          args=[topic.pk,
                                                topic.slug()])
        self.helper.form_method = "post"

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            HTML(
                "{% include 'misc/hat_choice.html' with edited_message=post %}"
            ),
            Hidden("last_post", "{{ last_post_pk }}"),
        )

        if topic.one_participant_remaining():
            self.helper["text"].wrap(
                Field,
                placeholder=_("Vous êtes seul dans cette conversation, "
                              "vous ne pouvez plus y écrire."),
                disabled=True,
            )
Esempio n. 18
0
    def __init__(self, content, reaction, *args, **kwargs):
        """initialize the form, handle antispam GUI
        :param content: the parent content
        :type content: zds.tutorialv2.models.models_database.PublishableContent
        :param reaction: the initial reaction if we edit, ``Ǹone```otherwise
        :type reaction: zds.tutorialv2.models.models_database.ContentReaction
        :param args:
        :param kwargs:
        """
        super(NoteForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('content:add-reaction') + u'?pk={}'.format(content.pk)
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Field('last_note')

        )

        if content.antispam():
            if not reaction:
                self.helper['text'].wrap(
                    Field,
                    placeholder=_(u'Vous avez posté il n\'y a pas longtemps. Merci de patienter '
                                  u'au moins 15 minutes entre deux messages consécutifs '
                                  u'afin de limiter le flood.'),
                    disabled=True)
        elif content.is_locked:
            self.helper['text'].wrap(
                Field,
                placeholder=_(u'Ce contenu est verrouillé.'),
                disabled=True
            )
        if reaction is not None:
            self.initial.setdefault("text", reaction.text)
        self.content = content