Skip to content

Commit

Permalink
Merge pull request #1924 from laws-africa/duplicate-consolidation
Browse files Browse the repository at this point in the history
disable the button if a consolidation exists at the default date
  • Loading branch information
goose-life authored Jan 9, 2024
2 parents 898eb71 + 7de1824 commit 57bb15c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions indigo_app/templates/indigo_api/timeline/_work_points_in_time.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
{% if perms.indigo_api.add_arbitraryexpressiondate %}
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
<div class="dropdown-menu">
<form method="POST" action="{% url 'new_arbitrary_expression_date' frbr_uri=work.frbr_uri %}">
{% csrf_token %}
<button class="dropdown-item" type="submit" name="date"
value="{{ consolidation_date|date:'Y-m-d' }}">{% trans 'Add consolidation date' %}: {{ consolidation_date|date:'Y-m-d' }}</button>
</form>
{% if existing_consolidation_at_default_date %}
<button class="dropdown-item disabled">
{% trans 'Consolidation already exists at' %} {{ consolidation_date|date:'Y-m-d' }}
</button>
{% else %}
<form method="POST" action="{% url 'new_arbitrary_expression_date' frbr_uri=work.frbr_uri %}">
{% csrf_token %}
<button class="dropdown-item" type="submit" name="date"
value="{{ consolidation_date|date:'Y-m-d' }}">{% trans 'Add consolidation date' %}: {{ consolidation_date|date:'Y-m-d' }}</button>
</form>
{% endif %}
</div>
{% endif %}

Expand Down
1 change: 1 addition & 0 deletions indigo_app/views/works.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ def get_context_data(self, **kwargs):
context = super(WorkAmendmentsView, self).get_context_data(**kwargs)
context['work_timeline'] = self.get_work_timeline(self.work)
context['consolidation_date'] = self.work.as_at_date() or datetime.date.today()
context['existing_consolidation_at_default_date'] = ArbitraryExpressionDate.objects.filter(work=self.work, date=context['consolidation_date']).exists()
return context

def get_work_timeline(self, work):
Expand Down

0 comments on commit 57bb15c

Please sign in to comment.