-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Improve event validation and option filtering for training progress and instructor badge awarding #2471
Conversation
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.
I left some comments. I think this is heading in a right direction, but I would like you to consider some of my proposals.
amy/trainings/views.py
Outdated
except ValidationError as e: | ||
errors.append(e) | ||
|
||
if len(errors) > 0: |
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.
Idiomatic Python version:
if len(errors) > 0: | |
if errors: |
I'm bumping this to the 4.3 milestone for time reasons. There's some more work needed here to address Piotr's review comments, and it's only a convenient extra to the checkout project rather than anything essential. |
… checked for filter
Co-authored-by: Piotr Banaszkiewicz <piotr@banaszkiewicz.org>
e6f916d
to
de08d5f
Compare
@pbanaszkiewicz I finally got around to addressing your comments on this PR. Ready for a re-review! |
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.
Looks good to me!
amy/trainings/utils.py
Outdated
Task.objects.get( | ||
person=trainee, | ||
event=event, | ||
role=Role.objects.get(name="learner"), |
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.
1 query less if you switch to role__name="learner"
.
) # do not save to DB as this violates the unique constraint we want to test | ||
p1.full_clean() # should be no error if only this progress exists | ||
with self.assertValidationErrors(["__all__"]): | ||
p2.full_clean() |
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.
Can you check the validation error message here?
Fixes #2342, fixes #2343 :