user lookup util

This commit is contained in:
Zach Hancock
2019-04-16 11:26:57 -04:00
committed by Alex Dusenbery
parent 03db25bd50
commit afe3cdb3ec
5 changed files with 257 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-04-18 20:33
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('organizations', '0006_auto_20171207_0259'),
('third_party_auth', '0022_auto_20181012_0307'),
]
operations = [
migrations.AddField(
model_name='ltiproviderconfig',
name='organization',
field=models.OneToOneField(blank=True, help_text="optional. If this provider is an Organization, this attribute can be used reference users in that Organization", null=True, on_delete=django.db.models.deletion.CASCADE, to='organizations.Organization'),
),
migrations.AddField(
model_name='oauth2providerconfig',
name='organization',
field=models.OneToOneField(blank=True, help_text="optional. If this provider is an Organization, this attribute can be used reference users in that Organization", null=True, on_delete=django.db.models.deletion.CASCADE, to='organizations.Organization'),
),
migrations.AddField(
model_name='samlproviderconfig',
name='organization',
field=models.OneToOneField(blank=True, help_text="optional. If this provider is an Organization, this attribute can be used reference users in that Organization", null=True, on_delete=django.db.models.deletion.CASCADE, to='organizations.Organization'),
),
]

View File

@@ -16,6 +16,7 @@ from django.core.exceptions import ValidationError
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from organizations.models import Organization
from provider.oauth2.models import Client
from provider.utils import long_token
from social_core.backends.base import BaseAuth
@@ -125,6 +126,16 @@ class ProviderConfig(ConfigurationModel):
'in a separate list of "Institution" login providers.'
),
)
organization = models.OneToOneField(
Organization,
blank=True,
null=True,
on_delete=models.CASCADE,
help_text=_(
'optional. If this provider is an Organization, this attribute '
'can be used reference users in that Organization'
)
)
site = models.ForeignKey(
Site,
default=settings.SITE_ID,

View File

@@ -64,9 +64,10 @@ class Oauth2ProviderConfigAdminTest(testutil.TestCase):
# Remove the icon_image from the POST data, to simulate unchanged icon_image
post_data = models.model_to_dict(provider1)
del post_data['icon_image']
# Remove max_session_length; it has a default null value which must be POSTed
# Remove max_session_length and organization. A default null value must be POSTed
# back as an absent value, rather than as a "null-like" included value.
del post_data['max_session_length']
del post_data['organization']
# Change the name, to verify POST
post_data['name'] = 'Another name'