Commit b9b87f9b by Muzaffar yousaf

Merge pull request #11949 from edx/fix-migrations

Making migrations in-sync with models.
parents 68ae1325 2e0a9b26
...@@ -13,14 +13,23 @@ from .models import ( ...@@ -13,14 +13,23 @@ from .models import (
SAMLConfiguration, SAMLConfiguration,
SAMLProviderData, SAMLProviderData,
LTIProviderConfig, LTIProviderConfig,
ProviderApiPermissions ProviderApiPermissions,
_PSA_OAUTH2_BACKENDS,
_PSA_SAML_BACKENDS
) )
from .tasks import fetch_saml_metadata from .tasks import fetch_saml_metadata
from third_party_auth.provider import Registry from third_party_auth.provider import Registry
class OAuth2ProviderConfigForm(forms.ModelForm):
""" Django Admin form class for OAuth2ProviderConfig """
backend_name = forms.ChoiceField(choices=((name, name) for name in _PSA_OAUTH2_BACKENDS))
class OAuth2ProviderConfigAdmin(KeyedConfigurationModelAdmin): class OAuth2ProviderConfigAdmin(KeyedConfigurationModelAdmin):
""" Django Admin class for OAuth2ProviderConfig """ """ Django Admin class for OAuth2ProviderConfig """
form = OAuth2ProviderConfigForm
def get_list_display(self, request): def get_list_display(self, request):
""" Don't show every single field in the admin change list """ """ Don't show every single field in the admin change list """
return ( return (
...@@ -31,8 +40,15 @@ class OAuth2ProviderConfigAdmin(KeyedConfigurationModelAdmin): ...@@ -31,8 +40,15 @@ class OAuth2ProviderConfigAdmin(KeyedConfigurationModelAdmin):
admin.site.register(OAuth2ProviderConfig, OAuth2ProviderConfigAdmin) admin.site.register(OAuth2ProviderConfig, OAuth2ProviderConfigAdmin)
class SAMLProviderConfigForm(forms.ModelForm):
""" Django Admin form class for SAMLProviderConfig """
backend_name = forms.ChoiceField(choices=((name, name) for name in _PSA_SAML_BACKENDS))
class SAMLProviderConfigAdmin(KeyedConfigurationModelAdmin): class SAMLProviderConfigAdmin(KeyedConfigurationModelAdmin):
""" Django Admin class for SAMLProviderConfig """ """ Django Admin class for SAMLProviderConfig """
form = SAMLProviderConfigForm
def get_list_display(self, request): def get_list_display(self, request):
""" Don't show every single field in the admin change list """ """ Don't show every single field in the admin change list """
return ( return (
......
...@@ -212,7 +212,7 @@ class OAuth2ProviderConfig(ProviderConfig): ...@@ -212,7 +212,7 @@ class OAuth2ProviderConfig(ProviderConfig):
prefix = 'oa2' prefix = 'oa2'
KEY_FIELDS = ('backend_name', ) # Backend name is unique KEY_FIELDS = ('backend_name', ) # Backend name is unique
backend_name = models.CharField( backend_name = models.CharField(
max_length=50, choices=[(name, name) for name in _PSA_OAUTH2_BACKENDS], blank=False, db_index=True, max_length=50, blank=False, db_index=True,
help_text=( help_text=(
"Which python-social-auth OAuth2 provider backend to use. " "Which python-social-auth OAuth2 provider backend to use. "
"The list of backend choices is determined by the THIRD_PARTY_AUTH_BACKENDS setting." "The list of backend choices is determined by the THIRD_PARTY_AUTH_BACKENDS setting."
...@@ -265,7 +265,7 @@ class SAMLProviderConfig(ProviderConfig): ...@@ -265,7 +265,7 @@ class SAMLProviderConfig(ProviderConfig):
prefix = 'saml' prefix = 'saml'
KEY_FIELDS = ('idp_slug', ) KEY_FIELDS = ('idp_slug', )
backend_name = models.CharField( backend_name = models.CharField(
max_length=50, default='tpa-saml', choices=[(name, name) for name in _PSA_SAML_BACKENDS], blank=False, max_length=50, default='tpa-saml', blank=False,
help_text="Which python-social-auth provider backend to use. 'tpa-saml' is the standard edX SAML backend.") help_text="Which python-social-auth provider backend to use. 'tpa-saml' is the standard edX SAML backend.")
idp_slug = models.SlugField( idp_slug = models.SlugField(
max_length=30, db_index=True, max_length=30, db_index=True,
......
...@@ -4,13 +4,16 @@ import ddt ...@@ -4,13 +4,16 @@ import ddt
import threading import threading
import time import time
import unittest import unittest
from unittest import skipIf
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.management import call_command
from django.conf import settings
from django.db import connection, IntegrityError from django.db import connection, IntegrityError
from django.db.transaction import atomic, TransactionManagementError from django.db.transaction import atomic, TransactionManagementError
from django.test import TestCase, TransactionTestCase from django.test import TestCase, TransactionTestCase
from util.db import commit_on_success, generate_int_id, outer_atomic from util.db import commit_on_success, generate_int_id, outer_atomic, NoOpMigrationModules
@ddt.ddt @ddt.ddt
...@@ -161,3 +164,17 @@ class GenerateIntIdTestCase(TestCase): ...@@ -161,3 +164,17 @@ class GenerateIntIdTestCase(TestCase):
for i in range(times): for i in range(times):
int_id = generate_int_id(minimum, maximum, used_ids) int_id = generate_int_id(minimum, maximum, used_ids)
self.assertIn(int_id, list(set(range(minimum, maximum + 1)) - used_ids)) self.assertIn(int_id, list(set(range(minimum, maximum + 1)) - used_ids))
class MigrationTests(TestCase):
"""
Tests for migrations.
"""
@skipIf(isinstance(settings.MIGRATION_MODULES, NoOpMigrationModules), 'Skip in case of NoOpMigrationModules')
def test_migrations_are_in_sync(self):
"""
Tests that the migration files are in sync with the models.
If this fails, you needs to run the Django command makemigrations.
"""
with self.assertRaises(SystemExit):
call_command('makemigrations', '-e')
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('commerce', '0002_commerceconfiguration'),
]
operations = [
migrations.AlterModelOptions(
name='commerceconfiguration',
options={},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import provider.utils
class Migration(migrations.Migration):
dependencies = [
('lti_provider', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='lticonsumer',
name='consumer_secret',
field=models.CharField(default=provider.utils.short_token, unique=True, max_length=32),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ccxcon', '0001_initial_ccxcon_model'),
]
operations = [
migrations.AlterModelOptions(
name='ccxcon',
options={'verbose_name': 'CCX Connector', 'verbose_name_plural': 'CCX Connectors'},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('coursetalk', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='coursetalkwidgetconfiguration',
name='platform_key',
field=models.CharField(help_text='The platform key associates CourseTalk widgets with your platform. Generally, it is the domain name for your platform. For example, if your platform is http://edx.org, the platform key is "edx".', max_length=50),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('credentials', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='credentialsapiconfig',
options={},
),
]
...@@ -39,7 +39,7 @@ djangorestframework-oauth==1.1.0 ...@@ -39,7 +39,7 @@ djangorestframework-oauth==1.1.0
edx-ccx-keys==0.1.2 edx-ccx-keys==0.1.2
edx-lint==0.4.3 edx-lint==0.4.3
edx-management-commands==0.0.1 edx-management-commands==0.0.1
edx-django-oauth2-provider==1.0.1 edx-django-oauth2-provider==1.0.2
edx-oauth2-provider==1.0.0 edx-oauth2-provider==1.0.0
edx-opaque-keys==0.2.1 edx-opaque-keys==0.2.1
edx-organizations==0.4.0 edx-organizations==0.4.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment