1 # -*- coding: utf-8 -*-
3 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from django import forms
7 from django.utils.translation import ugettext_lazy as _
9 from catalogue.constants import STAGES
12 class DocumentTextSaveForm(forms.Form):
14 Form for saving document's text:
16 * parent_revision - revision which the modified text originated from.
17 * comment - user's verbose comment; will be used in commit.
18 * stage - change to this stage
22 parent_revision = forms.IntegerField(widget=forms.HiddenInput, required=False)
23 text = forms.CharField(widget=forms.HiddenInput)
25 author_name = forms.CharField(
28 help_text=_(u"Your name"),
31 author_email = forms.EmailField(
33 label=_(u"Author's email"),
34 help_text=_(u"Your email address, so we can show a gravatar :)"),
37 comment = forms.CharField(
39 widget=forms.Textarea,
40 label=_(u"Your comments"),
41 help_text=_(u"Describe changes you made."),
44 stage = forms.ChoiceField(
45 choices=[(s, s) for s in STAGES],
48 help_text=_(u"If completed a work stage, change to another one."),
51 def __init__(self, *args, **kwargs):
52 user = kwargs.pop('user')
53 super(DocumentTextSaveForm, self).__init__(*args, **kwargs)
54 if user and user.is_authenticated():
55 self.fields['author_name'].required = False
56 self.fields['author_email'].required = False
59 class DocumentTextRevertForm(forms.Form):
61 Form for reverting document's text:
63 * revision - revision to revert to.
64 * comment - user's verbose comment; will be used in commit.
68 revision = forms.IntegerField(widget=forms.HiddenInput)
70 author_name = forms.CharField(
73 help_text=_(u"Your name"),
76 author_email = forms.EmailField(
78 label=_(u"Author's email"),
79 help_text=_(u"Your email address, so we can show a gravatar :)"),
82 comment = forms.CharField(
84 widget=forms.Textarea,
85 label=_(u"Your comments"),
86 help_text=_(u"Describe the reason for reverting."),
90 class DocumentTextPublishForm(forms.Form):
91 revision = forms.IntegerField(widget=forms.HiddenInput)