Fix markusplatz markusstrasse bug
This commit is contained in:
parent
0dd3f51668
commit
6d1da0b427
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.7 on 2018-01-05 02:00
|
||||
# Generated by Django 1.11.7 on 2018-01-05 13:49
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
@ -17,6 +17,6 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='lecture_terms',
|
||||
name='starttime',
|
||||
field=models.TimeField(default=datetime.datetime(2018, 1, 5, 2, 0, 11, 705365, tzinfo=utc)),
|
||||
field=models.TimeField(default=datetime.datetime(2018, 1, 5, 13, 49, 38, 439221, tzinfo=utc)),
|
||||
),
|
||||
]
|
||||
@ -1,22 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.7 on 2018-01-05 02:04
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('donar', '0002_auto_20180105_0300'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='lecture_terms',
|
||||
name='starttime',
|
||||
field=models.TimeField(default=datetime.datetime(2018, 1, 5, 2, 4, 12, 19246, tzinfo=utc)),
|
||||
),
|
||||
]
|
||||
@ -1,20 +0,0 @@
|
||||
# Generated by Django 2.0.1 on 2018-01-04 18:05
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('donar', '0009_auto_20171204_1648'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='lecture_terms',
|
||||
name='starttime',
|
||||
field=models.TimeField(default=datetime.datetime(2018, 1, 4, 18, 5, 54, 971358, tzinfo=utc)),
|
||||
),
|
||||
]
|
||||
32
ofu_app/apps/food/api/urls.py
Normal file
32
ofu_app/apps/food/api/urls.py
Normal file
@ -0,0 +1,32 @@
|
||||
"""ofu_app URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/1.11/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.conf.urls import url, include
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf.urls import url
|
||||
from apps.food.api import views as api_views
|
||||
|
||||
urlpatterns = [
|
||||
# API Version 1.1
|
||||
url(r'^food/$', api_views.FoodViewSetV1_1.as_view({'get': 'list'})),
|
||||
url(r'^food/(?P<location>feldkirchenstrasse|markusstrasse|erba|austrasse)/$',
|
||||
api_views.FoodViewSetV1_1.as_view({'get': 'list'})),
|
||||
url(r'food/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$',
|
||||
api_views.FoodViewSetV1_1.as_view({'get': 'list'})),
|
||||
url(
|
||||
r'food/(?P<location>feldkirchenstrasse|markusstrasse|erba|austrasse)/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$',
|
||||
api_views.FoodViewSetV1_1.as_view({'get': 'list'})),
|
||||
url(r'food/today/$', api_views.FoodViewSetV1_1.as_view({'get': 'list'})),
|
||||
url(r'food/week/$', api_views.FoodViewSetV1_1.as_view({'get': 'list'})),
|
||||
url(r'happy-hour', api_views.FoodViewSetV1_1.as_view({'get': 'list'})),
|
||||
]
|
||||
@ -34,9 +34,9 @@ class FoodViewSet(viewsets.ModelViewSet, ):
|
||||
elif location == locations[1]:
|
||||
queryset = queryset.filter(location__contains="Feldkirchen")
|
||||
elif location == locations[2]:
|
||||
queryset = queryset.filter(location__contains="Austraße")
|
||||
queryset = queryset.filter(location__contains="austraße")
|
||||
elif location == locations[3]:
|
||||
queryset = queryset.filter(location__contains="Markusplatz")
|
||||
queryset = queryset.filter(location__contains="markusplatz")
|
||||
if date:
|
||||
if date == "week":
|
||||
today = datetime.now()
|
||||
@ -49,12 +49,73 @@ class FoodViewSet(viewsets.ModelViewSet, ):
|
||||
else:
|
||||
queryset = queryset.filter(date=datetime.strptime(date, "%Y-%m-%d"))
|
||||
|
||||
print("LOCATION: %s" % str(location))
|
||||
print("DATE: " + str(date))
|
||||
print(str(queryset))
|
||||
|
||||
return queryset
|
||||
|
||||
|
||||
# @api_view(['GET'])
|
||||
@permission_classes((AllowAny,))
|
||||
class FoodViewSetV1_1(viewsets.ModelViewSet, ):
|
||||
"""
|
||||
API endpoint that allows users to be viewed or edited.
|
||||
"""
|
||||
# queryset = Menu.objects.all()
|
||||
serializer_class = MenuSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = Menu.objects.all()
|
||||
location = None
|
||||
if 'location' in self.kwargs:
|
||||
location = self.kwargs['location']
|
||||
|
||||
year = None
|
||||
if 'year' in self.kwargs:
|
||||
year = self.kwargs['year']
|
||||
month = None
|
||||
if 'month' in self.kwargs:
|
||||
month = self.kwargs['month']
|
||||
day = None
|
||||
if 'day' in self.kwargs:
|
||||
day = self.kwargs['day']
|
||||
|
||||
if location:
|
||||
# TODO better way to get location list
|
||||
locations = ["erba", "feldkirchenstrasse", "austrasse", "markusstrasse"]
|
||||
if locations.__contains__(location):
|
||||
print("Location: " + str(location))
|
||||
if location == locations[0]:
|
||||
queryset = queryset.filter(location__contains="Erba")
|
||||
elif location == locations[1]:
|
||||
queryset = queryset.filter(location__contains="Feldkirchen")
|
||||
elif location == locations[2]:
|
||||
queryset = queryset.filter(location__contains="Austraße")
|
||||
elif location == locations[3]:
|
||||
queryset = queryset.filter(location__contains="Markusplatz")
|
||||
|
||||
if year and month and day:
|
||||
date = '%s-%s-%s' % (year, month, day)
|
||||
queryset = queryset.filter(date=datetime.strptime(date, '%Y-%m-%d'))
|
||||
|
||||
# if date == "week":
|
||||
# today = datetime.now()
|
||||
# weekday = today.weekday()
|
||||
# monday = today - timedelta(weekday)
|
||||
# sunday = today + (timedelta(6 - weekday))
|
||||
# print("Monday: " + str(monday))
|
||||
# print("Sunday: " + str(sunday))
|
||||
# queryset = queryset.filter(date__gte=monday, date__lte=sunday)
|
||||
# else:
|
||||
# queryset = queryset.filter(date=datetime.strptime(date, "%Y-%m-%d"))
|
||||
|
||||
print("LOCATION: %s" % str(location))
|
||||
print(str(queryset))
|
||||
|
||||
return queryset
|
||||
|
||||
|
||||
# @api_view(['GET'])
|
||||
@permission_classes((AllowAny,))
|
||||
class HappyHourViewSet(viewsets.ModelViewSet):
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.7 on 2018-01-05 02:04
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('food', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='userfoodimage',
|
||||
old_name='thumbnail',
|
||||
new_name='thumb',
|
||||
),
|
||||
]
|
||||
@ -1,4 +1,6 @@
|
||||
# Generated by Django 2.0.1 on 2018-01-04 18:05
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.7 on 2018-01-05 13:49
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
@ -8,14 +10,14 @@ import django.db.models.deletion
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('food', '0005_auto_20171204_1634'),
|
||||
('food', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='menu',
|
||||
name='menu',
|
||||
field=models.ManyToManyField(related_name='foods', to='food.SingleFood'),
|
||||
migrations.RenameField(
|
||||
model_name='userfoodimage',
|
||||
old_name='thumbnail',
|
||||
new_name='thumb',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='userfoodimage',
|
||||
@ -25,20 +25,6 @@ apiRouter_v1 = routers.DefaultRouter()
|
||||
apiRouter_v1.register(r'food', api_views.FoodViewSet, base_name='Food')
|
||||
apiRouter_v1.register(r'happy-hour', api_views.HappyHourViewSet, base_name='HappyHours')
|
||||
|
||||
# API Version 1.1
|
||||
apiRouter_v1_1 = routers.DefaultRouter()
|
||||
apiRouter_v1_1.register(r'food', api_views.FoodViewSet, base_name='Food')
|
||||
apiRouter_v1_1.register(r'food/(?P<location>[feldkirchenstrasse, markusstrasse, erba, austrasse])/$',
|
||||
api_views.FoodViewSet, base_name='Food')
|
||||
apiRouter_v1_1.register(r'food/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$', api_views.FoodViewSet,
|
||||
base_name='Food')
|
||||
apiRouter_v1_1.register(
|
||||
r'food/(?P<location>)[feldkirchenstrasse, markusstrasse, erba, austrasse]/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$',
|
||||
api_views.FoodViewSet, base_name='Food')
|
||||
apiRouter_v1_1.register(r'food/today/$', api_views.FoodViewSet, base_name='Food')
|
||||
apiRouter_v1_1.register(r'food/week/$', api_views.FoodViewSet, base_name='Food')
|
||||
apiRouter_v1_1.register(r'happy-hour', api_views.HappyHourViewSet, base_name='HappyHours')
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.food, name='food'),
|
||||
|
||||
|
||||
@ -26,8 +26,8 @@ from django.conf.urls.static import static
|
||||
api_router_v1 = routers.DefaultRouter()
|
||||
api_router_v1.registry.extend(food_urls.apiRouter_v1.registry)
|
||||
|
||||
api_router_v1_1 = routers.DefaultRouter()
|
||||
api_router_v1_1.registry.extend(food_urls.apiRouter_v1_1.registry)
|
||||
# api_router_v1_1 = routers.DefaultRouter()
|
||||
# api_router_v1_1.registry.extend(food_urls.apiRouter_v1_1.registry)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^login/$', auth_views.login, {'template_name': 'registration/login.jinja'}, name='login'),
|
||||
@ -47,6 +47,6 @@ urlpatterns = [
|
||||
|
||||
# -- API --
|
||||
url(r'^api/v1/', include(api_router_v1.urls)),
|
||||
url(r'^api/v1.1/', include(api_router_v1_1.urls)),
|
||||
url(r'^api/v1.1/', include('apps.food.api.urls')),
|
||||
url(r'^api/auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
Reference in New Issue
Block a user