Skip to content
Snippets Groups Projects
Commit 771ca8cd authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add the lead to the round and ensure that all OTF staff are staff

parent 80f60f14
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-02-14 17:21
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('funds', '0020_applicationsubmission_form_fields'),
]
operations = [
migrations.AddField(
model_name='round',
name='lead',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
preserve_default=False,
),
]
......@@ -274,6 +274,7 @@ class Round(WorkflowStreamForm, SubmittableStreamForm): # type: ignore
parent_page_types = ['funds.FundType']
subpage_types = [] # type: ignore
lead = models.ForeignKey(settings.AUTH_USER_MODEL, limit_choices_to={'is_staff': True})
start_date = models.DateField(default=date.today)
end_date = models.DateField(
blank=True,
......@@ -283,6 +284,7 @@ class Round(WorkflowStreamForm, SubmittableStreamForm): # type: ignore
)
content_panels = SubmittableStreamForm.content_panels + [
FieldPanel('lead'),
MultiFieldPanel([
FieldRowPanel([
FieldPanel('start_date'),
......
......@@ -69,3 +69,6 @@ class User(AbstractUser):
username = None
objects = UserManager()
def __str__(self):
return self.get_full_name()
from django.conf import settings
def make_otf_staff(backend, user, response, *args, **kwargs):
_, email_domain = user.email.split('@')
if email_domain in settings.STAFF_EMAIL_DOMAINS:
user.is_staff = True
user.save()
......@@ -298,7 +298,8 @@ SOCIAL_AUTH_URL_NAMESPACE = 'social'
# Set the Google OAuth2 credentials in ENV variables or local.py
# To create a new set of credentials, go to https://console.developers.google.com/apis/credentials
# Make sure the Google+ API is enabled for your API project
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = ['opentechfund.org']
STAFF_EMAIL_DOMAINS = ['opentechfund.org']
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = STAFF_EMAIL_DOMAINS
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
......@@ -318,6 +319,7 @@ SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
'opentech.apply.users.pipeline.make_otf_staff',
)
# Bleach Settings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment