From d902caf7538edbca4069721cb574be43fbc411f2 Mon Sep 17 00:00:00 2001 From: Edo Storm Date: Wed, 18 Sep 2024 11:12:43 +0200 Subject: [PATCH] style: formatting --- main/templates/base/stepper.html | 2 +- main/templates/base/stepper_item.html | 2 +- proposals/utils/checkers.py | 14 +++++++------- proposals/utils/stepper.py | 19 ++++++++++++++----- proposals/utils/stepper_helpers.py | 2 +- proposals/utils/validate_sessions_tasks.py | 4 ++-- proposals/views/study_views.py | 1 - 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/main/templates/base/stepper.html b/main/templates/base/stepper.html index 6f0ba0df9..7f69a3acd 100644 --- a/main/templates/base/stepper.html +++ b/main/templates/base/stepper.html @@ -6,7 +6,7 @@ {% for item in stepper.build_stepper %}
  • {% if item.is_disabled %} -
    +
    {% counter counter value %} {{ item.title }}
    diff --git a/main/templates/base/stepper_item.html b/main/templates/base/stepper_item.html index 75b34f364..8ae0ebbb8 100644 --- a/main/templates/base/stepper_item.html +++ b/main/templates/base/stepper_item.html @@ -1,6 +1,6 @@
  • {% if item.is_disabled %} -
    +
    {{ item.title }}
    diff --git a/proposals/utils/checkers.py b/proposals/utils/checkers.py index 51aae7bbd..48e0777f3 100644 --- a/proposals/utils/checkers.py +++ b/proposals/utils/checkers.py @@ -42,6 +42,7 @@ def check(self): self.stepper.layout = RegularProposalLayout return [ProposalCreateChecker] + class ProposalCreateChecker( ModelFormChecker, ): @@ -63,7 +64,7 @@ def check(self): form_class=self.form_class, form_kwargs={}, url_func=self.get_url, - location=self.location + location=self.location, ) self.stepper.items.append( self.item, @@ -681,7 +682,7 @@ def make_stepper_item( form_class=self.form_class, form_kwargs=self.get_form_kwargs(), url_func=self.get_url, - error_func = self.get_checker_errors + error_func=self.get_checker_errors, ) def modified_is_current(self, request): @@ -761,14 +762,13 @@ def get_url( "tasks:session_overview", args=[self.study.pk], ) - + def get_checker_errors(self): from proposals.utils.validate_sessions_tasks import validate_sessions_tasks if validate_sessions_tasks(self.study, self.stepper.has_multiple_studies()): return True - return - + return class DocumentsChecker( @@ -786,7 +786,6 @@ def check( ), ] - def make_stepper_item(self): url = reverse( "proposals:consent", @@ -795,7 +794,8 @@ def make_stepper_item(self): item = PlaceholderItem( self.stepper, title=_("Documenten"), - location="attachments", ) + location="attachments", + ) item.get_url = lambda: url return item diff --git a/proposals/utils/stepper.py b/proposals/utils/stepper.py index 8aceafaf6..d59c61ca8 100644 --- a/proposals/utils/stepper.py +++ b/proposals/utils/stepper.py @@ -153,7 +153,7 @@ def has_multiple_studies( """ num_studies = self.proposal.study_set.count() return num_studies > 1 - + def get_form_errors(self): """ A method providing validation of all the forms making up the proposal. @@ -162,7 +162,14 @@ def get_form_errors(self): """ troublesome_pages = [] - study_forms = [StudyForm, StudyEndForm, StudyDesignForm, InterventionForm, ObservationForm, SessionOverviewForm] + study_forms = [ + StudyForm, + StudyEndForm, + StudyDesignForm, + InterventionForm, + ObservationForm, + SessionOverviewForm, + ] for item in self.items: if item.get_errors(): @@ -176,10 +183,12 @@ def get_form_errors(self): "page_name": page_name, } ) - #As individual sessions and tasks are not represented in the - #stepper, these are validated through an external function. + # As individual sessions and tasks are not represented in the + # stepper, these are validated through an external function. if hasattr(item, "form_class") and item.form_class == SessionOverviewForm: - troublesome_pages.extend(validate_sessions_tasks(item.study, self.has_multiple_studies())) + troublesome_pages.extend( + validate_sessions_tasks(item.study, self.has_multiple_studies()) + ) return troublesome_pages diff --git a/proposals/utils/stepper_helpers.py b/proposals/utils/stepper_helpers.py index b7659d156..539348a49 100644 --- a/proposals/utils/stepper_helpers.py +++ b/proposals/utils/stepper_helpers.py @@ -89,7 +89,7 @@ def is_current(self, request): if request.path == self.get_url(): return True return False - + def is_disabled(self): if not self.get_url(): return True diff --git a/proposals/utils/validate_sessions_tasks.py b/proposals/utils/validate_sessions_tasks.py index dd6b8f776..d367b5030 100644 --- a/proposals/utils/validate_sessions_tasks.py +++ b/proposals/utils/validate_sessions_tasks.py @@ -50,11 +50,11 @@ def validate_sessions_tasks(study, multiple_studies): ), } ) - + if multiple_studies: for dict in troublesome_session_pages: dict["page_name"] = "{}: {}".format( study.name, dict["page_name"], ) - return troublesome_session_pages \ No newline at end of file + return troublesome_session_pages diff --git a/proposals/views/study_views.py b/proposals/views/study_views.py index 654a78fa5..1c8843c69 100644 --- a/proposals/views/study_views.py +++ b/proposals/views/study_views.py @@ -120,4 +120,3 @@ def get_back_url(self): """Return to the Study design view""" proposal = Proposal.objects.get(pk=self.kwargs.get("pk")) return reverse("studies:design_end", args=(proposal.last_study().pk,)) -