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.models import Document
10 from catalogue.constants import STAGES
13 class DocumentTextSaveForm(forms.Form):
15 Form for saving document's text:
17 * parent_revision - revision which the modified text originated from.
18 * comment - user's verbose comment; will be used in commit.
19 * stage - change to this stage
23 parent_revision = forms.IntegerField(widget=forms.HiddenInput, required=False)
24 text = forms.CharField(widget=forms.HiddenInput)
26 author_name = forms.CharField(
29 help_text=_(u"Your name"),
32 author_email = forms.EmailField(
34 label=_(u"Author's email"),
35 help_text=_(u"Your email address, so we can show a gravatar :)"),
38 comment = forms.CharField(
40 widget=forms.Textarea,
41 label=_(u"Your comments"),
42 help_text=_(u"Describe changes you made."),
45 stage = forms.ChoiceField(
46 choices = [(s, s) for s in STAGES],
49 help_text=_(u"If completed a work stage, change to another one."),
52 def __init__(self, *args, **kwargs):
53 user = kwargs.pop('user')
54 r = super(DocumentTextSaveForm, self).__init__(*args, **kwargs)
55 if user and user.is_authenticated():
56 self.fields['author_name'].required = False
57 self.fields['author_email'].required = False
61 class DocumentTextRevertForm(forms.Form):
63 Form for reverting document's text:
65 * revision - revision to revert to.
66 * comment - user's verbose comment; will be used in commit.
70 revision = forms.IntegerField(widget=forms.HiddenInput)
72 author_name = forms.CharField(
75 help_text=_(u"Your name"),
78 author_email = forms.EmailField(
80 label=_(u"Author's email"),
81 help_text=_(u"Your email address, so we can show a gravatar :)"),
84 comment = forms.CharField(
86 widget=forms.Textarea,
87 label=_(u"Your comments"),
88 help_text=_(u"Describe the reason for reverting."),
92 class DocumentTextPublishForm(forms.Form):
93 revision = forms.IntegerField(widget=forms.HiddenInput)