SciPost Code Repository

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

Assign perms to EIC for reply-comments

parent b6aea4fe
No related branches found
No related tags found
No related merge requests found
<script>
$(document).ready(function(){
{% load bootstrap %}
var comment_text_input = $("#id_comment_text");
<script>
$(document).ready(function(){
var comment_text_input = $("#id_comment_text");
function set_comment_text(value) {
$("#preview-comment_text").text(value)
}
set_comment_text(comment_text_input.val())
comment_text_input.on('keyup', function(){
var new_text = $(this).val()
$("#preview-comment_text").text(new_text)
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}).trigger('keyup')
});
</script>
comment_text_input.keyup(function(){
var new_text = $(this).val()
set_comment_text(new_text)
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
})
<form enctype="multipart/form-data" action="{{url}}" method="post">
{% csrf_token %}
<div class="row">
<div class="col-md-9">
{{form.comment_text|bootstrap:'12,12'}}
<p>
In your comment, you can use LaTeX \$...\$ for in-text equations or \ [ ... \ ] for on-line equations.
</p>
<p id="goodCommenter"><em>
Be professional. Only serious and meaningful comments will be vetted through.
</em></p>
</div>
<div class="col-md-3 radio-list">
<label>Specify categorization(s):</label>
{{form.is_cor|bootstrap}}
{{form.is_rem|bootstrap}}
{{form.is_que|bootstrap}}
{{form.is_ans|bootstrap}}
{{form.is_obj|bootstrap}}
{{form.is_rep|bootstrap}}
{{form.is_val|bootstrap}}
{{form.is_lit|bootstrap}}
{{form.is_sug|bootstrap}}
</div>
</div>
});
</script>
<div class="row">
<div class="col-md-9">
{{form.remarks_for_editors|bootstrap:'12,12'}}
</div>
<div class="col-md-3">
{{form.file_attachment|bootstrap:'12,12'}}
</div>
</div>
<div class="row">
<div class="col-12">
<form enctype="multipart/form-data" action="{{url}}" method="post">
{% csrf_token %}
{% load crispy_forms_tags %}
{% crispy form %}
</form>
</div>
</div>
<div class="row">
<div class="col-12">
<input type="submit" name="submit" value="Submit your Comment for vetting" class="btn btn-primary" id="submit-id-submit">
<p class="mt-2" id="goodCommenter"><i>By clicking on Submit, you agree with the <a target="_blank" href="{% url 'scipost:terms_and_conditions' %}">Terms and Conditions</a>.</i></p>
</div>
</div>
</form>
<div class="row">
<div class="col-md-10">
<div class="col-md-9">
<h3>Preview of your comment:</h3>
<p id="preview-comment_text"></p>
</div>
......
......@@ -3,10 +3,6 @@
{% block comment_footer %}
{% if user.is_authenticated and perms.scipost.can_submit_comments %}
<hr class="small">
<div class="row">
<div class="col-12">
<h3><a href="{% url 'comments:reply_to_comment' comment_id=comment.id %}">Reply to this comment</a></h3>
</div>
</div>
<h3><a href="{% url 'comments:reply_to_comment' comment_id=comment.id %}">Reply to this comment</a></h3>
{% endif %}
{% endblock %}
......@@ -2,83 +2,11 @@
{% if user.is_authenticated and open_for_commenting and perms.scipost.can_submit_comments %}
<script>
$(document).ready(function(){
var comment_text_input = $("#id_comment_text");
function set_comment_text(value) {
$("#preview-comment_text").text(value)
}
set_comment_text(comment_text_input.val())
comment_text_input.keyup(function(){
var new_text = $(this).val()
set_comment_text(new_text)
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
})
});
</script>
<hr>
<div class="row" id="contribute_comment">
<div class="col-12">
<h2 class="highlight">Contribute a Comment:</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<form enctype="multipart/form-data"
action="{% url 'comments:new_comment' object_id=object_id type_of_object=type_of_object %}"
method="post">
{% csrf_token %}
<div class="row">
<div class="col-md-9">
{{form.comment_text|bootstrap:'12,12'}}
<p>
In your comment, you can use LaTeX \$...\$ for in-text equations or \ [ ... \ ] for on-line equations.
</p>
<p id="goodCommenter"><em>
Be professional. Only serious and meaningful comments will be vetted through.
</em></p>
</div>
<div class="col-md-3 radio-list">
<label>Specify categorization(s):</label>
{{form.is_cor|bootstrap}}
{{form.is_rem|bootstrap}}
{{form.is_que|bootstrap}}
{{form.is_ans|bootstrap}}
{{form.is_obj|bootstrap}}
{{form.is_rep|bootstrap}}
{{form.is_val|bootstrap}}
{{form.is_lit|bootstrap}}
{{form.is_sug|bootstrap}}
</div>
</div>
<div class="row">
<div class="col-md-9">
{{form.remarks_for_editors|bootstrap:'12,12'}}
</div>
<div class="col-md-3">
{{form.file_attachment|bootstrap:'12,12'}}
</div>
</div>
<h2 class="highlight" id="contribute_comment">Contribute a Comment:</h2>
<div class="row">
<div class="col-12">
<input type="submit" name="submit" value="Submit your Comment for vetting" class="btn btn-primary" id="submit-id-submit">
<p class="mt-2" id="goodCommenter"><i>By clicking on Submit, you agree with the <a target="_blank" href="{% url 'scipost:terms_and_conditions' %}">Terms and Conditions</a>.</i></p>
</div>
</div>
</form>
</div>
<div class="col-12">
<h3>Preview of your comment:</h3>
<p id="preview-comment_text"></p>
</div>
</div>
{% url 'comments:new_comment' object_id=object_id type_of_object=type_of_object as url %}
{% include 'comments/_add_comment_form.html' with form=form url=url %}
{% endif %}
......@@ -135,9 +135,9 @@ def reply_to_comment(request, comment_id):
is_author = False
if comment.submission and not is_author:
is_author = comment.submission.authors.filter(id=request.user.contributor.id).exists()
elif comment.commentary and not is_author:
if comment.commentary and not is_author:
is_author = comment.commentary.authors.filter(id=request.user.contributor.id).exists()
elif comment.thesislink and not is_author:
if comment.thesislink and not is_author:
is_author = comment.thesislink.author == request.user.contributor
form = CommentForm(request.POST or None, request.FILES or None)
......@@ -156,6 +156,10 @@ def reply_to_comment(request, comment_id):
'It will soon be vetted by an Editor.')
if newcomment.submission:
# Add permissions for EIC only, the Vetting-group already has it!
assign_perm('comments.can_vet_comments', newcomment.submission.editor_in_charge.user,
newcomment)
return redirect(newcomment.submission.get_absolute_url())
elif newcomment.commentary:
return redirect(newcomment.commentary.get_absolute_url())
......@@ -183,6 +187,10 @@ def reply_to_report(request, report_id):
newcomment.author = request.user.contributor
newcomment.save()
# Add permissions for EIC only, the Vetting-group already has it!
assign_perm('comments.can_vet_comments', newcomment.submission.editor_in_charge.user,
newcomment)
messages.success(request, '<h3>Thank you for contributing a Reply</h3>'
'It will soon be vetted by an Editor.')
return redirect(newcomment.submission.get_absolute_url())
......
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