Skip to content

Commit

Permalink
feat: addresses #17 & #21, adds more models to support survey
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed Mar 29, 2020
1 parent 95a7d3a commit 2bb5470
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 12 deletions.
39 changes: 39 additions & 0 deletions accounts/migrations/0023_auto_20200327_2153.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 3.0.3 on 2020-03-27 21:53

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('accounts', '0022_auto_20200324_0013'),
]

operations = [
migrations.AlterField(
model_name='socialnetwork',
name='base_url',
field=models.URLField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='socialnetwork',
name='url',
field=models.URLField(max_length=255),
),
migrations.AlterField(
model_name='source',
name='url',
field=models.URLField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='user',
name='role',
field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='accounts.Role'),
),
migrations.AlterField(
model_name='user',
name='url',
field=models.URLField(blank=True, default='', max_length=255),
),
]
10 changes: 5 additions & 5 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def __str__(self):
class SocialNetwork(models.Model):
name = models.CharField(blank=False, max_length=255)
description = models.TextField(blank=True, default='')
url = models.CharField(blank=False, max_length=255)
url = models.URLField(blank=False, max_length=255)
format = models.CharField(blank=False, max_length=8, choices=[('handle', 'handle'), ('url', 'url')])
base_url = models.CharField(blank=True, max_length=255)
base_url = models.URLField(blank=True, max_length=255)
font_awesome = models.CharField(blank=True, max_length=32)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Expand All @@ -69,7 +69,7 @@ def __str__(self):
class Source(models.Model):
name = models.CharField(blank=False, max_length=255, unique=True)
description = models.CharField(blank=True, max_length=255)
url = models.CharField(blank=True, max_length=255)
url = models.URLField(blank=True, max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Expand All @@ -93,9 +93,9 @@ class User(AbstractUser):
state = models.CharField(blank=True, default='', max_length=255)
postal_code = models.CharField(blank=True, default='', max_length=255)
country = CountryField(blank=True)
url = models.CharField(blank=True, default='', max_length=255)
url = models.URLField(blank=True, default='', max_length=255)
geom = models.PointField(blank=True, null=True)
role = models.ForeignKey(Role, on_delete=models.CASCADE)
role = models.ForeignKey(Role, blank=False, default='', on_delete=models.CASCADE)
socialnetworks = models.ManyToManyField(SocialNetwork, through='UserSocialNetwork')
notes = models.TextField(blank=True, default='')
source = models.ForeignKey(Source, on_delete=models.CASCADE, default=5)
Expand Down
48 changes: 48 additions & 0 deletions mdi/migrations/0047_auto_20200327_2153.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 3.0.3 on 2020-03-27 21:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mdi', '0046_auto_20200325_1825'),
]

operations = [
migrations.AddField(
model_name='organization',
name='logo_url',
field=models.URLField(blank=True, default='', max_length=255),
),
migrations.AddField(
model_name='organization',
name='media_url',
field=models.URLField(blank=True, default='', max_length=255),
),
migrations.AlterField(
model_name='license',
name='url',
field=models.URLField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='organization',
name='admin_email',
field=models.EmailField(default='', max_length=255),
),
migrations.AlterField(
model_name='organization',
name='email',
field=models.EmailField(max_length=255),
),
migrations.AlterField(
model_name='organization',
name='url',
field=models.URLField(blank=True, default='', max_length=255),
),
migrations.AlterField(
model_name='tool',
name='url',
field=models.URLField(max_length=255),
),
]
15 changes: 8 additions & 7 deletions mdi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.conf.global_settings import LANGUAGES
from django_countries.fields import CountryField
from datetime import date
from itertools import accumulate
from django.core.exceptions import ValidationError
from django.contrib.postgres.fields import HStoreField
from django.urls import reverse
Expand Down Expand Up @@ -120,7 +119,7 @@ def __str__(self):
class License(models.Model):
name = models.CharField(blank=False, max_length=255)
spdx = models.CharField(blank=False, max_length=64)
url = models.CharField(blank=True, max_length=255)
url = models.URLField(blank=True, max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Expand All @@ -134,7 +133,7 @@ def __str__(self):
class Tool(models.Model):
name = models.CharField(blank=False, max_length=255)
description = models.TextField(blank=True, default='')
url = models.CharField(blank=False, max_length=255)
url = models.URLField(blank=False, max_length=255)
license = models.ForeignKey(License, blank=True, null=True, on_delete=models.CASCADE)
pricing = models.ForeignKey(Pricing, blank=True, null=True, on_delete=models.CASCADE)
languages_supported = models.ManyToManyField(Language)
Expand All @@ -158,24 +157,26 @@ class Organization(models.Model):
state = models.CharField(blank=True, default='', max_length=255)
postal_code = models.CharField(blank=True, default='', max_length=255)
country = CountryField()
email = models.CharField(max_length=255)
url = models.CharField(blank=True, default='', max_length=255)
email = models.EmailField(max_length=255)
url = models.URLField(blank=True, default='', max_length=255)
media_url = models.URLField(blank=True, default='', max_length=255)
logo_url = models.URLField(blank=True, default='', max_length=255)
lat = models.FloatField(blank=True, null=True)
lng = models.FloatField(blank=True, null=True)
geom = models.PointField(blank=True, null=True)
founded = models.DateField(blank=True, null=True)
num_workers = models.IntegerField(blank=True, null=True)
# num_impacted = models.IntegerField(blank=True)
categories = models.ManyToManyField(Category, blank=True, null=True)
stage = models.ForeignKey(Stage, on_delete=models.CASCADE, blank=True, null=True)
stage = models.ForeignKey(Stage, blank=False, default='', on_delete=models.CASCADE)
source = models.ForeignKey(Source, on_delete=models.CASCADE, blank=True, null=True)
type = models.ForeignKey(Type, on_delete=models.CASCADE, blank=True, null=True)
sectors = models.ManyToManyField(Sector, blank=True, null=True)
legal_status = models.ManyToManyField(LegalStatus, blank=True, null=True)
challenges = models.ManyToManyField(Challenge, blank=True, null=True)
socialnetworks = models.ManyToManyField(SocialNetwork, through='OrganizationSocialNetwork')
notes = models.TextField(blank=True, default='')
admin_email = models.CharField(default='', max_length=255)
admin_email = models.EmailField(default='', max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Expand Down

0 comments on commit 2bb5470

Please sign in to comment.