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):
|
||||
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')
|
||||
|
|
|
@ -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)
|
||||
|
|
10
api/views.py
10
api/views.py
|
@ -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)
|
||||
|
|
|
@ -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')),
|
||||
]
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<th colspan="4">No children found.</th>
|
||||
<th colspan="5">No children found.</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue