SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 2c9926c7 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Introduce django-crispy-forms for Comments

parent 27a6c312
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,7 @@ INSTALLED_APPS = ( ...@@ -54,6 +54,7 @@ INSTALLED_APPS = (
'django_countries', 'django_countries',
'django_mathjax', 'django_mathjax',
'captcha', 'captcha',
'crispy_forms',
'commentaries', 'commentaries',
'comments', 'comments',
'journals', 'journals',
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
}); });
</script> </script>
{% load crispy_forms_tags %}
{% endblock headsup %} {% endblock headsup %}
...@@ -240,11 +241,13 @@ ...@@ -240,11 +241,13 @@
<section> <section>
<hr class="hr12"> <hr class="hr12">
<div class="row"> <div class="row">
<!--
<div class="col-3"> <div class="col-3">
<h1>Contribute a Comment</h1> <h1>Contribute a Comment</h1>
<p>Specify which category your comment belongs to (you can choose more than one).</p> <p>Specify which category your comment belongs to (you can choose more than one).</p>
<p>In your comment, you can use LaTeX \$...\$ for in-text equations or \ [ ... \ ] for on-line equations.</p> <p>In your comment, you can use LaTeX \$...\$ for in-text equations or \ [ ... \ ] for on-line equations.</p>
</div> </div>
<div class="col-9"> <div class="col-9">
<form action="{% url 'commentaries:commentary' commentary.id %}" method="post"> <form action="{% url 'commentaries:commentary' commentary.id %}" method="post">
{% csrf_token %} {% csrf_token %}
...@@ -272,6 +275,13 @@ ...@@ -272,6 +275,13 @@
</div> </div>
</div> </div>
</form> </form>
-->
<form action="{% url 'commentaries:commentary' commentary.id %}" method="post">
{% csrf_token %}
{% crispy form %}
</form>
</div> </div>
</div> </div>
</section> </section>
......
...@@ -2,6 +2,10 @@ from django import * ...@@ -2,6 +2,10 @@ from django import *
from .models import * from .models import *
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Field, Fieldset, HTML, Submit
COMMENT_ACTION_CHOICES = ( COMMENT_ACTION_CHOICES = (
# (0, 'modify'), # (0, 'modify'),
(1, 'accept'), (1, 'accept'),
...@@ -49,6 +53,29 @@ class CommentForm(forms.ModelForm): ...@@ -49,6 +53,29 @@ class CommentForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(CommentForm, self).__init__(*args, **kwargs) super(CommentForm, self).__init__(*args, **kwargs)
self.fields['comment_text'].widget.attrs.update({'placeholder': 'NOTE: only serious and meaningful Comments will be accepted.'}) self.fields['comment_text'].widget.attrs.update({'placeholder': 'NOTE: only serious and meaningful Comments will be accepted.'})
self.helper = FormHelper()
self.helper.layout = Layout(
HTML('<h1>Contribute a Comment</h1>'),
Div(
Div(
Fieldset(
'Specify categorization',
'is_rem', 'is_que', 'is_ans', 'is_obj', 'is_rep', 'is_val', 'is_lit', 'is_sug',
style="border: 0px"),
css_class="col-4"),
Div(
Field('comment_text'),
Field('anonymous'),
HTML('<p>In your comment, you can use LaTeX \$...\$ for in-text equations or \ [ ... \ ] for on-line equations.</p>'),
HTML('<p id="goodCommenter"><i>Be professional. Only serious and meaningful comments will be vetted through.</i></p>'),
HTML('<p id="goodCommenter"><i> By clicking on Submit, the commenter certifies that all sources used are duly referenced and cited. Failure to do so will lead to exclusion from the portal.</i></p>'),
Submit('submit', 'Submit', css_class="submitComment"),
css_class="col-8"),
css_class="row"),
)
class VetCommentForm(forms.Form): class VetCommentForm(forms.Form):
action_option = forms.ChoiceField(widget=forms.RadioSelect, choices=COMMENT_ACTION_CHOICES, required=True, label='Action') action_option = forms.ChoiceField(widget=forms.RadioSelect, choices=COMMENT_ACTION_CHOICES, required=True, label='Action')
......
...@@ -192,6 +192,10 @@ a:hover { ...@@ -192,6 +192,10 @@ a:hover {
text-decoration: underline; text-decoration: underline;
} }
.submitComment {
background-color: #002B49;
color: #FFA300;
}
header { header {
background-color: #002B49; background-color: #002B49;
......
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