diff --git a/src/agenda_culturel/forms.py b/src/agenda_culturel/forms.py
index 4c081c8..2242c47 100644
--- a/src/agenda_culturel/forms.py
+++ b/src/agenda_culturel/forms.py
@@ -20,8 +20,6 @@ from .models import (
Event,
RecurrentImport,
CategorisationRule,
- ModerationAnswer,
- ModerationQuestion,
Place,
Category,
)
@@ -417,46 +415,6 @@ class MergeDuplicates(Form):
return None
-class ModerationQuestionForm(ModelForm):
- class Meta:
- model = ModerationQuestion
- fields = "__all__"
-
-
-class ModerationAnswerForm(ModelForm):
- class Meta:
- model = ModerationAnswer
- exclude = ["question"]
- widgets = {
- "adds_tags": DynamicArrayWidgetTags(),
- "removes_tags": DynamicArrayWidgetTags(),
- }
-
-
-class ModerateForm(ModelForm):
- class Meta:
- model = Event
- fields = []
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
-
- mqs = ModerationQuestion.objects.all()
- mas = ModerationAnswer.objects.all()
-
- for q in mqs:
- self.fields[q.complete_id()] = ChoiceField(
- widget=RadioSelect,
- label=q.question,
- choices=[(a.pk, a.html_description()) for a in mas if a.question == q],
- required=True,
- )
- for a in mas:
- if a.question == q and a.valid_event(self.instance):
- self.fields[q.complete_id()].initial = a.pk
- break
-
-
class CategorisationForm(Form):
def __init__(self, *args, **kwargs):
if "events" in kwargs:
diff --git a/src/agenda_culturel/migrations/0109_delete_moderationanswer_delete_moderationquestion.py b/src/agenda_culturel/migrations/0109_delete_moderationanswer_delete_moderationquestion.py
new file mode 100644
index 0000000..e7e7e68
--- /dev/null
+++ b/src/agenda_culturel/migrations/0109_delete_moderationanswer_delete_moderationquestion.py
@@ -0,0 +1,19 @@
+# Generated by Django 4.2.9 on 2024-11-13 09:56
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('agenda_culturel', '0108_remove_duplicated_categories'),
+ ]
+
+ operations = [
+ migrations.DeleteModel(
+ name='ModerationAnswer',
+ ),
+ migrations.DeleteModel(
+ name='ModerationQuestion',
+ ),
+ ]
diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py
index 26e69de..1f08f56 100644
--- a/src/agenda_culturel/models.py
+++ b/src/agenda_culturel/models.py
@@ -1826,113 +1826,3 @@ class CategorisationRule(models.Model):
return True
-class ModerationQuestion(models.Model):
- question = models.CharField(
- verbose_name=_("Question"),
- help_text=_("Text that will be shown to moderators"),
- max_length=512,
- unique=True,
- )
-
- class Meta:
- verbose_name = _("Moderation question")
- verbose_name_plural = _("Moderation questions")
- permissions = [
- ("use_moderation_question", "Can use a moderation question to tag an event")
- ]
-
- def __str__(self):
- char_limit = 30
- return (
- (self.question[:char_limit] + "...")
- if char_limit < len(self.question)
- else self.question
- )
-
- def get_absolute_url(self):
- return reverse("view_mquestion", kwargs={"pk": self.pk})
-
- def complete_id(self):
- return "question_" + str(self.pk)
-
-
-class ModerationAnswer(models.Model):
- question = models.ForeignKey(
- ModerationQuestion,
- related_name="answers",
- verbose_name=_("Question"),
- help_text=_("Associated question from moderation"),
- on_delete=models.CASCADE,
- )
-
- answer = models.CharField(
- verbose_name=_("Answer"),
- help_text=_("Text that will be shown to moderators"),
- max_length=512,
- )
-
- adds_tags = ArrayField(
- models.CharField(max_length=64),
- verbose_name=_("Adds tags"),
- help_text=_("A list of tags that will be added if you choose this answer."),
- blank=True,
- null=True,
- )
- removes_tags = ArrayField(
- models.CharField(max_length=64),
- verbose_name=_("Removes tags"),
- help_text=_("A list of tags that will be removed if you choose this answer."),
- blank=True,
- null=True,
- )
-
- def complete_id(self):
- return "answer_" + str(self.question.pk) + "_" + str(self.pk)
-
- def html_description(self):
- result = self.answer + ''
- if self.adds_tags:
- result += " ".join(
- [
- '' + a + " "
- for a in self.adds_tags
- ]
- )
- if self.removes_tags:
- result += " ".join(
- [
- '' + a + " "
- for a in self.removes_tags
- ]
- )
- result += " "
- return mark_safe(result)
-
- def valid_event(self, event):
- if event.tags:
- if self.adds_tags:
- for t in self.adds_tags:
- if t not in event.tags:
- return False
-
- if self.removes_tags:
- for t in self.removes_tags:
- if t in event.tags:
- return False
-
- return True
- else:
- return not self.adds_tags or len(self.adds_tags) == 0
-
- def apply_answer(self, event):
- if not self.adds_tags:
- self.adds_tags = []
- if not self.removes_tags:
- self.removes_tags = []
-
- if event.tags:
- event.tags = list(
- (set(event.tags) | set(self.adds_tags)) - set(self.removes_tags)
- )
- else:
- event.tags = self.adds_tags
diff --git a/src/agenda_culturel/templates/agenda_culturel/edit-buttons-inc.html b/src/agenda_culturel/templates/agenda_culturel/edit-buttons-inc.html
index 389eac5..3c0c9da 100644
--- a/src/agenda_culturel/templates/agenda_culturel/edit-buttons-inc.html
+++ b/src/agenda_culturel/templates/agenda_culturel/edit-buttons-inc.html
@@ -1,7 +1,6 @@
{% load utils_extra %}
-
{% if event.pure_import %}
{% with event.get_local_version as local %}
{% if local %}
diff --git a/src/agenda_culturel/templates/agenda_culturel/moderationanswer_confirm_delete.html b/src/agenda_culturel/templates/agenda_culturel/moderationanswer_confirm_delete.html
deleted file mode 100644
index 86f533f..0000000
--- a/src/agenda_culturel/templates/agenda_culturel/moderationanswer_confirm_delete.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{% extends "agenda_culturel/page-admin.html" %}
-
-{% block title %}{% block og_title %}Supprimer la réponse #{{ object.pk }}{% endblock %}{% endblock %}
-
-{% block fluid %}{% endblock %}
-
-{% block content %}
-
-
Suppression de la réponse de modération {{ object.pk }}
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/src/agenda_culturel/templates/agenda_culturel/moderationanswer_form.html b/src/agenda_culturel/templates/agenda_culturel/moderationanswer_form.html
deleted file mode 100644
index 7d7bd58..0000000
--- a/src/agenda_culturel/templates/agenda_culturel/moderationanswer_form.html
+++ /dev/null
@@ -1,31 +0,0 @@
-{% extends "agenda_culturel/page-admin.html" %}
-{% load static %}
-
-{% block title %}{% block og_title %}{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'une réponse de modération{% endblock %}{% endblock %}
-
-{% block entete_header %}
-
-
-
-
-
-
-{% endblock %}
-
-
-{% block content %}
-
-{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'une réponse de modération
-{% if form.instance.pk %}Modifier{% else %}Ajouter{% endif %} une réponse à la question « {{ question }} »
-
-
-
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_confirm_delete.html b/src/agenda_culturel/templates/agenda_culturel/moderationquestion_confirm_delete.html
deleted file mode 100644
index 2839b97..0000000
--- a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_confirm_delete.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{% extends "agenda_culturel/page-admin.html" %}
-
-{% block title %}{% block og_title %}Supprimer la question #{{ object.pk }}{% endblock %}{% endblock %}
-
-{% block fluid %}{% endblock %}
-
-{% block content %}
-
-Suppression de la question de modération {{ object.pk }}
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_detail.html b/src/agenda_culturel/templates/agenda_culturel/moderationquestion_detail.html
deleted file mode 100644
index a6fecac..0000000
--- a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_detail.html
+++ /dev/null
@@ -1,71 +0,0 @@
-{% extends "agenda_culturel/page-admin.html" %}
-
-{% block title %}{% block og_title %}Question de modération #{{ object.pk }}{% endblock %}{% endblock %}
-
-{% load tag_extra %}
-{% load utils_extra %}
-{% load cat_extra %}
-
-{% block entete_header %}
- {% css_categories %}
-{% endblock %}
-
-
-{% block sidemenu-bouton %}
- {% picto_from_name "chevron-up" %}
- {% picto_from_name "chevron-down" %}
-{% endblock %}
-
-{% block content %}
-
-
-
- < Retour
-
- Question de modération #{{ object.pk }}
- {{ object.question }}
-
-
- {% if object.answers %}
- {% for answer in object.answers.all %}
-
-
-
- Réponse #{{ answer.pk }} : « {{ answer.answer }} »
- {% if answer.adds_tags %}
- Cette réponse ajoute les étiquettes suivantes à l'événement :
- {% for tag in answer.adds_tags %}
- {{ tag | tag_button }}
- {% endfor %}
-
- {% else %}
- Cette réponse n'ajoute pas d'étiquette à l'événement.
- {% endif %}
- {% if answer.removes_tags %}
- Cette réponse supprimer les étiquettes suivantes à l'événement :
- {% for tag in answer.removes_tags %}
- {{ tag | tag_button }}
- {% endfor %}
-
- {% else %}
- Cette réponse ne supprime pas d'étiquette à l'événement.
- {% endif %}
-
-
- {% endfor %}
- {% else %}
- Il n'y a pas encore de réponse associée à cette question.
- {% endif %}
-
-
-{% include "agenda_culturel/side-nav.html" with current="moderationquestions" %}
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_form.html b/src/agenda_culturel/templates/agenda_culturel/moderationquestion_form.html
deleted file mode 100644
index 04543af..0000000
--- a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_form.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% extends "agenda_culturel/page-admin.html" %}
-{% load static %}
-
-
-{% block title %}{% block og_title %}
-{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'une question de modération
-{% endblock %}{% endblock %}
-
-
-{% block content %}
-
-{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'une question de modération
-
-
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_list.html b/src/agenda_culturel/templates/agenda_culturel/moderationquestion_list.html
deleted file mode 100644
index 1c38275..0000000
--- a/src/agenda_culturel/templates/agenda_culturel/moderationquestion_list.html
+++ /dev/null
@@ -1,71 +0,0 @@
-{% extends "agenda_culturel/page-admin.html" %}
-
-{% block title %}{% block og_title %}Questions de modération{% endblock %}{% endblock %}
-
-{% load utils_extra %}
-{% load cat_extra %}
-{% block entete_header %}
- {% css_categories %}
-{% endblock %}
-
-{% block sidemenu-bouton %}
- {% picto_from_name "chevron-up" %}
- {% picto_from_name "chevron-down" %}
-{% endblock %}
-
-{% block content %}
-
-
-
- {% if object_list %}
- {% for question in object_list %}
-
-
-
-
- {% endfor %}
- {% else %}
- Il n'y a aucune question définie.
- {% endif %}
-
-
- {% if page_obj.has_previous %}
- « premier
- précédent
- {% endif %}
-
-
- Page {{ page_obj.number }} sur {{ page_obj.paginator.num_pages }}
-
-
- {% if page_obj.has_next %}
- suivant
- dernier »
- {% endif %}
-
-
-
-
-
-
-{% include "agenda_culturel/side-nav.html" with current="moderationquestions" %}
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/src/agenda_culturel/templates/agenda_culturel/side-nav.html b/src/agenda_culturel/templates/agenda_culturel/side-nav.html
index 3e74b88..7af6ff7 100644
--- a/src/agenda_culturel/templates/agenda_culturel/side-nav.html
+++ b/src/agenda_culturel/templates/agenda_culturel/side-nav.html
@@ -60,14 +60,6 @@
{% endif %}
- {% if perms.agenda_culturel.view_moderationquestion %}
-
- {% endif %}
{% if user.is_staff %}
Configuration interne
diff --git a/src/agenda_culturel/urls.py b/src/agenda_culturel/urls.py
index 12ec6f3..5101378 100644
--- a/src/agenda_culturel/urls.py
+++ b/src/agenda_culturel/urls.py
@@ -45,7 +45,6 @@ urlpatterns = [
set_duplicate,
name="set_duplicate",
),
- path("event//moderate", EventModerateView.as_view(), name="moderate_event"),
path("ajouter", import_event_proxy, name="add_event"),
path("ajouter/url", import_from_url, name="add_event_url"),
path("ajouter/urls", import_from_urls, name="add_event_urls"),
@@ -123,40 +122,6 @@ urlpatterns = [
path("duplicates//fix", fix_duplicate, name="fix_duplicate"),
path("duplicates//merge", merge_duplicate, name="merge_duplicate"),
path("duplicates//update/", update_duplicate_event, name="update_event"),
- path("mquestions/", ModerationQuestionListView.as_view(), name="view_mquestions"),
- path(
- "mquestions/add", ModerationQuestionCreateView.as_view(), name="add_mquestion"
- ),
- path(
- "mquestions//",
- ModerationQuestionDetailView.as_view(),
- name="view_mquestion",
- ),
- path(
- "mquestions//edit",
- ModerationQuestionUpdateView.as_view(),
- name="edit_mquestion",
- ),
- path(
- "mquestions//delete",
- ModerationQuestionDeleteView.as_view(),
- name="delete_mquestion",
- ),
- path(
- "mquestions//answers/add",
- ModerationAnswerCreateView.as_view(),
- name="add_manswer",
- ),
- path(
- "mquestions//answers//edit",
- ModerationAnswerUpdateView.as_view(),
- name="edit_manswer",
- ),
- path(
- "mquestions//answers//delete",
- ModerationAnswerDeleteView.as_view(),
- name="delete_manswer",
- ),
path("404/", page_not_found, name="page_not_found"),
path("500/", internal_server_error, name="internal_server_error"),
path("place//past", PlaceDetailViewPast.as_view(), name="view_place_past"),
diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py
index 67d2d83..9ceb531 100644
--- a/src/agenda_culturel/views.py
+++ b/src/agenda_culturel/views.py
@@ -29,9 +29,6 @@ from .forms import (
MergeDuplicates,
RecurrentImportForm,
CategorisationRuleImportForm,
- ModerationQuestionForm,
- ModerationAnswerForm,
- ModerateForm,
CategorisationForm,
EventAddPlaceForm,
PlaceForm,
@@ -49,8 +46,6 @@ from .models import (
RecurrentImport,
CategorisationRule,
remove_accents,
- ModerationQuestion,
- ModerationAnswer,
Place,
ReferenceLocation
)
@@ -619,30 +614,6 @@ class EventDetailView(UserPassesTestMixin, DetailView):
return obj
-class EventModerateView(
- SuccessMessageMixin, PermissionRequiredMixin, LoginRequiredMixin, UpdateView
-):
- model = Event
- permission_required = (
- "agenda_culturel.change_event",
- "agenda_culturel.use_moderation_question",
- )
- success_message = _("The event has been successfully modified.")
- form_class = ModerateForm
- template_name = "agenda_culturel/event_moderation_form.html"
-
- def form_valid(self, form):
- ModerationAnswer.objects.all()
-
- for f in form.cleaned_data:
- ModerationAnswer.objects.get(pk=form.cleaned_data[f]).apply_answer(
- form.instance
- )
-
- form.instance.moderated_date = timezone.now()
-
- return super().form_valid(form)
-
@login_required(login_url="/accounts/login/")
@permission_required("agenda_culturel.change_event")
@@ -1964,93 +1935,6 @@ def apply_categorisation_rules(request):
return HttpResponseRedirect(reverse_lazy("categorisation_rules"))
-#########################
-## Moderation Q&A
-#########################
-
-
-class ModerationQuestionListView(PermissionRequiredMixin, ListView):
- model = ModerationQuestion
- paginate_by = 10
- permission_required = "agenda_culturel.view_moderationquestion"
-
-
-class ModerationQuestionCreateView(
- SuccessMessageMixin, PermissionRequiredMixin, CreateView
-):
- model = ModerationQuestion
- permission_required = "agenda_culturel.add_moderationquestion"
-
- def get_success_url(self):
- return reverse_lazy("view_mquestion", kwargs={"pk": self.object.pk})
-
- form_class = ModerationQuestionForm
- success_message = _("The moderation question has been created with success.")
-
-
-class ModerationQuestionDetailView(PermissionRequiredMixin, DetailView):
- model = ModerationQuestion
- permission_required = (
- "agenda_culturel.view_moderationquestion",
- "agenda_culturel.view_moderationanswer",
- )
-
-
-class ModerationQuestionUpdateView(PermissionRequiredMixin, UpdateView):
- model = ModerationQuestion
- fields = ["question"]
- permission_required = "agenda_culturel.change_moderationquestion"
-
-
-class ModerationQuestionDeleteView(PermissionRequiredMixin, DeleteView):
- model = ModerationQuestion
- permission_required = "agenda_culturel.delete_moderationquestion"
- success_url = reverse_lazy("view_mquestions")
-
-
-class ModerationAnswerCreateView(
- PermissionRequiredMixin, SuccessMessageMixin, CreateView
-):
- model = ModerationAnswer
- permission_required = "agenda_culturel.add_answerquestion"
- form_class = ModerationAnswerForm
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context["question"] = get_object_or_404(
- ModerationQuestion, pk=self.kwargs["qpk"]
- )
- return context
-
- def form_valid(self, form):
- form.instance.question = ModerationQuestion.objects.get(pk=self.kwargs["qpk"])
- return super().form_valid(form)
-
- def get_success_url(self):
- return reverse_lazy("view_mquestion", kwargs={"pk": self.kwargs["qpk"]})
-
-
-class ModerationAnswerUpdateView(PermissionRequiredMixin, UpdateView):
- model = ModerationAnswer
- fields = ["answer", "adds_tags", "removes_tags"]
- permission_required = "agenda_culturel.change_answerquestion"
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context["question"] = get_object_or_404(
- ModerationQuestion, pk=self.kwargs["qpk"]
- )
- return context
-
- def get_success_url(self):
- return reverse_lazy("view_mquestion", kwargs={"pk": self.kwargs["qpk"]})
-
-
-class ModerationAnswerDeleteView(PermissionRequiredMixin, DeleteView):
- model = ModerationAnswer
- permission_required = "agenda_culturel.delete_answerquestion"
-
-
#########################
## Places
#########################