mirror of https://github.com/snachodog/mybuddy.git
Fix URLs configuration to prevent namespace issues between api and core apps.
This commit is contained in:
parent
42e2294c51
commit
55a908f546
|
@ -14,28 +14,36 @@ class ChildSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class DiaperChangeSerializer(serializers.HyperlinkedModelSerializer):
|
class DiaperChangeSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = DiaperChange
|
model = DiaperChange
|
||||||
fields = ('baby', 'time', 'wet', 'solid', 'color')
|
fields = ('child', 'time', 'wet', 'solid', 'color')
|
||||||
|
|
||||||
|
|
||||||
class FeedingSerializer(serializers.HyperlinkedModelSerializer):
|
class FeedingSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Feeding
|
model = Feeding
|
||||||
fields = ('baby', 'start', 'end', 'duration', 'type', 'method',
|
fields = ('child', 'start', 'end', 'duration', 'type', 'method',
|
||||||
'amount')
|
'amount')
|
||||||
|
|
||||||
|
|
||||||
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Note
|
model = Note
|
||||||
fields = ('baby', 'note', 'time')
|
fields = ('child', 'note', 'time')
|
||||||
|
|
||||||
|
|
||||||
class SleepSerializer(serializers.HyperlinkedModelSerializer):
|
class SleepSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Sleep
|
model = Sleep
|
||||||
fields = ('baby', 'start', 'end', 'duration')
|
fields = ('child', 'start', 'end', 'duration')
|
||||||
|
|
||||||
|
|
||||||
class TimerSerializer(serializers.HyperlinkedModelSerializer):
|
class TimerSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
@ -45,6 +53,8 @@ class TimerSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class TummyTimeSerializer(serializers.HyperlinkedModelSerializer):
|
class TummyTimeSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TummyTime
|
model = TummyTime
|
||||||
fields = ('baby', 'start', 'end', 'duration', 'milestone')
|
fields = ('child', 'start', 'end', 'duration', 'milestone')
|
||||||
|
|
|
@ -9,7 +9,7 @@ from .views import (ChildViewSet, DiaperChangeViewSet, FeedingViewSet,
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r'children', ChildViewSet)
|
router.register(r'children', ChildViewSet)
|
||||||
router.register(r'diaper-changes', DiaperChangeViewSet)
|
router.register(r'changes', DiaperChangeViewSet)
|
||||||
router.register(r'feedings', FeedingViewSet)
|
router.register(r'feedings', FeedingViewSet)
|
||||||
router.register(r'notes', NoteViewSet)
|
router.register(r'notes', NoteViewSet)
|
||||||
router.register(r'sleep', SleepViewSet)
|
router.register(r'sleep', SleepViewSet)
|
||||||
|
|
10
api/views.py
10
api/views.py
|
@ -26,7 +26,7 @@ class DiaperChangeViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = DiaperChangeSerializer
|
serializer_class = DiaperChangeSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
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)
|
return filter_by_params(self.request, DiaperChange, params)
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class FeedingViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = FeedingSerializer
|
serializer_class = FeedingSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
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)
|
return filter_by_params(self.request, Feeding, params)
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class NoteViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = NoteSerializer
|
serializer_class = NoteSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
params = ['baby__last_name']
|
params = ['child__last_name']
|
||||||
return filter_by_params(self.request, Note, params)
|
return filter_by_params(self.request, Note, params)
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class SleepViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = SleepSerializer
|
serializer_class = SleepSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
params = ['baby__last_name']
|
params = ['child__last_name']
|
||||||
return filter_by_params(self.request, Sleep, params)
|
return filter_by_params(self.request, Sleep, params)
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,5 +71,5 @@ class TummyTimeViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = TummyTimeSerializer
|
serializer_class = TummyTimeSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
params = ['baby__last_name']
|
params = ['child__last_name']
|
||||||
return filter_by_params(self.request, TummyTime, params)
|
return filter_by_params(self.request, TummyTime, params)
|
||||||
|
|
|
@ -13,6 +13,6 @@ urlpatterns = [
|
||||||
url('^password_reset/$', views.PasswordResetView.as_view(),
|
url('^password_reset/$', views.PasswordResetView.as_view(),
|
||||||
name='password_reset',),
|
name='password_reset',),
|
||||||
|
|
||||||
|
url(r'', include('api.urls', namespace='api')),
|
||||||
url(r'', include('core.urls')),
|
url(r'', include('core.urls')),
|
||||||
url(r'', include('api.urls')),
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4">No children found.</th>
|
<th colspan="5">No children found.</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="card-body text-success">
|
<div class="card-body text-success">
|
||||||
<h4 class="card-text">{{ timer.duration }}</h4>
|
<h4 class="card-text">{{ timer.duration }}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer text-muted">
|
<div class="card-footer text-muted small">
|
||||||
Started {{ timer.start }}
|
Started {{ timer.start }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue