Fix URLs configuration to prevent namespace issues between api and core apps.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-17 12:17:51 -04:00
parent 42e2294c51
commit 55a908f546
6 changed files with 24 additions and 14 deletions

View File

@ -14,28 +14,36 @@ class ChildSerializer(serializers.HyperlinkedModelSerializer):
class DiaperChangeSerializer(serializers.HyperlinkedModelSerializer):
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
class Meta:
model = DiaperChange
fields = ('baby', 'time', 'wet', 'solid', 'color')
fields = ('child', 'time', 'wet', 'solid', 'color')
class FeedingSerializer(serializers.HyperlinkedModelSerializer):
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
class Meta:
model = Feeding
fields = ('baby', 'start', 'end', 'duration', 'type', 'method',
fields = ('child', 'start', 'end', 'duration', 'type', 'method',
'amount')
class NoteSerializer(serializers.HyperlinkedModelSerializer):
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
class Meta:
model = Note
fields = ('baby', 'note', 'time')
fields = ('child', 'note', 'time')
class SleepSerializer(serializers.HyperlinkedModelSerializer):
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
class Meta:
model = Sleep
fields = ('baby', 'start', 'end', 'duration')
fields = ('child', 'start', 'end', 'duration')
class TimerSerializer(serializers.HyperlinkedModelSerializer):
@ -45,6 +53,8 @@ class TimerSerializer(serializers.HyperlinkedModelSerializer):
class TummyTimeSerializer(serializers.HyperlinkedModelSerializer):
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
class Meta:
model = TummyTime
fields = ('baby', 'start', 'end', 'duration', 'milestone')
fields = ('child', 'start', 'end', 'duration', 'milestone')

View File

@ -9,7 +9,7 @@ from .views import (ChildViewSet, DiaperChangeViewSet, FeedingViewSet,
router = routers.DefaultRouter()
router.register(r'children', ChildViewSet)
router.register(r'diaper-changes', DiaperChangeViewSet)
router.register(r'changes', DiaperChangeViewSet)
router.register(r'feedings', FeedingViewSet)
router.register(r'notes', NoteViewSet)
router.register(r'sleep', SleepViewSet)

View File

@ -26,7 +26,7 @@ class DiaperChangeViewSet(viewsets.ModelViewSet):
serializer_class = DiaperChangeSerializer
def get_queryset(self):
params = ['baby__last_name', 'wet', 'solid', 'color']
params = ['child__last_name', 'wet', 'solid', 'color']
return filter_by_params(self.request, DiaperChange, params)
@ -35,7 +35,7 @@ class FeedingViewSet(viewsets.ModelViewSet):
serializer_class = FeedingSerializer
def get_queryset(self):
params = ['baby__last_name', 'type', 'method', 'amount']
params = ['child__last_name', 'type', 'method', 'amount']
return filter_by_params(self.request, Feeding, params)
@ -44,7 +44,7 @@ class NoteViewSet(viewsets.ModelViewSet):
serializer_class = NoteSerializer
def get_queryset(self):
params = ['baby__last_name']
params = ['child__last_name']
return filter_by_params(self.request, Note, params)
@ -53,7 +53,7 @@ class SleepViewSet(viewsets.ModelViewSet):
serializer_class = SleepSerializer
def get_queryset(self):
params = ['baby__last_name']
params = ['child__last_name']
return filter_by_params(self.request, Sleep, params)
@ -71,5 +71,5 @@ class TummyTimeViewSet(viewsets.ModelViewSet):
serializer_class = TummyTimeSerializer
def get_queryset(self):
params = ['baby__last_name']
params = ['child__last_name']
return filter_by_params(self.request, TummyTime, params)

View File

@ -13,6 +13,6 @@ urlpatterns = [
url('^password_reset/$', views.PasswordResetView.as_view(),
name='password_reset',),
url(r'', include('api.urls', namespace='api')),
url(r'', include('core.urls')),
url(r'', include('api.urls')),
]

View File

@ -32,7 +32,7 @@
</tr>
{% empty %}
<tr>
<th colspan="4">No children found.</th>
<th colspan="5">No children found.</th>
</tr>
{% endfor %}
</tbody>

View File

@ -4,7 +4,7 @@
<div class="card-body text-success">
<h4 class="card-text">{{ timer.duration }}</h4>
</div>
<div class="card-footer text-muted">
<div class="card-footer text-muted small">
Started {{ timer.start }}
</div>
</div>