-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
27 changed files
with
336 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
benefits/core/migrations/0017_refactor_authprovider_claimsprovider.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Generated by Django 5.0.7 on 2024-08-02 22:52 | ||
|
||
from django.contrib.auth.management import create_permissions | ||
from django.db import migrations, models | ||
|
||
import benefits.core.models | ||
import benefits.secrets | ||
|
||
|
||
def create_all_permissions(apps, schema_editor): | ||
for app_config in apps.get_app_configs(): | ||
app_config.models_module = True | ||
create_permissions(app_config, apps=apps, verbosity=0) | ||
app_config.models_module = None | ||
|
||
|
||
def update_permissions(apps, schema_editor): | ||
# delete old permissions | ||
Permission = apps.get_model("auth", "Permission") | ||
old_permission_names = [ | ||
"Can view auth provider", | ||
"Can change auth provider", | ||
"Can add auth provider", | ||
"Can delete auth provider", | ||
] | ||
|
||
for name in old_permission_names: | ||
old_permission = Permission.objects.get(name=name) | ||
old_permission.delete() | ||
|
||
# add new permissions to staff group | ||
Group = apps.get_model("auth", "Group") | ||
staff_group = Group.objects.get(name="Cal-ITP") | ||
|
||
Permission = apps.get_model("auth", "Permission") | ||
new_permission_names = ["Can view claims provider", "Can change claims provider"] | ||
|
||
for name in new_permission_names: | ||
new_permission = Permission.objects.get(name=name) | ||
staff_group.permissions.add(new_permission) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0016_refactor_paymentprocessor_transitprocessor"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name="AuthProvider", | ||
new_name="ClaimsProvider", | ||
), | ||
migrations.RunPython(create_all_permissions), # this is needed to create the new permissions for the renamed model | ||
migrations.RunPython(update_permissions), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="authority", | ||
field=models.TextField(help_text="The fully qualified HTTPS domain name for an OAuth authority server"), | ||
), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="claim", | ||
field=models.TextField( | ||
blank=True, help_text="The name of the claim (name/value pair) that is used to verify eligibility", null=True | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="client_id_secret_name", | ||
field=benefits.core.models.SecretNameField( | ||
help_text="The name of the secret containing the client ID for this claims provider", | ||
max_length=127, | ||
validators=[benefits.secrets.SecretNameValidator()], | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="client_name", | ||
field=models.TextField(help_text="Unique identifier used to register this claims provider with Authlib registry"), | ||
), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="scheme", | ||
field=models.TextField(help_text="The authentication scheme to use"), | ||
), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="scope", | ||
field=models.TextField( | ||
blank=True, | ||
help_text="A space-separated list of identifiers used to specify what access privileges are being requested", | ||
null=True, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="sign_out_button_template", | ||
field=models.TextField(blank=True, help_text="Template that renders sign-out button", null=True), | ||
), | ||
migrations.AlterField( | ||
model_name="claimsprovider", | ||
name="sign_out_link_template", | ||
field=models.TextField(blank=True, help_text="Template that renders sign-out link", null=True), | ||
), | ||
migrations.RenameField( | ||
model_name="eligibilityverifier", | ||
old_name="auth_provider", | ||
new_name="claims_provider", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.