SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit fd9b0a5b authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Merge branch 'master' into development

parents 167f32b5 2a9acaf8
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ from django.db import models ...@@ -4,6 +4,7 @@ from django.db import models
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils import timezone from django.utils import timezone
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.urls import reverse
from guardian.shortcuts import assign_perm from guardian.shortcuts import assign_perm
...@@ -131,6 +132,9 @@ class Comment(TimeStampedModel): ...@@ -131,6 +132,9 @@ class Comment(TimeStampedModel):
def get_absolute_url(self): def get_absolute_url(self):
return self.content_object.get_absolute_url().split('#')[0] + '#comment_id' + str(self.id) return self.content_object.get_absolute_url().split('#')[0] + '#comment_id' + str(self.id)
def get_attachment_url(self):
return reverse('comments:attachment', args=(self.id,))
def grant_permissions(self): def grant_permissions(self):
# Import here due to circular import errors # Import here due to circular import errors
from submissions.models import Submission from submissions.models import Submission
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-9">
{{form.comment_text|bootstrap:'12,12'}} {{form.comment_text|bootstrap:'12,12'}}
<p> <p>
In your comment, you can use LaTeX \$...\$ for in-text equations or \ [ ... \ ] for on-line equations. In your comment, you can use LaTeX \$...\$ for in-text equations or \ [ ... \ ] for on-line equations.
</p> </p>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<p class="card-text"> <p class="card-text">
<a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a>: <a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a>:
<a href="{{comment.get_absolute_url}"> <a href="{{comment.get_absolute_url}}">
"{{comment.comment_text|slice:'30'}}{% if comment.comment_text|length > 30 %}...{% endif %}" "{{comment.comment_text|slice:'30'}}{% if comment.comment_text|length > 30 %}...{% endif %}"
</a> </a>
</p><p class="card-text pl-md-3"> </p><p class="card-text pl-md-3">
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
{% load file_extentions %} {% load file_extentions %}
<div class="comment"> <div class="comment">
{% include 'comments/_comment_identifier.html' with comment=comment %} {% include 'comments/_comment_identifier.html' with comment=comment %}
{% include 'comments/_comment_categories.html' with comment=comment %} {% include 'comments/_comment_categories.html' with comment=comment %}
...@@ -16,9 +15,9 @@ ...@@ -16,9 +15,9 @@
{% if comment.file_attachment %} {% if comment.file_attachment %}
<h3>Attachment:</h3> <h3>Attachment:</h3>
<p> <p>
<a target="_blank" href="{{ comment.file_attachment.url }}"> <a target="_blank" href="{{ comment.get_attachment_url }}">
{% if comment.file_attachment|is_image %} {% if comment.file_attachment|is_image %}
<img class="attachment attachment-comment" src="{{ comment.file_attachment.url }}"> <img class="attachment attachment-comment" src="{{ comment.get_attachment_url }}">
{% else %} {% else %}
{{ comment.file_attachment|filename }}<br><small>{{ comment.file_attachment.size|filesizeformat }}</small> {{ comment.file_attachment|filename }}<br><small>{{ comment.file_attachment.size|filesizeformat }}</small>
{% endif %} {% endif %}
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
{% if comment.file_attachment %} {% if comment.file_attachment %}
<h3>Attachment:</h3> <h3>Attachment:</h3>
<p> <p>
<a target="_blank" href="{{ comment.file_attachment.url }}"> <a target="_blank" href="{{ comment.get_attachment_url }}">
{% if comment.file_attachment|is_image %} {% if comment.file_attachment|is_image %}
<img class="attachment attachment-comment" src="{{ comment.file_attachment.url }}"> <img class="attachment attachment-comment" src="{{ comment.get_attachment_url }}">
{% else %} {% else %}
{{ comment.file_attachment|filename }}<br><small>{{ comment.file_attachment.size|filesizeformat }}</small> {{ comment.file_attachment|filename }}<br><small>{{ comment.file_attachment.size|filesizeformat }}</small>
{% endif %} {% endif %}
......
{% extends 'scipost/base.html' %}
{% load bootstrap %}
{% block pagetitle %}: Add Comment{% endblock pagetitle %}
{% block content %}
<h1 class="highlight">Add Comment</h1>
{% if user.is_authenticated and perms.scipost.can_submit_comments %}
<hr>
<h2 class="highlight" id="contribute_comment">Contribute a Comment:</h2>
{% include 'comments/_add_comment_form.html' with form=form url='' %}
{% endif %}
{% endblock content %}
...@@ -8,6 +8,7 @@ urlpatterns = [ ...@@ -8,6 +8,7 @@ urlpatterns = [
url(r'^vet_submitted$', views.vet_submitted_comments_list, name='vet_submitted_comments_list'), url(r'^vet_submitted$', views.vet_submitted_comments_list, name='vet_submitted_comments_list'),
url(r'^new/(?P<type_of_object>[a-z]+)/(?P<object_id>[0-9]+)$', views.new_comment, url(r'^new/(?P<type_of_object>[a-z]+)/(?P<object_id>[0-9]+)$', views.new_comment,
name='new_comment'), name='new_comment'),
url(r'^(?P<comment_id>[0-9]+)/attachment$', views.attachment, name='attachment'),
url(r'^(?P<comment_id>[0-9]+)/reply$', views.reply_to_comment, name='reply_to_comment'), url(r'^(?P<comment_id>[0-9]+)/reply$', views.reply_to_comment, name='reply_to_comment'),
url(r'^(?P<comment_id>[0-9]+)/vet$', views.vet_submitted_comment, url(r'^(?P<comment_id>[0-9]+)/vet$', views.vet_submitted_comment,
name='vet_submitted_comment'), name='vet_submitted_comment'),
......
from django.utils import timezone
from django.shortcuts import get_object_or_404, render, redirect
from django.contrib.auth.decorators import permission_required, login_required from django.contrib.auth.decorators import permission_required, login_required
from django.contrib import messages from django.contrib import messages
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db import transaction from django.db import transaction
from django.http import HttpResponse, Http404
from django.utils import timezone
from django.shortcuts import get_object_or_404, render, redirect
from guardian.shortcuts import get_objects_for_user from guardian.shortcuts import get_objects_for_user
import strings import strings
from .constants import EXTENTIONS_IMAGES, EXTENTIONS_PDF
from .models import Comment from .models import Comment
from .forms import CommentForm, VetCommentForm from .forms import CommentForm, VetCommentForm
from .utils import CommentUtils from .utils import CommentUtils, validate_file_extention
from theses.models import ThesisLink from theses.models import ThesisLink
from submissions.utils import SubmissionUtils from submissions.utils import SubmissionUtils
...@@ -20,7 +22,7 @@ from commentaries.models import Commentary ...@@ -20,7 +22,7 @@ from commentaries.models import Commentary
@permission_required('scipost.can_submit_comments', raise_exception=True) @permission_required('scipost.can_submit_comments', raise_exception=True)
def new_comment(request, **kwargs): def new_comment(request, **kwargs):
form = CommentForm(request.POST or None) form = CommentForm(request.POST or None, request.FILES or None)
if form.is_valid(): if form.is_valid():
object_id = int(kwargs["object_id"]) object_id = int(kwargs["object_id"])
type_of_object = kwargs["type_of_object"] type_of_object = kwargs["type_of_object"]
...@@ -41,6 +43,8 @@ def new_comment(request, **kwargs): ...@@ -41,6 +43,8 @@ def new_comment(request, **kwargs):
messages.success(request, strings.acknowledge_submit_comment) messages.success(request, strings.acknowledge_submit_comment)
return redirect(_object.get_absolute_url()) return redirect(_object.get_absolute_url())
context = {'form': form}
return(render(request, 'comments/add_comment.html', context))
@permission_required('scipost.can_vet_comments', raise_exception=True) @permission_required('scipost.can_vet_comments', raise_exception=True)
...@@ -178,3 +182,21 @@ def express_opinion(request, comment_id, opinion): ...@@ -178,3 +182,21 @@ def express_opinion(request, comment_id, opinion):
comment = get_object_or_404(Comment, pk=comment_id) comment = get_object_or_404(Comment, pk=comment_id)
comment.update_opinions(request.user.contributor.id, opinion) comment.update_opinions(request.user.contributor.id, opinion)
return redirect(comment.get_absolute_url()) return redirect(comment.get_absolute_url())
def attachment(request, comment_id):
"""
Open/read attachment of Comment if available.
"""
comment = get_object_or_404(Comment.objects.exclude(file_attachment=''), pk=comment_id)
if validate_file_extention(comment.file_attachment, EXTENTIONS_IMAGES):
content_type = 'image/jpeg'
elif validate_file_extention(comment.file_attachment, EXTENTIONS_PDF):
content_type = 'application/pdf'
else:
raise Http404
response = HttpResponse(comment.file_attachment.read(), content_type=content_type)
filename = 'comment-attachment-%s' % comment.file_attachment.name
response['Content-Disposition'] = ('filename=' + filename)
return response
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<a href="{% url 'scipost:landing_page' 'SciPostPhys' %}">SciPost Physics</a> <a href="{% url 'scipost:landing_page' 'SciPostPhys' %}">SciPost Physics</a>
</h1> </h1>
<div class="py-2"> <div class="py-2">
<h3 class="mb-2"><a href="{% url 'scipost:landing_page' 'SciPostPhys' %}">Go direct to SciPost Physics</a></h3> <h3 class="mb-2"><a href="{% url 'scipost:landing_page' 'SciPostPhys' %}">Go directly to SciPost Physics</a></h3>
<p>SciPost Physics publishes outstanding-quality research articles in all domains and subject areas of Physics.</p> <p>SciPost Physics publishes outstanding-quality research articles in all domains and subject areas of Physics.</p>
<p>The journal accepts three types of content: Letters, Articles and Reviews.</p> <p>The journal accepts three types of content: Letters, Articles and Reviews.</p>
<p>Letters report broad-interest, significant breakthroughs in Physics, of interest and importance to researchers in multiple subject areas.</p> <p>Letters report broad-interest, significant breakthroughs in Physics, of interest and importance to researchers in multiple subject areas.</p>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<a href="{% url 'journal:about' 'SciPostPhysProc' %}">SciPost Physics Proceedings</a> <span class="d-inline text-danger">New!</span> <a href="{% url 'journal:about' 'SciPostPhysProc' %}">SciPost Physics Proceedings</a> <span class="d-inline text-danger">New!</span>
</h1> </h1>
<div class="py-2"> <div class="py-2">
<h3 class="d-inline-block text-danger mb-2"><b>New!</b>&nbsp;&nbsp;&nbsp;<a href="{% url 'journal:about' 'SciPostPhysProc' %}">Go direct to SciPost Physics Proceedings</a></h3> <h3 class="d-inline-block text-danger mb-2"><b>New!</b>&nbsp;&nbsp;&nbsp;<a href="{% url 'journal:about' 'SciPostPhysProc' %}">Go directly to SciPost Physics Proceedings</a></h3>
<p>SciPost Physics Proceedings is a premium-quality, two-way open access, peer-witnessed refereed Journal for the general field of Physics.</p> <p>SciPost Physics Proceedings is a premium-quality, two-way open access, peer-witnessed refereed Journal for the general field of Physics.</p>
<p>It aims at providing a high-quality, openly accessible publishing venue for conference/workshop/school proceedings.</p> <p>It aims at providing a high-quality, openly accessible publishing venue for conference/workshop/school proceedings.</p>
<p>SciPost Physics Proceedings publishes articles in the domains of Experimental, Theoretical and Computational physics, in all specializations.</p> <p>SciPost Physics Proceedings publishes articles in the domains of Experimental, Theoretical and Computational physics, in all specializations.</p>
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
border-color: #d9534f; border-color: #d9534f;
} }
.has-error .help-block {
color: $brand-danger;
}
.has-error .multiple-checkbox .help-block { .has-error .multiple-checkbox .help-block {
color: $brand-danger; color: $brand-danger;
font-weight: 600; font-weight: 600;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment