From d28889db1a9fac70f3ff0ecb4ced1ac46c5e1ba3 Mon Sep 17 00:00:00 2001 From: Robert Raposa Date: Wed, 4 Mar 2020 10:56:52 -0500 Subject: [PATCH] delete oauth2.enforce_jwt_scopes waffle switch The code for this switch was removed in: https://github.com/edx/edx-platform/pull/23188 BOM-1324 --- ...0009_delete_enable_scopes_waffle_switch.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 openedx/core/djangoapps/oauth_dispatch/migrations/0009_delete_enable_scopes_waffle_switch.py diff --git a/openedx/core/djangoapps/oauth_dispatch/migrations/0009_delete_enable_scopes_waffle_switch.py b/openedx/core/djangoapps/oauth_dispatch/migrations/0009_delete_enable_scopes_waffle_switch.py new file mode 100644 index 0000000000..7ada16230b --- /dev/null +++ b/openedx/core/djangoapps/oauth_dispatch/migrations/0009_delete_enable_scopes_waffle_switch.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.28 on 2020-03-04 15:19 +from __future__ import unicode_literals +""" +Deletes the ENFORCE_JWT_SCOPES waffle switch that has already been deprecated and removed. + +See https://github.com/edx/edx-platform/pull/23188 for the removal +""" + +from django.db import migrations + +ENFORCE_JWT_SCOPES = 'oauth2.enforce_jwt_scopes' + + +def delete_switch(apps, schema_editor): + """ Delete the switch. """ + Switch = apps.get_model('waffle', 'Switch') + try: + Switch.objects.filter(name=ENFORCE_JWT_SCOPES).delete() + except Switch.DoesNotExist: + pass + + +def create_switch(apps, schema_editor): + """ Create the switch if it does not already exist. """ + Switch = apps.get_model('waffle', 'Switch') + Switch.objects.update_or_create(name=ENFORCE_JWT_SCOPES, defaults={'active': True}) + + +class Migration(migrations.Migration): + + dependencies = [ + ('oauth_dispatch', '0008_applicationaccess_filters'), + ] + + operations = [ + migrations.RunPython(delete_switch, reverse_code=create_switch), + ]