Commit 1cf3c566 authored by Robin Tissot's avatar Robin Tissot
Browse files

Fixes last edited link and add a delete button in the document list.

parent 60623bb8
...@@ -244,6 +244,13 @@ class Document(models.Model): ...@@ -244,6 +244,13 @@ class Document(models.Model):
else: else:
return 'ltr' return 'ltr'
@cached_property
def last_edited_part(self):
try:
return self.parts.order_by('-updated_at')[0]
except IndexError:
return None
@property @property
def training_model(self): def training_model(self):
return self.ocr_models.filter(training=True).first() return self.ocr_models.filter(training=True).first()
......
...@@ -49,11 +49,18 @@ ...@@ -49,11 +49,18 @@
<td class="text-right"> <td class="text-right">
{# <a href="{% url 'document-detail' pk=document.pk %}" class="btn btn-info disabled" title="{% trans 'View' %}"><i class="fas fa-eye"></i></a> #} {# <a href="{% url 'document-detail' pk=document.pk %}" class="btn btn-info disabled" title="{% trans 'View' %}"><i class="fas fa-eye"></i></a> #}
{# Note that doing one query per row is a lot faster than a subquery for some reason #} {# Note that doing one query per row is a lot faster than a subquery for some reason #}
<a href="{% url 'document-part-edit' pk=document.pk part_pk=document.parts.last.pk %}" {% if document.last_edited_part %}
<a href="{% url 'document-part-edit' pk=document.pk part_pk=document.last_edited_part.pk %}"
class="btn btn-info" class="btn btn-info"
title="{% trans 'Edit last updated Element' %}"> title="{% trans 'Edit last updated Element' %}">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>
</a> </a>
{% endif %}
<form method="post" class="inline-form" action="{% url 'document-publish' pk=document.pk %}" onsubmit="return confirm('{% trans "Do you really want to delete the document?" %}');">{% csrf_token %}
<input type="hidden" name="workflow_state" value="{{ document.WORKFLOW_STATE_ARCHIVED }}">
<button type="submit" value="" class="nav-item btn btn-danger" title="{% trans 'Delete' %}"><i class="fas fa-trash"></i></button>
</form>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment