Skip to content

Commit

Permalink
skip creating amendment tasks on approve
Browse files Browse the repository at this point in the history
  • Loading branch information
goose-life committed Oct 29, 2024
1 parent 301c358 commit ede2559
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions indigo/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def create_tasks(self, user, data):
# amendment tasks
self.amendment_tasks = []
for amendment in self.amendments:
if data.get(f'amendment_task_skip_{amendment.pk}'):
continue
# create new amendment tasks so that we don't overwrite descriptions on existing tasks
work = amendment.amended_work
self.amendment_tasks.append(
Expand Down
8 changes: 7 additions & 1 deletion indigo_api/templatetags/indigo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.conf import settings

from indigo.plugins import plugins
from indigo_api.models import Task
from indigo_api.timeline import describe_publication_event

register = template.Library()
Expand Down Expand Up @@ -91,4 +92,9 @@ def format_input_date(value):
except ValueError:
return value # If conversion fails, return the original value

return value.strftime('%Y-%m-%d')
return value.strftime('%Y-%m-%d')


@register.simple_tag
def amendment_date_tasks(amendment):
return Task.objects.filter(work=amendment.amended_work, timeline_date=amendment.date, code='apply-amendment')
1 change: 1 addition & 0 deletions indigo_app/forms/works.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,7 @@ def __init__(self, *args, **kwargs):

def add_amendment_task_description_fields(self):
for amendment in self.broker.amendments:
self.fields[f'amendment_task_skip_{amendment.pk}'] = forms.BooleanField(initial=False, required=False)
self.fields[f'amendment_task_description_{amendment.pk}'] = forms.CharField()

def save_changes(self, request):
Expand Down
15 changes: 14 additions & 1 deletion indigo_app/templates/indigo_app/place/_bulk_approve_form.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n %}
{% load i18n indigo %}

<div class="modal-dialog modal-dialog-scrollable modal-xl">
<div class="modal-content">
Expand Down Expand Up @@ -161,6 +161,19 @@ <h5 class="card-header">
The amendment has already been linked, so start at Step 3 of https://docs.laws.africa/managing-works/amending-works.{% endblocktrans %}
<textarea id="amendment_task_description_id_{{ amendment.pk }}" name="amendment_task_description_{{ amendment.pk }}" class="form-control mt-2" required rows="4"
>{{ description_default }}</textarea>
<div class="form-check mt-1">
<input class="form-check-input" type="checkbox" id="amendment_task_skip_{{ amendment.pk }}" name="amendment_task_skip_{{ amendment.pk }}">
<label class="form-check-label" for="amendment_task_skip_{{ amendment.pk }}">{% trans "Skip" %}</label>
</div>
{% amendment_date_tasks amendment as potential_duplicates %}
{% for task in potential_duplicates %}
<div class="mt-1"><span title="{% trans 'potential duplicate' %}">
<i class="fas fa-exclamation-triangle text-warning"></i>
<a target="_blank" href="{% url 'task_detail' place=task.place.place_code pk=task.pk %}">#{{ task.pk }}</a>
<i class="fas fa-fw task-icon-{{ task.state }} text-{{ task.state }} small me-2"></i><br/>
{{ task.description }}
</span></div>
{% endfor %}
</div>
{% endfor %}
</div>
Expand Down

0 comments on commit ede2559

Please sign in to comment.