summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2014-02-17 14:59:14 +0200
committerFilipp Lepalaan <f@230.to>2014-02-17 14:59:14 +0200
commitd3e089b71b64cfc1f9f96be141f41806ce5b9e77 (patch)
treef476fec3f91b0f29526457b02a34f443a593bb99
parentb494dfc0933c28729eaf8bc2105bbeb28d24ceae (diff)
downloadpudding-d3e089b71b64cfc1f9f96be141f41806ce5b9e77.tar.gz
pudding-d3e089b71b64cfc1f9f96be141f41806ce5b9e77.tar.bz2
pudding-d3e089b71b64cfc1f9f96be141f41806ce5b9e77.zip
Switching WS
-rw-r--r--apps/it/models.py6
-rw-r--r--apps/it/templates/view_issue.html6
-rw-r--r--apps/it/views.py1
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):