Skip to content

Commit

Permalink
Adjust testproj migrations to oauth-toolkit v1.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
glowka committed Apr 13, 2020
1 parent 6f3a16f commit 0eacfc9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion testproj/users/migrations/0002_setup_oauth2_apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Generated by Django 2.1.3 on 2018-12-19 07:57
import pkg_resources
from django.conf import settings
from django.db import migrations

Expand Down Expand Up @@ -27,10 +28,16 @@ def add_oauth_apps(apps, schema_editor):
Application.objects.get_or_create(client_id=app['client_id'], defaults=app)


def get_oauth_dependency():
oauth_version = pkg_resources.get_distribution('django-oauth-toolkit').version.split('.')[:2]
# 1.1 and 1.2 are before squasing migrations into 0001_initial
return '0006_auto_20171214_2232' if oauth_version in (('1', '1'), ('1', '2')) else '0001_initial'


class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('oauth2_provider', '0006_auto_20171214_2232'),
('oauth2_provider', get_oauth_dependency()),
('users', '0001_create_admin_user'),
]

Expand Down

0 comments on commit 0eacfc9

Please sign in to comment.