From d625fc0daec5f3b019877a9edb1823ada77703c8 Mon Sep 17 00:00:00 2001 From: Horilla Date: Fri, 5 Jul 2024 16:21:05 +0530 Subject: [PATCH] [UPDT] RECRUITMENT: Updated recruitment survey question form by changing option type questions format --- recruitment/models.py | 10 +- .../templates/survey/add_more_options.html | 30 ++++++ .../question_template_organized_form.html | 96 +++++++++++++------ .../templates/survey/template_form.html | 7 +- .../survey/template_update_form.html | 6 +- recruitment/urls.py | 14 ++- 6 files changed, 128 insertions(+), 35 deletions(-) create mode 100644 recruitment/templates/survey/add_more_options.html diff --git a/recruitment/models.py b/recruitment/models.py index 31ecb916d..62500bdb9 100644 --- a/recruitment/models.py +++ b/recruitment/models.py @@ -571,7 +571,11 @@ class RejectReason(HorillaModel): ) description = models.TextField(null=True, blank=True, max_length=255) company_id = models.ForeignKey( - Company, on_delete=models.CASCADE, null=True, blank=True + Company, + on_delete=models.CASCADE, + null=True, + blank=True, + verbose_name=_("Company"), ) objects = HorillaCompanyManager() @@ -654,11 +658,12 @@ class RecruitmentSurvey(HorillaModel): template_id = models.ManyToManyField( SurveyTemplate, verbose_name="Template", blank=True ) - question = models.TextField(null=False) + is_mandatory = models.BooleanField(default=False) recruitment_ids = models.ManyToManyField( Recruitment, verbose_name=_("Recruitment"), ) + question = models.TextField(null=False) job_position_ids = models.ManyToManyField( JobPosition, verbose_name=_("Job Positions"), editable=False ) @@ -670,7 +675,6 @@ class RecruitmentSurvey(HorillaModel): options = models.TextField( null=True, default="", help_text=_("Separate choices by ', '"), max_length=255 ) - is_mandatory = models.BooleanField(default=False) objects = HorillaCompanyManager(related_company_field="recruitment_ids__company_id") def __str__(self) -> str: diff --git a/recruitment/templates/survey/add_more_options.html b/recruitment/templates/survey/add_more_options.html new file mode 100644 index 000000000..34ab88152 --- /dev/null +++ b/recruitment/templates/survey/add_more_options.html @@ -0,0 +1,30 @@ +{% load i18n %} +
+
+ {{field_html}} + + + +
+ +
diff --git a/recruitment/templates/survey/question_template_organized_form.html b/recruitment/templates/survey/question_template_organized_form.html index 3be7706db..b05a308e6 100644 --- a/recruitment/templates/survey/question_template_organized_form.html +++ b/recruitment/templates/survey/question_template_organized_form.html @@ -1,5 +1,6 @@ {% load i18n %}{% load widget_tweaks %} {% load attendancefilters %} - +{% load basefilters %} +{{form.option_count}}
{% if form.verbose_name %}
@@ -12,38 +13,79 @@
{{form.non_field_errors}}
{% for field in form.visible_fields %} - {% if field.field.widget|is_text_area %} - - {{field.errors}} -
- - {{ field|add_class:"form-control" }} -
- - {% else %} -
- - {% if field.field.widget.input_type == "checkbox" %} -
- {{ field|add_class:"oh-switch__checkbox" }} - -
- {% else %} - {{ field|add_class:"form-control" }} - {% endif %} {{field.errors}} -
- {% endif %} +
+ + {{ field|add_class:"form-control" }} +
+ + {% else %} + {% if field.name|startswith:"option" %} +
+ {% if field.name == "options" %} + + {% endif %} + {{field.errors}} +
+ {{ field|add_class:"form-control" }} + {% if not field.name == "options" %} + + + + {% endif %} +
+
+ {% if forloop.last %} + + {% endif %} + {% else %} +
+ + {% if field.field.widget.input_type == "checkbox" %} +
+ {{ field|add_class:"oh-switch__checkbox" }} + +
+ {% else %} + {{ field|add_class:"form-control" }} + {% endif %} + {{field.errors}} +
+ {% endif %} + {% endif %} {% endfor %}
diff --git a/recruitment/templates/survey/template_form.html b/recruitment/templates/survey/template_form.html index 9d9686aff..2be18813c 100644 --- a/recruitment/templates/survey/template_form.html +++ b/recruitment/templates/survey/template_form.html @@ -9,12 +9,15 @@