From d3e089b71b64cfc1f9f96be141f41806ce5b9e77 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 17 Feb 2014 14:59:14 +0200 Subject: Switching WS --- apps/it/models.py | 6 +++++- apps/it/templates/view_issue.html | 6 +++++- apps/it/views.py | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'apps') 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 %}

{{ i.description }}

{% endfor %} -
+ {% for f in files %} + {{ f.attachment.name }} + {% endfor %} +
+
Edit Add Task Me too! 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): -- cgit v1.2.3