-
Notifications
You must be signed in to change notification settings - Fork 26
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
Refactor payments module to apply plugin mechanism consistently #4921
Refactor payments module to apply plugin mechanism consistently #4921
Conversation
…ently All other modules operate on the idea that the generic code populates the plugin options from the generic information and the specified options serializer, which allows plugins to be generically typed and not needing to perform additional input validation or conversion from the raw JSON data for the options to the Python/Django objects that are easier to work with. This does change the public API of the registry/plugins to take an extra argument, but enables us to apply static type checking (which already reveals some problems) and simpler plugin code.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4921 +/- ##
=======================================
Coverage 96.58% 96.59%
=======================================
Files 757 758 +1
Lines 25783 25798 +15
Branches 3390 3390
=======================================
+ Hits 24902 24919 +17
+ Misses 616 613 -3
- Partials 265 266 +1 ☔ View full report in Codecov by Sentry. |
Rather than just type-checking some files, we are close enough to type check most of the package and instead skip some files/subpackages with known (but not critical) type checking issues. Here and there we need to suppress some errors because the Django ORM magic is too much for Pyright.
dbdba94
to
e9aa4d7
Compare
@@ -127,7 +126,6 @@ def expected_parameters(self): | |||
class FormAdmin( | |||
FormioConfigMixin, | |||
RegistrationBackendFieldMixin, | |||
PaymentBackendChoiceFieldMixin, |
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.
irrelevant/unused because we only support the React-based change form page.
return_method = "GET" | ||
webhook_method = "POST" | ||
configuration_options = EmptyOptions | ||
configuration_options: type[serializers.Serializer] = EmptyOptions | ||
|
||
# override | ||
|
||
def start_payment( | ||
self, | ||
request: HttpRequest, |
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.
this stays HttpRequest because it's called outside of DRF views too
) -> PaymentInfo: | ||
raise NotImplementedError() | ||
|
||
def handle_return( | ||
self, request: HttpRequest, payment: "SubmissionPayment" | ||
self, | ||
request: Request, |
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.
changed to DRF request because plugin code is accessing DRF-specific properties that don't exist on HttpRequest
Part of #3457 - doing the refactor before making the required changes
All other modules operate on the idea that the generic code populates the plugin options from the generic information and the specified options serializer, which allows plugins to be generically typed and not needing to perform additional input validation or conversion from the raw JSON data for the options to the Python/Django objects that are easier to work with.
This does change the public API of the registry/plugins to take an extra argument, but enables us to apply static type checking (which already reveals some problems) and simpler plugin code.
Checklist
Check off the items that are completed or not relevant.
Impact on features
Release management
I have updated the translations assets (you do NOT need to provide translations)
./bin/makemessages_js.sh
./bin/compilemessages_js.sh
Dockerfile/scripts
./bin
folderCommit hygiene