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 Chunk
12 class DocumentPubmarkForm(forms.Form):
14 Form for marking revisions for publishing.
17 id = forms.CharField(widget=forms.HiddenInput)
18 publishable = forms.BooleanField(required=False, initial=True, label=_('Publishable'))
19 revision = forms.IntegerField(widget=forms.HiddenInput)
22 class DocumentTextSaveForm(forms.Form):
24 Form for saving document's text:
26 * parent_revision - revision which the modified text originated from.
27 * comment - user's verbose comment; will be used in commit.
28 * stage_completed - mark this change as end of given stage.
32 parent_revision = forms.IntegerField(widget=forms.HiddenInput, required=False)
33 text = forms.CharField(widget=forms.HiddenInput)
35 author_name = forms.CharField(
38 help_text=_(u"Your name"),
41 author_email = forms.EmailField(
43 label=_(u"Author's email"),
44 help_text=_(u"Your email address, so we can show a gravatar :)"),
47 comment = forms.CharField(
49 widget=forms.Textarea,
50 label=_(u"Your comments"),
51 help_text=_(u"Describe changes you made."),
54 stage_completed = forms.ModelChoiceField(
55 queryset=Chunk.tag_model.objects.all(),
57 label=_(u"Completed"),
58 help_text=_(u"If you completed a life cycle stage, select it."),
61 publishable = forms.BooleanField(
62 required=False, initial=False,
63 label=_('Publishable'),
64 help_text=_(u"Mark this revision as publishable."))
66 for_cybernauts = forms.BooleanField(
67 required=False, initial=False,
68 label=_(u"For Cybernauts"),
69 help_text=_(u"Mark this document for Cybernauts.")
72 def __init__(self, *args, **kwargs):
73 user = kwargs.pop('user')
74 chunk = kwargs.pop('chunk')
75 super(DocumentTextSaveForm, self).__init__(*args, **kwargs)
76 if user and user.is_authenticated():
77 self.fields['author_name'].required = False
78 self.fields['author_email'].required = False
79 self.fields['for_cybernauts'].initial = chunk.book.for_cybernauts
82 class DocumentTextRevertForm(forms.Form):
84 Form for reverting document's text:
86 * revision - revision to revert to.
87 * comment - user's verbose comment; will be used in commit.
91 revision = forms.IntegerField(widget=forms.HiddenInput)
93 author_name = forms.CharField(
96 help_text=_(u"Your name"),
99 author_email = forms.EmailField(
101 label=_(u"Author's email"),
102 help_text=_(u"Your email address, so we can show a gravatar :)"),
105 comment = forms.CharField(
107 widget=forms.Textarea,
108 label=_(u"Your comments"),
109 help_text=_(u"Describe the reason for reverting."),