diff --git a/todo/models.py b/todo/models.py index 2151fc8..a9582dc 100644 --- a/todo/models.py +++ b/todo/models.py @@ -1,10 +1,12 @@ from __future__ import unicode_literals + import datetime +import os import textwrap from django.conf import settings from django.contrib.auth.models import Group -from django.db import models, DEFAULT_DB_ALIAS +from django.db import DEFAULT_DB_ALIAS, models from django.db.transaction import Atomic, get_connection from django.urls import reverse from django.utils import timezone @@ -177,5 +179,12 @@ class Attachment(models.Model): timestamp = models.DateTimeField(default=datetime.datetime.now) file = models.FileField(upload_to=get_attachment_upload_dir, max_length=255) + def filename(self): + return os.path.basename(self.file.name) + + def extension(self): + name, extension = os.path.splitext(self.file.name) + return extension + def __str__(self): return f"{self.task.id} - {self.file.name}" diff --git a/todo/templates/todo/task_detail.html b/todo/templates/todo/task_detail.html index a1f8d29..eea9c91 100644 --- a/todo/templates/todo/task_detail.html +++ b/todo/templates/todo/task_detail.html @@ -115,6 +115,55 @@ {% endif %} +{% if attachments_enabled %} +
File | +Uploaded | +By | +Type | +
---|---|---|---|
{{ attachment.filename }} | +{{ attachment.timestamp }} | +{{ attachment.added_by.get_full_name }} | +{{ attachment.extension.lower }} | +