Commit c9fda0e6 authored by Cornee Traas's avatar Cornee Traas
Browse files

Add organization field to user

parent fbc37d2e
......@@ -14,6 +14,7 @@ def test_serialize_user(user):
"email": "john.doe@example.com",
"display_name": "John Doe",
"role": User.TEACHER,
"organization": "",
"courses": [],
}
......
......@@ -9,7 +9,7 @@ from oauth2_provider.models import Application, Grant
from courses.serializers import CourseSerializer
from users.models import User
USER_FIELDS = {"pk", "email", "display_name", "role", "courses"}
USER_FIELDS = {"pk", "email", "display_name", "role", "organization", "courses"}
@pytest.mark.django_db
......@@ -72,6 +72,7 @@ def test_user_viewset_detail(admin_api_client, user):
"email": "john.doe@example.com",
"display_name": "John Doe",
"role": User.TEACHER,
"organization": "",
"courses": [],
}, "response returned unexpected data"
......
......@@ -7,7 +7,7 @@ from users.models import User
class UserAdmin(BaseUserAdmin):
fieldsets = (
(None, {"fields": ("email", "password", "role", "courses")}),
(None, {"fields": ("email", "password", "role", "organization", "courses")}),
(_("Personal info"), {"fields": ("display_name",)}),
(
_("Permissions"),
......
# Generated by Django 2.1.1 on 2018-10-22 07:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0009_auto_20181002_1046'),
]
operations = [
migrations.AddField(
model_name='user',
name='organization',
field=models.CharField(blank=True, max_length=100),
),
]
......@@ -42,6 +42,7 @@ class User(AbstractUser):
ROLES = ((TEACHER, "Teacher"), (QDT, "Quality & Design Team"), (ADMIN, "Admin"))
role = models.CharField(max_length=10, choices=ROLES, blank=True)
organization = models.CharField(max_length=100, blank=True)
courses = models.ManyToManyField("courses.Course")
USERNAME_FIELD = "email"
......
......@@ -14,7 +14,7 @@ from users.models import User
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ["pk", "email", "display_name", "role", "courses"]
fields = ["pk", "email", "display_name", "role", "organization", "courses"]
courses = CourseSerializer(many=True)
......
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