Commit 946d9d6d authored by Mindiell's avatar Mindiell

Correcting REST API for rest_framework v3. Plus migrations

parent 794941fd
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('contact', '0001_initial'),
('organization', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Argumentary',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('lang', models.CharField(max_length=5, verbose_name='language', choices=[(b'en', 'English'), (b'de', 'German'), (b'fr', 'French')])),
('text', models.TextField(null=True)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Campaign',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('title', models.CharField(max_length=255)),
('description', models.CharField(max_length=512, blank=True)),
('start_date', models.DateField()),
('end_date', models.DateField()),
('default_lang', models.CharField(max_length=5, verbose_name='language', choices=[(b'en', 'English'), (b'de', 'German'), (b'fr', 'French')])),
('organization', models.ForeignKey(related_name='campaigns', to='organization.Organization')),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='CampaignContact',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('weight', models.IntegerField(default=0)),
('campaign', models.ForeignKey(to='campaign.Campaign')),
('contact', models.ForeignKey(to='contact.Contact')),
],
options={
},
bases=(models.Model,),
),
migrations.AddField(
model_name='argumentary',
name='campaign',
field=models.ForeignKey(to='campaign.Campaign'),
preserve_default=True,
),
]
......@@ -20,14 +20,15 @@ class CampaignSerializer(serializers.HyperlinkedModelSerializer):
class CampaignContactSerializer(serializers.HyperlinkedModelSerializer):
first_name = serializers.Field(source='contact.first_name')
last_name = serializers.Field(source='contact.last_name')
phone = serializers.Field(source='contact.phone')
full_name = serializers.ReadOnlyField(source='contact.full_name')
first_name = serializers.ReadOnlyField(source='contact.first_name')
last_name = serializers.ReadOnlyField(source='contact.last_name')
phone = serializers.ReadOnlyField(source='contact.phone')
groups = GroupSerializer(many=True, source='contact.groups')
contact_id = serializers.Field(source='contact.id')
photo = serializers.Field(source='contact.get_photo_url')
contact_id = serializers.ReadOnlyField(source='contact.id')
photo = serializers.ReadOnlyField(source='contact.get_photo_url')
class Meta:
model = CampaignContact
fields = ('id', 'weight', 'contact_id',
'first_name', 'last_name', 'phone', 'groups', 'photo')
'full_name', 'first_name', 'last_name', 'phone', 'groups', 'photo')
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Contact',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('first_name', models.CharField(max_length=64)),
('last_name', models.CharField(max_length=64)),
('phone', models.CharField(max_length=32)),
('twitter', models.CharField(max_length=64, blank=True)),
('mail', models.CharField(max_length=255, blank=True)),
('photo', models.ImageField(upload_to=b'contacts/photos', blank=True)),
],
options={
},
bases=(models.Model,),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('campaign', '0001_initial'),
('organization', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Feedback',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('comment', models.CharField(max_length=512, blank=True)),
('callee', models.ForeignKey(to='campaign.CampaignContact')),
('category', models.ForeignKey(to='organization.FeedbackCategory')),
],
options={
},
bases=(models.Model,),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('contact', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='FeedbackCategory',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('name', models.CharField(max_length=64)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Group',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('name', models.CharField(max_length=64)),
('media', models.CharField(max_length=255, blank=True)),
('contacts', models.ManyToManyField(related_name='groups', null=True, to='contact.Contact', blank=True)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='GroupType',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('name', models.CharField(max_length=64)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Organization',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('name', models.CharField(max_length=64)),
('sip_key', models.CharField(max_length=255)),
('users', models.ManyToManyField(related_name='organizations', null=True, to=settings.AUTH_USER_MODEL, blank=True)),
],
options={
},
bases=(models.Model,),
),
migrations.AddField(
model_name='grouptype',
name='organization',
field=models.ForeignKey(to='organization.Organization'),
preserve_default=True,
),
migrations.AddField(
model_name='group',
name='organization',
field=models.ForeignKey(to='organization.Organization'),
preserve_default=True,
),
migrations.AddField(
model_name='group',
name='type',
field=models.ForeignKey(blank=True, to='organization.GroupType', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='feedbackcategory',
name='organization',
field=models.ForeignKey(to='organization.Organization'),
preserve_default=True,
),
]
......@@ -10,7 +10,7 @@ class CategorySerializer(serializers.ModelSerializer):
class GroupSerializer(serializers.ModelSerializer):
type = serializers.Field(source='type.name')
type = serializers.ReadOnlyField(source='type.name')
class Meta:
model = Group
......
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