-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
0 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,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9 on 2016-01-26 13:41 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('sigma_core', '0009_auto_20160111_0057'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='School', | ||
fields=[ | ||
('group_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='sigma_core.Group')), | ||
('design', models.CharField(max_length=255)), | ||
], | ||
bases=('sigma_core.group',), | ||
), | ||
] |
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,7 @@ | ||
from django.db import models | ||
|
||
from sigma_core.models.group import Group | ||
|
||
|
||
class School(Group): | ||
design = models.CharField(max_length=255) |
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,22 @@ | ||
from rest_framework import serializers | ||
|
||
from sigma_core.models.school import School | ||
|
||
|
||
|
||
class BasicSchoolSerializer(serializers.ModelSerializer): | ||
""" | ||
Serialize School model without memberships. | ||
""" | ||
class Meta: | ||
model = School | ||
|
||
|
||
class SchoolSerializer(BasicSchoolSerializer): | ||
""" | ||
Serialize School model with memberships. | ||
""" | ||
class Meta: | ||
model = School | ||
|
||
memberships = serializers.PrimaryKeyRelatedField(read_only=True, many=True) |
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,15 @@ | ||
from django.http import Http404 | ||
|
||
from rest_framework import viewsets, decorators, status | ||
from rest_framework.response import Response | ||
from rest_framework.permissions import IsAuthenticated | ||
from dry_rest_permissions.generics import DRYPermissions | ||
|
||
from sigma_core.models.school import School | ||
from sigma_core.serializers.school import SchoolSerializer | ||
|
||
|
||
class SchoolViewSet(viewsets.ModelViewSet): | ||
queryset = School.objects.all() | ||
serializer_class = SchoolSerializer | ||
permission_classes = [IsAuthenticated, ]#DRYPermissions, ] |