diff --git a/chcemvediet/apps/inforequests/admin.py b/chcemvediet/apps/inforequests/admin.py index bb40c40b7..ed55c1425 100644 --- a/chcemvediet/apps/inforequests/admin.py +++ b/chcemvediet/apps/inforequests/admin.py @@ -14,7 +14,7 @@ ReadOnlyAdminInlineMixin, BulkDeleteAdminMixin) from chcemvediet.apps.inforequests.constants import ADMIN_EXTEND_SNOOZE_BY_DAYS -from .models import Inforequest, InforequestDraft, InforequestEmail, Branch, Action +from .models import Inforequest, InforequestDraft, InforequestEmail, Branch, Action, Feedback class DeleteNestedInforequestEmailAdminMixin(BulkDeleteAdminMixin, admin.ModelAdmin): @@ -463,3 +463,41 @@ def delete_model(self, request, obj): super(ActionAdmin, self).delete_model(request, obj) if request.POST.get(u'snooze') and self.can_snooze_previous_action(obj): self.snooze_action(obj.previous_action) + + +@admin.register(Feedback, site=admin.site) +class FeedbackAdmin(admin.ModelAdmin): + date_hierarchy = u'created' + list_display = [ + u'id', + decorate( + lambda o: admin_obj_format(o.inforequest), + short_description=u'Inforequest', + admin_order_field=u'inforequest' + ), + u'created', + u'content', + u'rating' + ] + list_filter = [ + u'created', + u'rating' + ] + ordering = [ + u'-created', + u'-id', + u'inforequest__id' + ] + exclude = [ + ] + readonly_fields = [ + u'inforequest', + u'content', + u'created', + u'rating' + ] + raw_id_fields = [ + u'inforequest' + ] + + diff --git a/chcemvediet/apps/inforequests/forms/__init__.py b/chcemvediet/apps/inforequests/forms/__init__.py index e96fc44a3..202534825 100644 --- a/chcemvediet/apps/inforequests/forms/__init__.py +++ b/chcemvediet/apps/inforequests/forms/__init__.py @@ -8,3 +8,4 @@ from .clarification_response import ClarificationResponseWizard from .appeal import AppealWizard from .action import SnoozeForm +from .feedback_action import FeedbackActionWizard diff --git a/chcemvediet/apps/inforequests/forms/feedback_action.py b/chcemvediet/apps/inforequests/forms/feedback_action.py new file mode 100644 index 000000000..7b5da81fe --- /dev/null +++ b/chcemvediet/apps/inforequests/forms/feedback_action.py @@ -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() diff --git a/chcemvediet/apps/inforequests/migrations/0023_auto_20231201_1635.py b/chcemvediet/apps/inforequests/migrations/0023_auto_20231201_1635.py new file mode 100644 index 000000000..3aee92134 --- /dev/null +++ b/chcemvediet/apps/inforequests/migrations/0023_auto_20231201_1635.py @@ -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')]), + ), + ] diff --git a/chcemvediet/apps/inforequests/migrations/0024_feedback_rating.py b/chcemvediet/apps/inforequests/migrations/0024_feedback_rating.py new file mode 100644 index 000000000..4b8011b50 --- /dev/null +++ b/chcemvediet/apps/inforequests/migrations/0024_feedback_rating.py @@ -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, + ), + ] diff --git a/chcemvediet/apps/inforequests/models/__init__.py b/chcemvediet/apps/inforequests/models/__init__.py index 9b19d5f2a..f86d88b3a 100644 --- a/chcemvediet/apps/inforequests/models/__init__.py +++ b/chcemvediet/apps/inforequests/models/__init__.py @@ -6,3 +6,4 @@ from .inforequestemail import InforequestEmail from .branch import Branch from .action import Action +from .feedback import Feedback diff --git a/chcemvediet/apps/inforequests/models/feedback.py b/chcemvediet/apps/inforequests/models/feedback.py new file mode 100644 index 000000000..ae74a65c9 --- /dev/null +++ b/chcemvediet/apps/inforequests/models/feedback.py @@ -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'], + ] diff --git a/chcemvediet/apps/inforequests/templates/inforequests/detail/detail.html b/chcemvediet/apps/inforequests/templates/inforequests/detail/detail.html index 89a517a75..e08da2acf 100644 --- a/chcemvediet/apps/inforequests/templates/inforequests/detail/detail.html +++ b/chcemvediet/apps/inforequests/templates/inforequests/detail/detail.html @@ -17,4 +17,5 @@
+ 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ť. +
diff --git a/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/content.html b/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/content.html new file mode 100644 index 000000000..0e10b7f02 --- /dev/null +++ b/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/content.html @@ -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 %} + + ++ 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. +
diff --git a/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/rating.html b/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/rating.html new file mode 100644 index 000000000..0e10b7f02 --- /dev/null +++ b/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/texts/rating.html @@ -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 %} + + ++ 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. +
diff --git a/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/wizard.html b/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/wizard.html new file mode 100644 index 000000000..e8d62751a --- /dev/null +++ b/chcemvediet/apps/inforequests/templates/inforequests/feedback_action/wizard.html @@ -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 %} + + + {% trans 'inforequests:feedback_action:submit' %} +{% endblock %} + +{% block body-plus-footer %} +