Commit c4c44503 authored by Benoit Alessandroni's avatar Benoit Alessandroni

Adding custom country field

parent 79dd84c4
[
{
"model": "coopstarter_data.country",
"pk": 1,
"fields": {
"name": "France",
"code": "AF"
}
},
{
"model": "coopstarter_data.country",
"pk": 2,
"fields": {
"name": "United Kingdom",
"code": "GB"
}
}
]
......@@ -2,7 +2,6 @@ from django.db import models
from django.core.mail import send_mail
from djangoldp.models import Model
from django.conf import settings
from django_countries.fields import CountryField
from django.contrib.auth import get_user_model
from django.db.models.signals import post_save, m2m_changed
from django.dispatch import receiver
......@@ -12,6 +11,13 @@ from django.utils import timezone
from django.template import loader
class Country (Model):
code = models.CharField(max_length=2, verbose_name="ISO Code")
name = models.CharField(max_length=64, verbose_name="Country name")
def __str__(self):
return self.name
class Language (Model):
code = models.CharField(max_length=2, verbose_name="ISO Code")
name = models.CharField(max_length=64, verbose_name="Language name")
......@@ -60,7 +66,7 @@ class Type (Model):
class Entrepreneur(Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name="entrepreneur_profile")
organisation = models.ForeignKey(Organisation, null=True, on_delete=models.CASCADE)
organisation = models.ForeignKey(Organisation, null=True, on_delete=models.CASCADE, related_name="entrepreneurs")
class Meta:
auto_author = 'user'
......@@ -79,8 +85,8 @@ class Entrepreneur(Model):
class Mentor(Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name="mentor_profile")
phone = models.CharField(max_length=25, null=True, blank=True, verbose_name='Phone number')
organisation = models.ForeignKey(Organisation, null=True, on_delete=models.CASCADE)
country = CountryField(blank=True)
organisation = models.ForeignKey(Organisation, null=True, on_delete=models.CASCADE, related_name="mentors")
country = models.ForeignKey(Country, null=True, related_name="mentors")
languages = models.ManyToManyField(Language, blank=True)
headline = models.CharField(max_length=256, blank=True, verbose_name='Headline or current position')
......@@ -112,7 +118,7 @@ class Mentor(Model):
class Review (Model):
comment = models.TextField(verbose_name="Comment", blank=True)
status = models.CharField(max_length=32, choices=(('pending', 'Pending'), ('inappropriate', 'Inappropriate'), ('validated', 'Validated'), ('to_improve', 'Improvement required')), verbose_name="Resource status", blank=True, null=True)
reviewer = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, on_delete=models.CASCADE, related_name='reviews')
reviewer = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE, related_name='reviews')
class Meta:
owner_field = 'reviewer'
......@@ -135,7 +141,7 @@ class Resource (Model):
publication_year = models.IntegerField(verbose_name="Publication Year")
language = models.ForeignKey(Language, blank=True, verbose_name="Language", related_name='resources')
fields = models.ManyToManyField(Field, blank=True, related_name='resources')
country = CountryField(verbose_name="Country of publication", blank=True)
country = models.ForeignKey(Country, null=True)
uri = models.CharField(max_length=4086, verbose_name="Location/weblink")
author = models.CharField(max_length=32, verbose_name="Author")
skills = models.TextField(verbose_name="Learning outcomes/skills")
......@@ -188,7 +194,7 @@ class Request (Model):
language = models.ForeignKey(Language, blank=True, verbose_name="Language")
fields = models.ManyToManyField(Field, blank=True)
country = CountryField(verbose_name="Country of publication", blank=True)
country = models.ForeignKey(Country, null=True)
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE, related_name="requests")
skills = models.TextField(verbose_name="Learning outcomes/skills")
......
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