Skip to content

Commit 7b408c1

Browse files
author
Kátia Nakamura
committed
cfp: add all reviwer's comment to cfp detail
1 parent 82b373a commit 7b408c1

File tree

6 files changed

+69
-16
lines changed

6 files changed

+69
-16
lines changed

pyconbalkan/cfp/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Meta:
4343

4444
class RateForm(ModelForm):
4545
mark = forms.IntegerField(widget=forms.NumberInput(attrs={'placeholder': 'Rating: from 1 to 10', 'class': 'form-control', 'max': 10, 'min': 1}), label='', )
46-
comment = forms.CharField(widget=forms.Textarea(attrs={'placeholder': 'Comment', 'class': 'form-control'}), label='')
46+
comment = forms.CharField(widget=forms.Textarea(attrs={'placeholder': 'Comment', 'class': 'form-control'}), label='', required=False)
4747

4848
class Meta:
4949
model = CFPRating
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 2.0.5 on 2018-08-10 18:59
2+
3+
from django.db import migrations
4+
import taggit.managers
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('cfp', '0008_auto_20180809_1350'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='cfprating',
16+
name='tags',
17+
field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'),
18+
),
19+
]

pyconbalkan/cfp/models.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.db import models
88
from django.db.models import CASCADE
99
from markdownx.models import MarkdownxField
10+
from markdownx.utils import markdownify
1011
from slugify import slugify
1112
from taggit.managers import TaggableManager
1213
from . import const
@@ -48,8 +49,17 @@ class CFPRating(models.Model):
4849
cfp = models.ForeignKey(Cfp, related_name="ratings", on_delete=CASCADE)
4950
user = models.ForeignKey(getattr(settings, "AUTH_USER_MODEL"), on_delete=CASCADE)
5051
comment = MarkdownxField(blank=True, null=True)
51-
tags = TaggableManager()
52+
tags = TaggableManager(blank=True)
5253

5354
class Meta:
5455
unique_together = (("user", "cfp",),)
5556

57+
@property
58+
def formatted_markdown(self):
59+
if self.comment:
60+
return markdownify(self.comment)
61+
return ''
62+
63+
def __str__(self):
64+
return '[{}] by {}'.format(self.mark, self.user.first_name)
65+

pyconbalkan/cfp/templates/cfp_detail.html

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,33 @@ <h2>by {{ cfp.name }} {% if cfp.company %}({{ cfp.company }}){% endif %}</h2>
1616
{{ cfp.description|safe }}
1717
</p>
1818

19-
{% if success %}
20-
<h2 class="success-message">
21-
{{ success }}
22-
</h2>
23-
{% endif %}
24-
25-
<form class="form" action="{% url 'cfp_detail' cfp.slug %}" method="POST" enctype="multipart/form-data" novalidate>
26-
<div class="form-group">
27-
{% csrf_token %}
28-
{{ form.as_p }}
29-
<input class="button button--blue button--fullwidth mb-xs-40" type="submit" value="Submit" />
30-
</div>
31-
</form>
19+
{% if success %}
20+
<h2 class="success-message">
21+
{{ success }}
22+
</h2>
23+
{% endif %}
24+
25+
<form class="form" action="{% url 'cfp_detail' cfp.slug %}" method="POST" enctype="multipart/form-data" novalidate>
26+
<div class="form-group">
27+
{% csrf_token %}
28+
{{ form.as_p }}
29+
<input class="button button--blue button--fullwidth mb-xs-40" type="submit" value="Submit" />
30+
</div>
31+
</form>
32+
33+
<h2>Other comments:</h2>
34+
{% for rating in ratings %}
35+
{% if rating.comment %}
36+
<hr class="line">
37+
<p class="cfp__comment">{{ rating.formatted_markdown|safe }}</p>
38+
<h4>by {{ rating.user.first_name }} </h4>
39+
{% if rating.tags.all %}
40+
<h3>Tags</h3> [{{ rating.tags.all | join:", " }}]
41+
{% endif %}
42+
<hr class="line">
43+
{% endif %}
44+
{% endfor %}
45+
3246
<a class="button button--yellow" href="{% url 'cfp_list' %}" role="button">Back to CFP List</a>
3347
</div>
3448
</div>

pyconbalkan/cfp/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ def cfp_list(request):
5454
@login_required
5555
def cfp_detail(request, slug):
5656
cfp = get_object_or_404(Cfp, slug=slug)
57+
ratings = CFPRating.objects.filter(cfp=cfp)
5758
context = {
5859
'cfp': cfp,
60+
'ratings': ratings,
5961
}
6062
initial = {
6163
'user': request.user,

pyconbalkan/core/static/css/components/sponsors.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.catch {
22
color: white;
3-
margin: 30px 0 40px; 0;
3+
margin: 30px 0 40px 0;
44
}
55

66
.catch p {
@@ -54,6 +54,14 @@
5454
padding: 20px;
5555
}
5656

57+
.cfp__description {
58+
margin-bottom: 20px;
59+
}
60+
61+
.cfp__comment {
62+
margin-bottom: 0;
63+
}
64+
5765
@media (max-width: 767px) {
5866
.card__info {
5967
top: -170px;

0 commit comments

Comments
 (0)