diff --git a/accounts/migrations/0023_auto_20200327_2153.py b/accounts/migrations/0023_auto_20200327_2153.py new file mode 100644 index 0000000..5ef3699 --- /dev/null +++ b/accounts/migrations/0023_auto_20200327_2153.py @@ -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), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index fbe98e1..ae5a84a 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -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) @@ -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) @@ -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) diff --git a/mdi/migrations/0047_auto_20200327_2153.py b/mdi/migrations/0047_auto_20200327_2153.py new file mode 100644 index 0000000..67b3c6f --- /dev/null +++ b/mdi/migrations/0047_auto_20200327_2153.py @@ -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), + ), + ] diff --git a/mdi/models.py b/mdi/models.py index 253e6fa..ecf8cbc 100644 --- a/mdi/models.py +++ b/mdi/models.py @@ -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 @@ -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) @@ -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) @@ -158,8 +157,10 @@ 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) @@ -167,7 +168,7 @@ class Organization(models.Model): 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) @@ -175,7 +176,7 @@ class Organization(models.Model): 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)