Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
Prepare for version 0.1.0
Browse files Browse the repository at this point in the history
- Reset migrations
- Fix tox issues (dependencies)
  • Loading branch information
mcab committed May 9, 2019
1 parent 210e077 commit 8b9d490
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 188 deletions.
34 changes: 15 additions & 19 deletions hiber/apps/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@
path('users/me', views.UserView.as_view(), name='user'),
path('users/create', views.UserCreateView.as_view(), name='user-create'),
path('users/delete', views.UserDeleteView.as_view(), name='user-delete'),
path(
'users/activate', views.ActivationView.as_view(),
name='user-activate'),
path(
'users/activate/resend',
views.ResendActivationView.as_view(),
name='user-activate-resend'),
path('users/activate',
views.ActivationView.as_view(),
name='user-activate'),
path('users/activate/resend',
views.ResendActivationView.as_view(),
name='user-activate-resend'),
path('password', views.SetPasswordView.as_view(), name='set-password'),
path(
'password/reset',
views.PasswordResetView.as_view(),
name='reset-password'),
path(
'password/reset/confirm',
views.PasswordResetConfirmView.as_view(),
name='reset-password-confirm'),
path('password/reset',
views.PasswordResetView.as_view(),
name='reset-password'),
path('password/reset/confirm',
views.PasswordResetConfirmView.as_view(),
name='reset-password-confirm'),
path('token/create', views.TokenCreateView.as_view(), name='token-create'),
path(
'token/destroy',
views.TokenDestroyView.as_view(),
name='token-destroy'),
path('token/destroy',
views.TokenDestroyView.as_view(),
name='token-destroy'),
path('token/login', views.TokenCreateView.as_view(), name='login'),
path('token/logout', views.TokenDestroyView.as_view(), name='logout'),
]
43 changes: 19 additions & 24 deletions hiber/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ class BatSerializer(serializers.ModelSerializer):
# TODO: Get current image to display an absolute path over API
id = serializers.ReadOnlyField()
rarity = ChoiceField(choices=Bat.RARITY_CHOICES)
habits = serializers.ListField(
child=ChoiceField(choices=Bat.HABIT_CHOICES))
habits = serializers.ListField(child=ChoiceField(
choices=Bat.HABIT_CHOICES))
size = FloatRangeField()
pups = IntegerRangeField()
risk = serializers.ListField(child=ChoiceField(choices=Bat.RISK_CHOICES))
risk_scope = serializers.ListField(
child=ChoiceField(choices=Bat.SCOPE_CHOICES))
risk_scope = serializers.ListField(child=ChoiceField(
choices=Bat.SCOPE_CHOICES))
bat_image = ImageRenditionField('fill-200x200')

class Meta:
Expand All @@ -89,8 +89,9 @@ class HouseSerializer(ConditionalRequiredMixin, serializers.ModelSerializer):
location = PointField()
property_type = ChoiceField(
choices=House._meta.get_field('property_type').choices)
created = serializers.DateTimeField(
default=serializers.CreateOnlyDefault(timezone.now()), read_only=True)
created = serializers.DateTimeField(default=serializers.CreateOnlyDefault(
timezone.now()),
read_only=True)
updated = serializers.DateTimeField(read_only=True)

class Meta:
Expand Down Expand Up @@ -125,28 +126,22 @@ class HouseEnvironmentFeaturesSerializer(ConditionalRequiredMixin,
]
id = serializers.ReadOnlyField()
house_id = serializers.ReadOnlyField()
habitat_degradation = serializers.ListField(
child=ChoiceField(
choices=HouseEnvironmentFeatures.HABITAT_DEGRADATION_CHOICES))
habitat_type = serializers.ListField(
child=ChoiceField(
choices=HouseEnvironmentFeatures.HABITAT_TYPE_CHOICES))
man_made_structure = serializers.ListField(
child=ChoiceField(
choices=HouseEnvironmentFeatures.MAN_MADE_STRUCTURE_CHOICES))
nearby_geography = serializers.ListField(
child=ChoiceField(
choices=HouseEnvironmentFeatures.NEARBY_GEOGRAPHY_CHOICES))
habitat_degradation = serializers.ListField(child=ChoiceField(
choices=HouseEnvironmentFeatures.HABITAT_DEGRADATION_CHOICES))
habitat_type = serializers.ListField(child=ChoiceField(
choices=HouseEnvironmentFeatures.HABITAT_TYPE_CHOICES))
man_made_structure = serializers.ListField(child=ChoiceField(
choices=HouseEnvironmentFeatures.MAN_MADE_STRUCTURE_CHOICES))
nearby_geography = serializers.ListField(child=ChoiceField(
choices=HouseEnvironmentFeatures.NEARBY_GEOGRAPHY_CHOICES))
slope = ChoiceField(
choices=HouseEnvironmentFeatures._meta.get_field('slope').choices)
day_noise = ChoiceField(
choices=HouseEnvironmentFeatures._meta.get_field('day_noise').choices)
night_noise = ChoiceField(
choices=HouseEnvironmentFeatures._meta.get_field(
'night_noise').choices)
noise_disturbance = serializers.ListField(
child=ChoiceField(
choices=HouseEnvironmentFeatures.NOISE_DISTURBANCE_CHOICES))
night_noise = ChoiceField(choices=HouseEnvironmentFeatures._meta.get_field(
'night_noise').choices)
noise_disturbance = serializers.ListField(child=ChoiceField(
choices=HouseEnvironmentFeatures.NOISE_DISTURBANCE_CHOICES))
night_light_pollution_amount = ChoiceField(
choices=HouseEnvironmentFeatures._meta.get_field(
'night_light_pollution_amount').choices)
Expand Down
7 changes: 3 additions & 4 deletions hiber/apps/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
router.register(r'houses', views.HouseViewSet)

v1_urlpatterns = [
path(
'docs/',
schema_view.with_ui('redoc', cache_timeout=0),
name='schema-redoc'),
path('docs/',
schema_view.with_ui('redoc', cache_timeout=0),
name='schema-redoc'),
url('^', include(router.urls)),
]

Expand Down
43 changes: 19 additions & 24 deletions hiber/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from ..bathouse.models import (Bat, House, HouseEnvironmentFeatures,
HousePhysicalFeatures, Observation)
from .permissions import (IsOwnerAndAuthenticated)
from .serializers import (
BatSerializer, HouseSerializer, HouseEnvironmentFeaturesSerializer,
HousePhysicalFeaturesSerializer, ObservationSerializer)
from .serializers import (BatSerializer, HouseSerializer,
HouseEnvironmentFeaturesSerializer,
HousePhysicalFeaturesSerializer,
ObservationSerializer)


class BatViewSet(viewsets.ReadOnlyModelViewSet):
Expand All @@ -31,10 +32,9 @@ def get_queryset(self, *args, **kwargs):
def perform_create(self, serializer):
serializer.save(watcher=self.request.user)

@action(
detail=True,
methods=['get', 'post'],
permission_classes=[IsOwnerAndAuthenticated])
@action(detail=True,
methods=['get', 'post'],
permission_classes=[IsOwnerAndAuthenticated])
def environment(self, request, pk=None):
"""
Returns a list of all the environment features
Expand All @@ -57,15 +57,13 @@ def environment(self, request, pk=None):
data["house_id"] = house.id
record = HouseEnvironmentFeatures(**data)
record.save()
return Response(
HouseEnvironmentFeaturesSerializer(record).data,
status=status.HTTP_201_CREATED)
return Response(HouseEnvironmentFeaturesSerializer(record).data,
status=status.HTTP_201_CREATED)
return HttpResponseServerError()

@action(
detail=True,
methods=['get', 'post'],
permission_classes=[IsOwnerAndAuthenticated])
@action(detail=True,
methods=['get', 'post'],
permission_classes=[IsOwnerAndAuthenticated])
def physical(self, request, pk=None):
"""
Returns a list of all the physical features
Expand All @@ -87,15 +85,13 @@ def physical(self, request, pk=None):
data["house_id"] = house.id
record = HousePhysicalFeatures(**data)
record.save()
return Response(
HousePhysicalFeaturesSerializer(record).data,
status=status.HTTP_201_CREATED)
return Response(HousePhysicalFeaturesSerializer(record).data,
status=status.HTTP_201_CREATED)
return HttpResponseServerError()

@action(
detail=True,
methods=['get', 'post'],
permission_classes=[IsOwnerAndAuthenticated])
@action(detail=True,
methods=['get', 'post'],
permission_classes=[IsOwnerAndAuthenticated])
def observations(self, request, pk=None):
"""
Returns a list of all the observations the house has
Expand All @@ -114,9 +110,8 @@ def observations(self, request, pk=None):
data["house_id"] = house.id
record = Observation(**data)
record.save()
return Response(
ObservationSerializer(record).data,
status=status.HTTP_201_CREATED)
return Response(ObservationSerializer(record).data,
status=status.HTTP_201_CREATED)
return HttpResponseServerError()


Expand Down
10 changes: 5 additions & 5 deletions hiber/apps/bathouse/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.1.7 on 2019-04-03 00:30
# Generated by Django 2.1.7 on 2019-05-09 00:01

from django.conf import settings
import django.contrib.gis.db.models.fields
Expand All @@ -15,8 +15,8 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('wagtailimages', '0001_squashed_0021'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('wagtailimages', '0001_squashed_0021'),
]

operations = [
Expand Down Expand Up @@ -54,7 +54,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('habitat_degradation', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(choices=[('DU', 'Dumping'), ('ER', 'Erosion'), ('TR', 'Trash'), ('NO', 'None'), ('OT', 'Other')], max_length=2), help_text='Habitat degradation present around the bat house', size=None)),
('other_habitat_degradation', models.CharField(blank=True, help_text='Habitat degradation if Other was selected', max_length=255)),
('habitat_type', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(choices=[('DE', 'Development'), ('FE', 'Forest Edge'), ('FG', 'Forest Gap'), ('FI', 'Field'), ('SR', 'Stream/River'), ('WP', 'Wetland/Pond'), ('OT', 'Other')], max_length=2), help_text='Type of environment around the bat house', size=None)),
('habitat_type', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(choices=[('DE', 'Development'), ('FE', 'Forest Edge'), ('FG', 'Forest Gap'), ('FI', 'Field'), ('SR', 'Stream/River'), ('WP', 'Wetland/Pond'), ('OT', 'Other')], help_text='Type of environment around the bat house', max_length=2), size=None)),
('other_habitat_type', models.CharField(blank=True, help_text='Habitat type if Other was selected', max_length=255)),
('man_made_structure', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(choices=[('BU', 'Building'), ('BR', 'Bridge'), ('DA', 'Dam'), ('DR', 'Dirt Road'), ('FE', 'Fence'), ('PR', 'Paved Roads'), ('TR', 'Trail'), ('NO', 'None'), ('OT', 'Other')], max_length=2), help_text='Man-made structures present around the bat house', size=None)),
('other_man_made_structure', models.CharField(blank=True, help_text='Man-made structures present if Other was selected', max_length=255)),
Expand Down Expand Up @@ -87,7 +87,7 @@ class Migration(migrations.Migration):
('other_color', models.CharField(blank=True, help_text='Color of bat house if Other is specified', max_length=255)),
('chambers', models.PositiveIntegerField(help_text='Number of chambers in bat house', validators=[django.core.validators.MinValueValidator(1)])),
('direction', models.CharField(choices=[('NO', 'North'), ('NE', 'Northeast'), ('EA', 'East'), ('SE', 'Southeast'), ('SO', 'South'), ('SW', 'Southwest'), ('WE', 'West'), ('NW', 'Northwest')], help_text='Direction which bat house is facing', max_length=2)),
('mounted_on', models.CharField(choices=[('BB', 'Back to back'), ('BD', 'Building'), ('PI', 'Pole by itself'), ('PI', 'Pole with another bat house'), ('TR', 'Tree'), ('OT', 'Other')], help_text='Item which bat house is mounted to', max_length=2)),
('mounted_on', models.CharField(choices=[('BD', 'Building'), ('PI', 'On a pole by itself'), ('PB', 'On a pole with another bat house, back to back'), ('TR', 'Tree'), ('OT', 'Other')], help_text='Item which bat house is mounted to', max_length=2)),
('other_mounted_on', models.CharField(blank=True, help_text='Mount type if Other is specified', max_length=255)),
('ground_height', models.PositiveIntegerField(help_text='Height above the ground surface (in feet)', validators=[django.core.validators.MinValueValidator(1)])),
('installed', models.DateField(help_text='Date when the bat house was installed')),
Expand All @@ -98,7 +98,7 @@ class Migration(migrations.Migration):
name='Observation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('checked', models.DateTimeField(help_text='Date and when the bat house was checked')),
('checked', models.DateTimeField(help_text='Date and time when the bat house was checked')),
('present', models.BooleanField(help_text='True if bats were there, False otherwise', verbose_name='bat presence')),
('occupants', models.IntegerField(blank=True, help_text='Amount of bats present in the bat house')),
('acoustic_monitor', models.CharField(choices=[('Y', 'Yes'), ('N', 'No'), ('U', 'Unsure')], help_text='Has a bat biologist came to setup acoustic monitoring around the bat house?', max_length=1)),
Expand Down
29 changes: 0 additions & 29 deletions hiber/apps/bathouse/migrations/0002_auto_20190430_1729.py

This file was deleted.

Loading

0 comments on commit 8b9d490

Please sign in to comment.