Remove univis check files, Refractor api
This commit is contained in:
parent
73e77e2545
commit
ab2c050ae6
50
ofu_app/apps/food/api/v1_2/serializers.py
Normal file
50
ofu_app/apps/food/api/v1_2/serializers.py
Normal file
@ -0,0 +1,50 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from apps.food.models import Menu, SingleFood, HappyHour, Allergene, UserFoodImage, FoodImage
|
||||
|
||||
|
||||
class UserFoodImageSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = UserFoodImage
|
||||
fields = ('id', 'image_image', 'image_thumb')
|
||||
|
||||
|
||||
class FoodImageSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = FoodImage
|
||||
fields = ('id', 'image', 'thumb')
|
||||
|
||||
|
||||
class AllergensSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Allergene
|
||||
fields = ('id', 'name')
|
||||
|
||||
|
||||
class SingleFoodSerializer(serializers.HyperlinkedModelSerializer):
|
||||
allergens = AllergensSerializer(many=True, read_only=True)
|
||||
image = FoodImageSerializer(many=False, read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = SingleFood
|
||||
fields = ('name', 'rating', 'price_student', 'price_employee', 'price_guest', 'allergens', 'image')
|
||||
|
||||
|
||||
class MenuSerializer(serializers.HyperlinkedModelSerializer):
|
||||
date = serializers.DateField(format='iso-8601')
|
||||
menu = SingleFoodSerializer(many=True, read_only=True)
|
||||
location = serializers.ChoiceField(choices=Menu.LOCATION_CHOICES)
|
||||
|
||||
class Meta:
|
||||
model = Menu
|
||||
fields = ('id', 'date', 'location', 'menu')
|
||||
|
||||
|
||||
class HappyHourSerializer(serializers.HyperlinkedModelSerializer):
|
||||
date = serializers.DateField(format='iso-8601')
|
||||
starttime = serializers.TimeField()
|
||||
endtime = serializers.TimeField()
|
||||
|
||||
class Meta:
|
||||
model = HappyHour
|
||||
fields = ('id', 'date', 'starttime', 'endtime', 'location', 'description')
|
||||
33
ofu_app/apps/food/api/v1_2/urls.py
Normal file
33
ofu_app/apps/food/api/v1_2/urls.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""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.v1_1 import views as api_views
|
||||
from apps.food.models import Menu
|
||||
|
||||
urlpatterns = [
|
||||
# API Version 1.1
|
||||
url(r'^food/$', api_views.FoodViewSetV1_1.as_view({'get': 'list'}), name='api-v1_1-food-all'),
|
||||
url(r'^food/(?P<location>' + Menu.FEKI + '|' + Menu.MARKUSPLATZ + '|' + Menu.ERBA + '|' + Menu.AUSTRASSE + ')/$',
|
||||
api_views.FoodViewSetV1_1.as_view({'get': 'list'}), name='api-v1_1-food-location'),
|
||||
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'}), name='api-v1_1-food-date'),
|
||||
url(
|
||||
r'food/(?P<location>' + Menu.FEKI + '|' + Menu.MARKUSPLATZ + '|' + Menu.ERBA + '|' + Menu.AUSTRASSE + ')/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$',
|
||||
api_views.FoodViewSetV1_1.as_view({'get': 'list'}), name='api-v1_1-food-location-date'),
|
||||
url(r'food/today/$', api_views.FoodViewSetV1_1.as_view({'get': 'list'}), name='api-v1_1-food-today'),
|
||||
url(r'food/week/$', api_views.FoodViewSetV1_1.as_view({'get': 'list'}), name='api-v1_1-food-week'),
|
||||
url(r'happy-hour', api_views.HappyHourViewSet.as_view({'get': 'list'}), name='api-v1_1-happy-hour-all'),
|
||||
]
|
||||
190
ofu_app/apps/food/api/v1_2/views.py
Normal file
190
ofu_app/apps/food/api/v1_2/views.py
Normal file
@ -0,0 +1,190 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
from apps.food.api.v1_1.serializers import MenuSerializer, HappyHourSerializer
|
||||
from apps.food.models import Menu, HappyHour
|
||||
from rest_framework import viewsets
|
||||
|
||||
from rest_framework.decorators import permission_classes
|
||||
from rest_framework.permissions import AllowAny
|
||||
|
||||
|
||||
# @api_view(['GET'])
|
||||
@permission_classes((AllowAny,))
|
||||
class FoodViewSet(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 = self.request.query_params.get('location')
|
||||
date = self.request.query_params.get('date')
|
||||
print(str(location).upper() == Menu.ERBA.upper())
|
||||
if location:
|
||||
print(str(location).upper() == Menu.ERBA.upper())
|
||||
if str(location).upper() is Menu.ERBA.upper():
|
||||
queryset = queryset.filter(location_contains='Erba')
|
||||
elif str(location).upper() is Menu.FEKI.upper():
|
||||
queryset = queryset.filter(location=Menu.FEKI)
|
||||
elif str(location).upper() is Menu.AUSTRASSE.upper():
|
||||
queryset = queryset.filter(location=Menu.AUSTRASSE)
|
||||
elif str(location).upper() is Menu.MARKUSPLATZ.upper():
|
||||
queryset = queryset.filter(location=Menu.MARKUSPLATZ)
|
||||
if date:
|
||||
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("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:
|
||||
if str(location).upper() == Menu.ERBA.upper():
|
||||
queryset = queryset.filter(location__contains=Menu.ERBA)
|
||||
elif str(location).upper() == Menu.FEKI.upper():
|
||||
queryset = queryset.filter(location__contains=Menu.FEKI)
|
||||
elif str(location).upper() == Menu.AUSTRASSE.upper():
|
||||
print("Before: " + str(queryset))
|
||||
queryset = queryset.filter(location__contains=Menu.AUSTRASSE)
|
||||
elif str(location).upper() == Menu.MARKUSPLATZ.upper():
|
||||
queryset = queryset.filter(location__contains=Menu.MARKUSPLATZ)
|
||||
print(queryset)
|
||||
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 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:
|
||||
if str(location).upper() == Menu.ERBA.upper():
|
||||
queryset = queryset.filter(location__contains=Menu.ERBA)
|
||||
elif str(location).upper() == Menu.FEKI.upper():
|
||||
queryset = queryset.filter(location__contains=Menu.FEKI)
|
||||
elif str(location).upper() == Menu.AUSTRASSE.upper():
|
||||
print("Before: " + str(queryset))
|
||||
queryset = queryset.filter(location__contains=Menu.AUSTRASSE)
|
||||
elif str(location).upper() == Menu.MARKUSPLATZ.upper():
|
||||
queryset = queryset.filter(location__contains=Menu.MARKUSPLATZ)
|
||||
print(queryset)
|
||||
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):
|
||||
"""
|
||||
API endpoint that allows users to be viewed or edited.
|
||||
"""
|
||||
queryset = HappyHour.objects.all()
|
||||
serializer_class = HappyHourSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = HappyHour.objects.all()
|
||||
type = self.request.query_params.get('type')
|
||||
|
||||
# if type == "food":
|
||||
# queryset = HappyHour.filter(location__contains="Austraße")
|
||||
# elif type == "drinks":
|
||||
# queryset = HappyHour.filter(location__contains="Austraße")
|
||||
|
||||
return queryset
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'Liederabend mit Martin Fösel (Gesang) und Beate Roux (Klavier)'
|
||||
('Internationale Konferenz zum Ganztag "WERA-IRN Konferenz Ganztägige Bildung '
|
||||
'aus einer international vergleichenden Perspektive", 30.11.- 02.12.17')
|
||||
'11. Bamberger Neuropsychologietag'
|
||||
('Vortrag Dr. Jessica Röhner: Die Untersuchung von fälschungs- und '
|
||||
'konstruktbezogener Varianz im IAT mit Hilfe von Diffusionsmodellanalysen')
|
||||
('Vortrag Dr. Anna Dechant: (Nicht-)Intentional Partnerlos. Wer ist '
|
||||
'(un-)freiwillig Single und wie verändert sich das mit der Zeit?')
|
||||
('Vortrag Dr. Oliver Arnold: Verhalten als kompensatorische Funktion von '
|
||||
'Einstellung und Verhaltenskosten: Die Person-Situation-Interaktion im Rahmen '
|
||||
'des Campell-Paradigmas')
|
||||
('Vortrag Prof. Dr. Christine Syrek: Mikropause bis Urlaub: Förderung von '
|
||||
'Gesundheit und Leistungsverhalten durch Erholung von arbeitsbezogenem Stress')
|
||||
('Vortrag PD Dr. Miriam Kunz: Wenn die Sprache versiegt: Affekterkennung bei '
|
||||
'Demenz')
|
||||
'Hochschulöffentliches Gespräch mit dem Mittelbau'
|
||||
'Hochschulöffentliches Gespräch mit Studierenden'
|
||||
Successfully migrate data
|
||||
@ -1,99 +0,0 @@
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'Abschlussworkshop Innovationslabor'
|
||||
'Auftaktworkshop Innovationslabor'
|
||||
'Bigband Aufbau'
|
||||
'Cajónbau Workshop'
|
||||
'Cajónbau Workshop'
|
||||
'Cajón Workshop'
|
||||
'Ensembleleitung Übung'
|
||||
'Fortbildungstag "Musik lebendig unterrichten"'
|
||||
'Fortbildungstag "Musik lebendig unterrichten"'
|
||||
'Fortbildungstag "Musik lebendig unterrichten"'
|
||||
'Fortbildungstag "Musik lebendig unterrichten"'
|
||||
'Kammerorchesterprobe'
|
||||
'Kammerorchesterprobe'
|
||||
'Kammerorchesterprobe'
|
||||
'Kammerorchesterprobe'
|
||||
'Kammerorchesterprobe'
|
||||
'Liederabend mit Martin Fösel (Gesang) und Beate Roux (Klavier)'
|
||||
'Probe für Liederabend mit Martin Fösel (Gesang) Beate Roux (Klavier) und'
|
||||
'Semester-Ouvertüre'
|
||||
'Staatsexamen Ensemblearbeit'
|
||||
'Aktivierende Methoden'
|
||||
'Aktivierende Methoden'
|
||||
'Andragogentag'
|
||||
'Visualisieren - Präsentieren'
|
||||
'Doktoranden-Kolloquium'
|
||||
('Internationale Konferenz zum Ganztag "WERA-IRN Konferenz Ganztägige Bildung '
|
||||
'aus einer international vergleichenden Perspektive", 30.11.- 02.12.17')
|
||||
'Tagung - WERA-IRN Extended Education'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Bamberger Peer-Beratungstraining'
|
||||
'Beratung im schulischen Kontext. Das Bamberger Peer-Beratungstraining'
|
||||
'Beratung im schulischen Kontext. Das Bamberger Peer-Beratungstraining'
|
||||
'Beratung im schulischen Kontext. Das Bamberger Peer-Beratungstraining'
|
||||
('Jahrestagung 2018 der Konferenz für Grundschulpädagogik und -didaktik an '
|
||||
'bayerischen Universitäten')
|
||||
'Lernwerkstattfortbildung für Schulleitungen'
|
||||
'Lernwerkstattfortbildung für Schulleitungen'
|
||||
'Lernwerkstattfortbildung für Schulleitungen'
|
||||
'Lernwerkstattfortbildung für Schulleitungen'
|
||||
'Lehrstuhlkolloquium'
|
||||
'Der Masterstudiengang Gerontologie in Erlangen'
|
||||
'Gruppentraining Sozialer Kompetenzen'
|
||||
'Infoabend Auslandssemester/-praktikum'
|
||||
'Nebenfachabend'
|
||||
'Pädagogik in einem (sozial-) psychiatrischen Arbeitsfeld'
|
||||
'Prüfungsangstbewältigung'
|
||||
'Psychische Erkrankungen bei Studierenden'
|
||||
'Schriftl. Prüfung "Masterstudiengang Educational Quality"'
|
||||
'Schulleitersymposium (SLS)'
|
||||
'Schulleitersymposium (SLS)'
|
||||
'Schulleitersymposium (SLS)'
|
||||
'Schulleitersymposium (SLS)'
|
||||
'Schulleitersymposium (SLS)'
|
||||
'Schwerpunktabend Sozialpädagogik'
|
||||
'Schwerpunktabend EFP'
|
||||
'Schwerpunktabend Erwachsenenbildung/Weiterbildung'
|
||||
'Forschertreffen'
|
||||
'Forschertreffen'
|
||||
'Forschertreffen'
|
||||
'Frau Penczek'
|
||||
'Jour fixe'
|
||||
'Jour fixe'
|
||||
'Praxis lehren'
|
||||
'Praxis lehren'
|
||||
'Workshop Bildung'
|
||||
'Workshop Bildung'
|
||||
'Workshop Bildung'
|
||||
'11. Bamberger Neuropsychologietag'
|
||||
'Disputation'
|
||||
'Training zur psychischen ersten Hilfe für Laien'
|
||||
('Vortrag Dr. Jessica Röhner: Die Untersuchung von fälschungs- und '
|
||||
'konstruktbezogener Varianz im IAT mit Hilfe von Diffusionsmodellanalysen')
|
||||
('Vortrag Dr. Anna Dechant: (Nicht-)Intentional Partnerlos. Wer ist '
|
||||
'(un-)freiwillig Single und wie verändert sich das mit der Zeit?')
|
||||
('Vortrag Dr. Oliver Arnold: Verhalten als kompensatorische Funktion von '
|
||||
'Einstellung und Verhaltenskosten: Die Person-Situation-Interaktion im Rahmen '
|
||||
'des Campell-Paradigmas')
|
||||
('Vortrag Prof. Dr. Christine Syrek: Mikropause bis Urlaub: Förderung von '
|
||||
'Gesundheit und Leistungsverhalten durch Erholung von arbeitsbezogenem Stress')
|
||||
('Vortrag PD Dr. Miriam Kunz: Wenn die Sprache versiegt: Affekterkennung bei '
|
||||
'Demenz')
|
||||
'Abschiedsvorlesung Prof. Dr. Rahm (noch unter Vorbehalt)'
|
||||
'Disputation Nusser'
|
||||
'Fakultätsweihnacht'
|
||||
'Hochschulöffentliches Gespräch mit dem Mittelbau'
|
||||
'Hochschulöffentliches Gespräch mit Studierenden'
|
||||
Successfully migrate data
|
||||
@ -1,22 +0,0 @@
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'ForMaD: Forum Mathematik-Didaktik'
|
||||
'Liederabend mit Martin Fösel (Gesang) und Beate Roux (Klavier)'
|
||||
('Internationale Konferenz zum Ganztag "WERA-IRN Konferenz Ganztägige Bildung '
|
||||
'aus einer international vergleichenden Perspektive", 30.11.- 02.12.17')
|
||||
'11. Bamberger Neuropsychologietag'
|
||||
('Vortrag Dr. Jessica Röhner: Die Untersuchung von fälschungs- und '
|
||||
'konstruktbezogener Varianz im IAT mit Hilfe von Diffusionsmodellanalysen')
|
||||
('Vortrag Dr. Anna Dechant: (Nicht-)Intentional Partnerlos. Wer ist '
|
||||
'(un-)freiwillig Single und wie verändert sich das mit der Zeit?')
|
||||
('Vortrag Dr. Oliver Arnold: Verhalten als kompensatorische Funktion von '
|
||||
'Einstellung und Verhaltenskosten: Die Person-Situation-Interaktion im Rahmen '
|
||||
'des Campell-Paradigmas')
|
||||
('Vortrag Prof. Dr. Christine Syrek: Mikropause bis Urlaub: Förderung von '
|
||||
'Gesundheit und Leistungsverhalten durch Erholung von arbeitsbezogenem Stress')
|
||||
('Vortrag PD Dr. Miriam Kunz: Wenn die Sprache versiegt: Affekterkennung bei '
|
||||
'Demenz')
|
||||
'Hochschulöffentliches Gespräch mit dem Mittelbau'
|
||||
'Hochschulöffentliches Gespräch mit Studierenden'
|
||||
Successfully migrate data
|
||||
Reference in New Issue
Block a user