diff options
Diffstat (limited to 'apps/it')
-rw-r--r-- | apps/it/models.py | 6 | ||||
-rw-r--r-- | apps/it/templates/view_issue.html | 6 | ||||
-rw-r--r-- | apps/it/views.py | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/apps/it/models.py b/apps/it/models.py index a397b6d..d7922e4 100644 --- a/apps/it/models.py +++ b/apps/it/models.py @@ -12,9 +12,13 @@ class Attachment(models.Model): content_object = generic.GenericForeignKey("content_type", "object_id") @classmethod - def get_content_type(self, model): + def get_content_type(cls, model): return ContentType.objects.get(app_label='it', model=model) + @classmethod + def get_files(cls, model): + ct = ContentType.objects.get_for_model() + return cls.objects.filter(content_type=ct, object_id=model.pk) class Issue(models.Model): description = models.TextField() diff --git a/apps/it/templates/view_issue.html b/apps/it/templates/view_issue.html index c4ee3ce..fe36f34 100644 --- a/apps/it/templates/view_issue.html +++ b/apps/it/templates/view_issue.html @@ -7,7 +7,11 @@ {% for i in issue.task_set.all %} <p>{{ i.description }}</p> {% endfor %} - <form action="{% url 'add_files' issue.pk %}" class="dropzone" id="my-awesome-dropzone"></form> + {% for f in files %} + <span class="label">{{ f.attachment.name }}</span> + {% endfor %} + <form action="{% url 'add_files' issue.pk %}" class="dropzone" id="my-awesome-dropzone"> + </form> <a class="btn btn-default" href="{% url 'edit_issue' issue.pk %}">Edit</a> <a class="btn btn-default" href="{% url 'add_task' issue.pk %}">Add Task</a> <a class="btn btn-default metoo" href="{% url 'metoo' issue.pk 1 %}">Me too!</a> diff --git a/apps/it/views.py b/apps/it/views.py index ebff296..fa13ed0 100644 --- a/apps/it/views.py +++ b/apps/it/views.py @@ -30,6 +30,7 @@ def search(request): def view_issue(request, pk): issue = Issue.objects.get(pk=pk) + files = Attachment.objects.filter(content_object=issue) return render(request, "view_issue.html", locals()) def edit_issue(request, pk=None): |