forked from mmmaly/chcemvediet
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add feedback functionality * Add feedback rating
- Loading branch information
1 parent
4e54c34
commit 42a2890
Showing
20 changed files
with
472 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# vim: expandtab | ||
# -*- coding: utf-8 -*- | ||
|
||
from django import forms | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from chcemvediet.apps.inforequests.models import Feedback | ||
from poleno.utils.urls import reverse | ||
from chcemvediet.apps.wizards.wizard import Bottom, Step, Wizard | ||
|
||
|
||
class FeedbackActionStep(Step): | ||
template = u'inforequests/feedback_action/wizard.html' | ||
form_template = u'main/forms/form_horizontal.html' | ||
|
||
|
||
class FeedbackContent(FeedbackActionStep): | ||
label = u'label free text feedback' | ||
text_template = u'inforequests/feedback_action/texts/content.html' | ||
global_fields = [u'content'] | ||
post_step_class = Bottom | ||
|
||
def add_fields(self): | ||
super(FeedbackContent, self).add_fields() | ||
|
||
self.fields[u'content'] = forms.CharField( | ||
label=_(u'inforequests:feedback_action:FeedbackContent:content:label'), | ||
required=False, | ||
widget=forms.Textarea(attrs={ | ||
u'placeholder': | ||
_(u'inforequests:feedback_action:FeedbackContent:content:placeholder'), | ||
u'class': u'pln-autosize', | ||
u'cols': u'', u'rows': u'' | ||
}) | ||
) | ||
|
||
|
||
class FeedbackRating(FeedbackActionStep): | ||
label = u'' | ||
text_template = u'inforequests/feedback_action/texts/rating.html' | ||
global_fields = [u'rating'] | ||
post_step_class = FeedbackContent | ||
|
||
def add_fields(self): | ||
super(FeedbackRating, self).add_fields() | ||
self.fields[u'rating'] = forms.TypedChoiceField( | ||
label=u' ', | ||
coerce=int, | ||
choices=Feedback.RATING_LEVELS._choices, | ||
widget=forms.RadioSelect(), | ||
) | ||
|
||
|
||
class FeedbackActionWizard(Wizard): | ||
first_step_class = FeedbackRating | ||
|
||
def __init__(self, request, index, inforequest): | ||
self.inforequest = inforequest | ||
super(FeedbackActionWizard, self).__init__(request, index) | ||
|
||
def get_instance_id(self): | ||
return u'{}-{}'.format(self.__class__.__name__, self.inforequest.pk) | ||
|
||
def get_step_url(self, step, anchor=u''): | ||
return reverse(u'inforequests:feedback_action', | ||
kwargs=dict(inforequest=self.inforequest, step=step)) + anchor | ||
|
||
def context(self, extra=None): | ||
res = super(FeedbackActionWizard, self).context(extra) | ||
res.update({ | ||
u'inforequest': self.inforequest | ||
}) | ||
return res | ||
|
||
def finish(self): | ||
feedback = Feedback( | ||
inforequest=self.inforequest, | ||
content=self.values[u'content'], | ||
rating=self.values[u'rating'] | ||
) | ||
feedback.save() | ||
|
||
return self.inforequest.get_absolute_url() |
33 changes: 33 additions & 0 deletions
33
chcemvediet/apps/inforequests/migrations/0023_auto_20231201_1635.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
import poleno.utils.date | ||
import poleno.utils.misc | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('inforequests', '0022_inforequest_published'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Feedback', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('content', models.TextField(blank=True)), | ||
('created', models.DateTimeField(default=poleno.utils.date.utc_now)), | ||
('inforequest', models.ForeignKey(to='inforequests.Inforequest', db_index=False)), | ||
], | ||
options={ | ||
'verbose_name_plural': 'Feedback', | ||
}, | ||
bases=(poleno.utils.misc.FormatMixin, models.Model), | ||
), | ||
migrations.AlterIndexTogether( | ||
name='feedback', | ||
index_together=set([('created', 'id')]), | ||
), | ||
] |
20 changes: 20 additions & 0 deletions
20
chcemvediet/apps/inforequests/migrations/0024_feedback_rating.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('inforequests', '0023_auto_20231201_1635'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='feedback', | ||
name='rating', | ||
field=models.SmallIntegerField(default=None, blank=True, choices=[(0, 'Stra\u0161n\xfd'), (1, 'Ve\u013emi zl\xfd'), (2, 'Zl\xfd'), (3, 'Priemern\xfd'), (4, 'Dobr\xfd'), (5, 'Ve\u013emi dobr\xfd'), (6, 'Vynikaj\xfaci'), (7, 'Mimoriadny')]), | ||
preserve_default=True, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# vim: expandtab | ||
# -*- coding: utf-8 -*- | ||
from django.db import models | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from poleno.utils.date import utc_now | ||
from poleno.utils.misc import FormatMixin | ||
from poleno.utils.models import FieldChoices, QuerySet | ||
|
||
|
||
class FeedbackQuerySet(QuerySet): | ||
def order_by_pk(self): | ||
return self.order_by(u'pk') | ||
|
||
|
||
class Feedback(FormatMixin, models.Model): | ||
# NOT NULL | ||
inforequest = models.ForeignKey(u'Inforequest', db_index=False) | ||
|
||
# May be empty | ||
content = models.TextField(blank=True) | ||
|
||
# NOT NULL | ||
created = models.DateTimeField(default=utc_now) | ||
|
||
RATING_LEVELS = FieldChoices( | ||
(u'ATROCIOUS', 0, _(u'inforequests:Feedback:rating:ATROCIOUS')), | ||
(u'VERY POOR', 1, _(u'inforequests:Feedback:rating:VERY_POOR')), | ||
(u'POOR', 2, _(u'inforequests:Feedback:rating:POOR')), | ||
(u'MEDIOCRE', 3, _(u'inforequests:Feedback:rating:MEDIOCRE')), | ||
(u'GOOD', 4, _(u'inforequests:Feedback:rating:GOOD')), | ||
(u'VERY GOOD', 5, _(u'inforequests:Feedback:rating:VERY_GOOD')), | ||
(u'EXCELLENT', 6, _(u'inforequests:Feedback:rating:EXCELLENT')), | ||
) | ||
|
||
rating = models.SmallIntegerField(choices=RATING_LEVELS._choices, blank=True, default=None) | ||
|
||
# Indexes: | ||
# -- inforequest: ForeignKey | ||
# -- created, id: index_together | ||
|
||
objects = FeedbackQuerySet.as_manager() | ||
|
||
class Meta: | ||
verbose_name_plural = u'Feedback' | ||
index_together = [ | ||
[u'created', u'id'], | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
chcemvediet/apps/inforequests/templates/inforequests/detail/feedback.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{# vim: set filetype=htmldjango shiftwidth=2 :#} | ||
{% load trans from i18n %} | ||
{% load url from poleno.utils %} | ||
|
||
{% comment %} | ||
% | ||
% Context: | ||
% -- inforequest: chcemvediet.apps.inforequests.models.Inforequest | ||
% | ||
{% endcomment %} | ||
|
||
<div class="chv-bar chv-bar-green"> | ||
<div class="chv-bar-icon"> | ||
<span class="chv-icon-stack"> | ||
<i class="chv-icon icon-circle"></i> | ||
<i class="chv-icon chv-icon-inv chv-icon-half icon-help"></i> | ||
</span> | ||
</div> | ||
<div class="chv-bar-heading"> | ||
{% trans 'inforequests:detail:feedback:heading' %} | ||
</div> | ||
</div> | ||
<div class="text-center chv-bellow-1"> | ||
{% include "inforequests/detail/texts/feedback.html" %} | ||
<a class="btn chv-btn-green" | ||
href="{% url 'inforequests:feedback_action' inforequest=inforequest %}"> | ||
<i class="chv-icon chv-icon-lg icon-help"></i> | ||
| ||
{% trans 'inforequests:detail:feedback:button' %} | ||
</a> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
chcemvediet/apps/inforequests/templates/inforequests/detail/texts/feedback.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{# vim: set filetype=htmldjango shiftwidth=2 :#} | ||
|
||
{% comment %} | ||
% | ||
% Context: | ||
% -- inforequest: chcemvediet.apps.inforequests.models.Inforequest | ||
% | ||
{% endcomment %} | ||
|
||
<p> | ||
Chceme zlepšovať portál Chcemvedieť.sk a preto nás zaujíma váš názor. Pomohol vám portál pri odosielaní a prijímaní žiadostí? Boli ste spokojní s poskytovanými funkcionalitami? Alebo naopak, boli ste s niečim nespokojní? Máte nápady na zlepšenie a radi by ste sa o ne podelili? Budeme radi, ak nám dáte spätnú väzbu a pomôžete nám portál zlepšovať. | ||
</p> |
18 changes: 18 additions & 0 deletions
18
chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/content.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{# vim: set filetype=htmldjango shiftwidth=2 :#} | ||
|
||
{% comment %} | ||
% | ||
% Context: | ||
% -- wizard: chcemvediet.apps.inforequests.forms.feedback_action.FeedbackActionWizard | ||
% -- step: chcemvediet.apps.inforequests.forms.feedback_action.FeedbackContent | ||
% -- inforequest: chcemvediet.apps.inforequests.models.Inforequest | ||
% | ||
{% endcomment %} | ||
|
||
|
||
<h4>Ako by ste zhodnotili portál?</h4> | ||
<p> | ||
Našim záujmom je zlepšovanie portálu a jeho funkcionalít. Zaujíma nás nie len toto, | ||
s čím ste spokojní a ktoré funkcionality portálu vám pomáhajú, ale aj to, kde si myslíte, že | ||
je treba nájsť zlepšenia. | ||
</p> |
18 changes: 18 additions & 0 deletions
18
chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/rating.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{# vim: set filetype=htmldjango shiftwidth=2 :#} | ||
|
||
{% comment %} | ||
% | ||
% Context: | ||
% -- wizard: chcemvediet.apps.inforequests.forms.feedback_action.FeedbackActionWizard | ||
% -- step: chcemvediet.apps.inforequests.forms.feedback_action.FeedbackContent | ||
% -- inforequest: chcemvediet.apps.inforequests.models.Inforequest | ||
% | ||
{% endcomment %} | ||
|
||
|
||
<h4>Ako by ste zhodnotili portál?</h4> | ||
<p> | ||
Našim záujmom je zlepšovanie portálu a jeho funkcionalít. Zaujíma nás nie len toto, | ||
s čím ste spokojní a ktoré funkcionality portálu vám pomáhajú, ale aj to, kde si myslíte, že | ||
je treba nájsť zlepšenia. | ||
</p> |
37 changes: 37 additions & 0 deletions
37
chcemvediet/apps/inforequests/templates/inforequests/feedback_action/wizard.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{# vim: set filetype=htmldjango shiftwidth=2 :#} | ||
{% extends step.base_template %} | ||
{% load trans from i18n %} | ||
|
||
{% comment %} | ||
% | ||
% Context: | ||
% -- wizard: chcemvediet.apps.inforequests.forms.feedback_action.FeedbackActionWizard | ||
% -- step: chcemvediet.apps.inforequests.forms.feedback_action.FeedbackActionStep | ||
% -- inforequest: chcemvediet.apps.inforequests.models.Inforequest | ||
% | ||
{% endcomment %} | ||
|
||
{% block title %} | ||
{% trans 'inforequests:feedback_action:title' %} | ||
| {{ block.super }} | ||
{% endblock %} | ||
|
||
{% block header-heading %} | ||
{% trans 'inforequests:feedback_action:heading' %} | ||
{% endblock %} | ||
|
||
{% block footer-cancel-href %}{{ inforequest.get_absolute_url }}{% endblock %} | ||
|
||
{% block footer-finish-label %} | ||
<i class="chv-icon chv-icon-lg icon-chevron-right"></i> | ||
| ||
{% trans 'inforequests:feedback_action:submit' %} | ||
{% endblock %} | ||
|
||
{% block body-plus-footer %} | ||
<div class="row"> | ||
<div class="col-sm-8"> | ||
{{ block.super }} | ||
</div> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.