Commit ba3b348d authored by Martin Lehoux's avatar Martin Lehoux

update documents

parent 445873cf
......@@ -20,8 +20,9 @@
<p class="ui {% if document.type == 'Annale' %}red{% else %}blue{% endif %} label">{{ document.type }}</p>
<p class="ui green label">{{document.documentDate.year}}</p>
</div>
<div class="ui two bottom attached buttons">
<a href="{% url 'core:download_document' document.id %}" class="ui blue basic labeled icon fluid button" target="_new"> <i class="cloud download icon"></i> Télécharger</a>
<div class="ui {% if document.type == "Annale" %}three{% else %}two{% endif %} bottom attached buttons">
<a href="{% url 'core:download_document' document.id %}" class="ui blue basic labeled icon fluid button" target="_new"> <i class="cloud download icon"></i> Sujet</a>
{% if document.type == "Annale" %}<a href="{% url 'core:download_correction' document.id %}" class="ui blue basic labeled icon fluid button" target="_new"> <i class="edit icon"></i> Correction{% endif %}
<button id="like" class="ui green basic icon button"> <i class="thumbs up icon"></i></a>
<button id="dislike" class="ui red basic icon button"> <i class="thumbs down icon"></i></a>
<button id="load" class="ui loading fluid button">Loading...</button>
......
......@@ -5,15 +5,16 @@
{{ document.name }}
</div>
{% if document.course.pk != Null %}<div class="meta"><a href="{% url 'core:get_course' document.course.pk %}">{{document.course}}</a></div>{% endif %}
<div class="description">{{ document.description }}</div>
<div class="description">{{ document.description or "" }}</div>
</div>
<div class="extra content">
<p class="ui {% if document.type == 'Annale' %}red{% else %}blue{% endif %} label">{{ document.type }}</p>
<p class="ui green label">{{document.documentDate.year}}</p>
</div>
<div class="ui three bottom attached buttons">
<div class="ui {% if document.type == "Annale" %}four{% else %}three{% endif %} bottom attached buttons">
<a href="{% url 'core:reject' 'document' document.pk %}" class="ui red basic icon fluid button"><i class="remove icon"></i></a>
<a href="{% url 'core:download_document' document.id %}" class="ui blue basic icon fluid button" target="_new"> <i class="cloud download icon"></i></a>
{% if document.type == "Annale" %}<a href="{% url 'core:download_correction' document.id %}" class="ui blue basic icon fluid button" target="_new"><i class="edit icon"></i></a>{% endif %}
<a href="{% url 'core:accept' 'document' document.pk %}" class="ui green basic icon fluid button"><i class="checkmark icon"></i></a>
</div>
</div>
\ No newline at end of file
......@@ -16,14 +16,14 @@
<p class="ui {% if document.type == 'Annale' %}red{% else %}blue{% endif %} label">{{ document.type }}</p>
<p class="ui green label">{{document.documentDate.year}}</p>
</div>
<div class="ui two bottom attached buttons">
<div class="ui one bottom attached buttons">
<a href="{% url 'core:get_document' document.id %}" class="ui violet basic labeled icon fluid button">
<i class="unhide icon"></i>
Détails
</a>
<a href="{% url 'core:download_document' document.id %}" class="ui blue basic right labeled icon fluid button" target="_new">
{% comment %} <a href="{% url 'core:download_document' document.id %}" class="ui blue basic right labeled icon fluid button" target="_new">
<i class="cloud download icon"></i>
Télécharger
</a>
</a> {% endcomment %}
</div>
</div>
\ No newline at end of file
......@@ -562,7 +562,26 @@ def download_document(request,document_id):
response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'inline; filename="'+document.name+'.pdf"'
return response
return response
@login_required
def download_correction(request, document_id):
try:
document = Document.objects.get(pk=document_id)
if not document.correction:
raise ObjectDoesNotExist
except ObjectDoesNotExist:
return error(request,"Le document que vous souhaitez télécharger n'existe pas")
# Redirect if the document is not accepted and the user is not mederator
if not document.isAccepted and not request.user.is_staff:
return error(request,"Vous essayez de télécharger un document non validé, mais vous n'êtes pas modérateur.")
response = HttpResponse(content=document.correction)
response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'inline; filename="'+document.name+'.pdf"'
return response
def error(request,message="Bienvenue sur la page d'affichage d'erreurs !"):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment