Skip to content

Commit

Permalink
Merge pull request #135 from TNRIS/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
brez committed Sep 12, 2019
2 parents c7f6819 + 931367c commit fad5858
Show file tree
Hide file tree
Showing 94 changed files with 929 additions and 397,721 deletions.
2 changes: 1 addition & 1 deletion lakegallery/api/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from rest_framework import routers
from .views import (ReservoirsViewSet, RWPAsReservoirsViewSet)
from .views import ReservoirsViewSet
from rest_framework_extensions.routers import NestedRouterMixin


Expand Down
12 changes: 2 additions & 10 deletions lakegallery/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@
from rest_framework_gis.serializers import GeoFeatureModelSerializer
from rest_framework.reverse import reverse

from map.models import MajorReservoirs, RWPAs
from map.models import MajorReservoirs


class ReservoirsSerializer(GeoFeatureModelSerializer):
class Meta:
model = MajorReservoirs
geo_field = 'geom'
auto_bbox = True
fields = ('res_lbl', 'region')


class RWPAsSerializer(GeoFeatureModelSerializer):
class Meta:
model = RWPAs
geo_field = 'geom'
auto_bbox = True
fields = ('reg_name', 'letter')
fields = ('res_lbl',)


class ReservoirURLSerializer(serializers.HyperlinkedModelSerializer):
Expand Down
24 changes: 3 additions & 21 deletions lakegallery/api/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from .serializers import (RWPAsSerializer, ReservoirsSerializer,
from .serializers import (ReservoirsSerializer,
ReservoirURLSerializer)
from .filters import URLFilter

from rest_framework_extensions.mixins import NestedViewSetMixin

from map.models import MajorReservoirs, RWPAs
from map.models import MajorReservoirs


class ReservoirsViewSet(NestedViewSetMixin, viewsets.ReadOnlyModelViewSet):
Expand All @@ -16,22 +16,4 @@ class ReservoirsViewSet(NestedViewSetMixin, viewsets.ReadOnlyModelViewSet):
serializer_class = ReservoirsSerializer
lookup_field = 'res_lbl'
queryset = MajorReservoirs.objects.all().order_by('res_lbl')
filter_fields = ('res_lbl', 'region')


class RWPAsReservoirsViewSet(NestedViewSetMixin,
viewsets.ReadOnlyModelViewSet):
"""
API endpoint that returns the reservoirs for the specified region w/ URLs
"""
serializer_class = ReservoirURLSerializer
lookup_field = 'res_lbl'
queryset = MajorReservoirs.objects.all().order_by('res_lbl')

# filter_fields = ('res_lbl', )
filter_class = URLFilter
# Uses custom filter_class opposed to out-of-the-box filter_fields to allow
# question mark query/filtering against the serializer URL field. This is
# not actually needed since a user who has the URL also has the lake name
# and can (and probably should) query just using it but i set this up
# regardless in the name of completeness.
filter_fields = ('res_lbl')
2 changes: 1 addition & 1 deletion lakegallery/lakegallery/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
VERSION = '2.3.1'
VERSION = '2.5.0'

ALLOWED_HOSTS = ['localhost', '0.0.0.0', '.tnris.org', '.tnris.org.']

Expand Down
44 changes: 24 additions & 20 deletions lakegallery/map/admin.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
from django.contrib.gis import admin
from .models import (MajorReservoirs, RWPAs, HistoricalAerialLinks,
from .models import (MajorReservoirs, HistoricalAerialLinks,
StoryContent, LakeStatistics, SignificantEvents,
BoatRamps, ChannelMarkers, Hazards, Parks)


class MajorReservoirsAdmin(admin.OSMGeoAdmin):
list_display = ['res_lbl', 'region', 'story']
ordering = ['region', 'res_lbl']
list_filter = ['region']


class RWPAsAdmin(admin.OSMGeoAdmin):
list_display = ['letter', 'reg_name']
ordering = ['letter']
list_display = ['res_lbl', 'story']
ordering = ['res_lbl']
list_per_page = 50
list_filter = ['story']
search_fields = ['res_lbl']


class HistoricalAerialLinksAdmin(admin.ModelAdmin):
list_display = ('lake', 'year', 'link')
ordering = ('lake', 'year', 'link')
list_per_page = 50
list_filter = ['lake']
search_fields = ['lake__res_lbl', 'year'] # search related field

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand Down Expand Up @@ -65,6 +62,7 @@ class StoryContentAdmin(admin.ModelAdmin):
readonly_fields = ('summ_main_tag', 'hist_main_tag', 'hist_tag',
'one_main_tag', 'one_tag', 'two_main_tag', 'two_tag',
'three_main_tag', 'three_tag')
search_fields = ['lake__res_lbl'] # search related res_lbl field

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand Down Expand Up @@ -103,6 +101,8 @@ class LakeStatisticsAdmin(admin.ModelAdmin):
'num_of_floodgates',
'discharge_capacity']})
]
list_filter = ['primary_purposes', 'location']
search_fields = ['lake__res_lbl'] # search related res_lbl field & location

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand All @@ -116,7 +116,8 @@ class SignificantEventsAdmin(admin.ModelAdmin):
list_display = ('lake', 'event_type', 'date', 'height')
ordering = ('lake', 'event_type', 'date')
list_per_page = 50
list_filter = ['lake', 'event_type']
list_filter = ['event_type']
search_fields = ['lake__res_lbl'] # search related res_lbl field

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand All @@ -132,10 +133,11 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):


class BoatRampsAdmin(admin.OSMGeoAdmin):
list_display = ('lake', 'name')
ordering = ('lake', 'name')
list_display = ('lake', 'name', 'operator')
ordering = ('lake', 'name', 'operator')
list_per_page = 50
list_filter = ['lake']
list_filter = ['operator']
search_fields = ['lake__res_lbl', 'name'] # search related res_lbl field, name & operator

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand All @@ -146,10 +148,11 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):


class ChannelMarkersAdmin(admin.OSMGeoAdmin):
list_display = ('lake', 'marker_id')
ordering = ('lake', 'marker_id')
list_display = ('lake', 'marker_id', 'year')
ordering = ('lake', 'marker_id', 'year')
list_per_page = 50
list_filter = ['lake']
list_filter = ['year']
search_fields = ['lake__res_lbl'] # search related res_lbl field

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand All @@ -163,7 +166,8 @@ class HazardsAdmin(admin.OSMGeoAdmin):
list_display = ('lake', 'hazard_type', 'num_buoys')
ordering = ('lake', 'hazard_type')
list_per_page = 50
list_filter = ['lake']
list_filter = ['hazard_type']
search_fields = ['lake__res_lbl'] # search related res_lbl field

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand All @@ -177,7 +181,8 @@ class ParksAdmin(admin.OSMGeoAdmin):
list_display = ('lake', 'name', 'park_type')
ordering = ('lake', 'name')
list_per_page = 50
list_filter = ['lake']
list_filter = ['park_type']
search_fields = ['lake__res_lbl'] # search related res_lbl field

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "lake":
Expand All @@ -188,7 +193,6 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):


admin.site.register(MajorReservoirs, MajorReservoirsAdmin)
admin.site.register(RWPAs, RWPAsAdmin)
admin.site.register(HistoricalAerialLinks, HistoricalAerialLinksAdmin)
admin.site.register(StoryContent, StoryContentAdmin)
admin.site.register(LakeStatistics, LakeStatisticsAdmin)
Expand Down
1 change: 0 additions & 1 deletion lakegallery/map/data/RWPAs_WGS84.cpg

This file was deleted.

Binary file removed lakegallery/map/data/RWPAs_WGS84.dbf
Binary file not shown.
1 change: 0 additions & 1 deletion lakegallery/map/data/RWPAs_WGS84.prj

This file was deleted.

Binary file removed lakegallery/map/data/RWPAs_WGS84.sbn
Binary file not shown.
Binary file removed lakegallery/map/data/RWPAs_WGS84.sbx
Binary file not shown.
Binary file removed lakegallery/map/data/RWPAs_WGS84.shp
Binary file not shown.
1,414 changes: 0 additions & 1,414 deletions lakegallery/map/data/RWPAs_WGS84.shp.xml

This file was deleted.

Binary file removed lakegallery/map/data/RWPAs_WGS84.shx
Binary file not shown.
30 changes: 1 addition & 29 deletions lakegallery/map/load.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
from django.contrib.gis.utils import LayerMapping
from .models import (MajorReservoirs, RWPAs, BoatRamps, ChannelMarkers,
from .models import (MajorReservoirs, BoatRamps, ChannelMarkers,
Hazards, Parks)

majorreservoirs_mapping = {
'res_name': 'RES_NAME',
'type': 'TYPE',
'status': 'STATUS',
'res_lbl': 'RES_LBL',
'region': 'Region',
'geom': 'MULTIPOLYGON25D',
}

Expand All @@ -18,21 +17,6 @@
'2017_Major_Reservoirs_With_Regions_WGS84.shp'),
)

rwpas_mapping = {
'objectid': 'OBJECTID',
'reg_name': 'REG_NAME',
'letter': 'LETTER',
'shape_leng': 'Shape_Leng',
'shape_area': 'Shape_Area',
'geom': 'MULTIPOLYGON',
}

rwpas_shp = os.path.abspath(
os.path.join(os.path.dirname(
__file__), 'data',
'RWPAs_WGS84.shp'),
)

boatramps_mapping = {
'lake': {'res_lbl': 'Lake'},
'name': 'NAME',
Expand Down Expand Up @@ -91,18 +75,6 @@


def run(verbose=True):
# lm = LayerMapping(
# MajorReservoirs, majorreservoirs_shp, majorreservoirs_mapping,
# transform=False, encoding='iso-8859-1',
# )
# lm.save(strict=True, verbose=verbose)

# lm = LayerMapping(
# RWPAs, rwpas_shp, rwpas_mapping,
# transform=False, encoding='iso-8859-1',
# )
# lm.save(strict=True, verbose=verbose)

lm = LayerMapping(
BoatRamps, boatramps_shp, boatramps_mapping,
transform=False, encoding='iso-8859-1',
Expand Down
18 changes: 18 additions & 0 deletions lakegallery/map/migrations/0034_delete_rwpas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-09-11 13:37
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('map', '0033_auto_20190613_1206'),
]

operations = [
migrations.DeleteModel(
name='RWPAs',
),
]
19 changes: 19 additions & 0 deletions lakegallery/map/migrations/0035_remove_majorreservoirs_region.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-09-11 19:24
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('map', '0034_delete_rwpas'),
]

operations = [
migrations.RemoveField(
model_name='majorreservoirs',
name='region',
),
]
19 changes: 0 additions & 19 deletions lakegallery/map/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class MajorReservoirs(gismodels.Model):
type = models.CharField(max_length=50)
status = models.CharField(max_length=50)
res_lbl = models.CharField(max_length=100)
region = models.CharField(max_length=1)
story = models.CharField(max_length=8, choices=story_choices,
default='disabled')

Expand All @@ -36,24 +35,6 @@ class Meta:
ordering = ['res_lbl']


class RWPAs(gismodels.Model):
objectid = models.BigIntegerField()
reg_name = models.CharField(max_length=25)
letter = models.CharField(max_length=1)
shape_leng = models.FloatField()
shape_area = models.FloatField()

geom = gismodels.MultiPolygonField(srid=4326)
objects = gismodels.GeoManager()

def __str__(self):
return self.reg_name

class Meta:
verbose_name = "RWPA"
verbose_name_plural = "RWPAs"


class HistoricalAerialLinks(models.Model):
link = models.URLField()
year = models.IntegerField(choices=YEAR_CHOICES,
Expand Down
14 changes: 3 additions & 11 deletions lakegallery/map/static/map/admin_style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
/*DOCUMENT*/
@font-face {
font-family: "Clear Sans";
src: url("font/EOT/ClearSans-Light.eot");
src:
url("font/WOFF/ClearSans-Light.woff") format("woff"),
url("font/TTF/ClearSans-Light.ttf") format("ttf"),
url("font/SVG/ClearSans-Light.svg#filename") format("svg");
}

body {
font-family: "Clear Sans";
font-family: 'Roboto', sans-serif;
}

/*ADMIN SITE*/
Expand All @@ -33,12 +25,12 @@ body {

table > caption {
background-color: #3C5163 !important;
}
}

fieldset.module.aligned > h2 {
background-color: #3C5163 !important;
}

#changelist-filter > h2 {
background-color: #3C5163 !important;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit fad5858

Please sign in to comment.