Skip to content
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

Feature/revise study end questions 4 #707

Merged
merged 24 commits into from
Oct 8, 2024

Conversation

EdoStorm96
Copy link
Contributor

fixes #546. This was an olde branch I had worked on. This implementation is not entirely what we settled on, as we initially wanted to also have a small table representing the trajectories on the Knowledge Security page if there were multiple trajectories. I do still have a template lying around for this somewhere ... But I don't think it is the most important thing now. At least we have the updated questions/texts in here now.

As far as I can tell, everything here is working well. Though there are a lot of changes, nothing too crazy happening.

@EdoStorm96 EdoStorm96 requested a review from miggol September 25, 2024 14:50
@EdoStorm96 EdoStorm96 linked an issue Sep 25, 2024 that may be closed by this pull request
@EdoStorm96 EdoStorm96 marked this pull request as ready for review September 25, 2024 14:57
Copy link
Contributor

@miggol miggol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of small remarks but nothing major, excellent turnaround

@@ -497,6 +497,42 @@ class PracticeReasons(models.IntegerChoices):
MaxWordsValidator(SELF_ASSESSMENT_MAX_WORDS),
],
)
knowledge_security = models.CharField(
_("Zijn er kwesties rondom kennisveiligheid?"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of these strings remain untranslated

@@ -862,7 +919,7 @@ class Meta:
_soft_validation_fields = ["translated_forms", "translated_forms_languages"]

def clean(self):
cleaned_data = super(TranslatedConsentForms, self).clean()
cleaned_data = super(TranslatedConsentForm, self).clean()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TranslatedConsentFormsView still uses a plural which is a tiny bit confusing


def check(self):
if self.stepper.has_multiple_studies():
self.title = _("Trajecten afronding")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch

obj = self.obj

rows_to_remove = []
for x in range(0, len(self.row_fields), 2):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such an unnecessarily complicated way to remove at most two fields. But it's kind of funny as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have kindoff a love/hate relationship with this ... I often start thinking of a way to get rid of it, but then end up spending too much time on it (again ...) and I just move on. I'll get around to it someday ;p

"risk",
"risk_details",
]
widgets = {
"deception": BootstrapRadioSelect(),
"negativity": BootstrapRadioSelect(),
"stressful": BootstrapRadioSelect(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is still mentioned in _soft_validation_fields

studies/forms.py Outdated
"risk",
)
for field in self.base_fields:
self.fields[field].empty_label = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this does anything if we set choices explicitly anyway

studies/forms.py Outdated
self.fields["stressful"].choices = YesNoDoubt.choices
self.fields["risk"].empty_label = None
self.fields["risk"].choices = YesNoDoubt.choices
self.base_fields = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we reference base_fields in clean() we should make sure we define it before calling super().__init__(). Or else the super init might call clean before base_fields is defined, resulting in an error.

I can't get this to actually happen though, so it might depend on MRO. But we know it's possible.

reviews/tests.py Outdated
self.study.save()

reasons = auto_review(self.proposal)
self.assertEqual(len(reasons), 6)

self.study.risk = YesNoDoubt.YES
self.study.researcher_risk = YesNoDoubt.YES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

researcher_risk is a proposal attribute

Nice that you thought of updating the tests though! But also remember to test your tests :)

@EdoStorm96
Copy link
Contributor Author

So, I've addressed your comments. The translations were a lot of work, because a lot of stuff was behind (#705 ...). I promise to keep translations up-to-date from now on 😔.

Most of the translations regarding this branch I've pulled from my old branch. Other things, which I've previously forgotten, I've just translated to my best intuition ... This should bring most of the translations for major/4 up to date.

@EdoStorm96 EdoStorm96 requested a review from miggol September 30, 2024 15:08
@EdoStorm96 EdoStorm96 linked an issue Sep 30, 2024 that may be closed by this pull request
@EdoStorm96
Copy link
Contributor Author

Ok, I've also adressed a dead link on index.html here. I ran into this during the translations. fixes #710.

@EdoStorm96 EdoStorm96 linked an issue Oct 1, 2024 that may be closed by this pull request
@EdoStorm96
Copy link
Contributor Author

Woops, so I missed the issue with the tests you pointed out, which turned me onto the other issue with the tests, that we discussed earlier.

Copy link
Contributor

@miggol miggol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With every PR things are looking better and better, on both the code and application side. Having a hard time keeping up with all the improvements.

I wanted to mention that the diff page needs a new lick of paint but I see there's already an issue for that (#706).

Because this branch as is does have breaking errors I'm not approving right now but I expect the fixes to be simple.

studies/forms.py Outdated
"""

self.base_fields = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay whoops, there's another issue with this. Turns out that self.base_fields is a reserved attribute used in BaseModelForm which in fact messes with form initialization.

I assume that's just a coincidence and you did not intend to name it that way specifically, so renaming self.base_fields to something like self.choice_fields should resolve the resulting AttributeError.

@@ -29,7 +29,7 @@
class StudyForm(SoftValidationMixin, ConditionalModelForm):

age_groups_header = TemplatedFormTextField(
header=_("De leeftijdsgroup van je deelnemers"), header_element="h4"
header=_("De leeftijdsgroep van je deelnemers"), header_element="h4"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had such a hard time discerning what actually changed here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful

reviews/tests.py Outdated
self.study.save()

reasons = auto_review(self.proposal)
self.assertEqual(len(reasons), 6)

self.study.risk = YesNoDoubt.YES
self.study.proposal.researcher_risk = YesNoDoubt.YES
self.study.save()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests seem to pass fine without saving the object. But if you could save the proposal object here instead of the study at least it will be internally consistent, should there be a case (in the future) where saving does matter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, way better like this. Backslashes stress me out

@@ -1029,15 +1051,17 @@ def create_context_pdf(context, model):
sections.append(StudyOverviewSection(study))
sections.append(InformedConsentFormsSection(study.documents))

extra_documents = get_extra_documents(model)
sections.append(KnowledgeSecuritySection(proposal))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When generating a PDF for a proposal with sessions, line 1050 causes an error. I suspect this is just a mismatched indent and that the line just needs one more indentation level.

This doesn't seem to be related to this PR in particular, so I couldn't select the specific line in this review. But if you could quickly fix it here that would be great.

@EdoStorm96 EdoStorm96 requested a review from miggol October 2, 2024 13:24
Copy link
Contributor

@miggol miggol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

@EdoStorm96 EdoStorm96 merged commit 262cc6a into major/4 Oct 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra question re knowledge security and safety researchers fix dead links on index.html Translations
2 participants