Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhaney committed Feb 27, 2020
2 parents 3b1873c + a36aae9 commit 149982f
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 41 deletions.
2 changes: 0 additions & 2 deletions database_management/compiled_historical_collection.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/data_hub/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
))
Expand Down
14 changes: 4 additions & 10 deletions src/data_hub/lore/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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',)
Expand Down Expand Up @@ -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),
Expand All @@ -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)
1 change: 0 additions & 1 deletion src/data_hub/lore/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
31 changes: 31 additions & 0 deletions src/data_hub/lore/migrations/0015_auto_20200227_1025.py
Original file line number Diff line number Diff line change
@@ -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',
),
]
21 changes: 21 additions & 0 deletions src/data_hub/lore/migrations/0016_auto_20200227_1026.py
Original file line number Diff line number Diff line change
@@ -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',
),
]
16 changes: 16 additions & 0 deletions src/data_hub/lore/migrations/0017_delete_scale.py
Original file line number Diff line number Diff line change
@@ -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',
),
]
24 changes: 0 additions & 24 deletions src/data_hub/lore/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,16 @@ 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"""

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)
Expand Down Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down
5 changes: 2 additions & 3 deletions src/data_hub/lore/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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__'

0 comments on commit 149982f

Please sign in to comment.