Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'andreif-feature/support-django2'
- Loading branch information
Showing
11 changed files
with
100 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# coding=utf-8 | ||
import six | ||
import django | ||
from django.db import models | ||
|
||
if django.VERSION >= (2, 0): | ||
from django.urls import reverse | ||
else: | ||
from django.core.urlresolvers import reverse | ||
|
||
|
||
def get_rel_model(field): | ||
if django.VERSION >= (2, 0): | ||
return field.model | ||
|
||
user_model = field.rel.to | ||
if isinstance(user_model, six.string_types): | ||
app_label, model_name = user_model.split('.') | ||
user_model = models.get_model(app_label, model_name) | ||
return user_model |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# coding=utf-8 | ||
import django | ||
from django.conf.urls import include | ||
from django.contrib import admin | ||
|
||
if django.VERSION < (1, 9): | ||
admin_urls = include(admin.site.urls) | ||
else: | ||
admin_urls = admin.site.urls |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 | ||
from __future__ import unicode_literals, absolute_import | ||
|
||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase | ||
from social_django.compat import reverse | ||
from social_django.models import UserSocialAuth | ||
|
||
|
||
class SocialAdminTest(TestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
User = get_user_model() | ||
User.objects.create_superuser( | ||
username='admin', email='admin@test.com', first_name='Admin', | ||
password='super-duper-test' | ||
) | ||
|
||
def test_admin_app_name(self): | ||
"""The App name in the admin index page""" | ||
self.client.login(username='admin', password='super-duper-test') | ||
response = self.client.get(reverse('admin:index')) | ||
self.assertContains(response, "Social_Django") | ||
|
||
def test_social_auth_changelist(self): | ||
"""The App name in the admin index page""" | ||
self.client.login(username='admin', password='super-duper-test') | ||
meta = UserSocialAuth._meta | ||
url_name = 'admin:%s_%s_changelist' % (meta.app_label, meta.model_name) | ||
self.client.get(reverse(url_name)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
# -*- coding: utf-8 | ||
from django.conf.urls import url, include | ||
from .compat import admin_urls | ||
|
||
from social_django.urls import urlpatterns as social_django_urls | ||
|
||
urlpatterns = [ | ||
url(r'^', include(social_django_urls, namespace='social')), | ||
url(r'^admin/', admin_urls), | ||
url(r'^', include('social_django.urls', namespace='social')), | ||
] |
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