From a36aae990547fca60b8955f4132f27762823cb49 Mon Sep 17 00:00:00 2001 From: jwhaney Date: Thu, 27 Feb 2020 10:32:36 -0600 Subject: [PATCH] remove all reference to scale in historical products & photo indexes related to issue #53 --- .../compiled_historical_collection.sql | 2 -- src/data_hub/dashboard.py | 1 - src/data_hub/lore/admin.py | 14 +++------ src/data_hub/lore/forms.py | 1 - .../migrations/0015_auto_20200227_1025.py | 31 +++++++++++++++++++ .../migrations/0016_auto_20200227_1026.py | 21 +++++++++++++ .../lore/migrations/0017_delete_scale.py | 16 ++++++++++ src/data_hub/lore/models.py | 24 -------------- src/data_hub/lore/serializers.py | 5 ++- 9 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 src/data_hub/lore/migrations/0015_auto_20200227_1025.py create mode 100644 src/data_hub/lore/migrations/0016_auto_20200227_1026.py create mode 100644 src/data_hub/lore/migrations/0017_delete_scale.py diff --git a/database_management/compiled_historical_collection.sql b/database_management/compiled_historical_collection.sql index aa2024a2..68a17429 100644 --- a/database_management/compiled_historical_collection.sql +++ b/database_management/compiled_historical_collection.sql @@ -26,10 +26,8 @@ SELECT historical_collection.id as collection_id, 'number_of_frames', product.number_of_frames, 'medium', product.medium, 'print_type', product.print_type, - 'scale', scale.scale, 'frame_size', frame_size.frame_size) FROM product - LEFT JOIN scale ON scale.id=product.scale_id LEFT JOIN frame_size ON frame_size.id=product.frame_size_id WHERE product.collection_id=historical_collection.id), ',') as products, CASE diff --git a/src/data_hub/dashboard.py b/src/data_hub/dashboard.py index 4e0a08ee..355c0aa4 100644 --- a/src/data_hub/dashboard.py +++ b/src/data_hub/dashboard.py @@ -71,7 +71,6 @@ def init_with_context(self, context): css_classes=('grp-collapse grp-closed',), models=('lore.models.Agency', 'lore.models.FrameSize', - 'lore.models.Scale', 'lore.models.County', 'lore.models.Collection'), )) diff --git a/src/data_hub/lore/admin.py b/src/data_hub/lore/admin.py index 43428128..7b381992 100644 --- a/src/data_hub/lore/admin.py +++ b/src/data_hub/lore/admin.py @@ -3,11 +3,11 @@ from django.contrib import admin -from .filters import CollectionAgencyNameFilter, CollectionCountyFilter, \ - CountyDropdownFilter +from .filters import (CollectionAgencyNameFilter, CollectionCountyFilter, + CountyDropdownFilter) from .forms import CollectionForm, ProductForm from .models import (Agency, Collection, County, CountyRelate, FrameSize, - LineIndex, MicroficheIndex, PhotoIndex, Product, Scale, + LineIndex, MicroficheIndex, PhotoIndex, Product, ScannedPhotoIndexLink) @@ -24,11 +24,6 @@ class FrameSizeAdmin(admin.ModelAdmin): ordering = ('frame_size',) -class ScaleAdmin(admin.ModelAdmin): - model = Scale - ordering = ('scale',) - - class PhotoIndexInlineAdmin(admin.StackedInline): classes = ('grp-collapse grp-closed',) inline_classes = ('grp-collapse grp-closed',) @@ -115,7 +110,6 @@ def county_names(self, collection): county_names.short_description = "Counties in Collection" -# Register your models here. class CountyAdmin(admin.ModelAdmin): list_filter = ( ('name', CountyDropdownFilter), @@ -126,8 +120,8 @@ class CountyAdmin(admin.ModelAdmin): # search_fields = ['name', 'fips'] +# Register your models here. admin.site.register(Agency, AgencyAdmin) admin.site.register(Collection, CollectionAdmin) admin.site.register(County, CountyAdmin) admin.site.register(FrameSize, FrameSizeAdmin) -admin.site.register(Scale, ScaleAdmin) diff --git a/src/data_hub/lore/forms.py b/src/data_hub/lore/forms.py index e7d6fa14..94eb57de 100644 --- a/src/data_hub/lore/forms.py +++ b/src/data_hub/lore/forms.py @@ -8,7 +8,6 @@ class ProductForm(forms.ModelForm): class Meta: model = Product - # hide scale and scanned fields based on issue #53; still present in model. fields = ('frame_size', 'coverage', 'number_of_frames', 'medium', 'print_type', 'clean_status', 'physical_location', 'remarks') diff --git a/src/data_hub/lore/migrations/0015_auto_20200227_1025.py b/src/data_hub/lore/migrations/0015_auto_20200227_1025.py new file mode 100644 index 00000000..0b9965f5 --- /dev/null +++ b/src/data_hub/lore/migrations/0015_auto_20200227_1025.py @@ -0,0 +1,31 @@ +# Generated by Django 2.0.13 on 2020-02-27 16:25 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lore', '0014_collection_photo_index_only'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='scale', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='lore.Scale'), + ), + migrations.AlterUniqueTogether( + name='photoindex', + unique_together=set(), + ), + migrations.AlterUniqueTogether( + name='product', + unique_together=set(), + ), + migrations.RemoveField( + model_name='product', + name='scanned', + ), + ] diff --git a/src/data_hub/lore/migrations/0016_auto_20200227_1026.py b/src/data_hub/lore/migrations/0016_auto_20200227_1026.py new file mode 100644 index 00000000..595f46a3 --- /dev/null +++ b/src/data_hub/lore/migrations/0016_auto_20200227_1026.py @@ -0,0 +1,21 @@ +# Generated by Django 2.0.13 on 2020-02-27 16:26 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('lore', '0015_auto_20200227_1025'), + ] + + operations = [ + migrations.RemoveField( + model_name='photoindex', + name='scale', + ), + migrations.RemoveField( + model_name='product', + name='scale', + ), + ] diff --git a/src/data_hub/lore/migrations/0017_delete_scale.py b/src/data_hub/lore/migrations/0017_delete_scale.py new file mode 100644 index 00000000..cdf812f5 --- /dev/null +++ b/src/data_hub/lore/migrations/0017_delete_scale.py @@ -0,0 +1,16 @@ +# Generated by Django 2.0.13 on 2020-02-27 16:27 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('lore', '0016_auto_20200227_1026'), + ] + + operations = [ + migrations.DeleteModel( + name='Scale', + ), + ] diff --git a/src/data_hub/lore/models.py b/src/data_hub/lore/models.py index 4442197b..11737be2 100644 --- a/src/data_hub/lore/models.py +++ b/src/data_hub/lore/models.py @@ -43,22 +43,6 @@ def __str__(self): return str(self.frame_size) -class Scale(models.Model): - """Domain defining allowable scale values""" - - class Meta: - db_table = 'scale' - verbose_name_plural = 'Scales' - - id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) - scale = models.PositiveIntegerField('Scale', unique=True) - created = models.DateTimeField('Created', auto_now_add=True) - last_modified = models.DateTimeField('Last Modified', auto_now=True) - - def __str__(self): - return str(self.scale) - - class PhotoIndex(models.Model): """Defines historical imagery collection photo indexes""" @@ -66,12 +50,9 @@ class Meta: db_table = 'photo_index' verbose_name = 'Photo Index' verbose_name_plural = 'Photo Indexes' - unique_together = ('collection', 'scale', 'number_of_frames', - 'scanned', 'physical_location') id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) collection = models.ForeignKey('Collection', on_delete=models.CASCADE) - scale = models.ForeignKey('Scale', on_delete=models.CASCADE, null=True, blank=True) number_of_frames = models.PositiveIntegerField('Number of Frames', default=1) scanned = models.PositiveIntegerField('Scanned', default=0) scanned_location = models.CharField('Scanned Location', max_length=254, null=True, blank=True) @@ -190,14 +171,10 @@ class Meta: db_table = 'product' verbose_name = 'Product' verbose_name_plural = 'Products' - unique_together = ("collection", "scale", "frame_size", - "number_of_frames", "scanned", "medium", - "physical_location") id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) collection = models.ForeignKey('Collection', on_delete=models.CASCADE, related_name='Products') - scale = models.ForeignKey('Scale', on_delete=models.CASCADE) frame_size = models.ForeignKey('FrameSize', on_delete=models.CASCADE) COVERAGE_TYPE_CHOICE = ( ('Full', 'Full'), @@ -207,7 +184,6 @@ class Meta: choices=COVERAGE_TYPE_CHOICE, default='Partial') number_of_frames = models.PositiveIntegerField('Number of Frames', default=0) - scanned = models.PositiveIntegerField('Scanned', default=0) MEDIUM_TYPE_CHOICE = ( ('Film', 'Film'), diff --git a/src/data_hub/lore/serializers.py b/src/data_hub/lore/serializers.py index 6cb7af79..846e52be 100644 --- a/src/data_hub/lore/serializers.py +++ b/src/data_hub/lore/serializers.py @@ -24,7 +24,6 @@ class ProductSerializer(serializers.ModelSerializer): NumFrames = serializers.IntegerField( source="number_of_frames", read_only=True) PrintType = serializers.SlugField(source="print_type", read_only=True) - Scale = serializers.IntegerField(source="scale.scale", read_only=True) def county_fips(self, product): fips = self.context['request'].query_params.get('countyFips') @@ -33,10 +32,10 @@ def county_fips(self, product): class Meta: model = Product fields = ('AcquiringAgency', 'CountyFIPS', 'Date', 'NumFrames', - 'PrintType', 'Scale') + 'PrintType') class CollectionSerializer(serializers.ModelSerializer): class Meta: model = ChcView - fields = '__all__' + fields = '__all__'