Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from crispy_forms.bootstrap import FormActions, Tab, TabHolder
2from crispy_forms.helper import FormHelper
3from crispy_forms.layout import (
4 HTML,
5 Button,
6 ButtonHolder,
7 Div,
8 Field,
9 Fieldset,
10 Layout,
11 Submit,
12)
13from django.forms import ModelForm
15from discuss_data.core.helpers import get_help_texts
17from .models import Publication
19UPDATED_MSG = """
20 {% if updated %}<div id='updated-msg' class='alert alert-success' ic-trigger-on='scrolled-into-view' ic-action='delay:2500;fadeOut;remove' role='alert'>
21 <span class='spinner-sm'></span><strong>{{ target|title }} saved</strong></div>{% endif %}
22 {% if err %}<div id='updated-msg' class='alert alert-danger' role='alert'>
23 <span class='spinner-sm'></span><strong>Error! {{ target|title }} could not be saved. Error encountered in fields {% for field in err %} {{ field }}, {% endfor %}</strong></div> {% endif %}"""
25ADD_EDIT_HEADING = (
26 "<h2>{% if new %}Add{% else %}Edit{% endif %} {{ target|title }}</h2><hr>"
27)
28REQ_FIELD = "<p class='help-block'>[*] required field</p><hr>"
31class PublicationForm(ModelForm):
32 class Meta:
33 model = Publication
34 # fields = '__all__'
35 fields = [
36 "title",
37 "authors_text",
38 "places_text",
39 "publisher_text",
40 "included_text",
41 "year",
42 "url",
43 "isbn",
44 "doi",
45 "pages",
46 # "description",
47 ]
48 help_texts = get_help_texts("edit-publication")
50 helper = FormHelper()
51 helper.form_tag = False
52 helper.layout = Layout(
53 Div(
54 Div("title", css_class="col-md-12",),
55 Div("authors_text", css_class="col-md-6",),
56 Div("publisher_text", css_class="col-md-2",),
57 Div("places_text", css_class="col-md-2",),
58 Div("year", css_class="col-md-2",),
59 Div("included_text", css_class="col-md-10",),
60 Div("pages", css_class="col-md-2",),
61 Div("url", css_class="col-md-6",),
62 Div("doi", css_class="col-md-3",),
63 Div("isbn", css_class="col-md-3",),
64 # Div("description", css_class="col-md-6",),
65 css_class="row",
66 ),
67 HTML(REQ_FIELD),
68 HTML("<span id='indicator'><span class='spinner-sm'></span> Saving...</span>"),
69 FormActions(Submit("save", "Save {{ target }}", ic_indicator="#indicator"),),
70 Div(HTML(UPDATED_MSG),),
71 )