Skip to content

Commit

Permalink
feat: toward #17 and #21, survey models, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed May 11, 2020
1 parent d13d1b0 commit c3e7564
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 5 deletions.
3 changes: 0 additions & 3 deletions accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class CustomUserAdmin(UserAdmin, OSMGeoAdmin):
ordering = [Lower('email'), ]


# admin.site.register(get_user_model(), CustomUserAdmin)


@admin.register(Role)
class RoleAdmin(ModelAdmin):
list_display = ('name', 'order', 'description')
Expand Down
48 changes: 48 additions & 0 deletions mdi/migrations/0063_auto_20200508_0028.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 3.0.3 on 2020-05-08 00:28

import django.contrib.postgres.fields.ranges
from django.db import migrations, models
import django.db.models.deletion
import django_countries.fields


class Migration(migrations.Migration):

dependencies = [
('mdi', '0062_auto_20200505_0225'),
]

operations = [
migrations.CreateModel(
name='GeographicScope',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('scope', models.CharField(blank=True, choices=[(0, 'Local'), (1, 'Regional'), (2, 'National'), (3, 'International')], max_length=8)),
('city', models.CharField(blank=True, default='', max_length=255)),
('region', models.CharField(blank=True, default='', max_length=255)),
('country', django_countries.fields.CountryField(blank=True, max_length=2)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
migrations.AddField(
model_name='organization',
name='code_availability',
field=models.CharField(blank=True, choices=[(0, 'Yes'), (1, 'Partially'), (2, 'No')], max_length=8),
),
migrations.AddField(
model_name='organization',
name='impacted_exact_number',
field=models.IntegerField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name='organization',
name='impacted_range',
field=django.contrib.postgres.fields.ranges.IntegerRangeField(default=None, null=True),
),
migrations.AddField(
model_name='organization',
name='geographic_scope',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='mdi.GeographicScope'),
),
]
24 changes: 24 additions & 0 deletions mdi/migrations/0064_auto_20200508_0246.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.0.3 on 2020-05-08 02:46

import django.contrib.postgres.fields.ranges
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mdi', '0063_auto_20200508_0028'),
]

operations = [
migrations.AlterField(
model_name='geographicscope',
name='scope',
field=models.CharField(blank=True, choices=[(0, 'Local'), (1, 'Regional'), (2, 'National'), (3, 'International')], max_length=16),
),
migrations.AlterField(
model_name='organization',
name='impacted_range',
field=django.contrib.postgres.fields.ranges.IntegerRangeField(blank=True, default=None, null=True),
),
]
41 changes: 41 additions & 0 deletions mdi/migrations/0065_auto_20200508_0354.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 3.0.3 on 2020-05-08 03:54

from django.db import migrations, models
import django_countries.fields


class Migration(migrations.Migration):

dependencies = [
('mdi', '0064_auto_20200508_0246'),
]

operations = [
migrations.RemoveField(
model_name='organization',
name='geographic_scope',
),
migrations.AddField(
model_name='organization',
name='geo_scope',
field=models.CharField(blank=True, choices=[(0, 'Local'), (1, 'Regional'), (2, 'National'), (3, 'International')], max_length=16),
),
migrations.AddField(
model_name='organization',
name='geo_scope_city',
field=models.CharField(blank=True, default='', max_length=255),
),
migrations.AddField(
model_name='organization',
name='geo_scope_country',
field=django_countries.fields.CountryField(blank=True, max_length=2),
),
migrations.AddField(
model_name='organization',
name='geo_scope_region',
field=models.CharField(blank=True, default='', max_length=255),
),
migrations.DeleteModel(
name='GeographicScope',
),
]
49 changes: 49 additions & 0 deletions mdi/migrations/0066_auto_20200511_1814.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 3.0.3 on 2020-05-11 18:14

from django.db import migrations, models
import django_countries.fields


class Migration(migrations.Migration):

dependencies = [
('mdi', '0065_auto_20200508_0354'),
]

operations = [
migrations.AddField(
model_name='organization',
name='founded_max_date',
field=models.DateField(blank=True, null=True),
),
migrations.AddField(
model_name='organization',
name='founded_min_date',
field=models.DateField(blank=True, null=True),
),
migrations.AlterField(
model_name='organization',
name='geo_scope',
field=models.CharField(blank=True, choices=[(0, 'Local'), (1, 'Regional'), (2, 'National'), (3, 'International')], max_length=16, verbose_name='Geographic scope'),
),
migrations.AlterField(
model_name='organization',
name='geo_scope_city',
field=models.CharField(blank=True, default='', max_length=255, verbose_name='Geographic scope – City'),
),
migrations.AlterField(
model_name='organization',
name='geo_scope_country',
field=django_countries.fields.CountryField(blank=True, max_length=2, verbose_name='Geographic scope – Country'),
),
migrations.AlterField(
model_name='organization',
name='geo_scope_region',
field=models.CharField(blank=True, default='', max_length=255, verbose_name='Geographic scope – Region'),
),
migrations.AlterField(
model_name='organization',
name='num_workers',
field=models.IntegerField(blank=True, null=True, verbose_name='Number of workers'),
),
]
17 changes: 15 additions & 2 deletions mdi/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib.postgres.fields import IntegerRangeField
from django.contrib.auth import get_user_model
from django.contrib.gis.db import models
from datetime import date
Expand Down Expand Up @@ -213,15 +214,27 @@ class Organization(models.Model):
lat = models.FloatField(blank=True, null=True)
lng = models.FloatField(blank=True, null=True)
geom = models.PointField(blank=True, null=True)
# founded_ min_ and max_dates are a strategy to represent date specificity (to the year, month, day).
# See https://softwareengineering.stackexchange.com/a/194294/365490
founded = models.DateField(blank=True, null=True)
num_workers = models.IntegerField(blank=True, null=True)
founded_min_date = models.DateField(blank=True, null=True)
founded_max_date = models.DateField(blank=True, null=True)
num_workers = models.IntegerField(blank=True, null=True, verbose_name='Number of workers', )
related_individuals = models.ManyToManyField(
get_user_model(),
through='EntitiesEntities',
through_fields=['from_org', 'to_ind']
)
related_organizations = models.ManyToManyField('self', through='EntitiesEntities')
# num_impacted = models.IntegerField(blank=True)
geo_scope = models.CharField(blank=True, max_length=16,
choices=[(0, 'Local'), (1, 'Regional'), (2, 'National'), (3, 'International')],
verbose_name='Geographic scope', )
geo_scope_city = models.CharField(blank=True, default='', max_length=255, verbose_name='Geographic scope – City', )
geo_scope_region = models.CharField(blank=True, default='', max_length=255, verbose_name='Geographic scope – Region', )
geo_scope_country = CountryField(blank=True, verbose_name='Geographic scope – Country', )
impacted_range = IntegerRangeField(blank=True, null=True, default=None)
impacted_exact_number = models.IntegerField(blank=True, null=True, default=None)
code_availability = models.CharField(blank=True, max_length=8, choices=[(0, 'Yes'), (1, 'Partially'), (2, 'No')])
categories = models.ManyToManyField(Category, blank=True,)
stage = models.ForeignKey(Stage, blank=True, null=True, default=None, on_delete=models.CASCADE)
source = models.ForeignKey(Source, on_delete=models.CASCADE, blank=True, null=True)
Expand Down

0 comments on commit c3e7564

Please sign in to comment.