Skip to content

Commit

Permalink
style: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
EdoStorm96 committed Sep 18, 2024
1 parent 3e20a88 commit d902caf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion main/templates/base/stepper.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% for item in stepper.build_stepper %}
<li>
{% if item.is_disabled %}
<div class="stepper-item disabled {{ item.css_classes }}" >
<div class="stepper-item disabled {{ item.css_classes }}">
<span class="stepper-bubble {{ bubble_size.0 }}">{% counter counter value %}</span>
<span>{{ item.title }}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion main/templates/base/stepper_item.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<li>
{% if item.is_disabled %}
<div class="stepper-item disabled {{ item.css_classes }}" >
<div class="stepper-item disabled {{ item.css_classes }}">
<span class="stepper-bubble {{ bubble_size.0 }}"></span>
<span>{{ item.title }}</span>
</div>
Expand Down
14 changes: 7 additions & 7 deletions proposals/utils/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def check(self):
self.stepper.layout = RegularProposalLayout
return [ProposalCreateChecker]


class ProposalCreateChecker(
ModelFormChecker,
):
Expand All @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand All @@ -786,7 +786,6 @@ def check(
),
]


def make_stepper_item(self):
url = reverse(
"proposals:consent",
Expand All @@ -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

Expand Down
19 changes: 14 additions & 5 deletions proposals/utils/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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():
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion proposals/utils/stepper_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions proposals/utils/validate_sessions_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
return troublesome_session_pages
1 change: 0 additions & 1 deletion proposals/views/study_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))

0 comments on commit d902caf

Please sign in to comment.