Skip to content

Commit

Permalink
Change fields requirement on edit legislation page.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielastrezea committed Oct 24, 2017
1 parent 2bc2cc7 commit 05cc5f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
1 change: 0 additions & 1 deletion lcc/templates/legislation/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
action="{% url 'lcc:legislation:add' %}">
{% csrf_token %}

<h1>{{ form.errors }}</h1>
<div class='law-meta-data-container'>
<div>
<label class="label-large" for="id_title">Title <p style="display: inline-block; color: red;" title="This field is required.">*</p></label>
Expand Down
18 changes: 9 additions & 9 deletions lcc/templates/legislation/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

{% block extra-scripts %}
<script src="{% static "js/legislation_edit.js" %}"></script>
<script src="{% static "js/upload.js" %}"></script>
{% endblock %}


Expand All @@ -18,7 +19,7 @@
{% csrf_token %}
<div class='law-meta-data-container'>
<div>
<label class="label-large" for="id_title">Title</label>
<label class="label-large" for="id_title">Title <p style="display: inline-block; color: red;" title="This field is required.">*</p></label>
</div>
<div>
<input class='law-meta-data-text-field' type="text" name="title"
Expand All @@ -32,7 +33,7 @@
</div>

<div class="clearfix">
<textarea class='law-meta-data-text-field law-meta-data-abstract-field' name="abstract" maxlength="1024" required id="id_abstract" placeholder="Add Abstract">{{ form.abstract.value|default_if_none:'' }}</textarea>
<textarea class='law-meta-data-text-field law-meta-data-abstract-field' name="abstract" maxlength="1024" id="id_abstract" placeholder="Add Abstract">{{ form.abstract.value|default_if_none:'' }}</textarea>
<small class="pull-right" id="rem_char"></small>
</div>
</div>
Expand All @@ -58,25 +59,24 @@

<div class="container upload-container" style="display:none;" id="upload_container_file">
<div>
<label style="margin-bottom: 0" class="label-large" for="id_pdf_file">Upload file</label>
<label style="margin-bottom: 0" class="label-large" for="id_pdf_file">Upload file <p style="display: inline-block; color: red;" title="This field is required.">*</p></label>
</div>

<div class="label-description">
Attention: all your articles that might have been added to this law will be lost if you upload another file!<span style="font-weight: bold; cursor:pointer;" id="renounce-upload"> Cancel!</a>
</div>

<div class="custom-file-upload">
<input type="file" name="pdf_file" name="myfiles[]" id="id_pdf_file" accept=".pdf, .Pdf, .PDF, .PDf">
<input type="file" name="pdf_file" required name="myfiles[]" id="id_pdf_file" accept=".pdf, .Pdf, .PDF, .PDf">
</div>
</div>

</div>


<div class='law-meta-data-container'>
<div class="selector selector-inline--4">
<div>
<label class="label-medium" for="id_country">Country:</label>
<label class="label-medium" for="id_country">Country <p style="display: inline-block; color: red;" title="This field is required.">*</p>:</label>
</div>
<div>
<select name="country" required id="id_country" class="law-meta-data-combobox">
Expand Down Expand Up @@ -151,7 +151,7 @@
<label class="label-medium" for="id_website">Website:</label>
</div>
<div>
<input class='law-meta-data-text-field' type="text" id="id_website" required
<input class='law-meta-data-text-field' type="text" id="id_website"
name="website" maxlength="256" value="{{ form.website.value|default_if_none:'' }}"/>
{% if errors.website %}
<span class="year-details error">{{ errors.website }}</span>
Expand All @@ -164,7 +164,7 @@
<label class="label-medium" for="id_source">Source:</label>
</div>
<div>
<input class='law-meta-data-text-field' type="text" id="id_source" required
<input class='law-meta-data-text-field' type="text" id="id_source"
name="source" maxlength="256" value="{{ form.source.value|default_if_none:'' }}"/>
</div>
</div>
Expand Down Expand Up @@ -229,7 +229,7 @@
</div>
<div>
<input class='law-meta-data-text-field' type="text"
id="id_year_mention" required
id="id_year_mention"
name="year_mention" maxlength="256" value="{{ form.year_mention.value|default_if_none:'' }}"/>
<!-- TODO: this checks if the field have a 4 digit string. Could be done in js. -->
{% if form.errors.year_mention %}
Expand Down
8 changes: 6 additions & 2 deletions lcc/views/legislation.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ def form_valid(self, form):
legislation = form.save()
if 'pdf_file' in self.request.FILES:
pdf = pdftotext.PDF(legislation.pdf_file)
models.LegislationPage.objects.filter(legislation=legislation).delete()
models.LegislationPage.objects.filter(
legislation=legislation).delete()
legislation_save_pdf_pages(legislation, pdf)

return HttpResponseRedirect(reverse("lcc:legislation:explorer"))
return HttpResponseRedirect(
reverse('lcc:legislation:details',
kwargs={'legislation_pk': legislation.pk})
)

0 comments on commit 05cc5f9

Please sign in to comment.