1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django import forms
5 from django.utils.translation import gettext_lazy as _
7 from documents.models import Chunk
10 class DocumentPubmarkForm(forms.Form):
12 Form for marking revisions for publishing.
15 id = forms.CharField(widget=forms.HiddenInput)
16 publishable = forms.BooleanField(required=False, initial=True,
17 label=_('Publishable'))
18 revision = forms.IntegerField(widget=forms.HiddenInput)
21 class DocumentTextSaveForm(forms.Form):
23 Form for saving document's text:
25 * parent_revision - revision which the modified text originated from.
26 * comment - user's verbose comment; will be used in commit.
27 * stage_completed - mark this change as end of given stage.
31 parent_revision = forms.IntegerField(widget=forms.HiddenInput, required=False)
32 text = forms.CharField(widget=forms.HiddenInput)
34 author_name = forms.CharField(
37 help_text=_(u"Your name"),
40 author_email = forms.EmailField(
42 label=_(u"Author's email"),
43 help_text=_(u"Your email address, so we can show a gravatar :)"),
46 comment = forms.CharField(
48 widget=forms.Textarea,
49 label=_(u"Your comments"),
50 help_text=_(u"Describe changes you made."),
53 stage_completed = forms.ModelChoiceField(
54 queryset=Chunk.tag_model.objects.all(),
56 label=_(u"Completed"),
57 help_text=_(u"If you completed a life cycle stage, select it."),
60 publishable = forms.BooleanField(required=False, initial=False,
61 label=_('Publishable'),
62 help_text=_(u"Mark this revision as publishable.")
65 def __init__(self, *args, **kwargs):
66 user = kwargs.pop('user')
67 r = super(DocumentTextSaveForm, self).__init__(*args, **kwargs)
68 if user and user.is_authenticated:
69 self.fields['author_name'].required = False
70 self.fields['author_email'].required = False
74 class DocumentTextRevertForm(forms.Form):
76 Form for reverting document's text:
78 * revision - revision to revert to.
79 * comment - user's verbose comment; will be used in commit.
83 revision = forms.IntegerField(widget=forms.HiddenInput)
85 author_name = forms.CharField(
88 help_text=_(u"Your name"),
91 author_email = forms.EmailField(
93 label=_(u"Author's email"),
94 help_text=_(u"Your email address, so we can show a gravatar :)"),
97 comment = forms.CharField(
99 widget=forms.Textarea,
100 label=_(u"Your comments"),
101 help_text=_(u"Describe the reason for reverting."),