-
Notifications
You must be signed in to change notification settings - Fork 96
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
Make the models swappable #117
Conversation
Following the pattern used in django-oauth2-toolkit
Hi @mhindery I've squashed the previous migrations and used the squashed version to apply the swappable logic. So that existing installations should still function without any issues. Doing some manual testing the PR works with: an existing installation of djangosaml2idp with previous migrations applied I haven't looked at the admin system - but typically this involves unregistering and re-registering the admin models in the overriding app. It'd be good to gauge whether you'd be interested in merging the PR as I'm currently building some functionality that depends on it. Essentially I need to add some extra fields to the ServiceProvider model |
djangosaml2idp/models.py
Outdated
@@ -16,6 +16,7 @@ | |||
from saml2 import xmldsig | |||
|
|||
from .idp import IDP | |||
from .settings import SERVICE_PROVIDER_MODEL |
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.
Shouldn't this be from django.conf import settings
? that way you're actually importing the settings proxy object.
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.
Nevermind. I looked back over the Oauth toolkit implementation and it looks like you're doing it the same way.
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 don't see any issues with this.
Again following Django-oauth-toolkits configuration, this automatically uses the overridden model in the admin, and allow for overriding of the admin model.
Hi @lgarvey , this is a great addition, I'm definitely happy to merge this in. |
Ideally this gets some documentation added as well, but that is something I can add later. Let me know if you are done and not plan any more changes in the PR, then I'll merge it. |
It all seems good from this end - one very minor point: If overriding a model, the migration for the overridden model has to run before the migrations for djangosaml2idp or else there'll be an error. The django-oauth-toolkit advises to put a run_before statement into your overriding migration to ensure they are executed in the correct order, e.g
I think the name of the squashed (and swappable) migration should be something less verbose, e.g: But aside from that everything seems good. |
This seems all good to merge now. |
Hello, Is there any reason why this PR has not been merged in upstream? |
This PR follows the pattern used in django-oauth2-toolkit - and is suggested in #90
I have a need to extend the ServiceProvider model to add some additional features so I thought I'd raise a PR to add swappable functionality. I can also add some documentation if required.
I assume unit tests aren't required as it's leveraging the swappable api in django?