-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments and simplifications. #531
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -804,11 +804,14 @@ def is_certificate_required(self): | |
|
||
@property | ||
def description(self) -> str: | ||
out: list[str] = [] | ||
""" | ||
Human-readable description built from associated actions and conditions. | ||
|
||
out.append( | ||
f"Condition of type {self.condition_code.code} - {self.condition_code.description}", | ||
) | ||
:dependencies: with_reference_price_string must be called in queries using this property. | ||
""" | ||
out: list[str] = [ | ||
f"Condition of type {self.condition_code.code} - {self.condition_code.description}" | ||
] | ||
|
||
if self.required_certificate: | ||
out.append( | ||
|
@@ -829,29 +832,37 @@ def description(self) -> str: | |
|
||
@property | ||
def condition_string(self) -> str: | ||
out: list[str] = [] | ||
""" | ||
Returns a string representation of the component conditions. | ||
|
||
components = self.components.latest_approved() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
This is the duty_sentence, if there is one measure, measure_type and additional_code or | ||
if there are more than one measure_type and additional_code. | ||
|
||
:dependencies: with_duty_sentence must be called in queries using this property. | ||
""" | ||
Comment on lines
834
to
+842
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this method even used anywhere? I've never really understood what it is meant to be showing? |
||
measures: set[str] = set() | ||
measure_types: set[str] = set() | ||
additional_codes: set[str] = set() | ||
|
||
for mcc in components: | ||
measures.add(mcc.condition.dependent_measure.sid) | ||
measure_types.add(mcc.condition.dependent_measure.measure_type.sid) | ||
if mcc.condition.dependent_measure.additional_code: | ||
for mcc in self.components.latest_approved(): | ||
# TODO ^ select_related condition_measure, condition_measure.measure_type ? | ||
condition_measure = mcc.condition.dependent_measure | ||
|
||
measures.add(condition_measure.sid) | ||
measure_types.add(condition_measure.measure_type.sid) | ||
if condition_measure.additional_code: | ||
additional_codes.add( | ||
mcc.condition.dependent_measure.additional_code.sid, | ||
condition_measure.additional_code.sid, | ||
) | ||
|
||
if ( | ||
len(measures) == len(measure_types) == len(additional_codes) == 1 | ||
or len(measure_types) > 1 | ||
or len(additional_codes) > 1 | ||
): | ||
out.append(self.duty_sentence) | ||
return self.duty_sentence | ||
|
||
return "".join(out) | ||
return "" | ||
|
||
|
||
class MeasureConditionComponent(TrackedModel): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So instead of overriding form_valid (which also calls form_invalid) on
TrackedModelChangeView
should we instead override the post call do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably - at the moment I was getting a load of test failures with this change, I need to get past.
Though, this may be another issue as since I re-setup my env again, I noticed I am getting them in plain master now :(