From 3ecde1fbc954ad9d026a96514bd9a2e732c207bb Mon Sep 17 00:00:00 2001
From: Jean-Sebastien Caux <J.S.Caux@uva.nl>
Date: Thu, 16 Feb 2017 09:43:15 +0000
Subject: [PATCH] Fix media 404 bug from comments attachments

---
 README.md                                          |  1 +
 SciPost_v1/settings.py                             |  1 +
 SciPost_v1/urls.py                                 |  5 +----
 .../templates/submissions/submission_detail.html   | 14 ++++++++++++++
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 1ebdbdcb3..78fda0caa 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,7 @@ In this project, host-specific settings are defined in the `scipost-host-setting
     "CERTFILE": "none",
     "DEBUG": true,
     "ADMINS": "",
+    "MANAGERS": "",
     "ALLOWED_HOSTS": ["localhost", "127.0.0.1"],
     "SESSION_COOKIE_SECURE": false,
     "CSRF_COOKIE_SECURE": false,
diff --git a/SciPost_v1/settings.py b/SciPost_v1/settings.py
index d5c8742e9..851298a82 100644
--- a/SciPost_v1/settings.py
+++ b/SciPost_v1/settings.py
@@ -35,6 +35,7 @@ DEBUG = host_settings["DEBUG"]
 
 # Emails for server error reporting
 ADMINS = host_settings["ADMINS"]
+MANAGERS = host_settings["MANAGERS"]
 
 ALLOWED_HOSTS = host_settings["ALLOWED_HOSTS"]
 
diff --git a/SciPost_v1/urls.py b/SciPost_v1/urls.py
index e1c8742b3..8bb1cbd45 100644
--- a/SciPost_v1/urls.py
+++ b/SciPost_v1/urls.py
@@ -15,7 +15,6 @@ Including another URLconf
 """
 from django.conf import settings
 from django.conf.urls import include, url
-from django.conf.urls.static import static
 from django.contrib import admin
 
 urlpatterns = [
@@ -33,7 +32,5 @@ urlpatterns = [
     url(r'^theses/', include('theses.urls', namespace="theses")),
     url(r'^thesis/', include('theses.urls', namespace="theses")),
     url(r'^captcha/', include('captcha.urls')),
-] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+]
 
-
-# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html
index 9a55f0395..68750602f 100644
--- a/submissions/templates/submissions/submission_detail.html
+++ b/submissions/templates/submissions/submission_detail.html
@@ -6,6 +6,8 @@
 
 {% load scipost_extras %}
 {% load submissions_extras %}
+{% load filename %}
+{% load file_extentions %}
 
   <script>
     $(document).ready(function(){
@@ -198,6 +200,18 @@
                                 </div>
                                 <div class="col-12">
                                     <p>{{ reply.comment_text|linebreaks }}</p>
+				    {% if reply.file_attachment %}
+				    <h3>Attachment:</h3>
+				    <p>
+				      <a target="_blank" href="{{ reply.file_attachment.url }}">
+					{% if reply.file_attachment|is_image %}
+					<img class="attachment attachment-comment" src="{{ reply.file_attachment.url }}">                                                                              
+					{% else %}
+					{{ reply.file_attachment|filename }}<br><small>{{ reply.file_attachment.size|filesizeformat }}</small>
+					{% endif %}
+				      </a>
+				    </p>
+				    {% endif %}
                                 </div>
                             </div>
                         </div>
-- 
GitLab