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,
19 label=_('Publishable'))
20 revision = forms.IntegerField(widget=forms.HiddenInput)
23 class DocumentTextSaveForm(forms.Form):
25 Form for saving document's text:
27 * parent_revision - revision which the modified text originated from.
28 * comment - user's verbose comment; will be used in commit.
29 * stage_completed - mark this change as end of given stage.
33 parent_revision = forms.IntegerField(widget=forms.HiddenInput, required=False)
34 text = forms.CharField(widget=forms.HiddenInput)
36 author_name = forms.CharField(
39 help_text=_(u"Your name"),
42 author_email = forms.EmailField(
44 label=_(u"Author's email"),
45 help_text=_(u"Your email address, so we can show a gravatar :)"),
48 comment = forms.CharField(
50 widget=forms.Textarea,
51 label=_(u"Your comments"),
52 help_text=_(u"Describe changes you made."),
55 stage_completed = forms.ModelChoiceField(
56 queryset=Chunk.tag_model.objects.all(),
58 label=_(u"Completed"),
59 help_text=_(u"If you completed a life cycle stage, select it."),
62 publishable = forms.BooleanField(required=False, initial=False,
63 label=_('Publishable'),
64 help_text=_(u"Mark this revision as publishable.")
67 for_cybernauts = forms.BooleanField(
68 required=False, initial=False,
69 label=_(u"For Cybernauts"),
70 help_text=_(u"Mark this document for Cybernauts.")
73 def __init__(self, *args, **kwargs):
74 user = kwargs.pop('user')
75 chunk = kwargs.pop('chunk')
76 super(DocumentTextSaveForm, self).__init__(*args, **kwargs)
77 if user and user.is_authenticated():
78 self.fields['author_name'].required = False
79 self.fields['author_email'].required = False
80 self.fields['for_cybernauts'].initial = chunk.book.for_cybernauts
83 class DocumentTextRevertForm(forms.Form):
85 Form for reverting document's text:
87 * revision - revision to revert to.
88 * comment - user's verbose comment; will be used in commit.
92 revision = forms.IntegerField(widget=forms.HiddenInput)
94 author_name = forms.CharField(
97 help_text=_(u"Your name"),
100 author_email = forms.EmailField(
102 label=_(u"Author's email"),
103 help_text=_(u"Your email address, so we can show a gravatar :)"),
106 comment = forms.CharField(
108 widget=forms.Textarea,
109 label=_(u"Your comments"),
110 help_text=_(u"Describe the reason for reverting."),