From 67710a31660da7de55e93d07b3b9076d1d6021be Mon Sep 17 00:00:00 2001 From: cbum-dev Date: Thu, 21 Mar 2024 00:27:13 +0530 Subject: [PATCH 1/3] Issue18 --- .../templates/orga/cfp/question_view.html | 64 +++++++++++++++---- src/pretalx/orga/urls.py | 15 +++++ src/pretalx/orga/views/cfp.py | 62 ++++++++++++++++++ src/pretalx/submission/models/question.py | 4 ++ 4 files changed, 134 insertions(+), 11 deletions(-) diff --git a/src/pretalx/orga/templates/orga/cfp/question_view.html b/src/pretalx/orga/templates/orga/cfp/question_view.html index b8d0a2ff4..6ae1ae5b0 100644 --- a/src/pretalx/orga/templates/orga/cfp/question_view.html +++ b/src/pretalx/orga/templates/orga/cfp/question_view.html @@ -29,9 +29,10 @@ {% translate "Question" %} {% translate "Target" %} - {% translate "required" %} - {% translate "active" %} - {% translate "Answers" %} + {% translate "Required" %} + {% translate "Active" %} + {% translate "Public" %} + {% translate "Answers" %} @@ -47,17 +48,58 @@ {{ question.get_target_display }} - - - {% if question.question_required == "require after" or question.freeze_after%} - - {% endif %} +
+ + {% if question.question_required == "required" %} + Required + {% elif question.question_required == "optional" %} + Optional + {% else %} + Deadline + {% endif %} + +
- - + + {% if question.active %} + + {% else %} + + {% endif %} + + + + {% if question.answer_count == 0%} + + {% if question.is_public == True %} + + {% else %} + + {% endif %} + + {% else %} + {% if question.is_public == True %} + + {% else %} + + {% endif %} + {% endif %} - + {{ question.answer_count }} diff --git a/src/pretalx/orga/urls.py b/src/pretalx/orga/urls.py index e225a74f8..28c3be07a 100644 --- a/src/pretalx/orga/urls.py +++ b/src/pretalx/orga/urls.py @@ -170,6 +170,21 @@ cfp.CfPQuestionToggle.as_view(), name="cfp.question.toggle", ), + path( + "active", + cfp.CfPQuestionActive.as_view(), + name="cfp.question.active", + ), + path( + "required", + cfp.CfPQuestionRequired.as_view(), + name="cfp.question.required", + ), + path( + "public", + cfp.CfPQuestionPublic.as_view(), + name="cfp.question.public", + ) ] ), ), diff --git a/src/pretalx/orga/views/cfp.py b/src/pretalx/orga/views/cfp.py index d90e6e432..3227a661d 100644 --- a/src/pretalx/orga/views/cfp.py +++ b/src/pretalx/orga/views/cfp.py @@ -357,6 +357,68 @@ def dispatch(self, request, *args, **kwargs): return redirect(question.urls.base) +class CfPQuestionActive(PermissionRequired, View): + permission_required = "orga.edit_question" + + def get_object(self) -> Question: + return Question.all_objects.filter( + pk=self.kwargs.get("pk") + ).first() + + def dispatch(self, request, *args, **kwargs): + question = self.get_object() + question.active = not question.active + question.save(update_fields=["active"]) + return redirect(question.urls.list) + + +class CfPQuestionRequired(PermissionRequired, View): + permission_required = "orga.edit_question" + + def get_object(self) -> Question: + return Question.all_objects.filter( + pk=self.kwargs.get("pk") + ).first() + + def dispatch(self, request, *args, **kwargs): + question = self.get_object() + + current_value = question.question_required + + if current_value == "optional": + question.question_required = "required" + elif current_value == "required": + question.question_required = "after_deadline" + return redirect(question.urls.edit) + else: + question.question_required = "optional" + + question.save(update_fields=["question_required"]) + return redirect(question.urls.list) + + +class CfPQuestionPublic(PermissionRequired, View): + permission_required = "orga.edit_question" + + def get_object(self) -> Question: + return Question.all_objects.filter( + pk=self.kwargs.get("pk") + ).first() + + def dispatch(self, request, *args, **kwargs): + question = self.get_object() + + current_value = question.is_public + + if current_value == True : + question.is_public = False + else: + question.is_public = True + + question.save(update_fields=["is_public"]) + return redirect(question.urls.list) + + class CfPQuestionRemind(EventPermissionRequired, TemplateView): template_name = "orga/cfp/question_remind.html" permission_required = "orga.view_question" diff --git a/src/pretalx/submission/models/question.py b/src/pretalx/submission/models/question.py index 3e46e65ba..607d13d7d 100644 --- a/src/pretalx/submission/models/question.py +++ b/src/pretalx/submission/models/question.py @@ -272,11 +272,15 @@ def read_only(self): class urls(EventUrls): base = "{self.event.cfp.urls.questions}{self.pk}/" + list = "{self.event.cfp.urls.questions}" edit = "{base}edit" up = "{base}up" down = "{base}down" delete = "{base}delete" toggle = "{base}toggle" + active = "{base}active" + required = "{base}required" + public = "{base}public" def __str__(self): return str(self.question) From 42ff9637501ff5078e7ee295c4c6f2a49b1c1875 Mon Sep 17 00:00:00 2001 From: cbum-dev Date: Thu, 21 Mar 2024 02:50:48 +0530 Subject: [PATCH 2/3] Fixes Checks Validation --- src/pretalx/orga/urls.py | 2 +- src/pretalx/orga/views/cfp.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pretalx/orga/urls.py b/src/pretalx/orga/urls.py index 28c3be07a..2e0a78c24 100644 --- a/src/pretalx/orga/urls.py +++ b/src/pretalx/orga/urls.py @@ -184,7 +184,7 @@ "public", cfp.CfPQuestionPublic.as_view(), name="cfp.question.public", - ) + ), ] ), ), diff --git a/src/pretalx/orga/views/cfp.py b/src/pretalx/orga/views/cfp.py index 3227a661d..0efe3c547 100644 --- a/src/pretalx/orga/views/cfp.py +++ b/src/pretalx/orga/views/cfp.py @@ -396,7 +396,7 @@ def dispatch(self, request, *args, **kwargs): question.save(update_fields=["question_required"]) return redirect(question.urls.list) - + class CfPQuestionPublic(PermissionRequired, View): permission_required = "orga.edit_question" @@ -410,15 +410,15 @@ def dispatch(self, request, *args, **kwargs): current_value = question.is_public - if current_value == True : + if current_value is True: question.is_public = False else: question.is_public = True question.save(update_fields=["is_public"]) return redirect(question.urls.list) - - + + class CfPQuestionRemind(EventPermissionRequired, TemplateView): template_name = "orga/cfp/question_remind.html" permission_required = "orga.view_question" From 1338dd4d76db402f6861383655f4307a6b85a811 Mon Sep 17 00:00:00 2001 From: cbum-dev Date: Sat, 23 Mar 2024 17:06:07 +0530 Subject: [PATCH 3/3] Fixes Color consistency issue in question page --- src/pretalx/orga/forms/cfp.py | 14 +++++++++++--- .../orga/templates/orga/cfp/question_view.html | 8 ++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/pretalx/orga/forms/cfp.py b/src/pretalx/orga/forms/cfp.py index 0d288014c..84d917e7f 100644 --- a/src/pretalx/orga/forms/cfp.py +++ b/src/pretalx/orga/forms/cfp.py @@ -87,16 +87,24 @@ def __init__(self, *args, obj, **kwargs): self.fields[field_name].widget.attrs["placeholder"] = "" for attribute in self.request_require_fields: field_name = f"cfp_ask_{attribute}" + visibility = obj.cfp.fields.get(attribute, default_fields()[attribute])["visibility"] + if visibility == "optional": + css_class = "btn btn-outline-dark btn-sm" + elif visibility == "required": + css_class = "btn btn-outline-success btn-sm" + else: + css_class = "btn btn-outline-danger btn-sm" self.fields[field_name] = forms.ChoiceField( required=True, initial=obj.cfp.fields.get(attribute, default_fields()[attribute])[ "visibility" ], choices=[ - ("do_not_ask", _("Do not ask")), - ("optional", _("Ask, but do not require input")), - ("required", _("Ask and require input")), + ("do_not_ask", _("Not Active")), + ("optional", _("Optional")), + ("required", _("Required")), ], + widget=forms.Select(attrs={'class': css_class}), ) if not obj.is_multilingual: self.fields.pop("cfp_ask_content_locale", None) diff --git a/src/pretalx/orga/templates/orga/cfp/question_view.html b/src/pretalx/orga/templates/orga/cfp/question_view.html index 6ae1ae5b0..6b761d8f4 100644 --- a/src/pretalx/orga/templates/orga/cfp/question_view.html +++ b/src/pretalx/orga/templates/orga/cfp/question_view.html @@ -74,9 +74,9 @@ {% if question.active %} - + {% else %} - + {% endif %} @@ -84,9 +84,9 @@ {% if question.answer_count == 0%} {% if question.is_public == True %} - + {% else %} - + {% endif %} {% else %}