Commit 19026697 authored by Aymeric Barantal's avatar Aymeric Barantal

name correctly foreign key

parent 9614b0b5
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('organization', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Argumentary',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('lang', models.CharField(max_length=255)),
],
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)),
('start_date', models.DateTimeField()),
('end_date', models.DateTimeField()),
('default_lang', models.CharField(max_length=5)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='CampaignContact',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('weight', models.IntegerField(default=0)),
('campaign_id', models.ForeignKey(to='campaign.Campaign')),
],
options={
},
bases=(models.Model,),
),
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)),
('mail', models.CharField(max_length=255)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Group',
fields=[
('id', models.AutoField(serialize=False, primary_key=True)),
('name', models.CharField(max_length=64)),
('type', models.CharField(max_length=255)),
('media', models.CharField(max_length=255)),
('contacts', models.ManyToManyField(to='campaign.Contact')),
('organisation_id', models.ForeignKey(to='organization.Organization')),
],
options={
},
bases=(models.Model,),
),
migrations.AddField(
model_name='campaigncontact',
name='contact_id',
field=models.ForeignKey(to='campaign.Contact'),
preserve_default=True,
),
migrations.AddField(
model_name='argumentary',
name='campaign_id',
field=models.ForeignKey(to='campaign.Campaign'),
preserve_default=True,
),
]
......@@ -29,7 +29,7 @@ class Campaign(models.Model):
class Argumentary(models.Model):
id = models.AutoField(primary_key=True)
campaign_id = models.ForeignKey(Campaign)
campaign = models.ForeignKey(Campaign)
lang = models.CharField(max_length=255)
text = models.TextField(null=True)
......@@ -37,6 +37,6 @@ class Argumentary(models.Model):
class CampaignContact(models.Model):
"""List contact related to a campaign with a given weight"""
id = models.AutoField(primary_key=True)
campaign_id = models.ForeignKey(Campaign)
contact_id = models.ForeignKey(Contact)
campaign = models.ForeignKey(Campaign)
contact = models.ForeignKey(Contact)
weight = models.IntegerField(default=0)
from django.contrib import admin
from campaign.organization.models import Organization, Group
from campaign.organization.models import Organization, Group, FeedbackCategory
admin.site.register(Organization)
admin.site.register(Group)
admin.site.register(FeedbackCategory)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
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.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
options={
},
bases=(models.Model,),
),
]
......@@ -7,7 +7,7 @@ class Organization(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=64)
sip_key = models.CharField(max_length=255)
users = models.ForeignKey(User, null=True, blank=True)
users = models.ManyToManyField(User, null=True, blank=True)
def __unicode__(self):
return self.name
......@@ -16,7 +16,7 @@ class Organization(models.Model):
class Group(models.Model):
"""Group model to qualify contacts"""
id = models.AutoField(primary_key=True)
organisation_id = models.ForeignKey(Organization)
organisation = models.ForeignKey(Organization)
name = models.CharField(max_length=64)
type = models.CharField(max_length=255, blank=True)
media = models.CharField(max_length=255, blank=True)
......@@ -24,3 +24,11 @@ class Group(models.Model):
def __unicode__(self):
return self.name
class FeedbackCategory(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=64)
def __unicode__(self):
return self.name
......@@ -38,6 +38,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'campaign.campaign',
'campaign.organization',
'campaign.feedback',
)
MIDDLEWARE_CLASSES = (
......
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