Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 464fe5ba17 | |||
| 002aeff50a | |||
| 652e3d50eb | |||
| f0bca5e89a | |||
| 5b67afeec4 | |||
| dd9d3565ed | |||
| 62df896c68 | |||
| 42d61ecaca | |||
| b86d4c473c | |||
| 4db42a6f72 |
@ -28,6 +28,8 @@ LOGIN_REDIRECT_URL = 'roomservice:home'
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 40000
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
@ -183,11 +185,11 @@ LOGGING = {
|
||||
# 'level': 'INFO',
|
||||
# },
|
||||
|
||||
'roomservice': {
|
||||
'roomservice.utils': {
|
||||
'handlers': ['console'],
|
||||
'level': 'INFO',
|
||||
},
|
||||
'roomservice.management.sample_data_creation': {
|
||||
'roomservice.management': {
|
||||
'handlers': ['console'],
|
||||
'level': 'DEBUG'
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ urlpatterns = [
|
||||
path('api/', include('roomservice.api.urls')),
|
||||
|
||||
# API Docs
|
||||
# path('api/docs/', include_docs_urls(title='Respool API Docs', public=True,
|
||||
# authentication_classes=[BasicAuthentication, ],
|
||||
# permission_classes=[AllowAny, ])),
|
||||
path('api/docs/', include_docs_urls(title='Respool API Docs', public=True,
|
||||
authentication_classes=[BasicAuthentication, ],
|
||||
permission_classes=[AllowAny, ])),
|
||||
]
|
||||
|
||||
@ -6,4 +6,5 @@ Pillow==5.1.0
|
||||
django-extensions==2.0.7
|
||||
requests==2.18.4
|
||||
djangorestframework==3.8.2
|
||||
coreapi==2.3.3
|
||||
coreapi==2.3.3
|
||||
xmltodict==0.11.0
|
||||
@ -1,16 +1,20 @@
|
||||
from django.contrib import admin
|
||||
from .models import Staff, Room, RoomType, BookingGroup, Booking, Equipment, Location, Building, NumEquipment, \
|
||||
AccessPoint, Favorite
|
||||
from .models import Room, Building, RoomType, OrgUnit, Equipment, Staff, Lecture, LectureTerm, LectureSpecifiaction, \
|
||||
LectureType
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(Lecture)
|
||||
admin.site.register(LectureTerm)
|
||||
admin.site.register(LectureSpecifiaction)
|
||||
admin.site.register(LectureType)
|
||||
admin.site.register(Staff)
|
||||
admin.site.register(Room)
|
||||
admin.site.register(RoomType)
|
||||
admin.site.register(BookingGroup)
|
||||
admin.site.register(Booking)
|
||||
# admin.site.register(BookingGroup)
|
||||
# admin.site.register(Booking)
|
||||
admin.site.register(Equipment)
|
||||
admin.site.register(Location)
|
||||
admin.site.register(Building)
|
||||
admin.site.register(NumEquipment)
|
||||
admin.site.register(AccessPoint)
|
||||
admin.site.register(Favorite)
|
||||
# admin.site.register(NumEquipment)
|
||||
# admin.site.register(AccessPoint)
|
||||
# admin.site.register(Favorite)
|
||||
admin.site.register(OrgUnit)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from roomservice.models import Booking, Room
|
||||
from roomservice.models import Room
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
@ -8,13 +8,13 @@ class RoomSerializer(serializers.HyperlinkedModelSerializer):
|
||||
fields = ('id',)
|
||||
|
||||
|
||||
class BookingSerializer(serializers.HyperlinkedModelSerializer):
|
||||
room = RoomSerializer(many=False, read_only=True)
|
||||
start_date = serializers.DateField(format='iso-8601')
|
||||
end_date = serializers.DateField(format='iso-8601')
|
||||
start_time = serializers.TimeField(format='iso-8601')
|
||||
end_time = serializers.TimeField(format='iso-8601')
|
||||
|
||||
class Meta:
|
||||
model = Booking
|
||||
fields = ('id', 'room', 'start_date', 'end_date', 'start_time', 'end_time')
|
||||
# class BookingSerializer(serializers.HyperlinkedModelSerializer):
|
||||
# room = RoomSerializer(many=False, read_only=True)
|
||||
# start_date = serializers.DateField(format='iso-8601')
|
||||
# end_date = serializers.DateField(format='iso-8601')
|
||||
# start_time = serializers.TimeField(format='iso-8601')
|
||||
# end_time = serializers.TimeField(format='iso-8601')
|
||||
#
|
||||
# class Meta:
|
||||
# model = Booking
|
||||
# fields = ('id', 'room', 'start_date', 'end_date', 'start_time', 'end_time')
|
||||
|
||||
@ -3,5 +3,5 @@ from . import views
|
||||
|
||||
app_name = 'roomservice.api'
|
||||
urlpatterns = [
|
||||
path('booking', views.ApiBooking.as_view(), name='api-booking'),
|
||||
# path('booking', views.ApiBooking.as_view(), name='api-booking'),
|
||||
]
|
||||
@ -1,21 +1,22 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from roomservice.models import Booking
|
||||
from roomservice.api.serializers import BookingSerializer
|
||||
# from roomservice.models import Booking
|
||||
# from roomservice.api.serializers import BookingSerializer
|
||||
|
||||
from rest_framework import generics
|
||||
from rest_framework.decorators import permission_classes
|
||||
from rest_framework.permissions import IsAuthenticated, AllowAny
|
||||
|
||||
|
||||
@permission_classes((AllowAny,))
|
||||
class ApiBooking(generics.ListAPIView):
|
||||
serializer_class = BookingSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = Booking.objects.all()
|
||||
roomId = self.request.query_params.get('room_id')
|
||||
|
||||
if roomId:
|
||||
queryset = queryset.filter(room=roomId)
|
||||
return queryset
|
||||
#
|
||||
# @permission_classes((AllowAny,))
|
||||
# class ApiBooking(generics.ListAPIView):
|
||||
# """Lists all Bookings"""
|
||||
# serializer_class = BookingSerializer
|
||||
#
|
||||
# def get_queryset(self):
|
||||
# queryset = Booking.objects.all()
|
||||
# roomId = self.request.query_params.get('room_id')
|
||||
#
|
||||
# if roomId:
|
||||
# queryset = queryset.filter(room=roomId)
|
||||
# return queryset
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
from django.db import models
|
||||
from .models import Favorite
|
||||
from django.forms import ModelForm
|
||||
|
||||
|
||||
class AuthorForm(ModelForm):
|
||||
class Meta:
|
||||
model = Favorite
|
||||
fields = ['room', 'staff']
|
||||
# from django.db import models
|
||||
# from .models import Favorite
|
||||
# from django.forms import ModelForm
|
||||
#
|
||||
#
|
||||
# class FavoriteForm(ModelForm):
|
||||
# class Meta:
|
||||
# model = Favorite
|
||||
# fields = ['room']
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from roomservice.utils import migrate_data_rooms
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Import room data from univis prg api"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
migrate_data_rooms.main()
|
||||
@ -0,0 +1,32 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from roomservice.utils import migrate_data_rooms
|
||||
from roomservice.models import Equipment
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
UNIVIS_IDS_MAP = [{'id': 'LOSE', 'name': 'Lose Bestuhlung'},
|
||||
{'id': 'FEST', 'name': 'Feste Bestuhlung'},
|
||||
{'id': 'ANST', 'name': 'Sitzreihen ansteigend'},
|
||||
{'id': 'DARK', 'name': 'Verdunklung'},
|
||||
{'id': 'VISU', 'name': 'DocCam'},
|
||||
{'id': 'DBEAM', 'name': 'Doppelprojektion'},
|
||||
{'id': 'PC', 'name': 'Interner PC'},
|
||||
{'id': 'MIKR', 'name': 'Pultmikrofon'},
|
||||
{'id': 'FUNK', 'name': 'Funkmikrofon'},
|
||||
{'id': 'INDUK', 'name': 'Induktive Höranlage'},
|
||||
{'id': 'DVD', 'name': 'DVD-Player'},
|
||||
{'id': 'BLURAY', 'name': 'BluRay-Player'},
|
||||
{'id': 'PRUEF', 'name': 'Prüfungsraum'},
|
||||
{'id': 'OHEAD', 'name': 'Overheadprojektor'}]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Import room data from univis prg api"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
logger.info("Start:\nEquipment: {}".format(Equipment.objects.count()))
|
||||
for elem in UNIVIS_IDS_MAP:
|
||||
equip, _ = Equipment.objects.update_or_create(univis_id=elem['id'], name=elem['name'])
|
||||
logger.info("Start:\nEquipment: {}".format(Equipment.objects.count()))
|
||||
@ -0,0 +1,31 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from roomservice.utils import migrate_data_rooms
|
||||
from roomservice.models import LectureSpecifiaction
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
UNIVIS_IDS_MAP = [{'id': 'OBLIG', 'name': 'obligatorische Lehrveranstaltung'},
|
||||
{'id': 'GENERALE', 'name': 'Studium Generale'},
|
||||
{'id': 'ENGLISH', 'name': 'Englischsprachig'},
|
||||
{'id': 'ETCS', 'name': 'ECTS-Studium'},
|
||||
{'id': 'WOMSPE', 'name': 'Frauenspezifisch/Geschlechtervergl'},
|
||||
{'id': 'ANPFLICHT', 'name': 'Anwesenheitspflicht'},
|
||||
{'id': 'MODULSTUD', 'name': 'Modulstudium'},
|
||||
{'id': 'FRUEH', 'name': 'Frühstudium'},
|
||||
{'id': 'ZENIS', 'name': 'Zentrum für Interreligiöse Studien'},
|
||||
{'id': 'BENSCHEIN', 'name': 'benoteter Schein'},
|
||||
{'id': 'ERWEI', 'name': 'Erweiterungsbereich'},
|
||||
{'id': 'ZENMAS', 'name': ' Zentrum für Mittelalterstudien'},
|
||||
]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Import room data from univis prg api"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
logger.info("Start:\nLecture Specs: {}".format(LectureSpecifiaction.objects.count()))
|
||||
for elem in UNIVIS_IDS_MAP:
|
||||
equip, _ = LectureSpecifiaction.objects.update_or_create(univis_id=elem['id'], name=elem['name'])
|
||||
logger.info("Start:\nLecture Specs: {}".format(LectureSpecifiaction.objects.count()))
|
||||
@ -0,0 +1,55 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from roomservice.utils import migrate_data_rooms
|
||||
from roomservice.models import LectureType
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
UNIVIS_IDS_MAP = [{'id': 'V', 'name': 'Vorlesung'},
|
||||
|
||||
{'id': 'Vorlesung', 'name': 'Vorlesung'},
|
||||
{'id': 'Vorlesung/Seminar', 'name': 'Vorlesung/Seminar'},
|
||||
|
||||
{'id': 'Seminar', 'name': 'Seminar'},
|
||||
{'id': 'Hauptseminar', 'name': 'Hauptseminar'},
|
||||
{'id': 'Oberseminar', 'name': 'Oberseminar'},
|
||||
{'id': 'Blockseminar', 'name': 'Blockseminar'},
|
||||
{'id': 'Seminar/Oberseminar', 'name': 'Seminar/Oberseminar'},
|
||||
{'id': 'Seminaristischer Unterricht', 'name': 'Seminaristischer Unterricht'},
|
||||
{'id': 'Vertiefungsseminar', 'name': 'Vertiefungsseminar'},
|
||||
{'id': 'Proseminar', 'name': 'Proseminar'},
|
||||
{'id': 'Seminar/Hauptseminar', 'name': 'Seminar/Hauptseminar'},
|
||||
{'id': 'Forschungsseminar', 'name': 'Forschungsseminar'},
|
||||
|
||||
{'id': 'Ü', 'name': 'Übung'},
|
||||
{'id': 'Übung', 'name': 'Übung'},
|
||||
{'id': 'Übung/Blockseminar', 'name': 'Übung/Blockseminar'},
|
||||
{'id': 'Übung/Tutorium', 'name': 'Übung/Tutorium'},
|
||||
|
||||
{'id': 'Praktikum', 'name': 'Praktikum'},
|
||||
{'id': 'Forschungspraktikum', 'name': 'Forschungspraktikum'},
|
||||
{'id': 'Sonstige Lehrveranstaltung', 'name': 'Sonstige Lehrveranstaltung'},
|
||||
{'id': 'Tutorien', 'name': 'Tutorien'},
|
||||
|
||||
{'id': 'Kolloquium', 'name': 'Kolloquium'},
|
||||
{'id': 'Repetitorium', 'name': 'Repetitorium'},
|
||||
|
||||
{'id': 'Vorlesung und Übung', 'name': 'Vorlesung und Übung'},
|
||||
{'id': 'Seminar/Proseminar', 'name': 'Seminar/Proseminar'},
|
||||
{'id': 'Seminar/Übung', 'name': 'Seminar/Übung'},
|
||||
{'id': 'feldarchäologisches Praktikum', 'name': 'feldarchäologisches Praktikum'},
|
||||
{'id': 'Exkursion', 'name': 'Exkursion'},
|
||||
# {'id': 'Klausurenkurs', 'name': 'Klausurenkurs'},
|
||||
# {'id': 'Klausurenkurs', 'name': 'Klausurenkurs'},
|
||||
]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Import room data from univis prg api"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
logger.info("Start:\nLecture Types: {}".format(LectureType.objects.count()))
|
||||
for elem in UNIVIS_IDS_MAP:
|
||||
equip, _ = LectureType.objects.update_or_create(univis_id=elem['id'], name=elem['name'])
|
||||
logger.info("Start:\nLecture Types: {}".format(LectureType.objects.count()))
|
||||
@ -0,0 +1,9 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from roomservice.utils import migrate_data_lectures
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Import room data from univis prg api"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
migrate_data_lectures.main()
|
||||
@ -1,153 +0,0 @@
|
||||
from roomservice.models import RoomType, Room, NumEquipment, Building, Location, Equipment, Booking, BookingGroup, \
|
||||
Staff, AccessPoint, Favorite
|
||||
from django.contrib.auth.models import User
|
||||
import logging
|
||||
import random
|
||||
import datetime
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LOCATIONS = ['Bamberg', 'Erlangen', 'Crailsheim', 'Hamburg', 'Chemnitz', 'Dresden', 'Sebnitz', 'Gunzenhausen',
|
||||
'Nürnberg']
|
||||
BUILDINGS = ['253', '274', '134', '256', '142', '432', '652', '333', '233', '444', '332']
|
||||
ROOMTYPE = ['Office', 'Conference Room', 'Teaching Room']
|
||||
BOOKING_GROUP = ['Boss', 'SectionA', 'SectionB', 'SectionC', 'Standard']
|
||||
EQUIPMENT = ['Beamer', 'Flipchart']
|
||||
|
||||
|
||||
def create():
|
||||
logger.info('Location Count: {}'.format(Location.objects.count()))
|
||||
create_locations(LOCATIONS)
|
||||
logger.info('Location Count: {}'.format(Location.objects.count()))
|
||||
|
||||
logger.info('Building Count: {}'.format(Building.objects.count()))
|
||||
create_buildings(BUILDINGS)
|
||||
logger.info('Building Count: {}'.format(Building.objects.count()))
|
||||
|
||||
logger.info('RoomType Count: {}'.format(RoomType.objects.count()))
|
||||
create_room_type(ROOMTYPE)
|
||||
logger.info('RoomType Count: {}'.format(RoomType.objects.count()))
|
||||
|
||||
logger.info('BookingGroup Count: {}'.format(BookingGroup.objects.count()))
|
||||
create_booking_group(BOOKING_GROUP)
|
||||
logger.info('BookingGroup Count: {}'.format(BookingGroup.objects.count()))
|
||||
|
||||
logger.info('Equipment Count: {}'.format(Equipment.objects.count()))
|
||||
create_equipment(EQUIPMENT)
|
||||
logger.info('Equipment Count: {}'.format(Equipment.objects.count()))
|
||||
|
||||
logger.info('Staff Count: {}'.format(Staff.objects.count()))
|
||||
create_staff()
|
||||
logger.info('Staff Count: {}'.format(Staff.objects.count()))
|
||||
|
||||
logger.info('Room Count: {}'.format(Room.objects.count()))
|
||||
create_room()
|
||||
logger.info('Room Count: {}'.format(Room.objects.count()))
|
||||
|
||||
logger.info('Booking Count: {}'.format(Booking.objects.count()))
|
||||
create_booking()
|
||||
logger.info('Booking Count: {}'.format(Booking.objects.count()))
|
||||
|
||||
logger.info('NumEquipment Count: {}'.format(NumEquipment.objects.count()))
|
||||
create_num_equipment()
|
||||
logger.info('NumEquipment Count: {}'.format(NumEquipment.objects.count()))
|
||||
|
||||
logger.info('AccessPoint Count: {}'.format(AccessPoint.objects.count()))
|
||||
create_access_point()
|
||||
logger.info('AccessPoint Count: {}'.format(AccessPoint.objects.count()))
|
||||
|
||||
logger.info('Favorites Count: {}'.format(Favorite.objects.count()))
|
||||
create_favorite()
|
||||
logger.info('Favorites Count: {}'.format(Favorite.objects.count()))
|
||||
|
||||
|
||||
def create_locations(names):
|
||||
for name in names:
|
||||
location, _ = Location.objects.get_or_create(name=name)
|
||||
|
||||
|
||||
def create_buildings(names):
|
||||
for name in names:
|
||||
building, _ = Building.objects.get_or_create(name=name, location=random.choice(Location.objects.all()))
|
||||
|
||||
|
||||
def create_room_type(types):
|
||||
for type in types:
|
||||
building, _ = RoomType.objects.get_or_create(type=type)
|
||||
|
||||
|
||||
def create_booking_group(names):
|
||||
for name in names:
|
||||
booking_group, _ = BookingGroup.objects.get_or_create(name=name)
|
||||
|
||||
|
||||
def create_equipment(names):
|
||||
for name in names:
|
||||
equipment, _ = Equipment.objects.get_or_create(name=name)
|
||||
|
||||
|
||||
def create_staff():
|
||||
for i in range(1, 30):
|
||||
user, _ = User.objects.get_or_create(username='MannFrau{}'.format(i), email='mann{}@frau.de'.format(i),
|
||||
password='1234abcdef#')
|
||||
staff, _ = Staff.objects.get_or_create(user=random.choice(User.objects.all()))
|
||||
staff.booking_group.add(random.choice(BookingGroup.objects.all()))
|
||||
# booking_group = random.choice(BookingGroup.objects.all())
|
||||
staff.save()
|
||||
|
||||
|
||||
def create_room():
|
||||
for i in range(1, 40):
|
||||
room, _ = Room.objects.get_or_create(building=random.choice(Building.objects.all()),
|
||||
room_number=random.randint(100, 956),
|
||||
capacity=random.randint(10, 400), seating=random.randint(0, 1),
|
||||
barrier_free=random.randint(0, 1), cooling=random.randint(0, 1),
|
||||
room_type=random.choice(RoomType.objects.all()),
|
||||
floor=random.randint(1, 6),
|
||||
admin=random.choice(BookingGroup.objects.all()),
|
||||
service_staff=random.choice(Staff.objects.all()))
|
||||
|
||||
|
||||
def create_booking():
|
||||
for i in range(1, 80):
|
||||
year = random.choice(range(2018, 2019))
|
||||
month = random.choice(range(1, 12))
|
||||
day = random.choice(range(1, 28))
|
||||
random_start_date = datetime.datetime(year, month, day)
|
||||
|
||||
delta = random.choice(range(0, 2))
|
||||
random_enddate_date = random_start_date + datetime.timedelta(delta)
|
||||
|
||||
hour = random.choice(range(6, 22))
|
||||
minute = random.choice(range(1, 59))
|
||||
start_time = datetime.datetime(year, month, day, hour=hour, minute=minute)
|
||||
|
||||
delta = random.choice(range(0, 3))
|
||||
end_time_time = start_time + datetime.timedelta(hours=delta)
|
||||
|
||||
booking, _ = Booking.objects.get_or_create(room=random.choice(Room.objects.all()),
|
||||
staff=random.choice(Staff.objects.all()),
|
||||
start_date=random_start_date, end_date=random_enddate_date,
|
||||
start_time=start_time, end_time=end_time_time,
|
||||
intervall=random.choice(range(0, 3)))
|
||||
|
||||
|
||||
def create_num_equipment():
|
||||
for i in range(1, 80):
|
||||
num_equipment = NumEquipment.objects.get_or_create(room=random.choice(Room.objects.all()),
|
||||
equipment=random.choice(Equipment.objects.all()),
|
||||
count=random.choice(range(1, 3)))
|
||||
|
||||
|
||||
def create_access_point():
|
||||
for i in range(1, 25):
|
||||
access_point, _ = AccessPoint.objects.get_or_create(mac_address=''.join(
|
||||
random.choices(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'], k=12)))
|
||||
for i in range(1, random.randint(1, 4)):
|
||||
access_point.rooms.add(random.choice(Room.objects.all()))
|
||||
access_point.save()
|
||||
|
||||
|
||||
def create_favorite():
|
||||
for staff in Staff.objects.all():
|
||||
favorite, _ = Favorite.objects.get_or_create(staff=staff, room=random.choice(Room.objects.all()))
|
||||
@ -3,19 +3,12 @@ from django.contrib.auth.models import User
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class Location(models.Model):
|
||||
name = models.CharField(max_length=16)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.name)
|
||||
|
||||
|
||||
class Building(models.Model):
|
||||
name = models.CharField(max_length=16)
|
||||
location = models.ForeignKey(Location, on_delete=models.CASCADE)
|
||||
key = models.CharField(max_length=8, unique=True)
|
||||
address = models.CharField(max_length=32)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.name)
|
||||
return '{}'.format(self.key)
|
||||
|
||||
|
||||
class RoomType(models.Model):
|
||||
@ -25,85 +18,164 @@ class RoomType(models.Model):
|
||||
return '{}'.format(self.type)
|
||||
|
||||
|
||||
class BookingGroup(models.Model):
|
||||
name = models.CharField(max_length=64)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.name)
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
# class BookingGroup(models.Model):
|
||||
# name = models.CharField(max_length=64)
|
||||
#
|
||||
# def __str__(self):
|
||||
# return '{}'.format(self.name)
|
||||
#
|
||||
#
|
||||
class Staff(models.Model):
|
||||
booking_group = models.ManyToManyField(BookingGroup)
|
||||
# username = personal_id
|
||||
# booking_group = models.ManyToManyField(BookingGroup)
|
||||
# username = ba - Nummer
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.user.username)
|
||||
return '{} {}'.format(self.user.first_name, self.user.last_name)
|
||||
|
||||
|
||||
class Room(models.Model):
|
||||
building = models.ForeignKey('Building', on_delete=models.CASCADE)
|
||||
room_number = models.CharField(max_length=16)
|
||||
capacity = models.IntegerField()
|
||||
seating = models.BooleanField()
|
||||
barrier_free = models.BooleanField()
|
||||
cooling = models.BooleanField()
|
||||
room_type = models.ForeignKey(RoomType, on_delete=models.PROTECT)
|
||||
floor = models.SmallIntegerField()
|
||||
admin = models.ForeignKey(BookingGroup, on_delete=models.SET_DEFAULT, default=1)
|
||||
service_staff = models.ForeignKey(Staff, on_delete=models.PROTECT)
|
||||
class OrgUnit(models.Model):
|
||||
title = models.CharField(max_length=32)
|
||||
|
||||
def __str__(self):
|
||||
return '{} - {}'.format(self.building.name, self.room_number)
|
||||
return '{}'.format(self.title)
|
||||
|
||||
|
||||
class Equipment(models.Model):
|
||||
univis_id = models.CharField(max_length=8)
|
||||
name = models.CharField(max_length=32)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.univis_id)
|
||||
|
||||
|
||||
class Room(models.Model):
|
||||
building = models.ForeignKey('Building', on_delete=models.CASCADE, null=True, blank=True)
|
||||
room_number = models.CharField(max_length=16)
|
||||
capacity = models.IntegerField(null=True, blank=True)
|
||||
floor = models.SmallIntegerField(null=True, blank=True)
|
||||
univis_id = models.IntegerField(unique=True)
|
||||
univis_key = models.CharField(unique=True, max_length=64)
|
||||
room_type = models.ForeignKey(RoomType, on_delete=models.PROTECT, null=True, blank=True)
|
||||
# TODO: extract equipment
|
||||
description = models.CharField(max_length=64, null=True, blank=True)
|
||||
equipment = models.ManyToManyField(Equipment)
|
||||
|
||||
orgname = models.ForeignKey(OrgUnit, on_delete=models.PROTECT, related_name='room_orgname', null=True, blank=True)
|
||||
orgunits = models.ManyToManyField(OrgUnit)
|
||||
|
||||
# seating = models.BooleanField()
|
||||
# barrier_free = models.BooleanField()
|
||||
# cooling = models.BooleanField()
|
||||
|
||||
# admin = models.ForeignKey(BookingGroup, on_delete=models.SET_DEFAULT, default=1)
|
||||
# service_staff = models.ForeignKey(Staff, on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
if self.building == None:
|
||||
return '{}/{}'.format(None, self.room_number)
|
||||
else:
|
||||
return '{}/{} - {}'.format(self.building.key, self.room_number, self.orgname)
|
||||
|
||||
|
||||
#
|
||||
# class NumEquipment(models.Model):
|
||||
# room = models.ForeignKey(Room, on_delete=models.CASCADE)
|
||||
# equipment = models.ForeignKey(Equipment, on_delete=models.CASCADE)
|
||||
# count = models.SmallIntegerField()
|
||||
#
|
||||
# def __str__(self):
|
||||
# return '{} - {} - {}'.format(self.room.room_number, self.equipment.name, self.count)
|
||||
#
|
||||
# class Exclude_Term(models.Model):
|
||||
# date = models.DateField()
|
||||
|
||||
class LectureSpecifiaction(models.Model):
|
||||
univis_id = models.CharField(max_length=8)
|
||||
name = models.CharField(max_length=32)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.univis_id)
|
||||
|
||||
|
||||
class LectureType(models.Model):
|
||||
#univis_id = models.CharField(max_length=8)
|
||||
name = models.CharField(max_length=32)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.name)
|
||||
|
||||
|
||||
class NumEquipment(models.Model):
|
||||
room = models.ForeignKey(Room, on_delete=models.CASCADE)
|
||||
equipment = models.ForeignKey(Equipment, on_delete=models.CASCADE)
|
||||
count = models.SmallIntegerField()
|
||||
class Lecture(models.Model):
|
||||
univis_id = models.IntegerField(unique=True)
|
||||
univis_key = models.CharField(unique=True, max_length=64)
|
||||
type = models.ForeignKey(LectureType, on_delete=models.PROTECT, null=True, blank=True)
|
||||
title = models.CharField(max_length=64)
|
||||
short = models.CharField(max_length=16, null=True, blank=True)
|
||||
ects = models.FloatField(null=True, blank=True)
|
||||
sws = models.FloatField(null=True, blank=True)
|
||||
estimated_visitor = models.PositiveIntegerField(null=True, blank=True)
|
||||
specification = models.ManyToManyField(LectureSpecifiaction)
|
||||
orgname = models.ForeignKey(OrgUnit, on_delete=models.PROTECT, related_name='lecture_orgname', null=True,
|
||||
blank=True)
|
||||
orgunits = models.ManyToManyField(OrgUnit)
|
||||
url_description = models.URLField(null=True, blank=True)
|
||||
|
||||
organizational = models.TextField(max_length=64, null=True, blank=True)
|
||||
time_description = models.TextField(max_length=64, null=True, blank=True)
|
||||
summary = models.TextField(max_length=64, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return '{} - {} - {}'.format(self.room.room_number, self.equipment.name, self.count)
|
||||
return '{}'.format(self.title)
|
||||
|
||||
|
||||
class Booking(models.Model):
|
||||
DAY = 0
|
||||
WEEK = 1
|
||||
EVERY_TWO_WEEKS = 2
|
||||
MONTH = 3
|
||||
|
||||
TYPE_CHOICES = ((DAY, 'DAY'), (WEEK, 'WEEK'), (EVERY_TWO_WEEKS, 'EVERY_TWO_WEEKS'), (MONTH, 'MONTH'))
|
||||
room = models.ForeignKey(Room, on_delete=models.CASCADE)
|
||||
staff = models.ForeignKey(Staff, on_delete=models.CASCADE)
|
||||
start_date = models.DateField()
|
||||
end_date = models.DateField()
|
||||
start_time = models.TimeField()
|
||||
end_time = models.TimeField()
|
||||
intervall = models.IntegerField(choices=TYPE_CHOICES)
|
||||
class LectureTerm(models.Model):
|
||||
# room = models.ForeignKey(Room, on_delete=models.CASCADE)
|
||||
room = models.CharField(max_length=64, null=True, blank=True)
|
||||
start_date = models.DateField(null=True, blank=True)
|
||||
end_date = models.DateField(null=True, blank=True)
|
||||
start_time = models.TimeField(null=True, blank=True)
|
||||
end_time = models.TimeField(null=True, blank=True)
|
||||
exclude = models.CharField(max_length=128, null=True, blank=True)
|
||||
repeat = models.CharField(max_length=16, null=True, blank=True)
|
||||
lecture = models.ForeignKey(Lecture, on_delete=models.CASCADE, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return '{} - {} - {}'.format(self.room.room_number, self.start_date.strftime('%Y - %m - %d'),
|
||||
self.end_date.strftime('%Y - %m - %d'))
|
||||
return '{}'.format(self.lecture.title)
|
||||
|
||||
|
||||
class AccessPoint(models.Model):
|
||||
mac_address = models.CharField(max_length=12)
|
||||
rooms = models.ManyToManyField(Room)
|
||||
|
||||
def __str__(self):
|
||||
return '{}'.format(self.mac_address)
|
||||
|
||||
|
||||
class Favorite(models.Model):
|
||||
staff = models.ForeignKey(Staff, on_delete=models.CASCADE)
|
||||
room = models.ForeignKey(Room, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return '{} - {}'.format(self.staff.user.username, self.room.room_number)
|
||||
# class Booking(models.Model):
|
||||
# DAY = 0
|
||||
# WEEK = 1
|
||||
# EVERY_TWO_WEEKS = 2
|
||||
# MONTH = 3
|
||||
#
|
||||
# TYPE_CHOICES = ((DAY, 'DAY'), (WEEK, 'WEEK'), (EVERY_TWO_WEEKS, 'EVERY_TWO_WEEKS'), (MONTH, 'MONTH'))
|
||||
# room = models.ForeignKey(Room, on_delete=models.CASCADE)
|
||||
# staff = models.ForeignKey(Staff, on_delete=models.CASCADE)
|
||||
# start_date = models.DateField()
|
||||
# end_date = models.DateField()
|
||||
# start_time = models.TimeField()
|
||||
# end_time = models.TimeField()
|
||||
# intervall = models.IntegerField(choices=TYPE_CHOICES)
|
||||
#
|
||||
# def __str__(self):
|
||||
# return '{} - {} - {}'.format(self.room.room_number, self.start_date.strftime('%Y - %m - %d'),
|
||||
# self.end_date.strftime('%Y - %m - %d'))
|
||||
#
|
||||
#
|
||||
# class AccessPoint(models.Model):
|
||||
# mac_address = models.CharField(max_length=12)
|
||||
# rooms = models.ManyToManyField(Room)
|
||||
#
|
||||
# def __str__(self):
|
||||
# return '{}'.format(self.mac_address)
|
||||
#
|
||||
#
|
||||
# class Favorite(models.Model):
|
||||
# staff = models.ForeignKey(Staff, on_delete=models.CASCADE)
|
||||
# room = models.ForeignKey(Room, on_delete=models.CASCADE)
|
||||
#
|
||||
# def __str__(self):
|
||||
# return '{} - {}'.format(self.staff.user.username, self.room.room_number)
|
||||
|
||||
@ -3,12 +3,14 @@ from . import views
|
||||
|
||||
app_name = 'roomservice'
|
||||
urlpatterns = [
|
||||
path('', views.favorites, name='home'),
|
||||
path('favorite', views.add_favorites, name='add-fav'),
|
||||
# path('', views.favorites, name='home'),
|
||||
# path('favorite/', views.add_favorites, name='add-fav'),
|
||||
|
||||
path('error/', views.error, name='error'),
|
||||
path('success/', views.success, name='success'),
|
||||
|
||||
path('adminpage', views.admin, name='admin'),
|
||||
path('booking', views.booking, name='booking'),
|
||||
path('booking/<int:id>', views.booking, name='booking'),
|
||||
path('search', views.search, name='search'),
|
||||
path('location_search', views.location_based_search, name='location-based-search'),
|
||||
path('filter_search', views.filter_search, name='filter-search')]
|
||||
|
||||
|
||||
197
roofis2/roomservice/utils/migrate_data_lectures.py
Normal file
197
roofis2/roomservice/utils/migrate_data_lectures.py
Normal file
@ -0,0 +1,197 @@
|
||||
from datetime import datetime
|
||||
import json
|
||||
from pprint import pprint
|
||||
from django.db.utils import IntegrityError
|
||||
from roomservice.utils.parser import univis_lectures_parser
|
||||
from roomservice.models import Lecture, LectureSpecifiaction, OrgUnit, LectureType, LectureTerm
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# CONFIG Fakultaet
|
||||
FAKULTAET_GuK = "Fakult%E4t%20Geistes-%20und%20Kulturwissenschaften"
|
||||
FAKULTAET_SoWi = "Fakult%E4t%20Sozial-%20und%20Wirtschaftswissenschaften"
|
||||
FAKULTAET_HuWi = "Fakult%E4t%20Humanwissenschaften"
|
||||
FAKULTAET_WIAI = "Fakult%E4t%20Wirtschaftsinformatik"
|
||||
|
||||
|
||||
# CONFIG ROOMS
|
||||
def univis_rooms(fakultaet):
|
||||
return "http://univis.uni-bamberg.de/prg?search=rooms&department=" + fakultaet + "&show=xml"
|
||||
|
||||
|
||||
# CONFIG LECTURES
|
||||
def univis_lectures(fakultaet):
|
||||
return "http://univis.uni-bamberg.de/prg?search=lectures&department=" + fakultaet + "&show=exml"
|
||||
|
||||
|
||||
def getJsonFromFile(path):
|
||||
with open(path, "r") as file:
|
||||
return json.load(file)
|
||||
|
||||
|
||||
def writeUnivisLectureTermsInDB(lecture, lecture_obj):
|
||||
if 'terms' in lecture:
|
||||
if type(lecture['terms']['term']) == list:
|
||||
logger.info(lecture['terms']['term'])
|
||||
for term in lecture['terms']['term']:
|
||||
logger.info(term)
|
||||
exclude = dict(term).get('exclude')
|
||||
starttime = dict(term).get('starttime')
|
||||
endtime = dict(term).get('endtime')
|
||||
startdate = dict(term).get('startdate')
|
||||
enddate = dict(term).get('enddate')
|
||||
repeat = dict(term).get('repeat')
|
||||
room = dict(term).get('room')
|
||||
if not room:
|
||||
logger.info('ROOOOOOOOM ___________________________________________')
|
||||
logger.info(lecture['terms'])
|
||||
term_obj, _ = LectureTerm.objects.update_or_create(exclude=exclude,
|
||||
repeat=repeat,
|
||||
room=room,
|
||||
lecture=lecture_obj)
|
||||
|
||||
if startdate:
|
||||
term_obj.start_date = dict(term).get('startdate') # datetime.strptime(startdate, '%Y-%m-%d')
|
||||
if enddate:
|
||||
term_obj.end_date = dict(term).get('enddate') # datetime.strptime(enddate, '%Y-%m-%d')
|
||||
if starttime:
|
||||
term_obj.start_time = dict(term).get('starttime') # datetime.strptime(starttime, '%H:%M')
|
||||
if endtime:
|
||||
term_obj.end_time = dict(term).get('endtime') # datetime.strptime(endtime, '%H:%M'),
|
||||
term_obj.save()
|
||||
|
||||
else:
|
||||
term = lecture['terms']['term']
|
||||
exclude = dict(term).get('exclude')
|
||||
starttime = dict(term).get('starttime')
|
||||
endtime = dict(term).get('endtime')
|
||||
startdate = dict(term).get('startdate')
|
||||
enddate = dict(term).get('enddate')
|
||||
repeat = dict(term).get('repeat')
|
||||
room = dict(term).get('room')
|
||||
if not room:
|
||||
logger.info('ROOOOOOOOM2 ___________________________________________')
|
||||
logger.info(lecture)
|
||||
|
||||
term_obj, _ = LectureTerm.objects.update_or_create(exclude=exclude,
|
||||
repeat=repeat,
|
||||
room=room,
|
||||
lecture=lecture_obj)
|
||||
if startdate:
|
||||
term_obj.start_date = dict(term).get('startdate') # datetime.strptime(startdate, '%Y-%m-%d')
|
||||
if enddate:
|
||||
term_obj.end_date = dict(term).get('enddate') # datetime.strptime(enddate, '%Y-%m-%d')
|
||||
if starttime:
|
||||
term_obj.start_time = dict(term).get('starttime') # datetime.strptime(starttime, '%H:%M')
|
||||
if endtime:
|
||||
term_obj.end_time = dict(term).get('endtime') # datetime.strptime(endtime, '%H:%M'),
|
||||
term_obj.save()
|
||||
|
||||
|
||||
def writeUnivisLectureDataInDB(data):
|
||||
for lecture in data:
|
||||
if not 'courses' in lecture:
|
||||
lecture = dict(lecture)
|
||||
univis_key = lecture['@key']
|
||||
univis_id = lecture['id']
|
||||
short = lecture.get('short')
|
||||
name = lecture['name']
|
||||
url_description = lecture.get('url_description')
|
||||
turnout = lecture.get('turnout')
|
||||
if name == 'Projektpraktikum Mensch-Computer-Interaktion':
|
||||
logger.info(lecture)
|
||||
organizational = lecture.get('organizational')
|
||||
time_description = lecture.get('time_description')
|
||||
summary = lecture.get('summary')
|
||||
orgname, _ = OrgUnit.objects.get_or_create(title=lecture['orgname'])
|
||||
|
||||
ects_cred = lecture.get('ects_cred')
|
||||
if ects_cred:
|
||||
ects_cred = float(str(lecture['ects_cred']).replace(',', '.'))
|
||||
|
||||
sws = None
|
||||
if 'sws' in lecture:
|
||||
sws = float(str(lecture['sws']).replace(',', '.'))
|
||||
|
||||
type = None
|
||||
if 'type' in lecture:
|
||||
type, _ = LectureType.objects.get_or_create(name=lecture['type'])
|
||||
|
||||
# logger.info(name)
|
||||
lecture_obj, _ = Lecture.objects.update_or_create(univis_id=univis_id, univis_key=univis_key, title=name,
|
||||
orgname=orgname, short=short, ects=ects_cred,
|
||||
sws=sws, url_description=url_description,
|
||||
estimated_visitor=turnout, organizational=organizational,
|
||||
time_description=time_description, summary=summary,
|
||||
type=type)
|
||||
|
||||
lecture_specs_options = LectureSpecifiaction.objects.all()
|
||||
for lecture_spec in lecture_specs_options:
|
||||
univis_id = lecture_spec.univis_id.lower()
|
||||
if univis_id in lecture and lecture[univis_id] == 'ja':
|
||||
lecture_obj.specification.add(lecture_spec)
|
||||
|
||||
orgunits = None
|
||||
if 'orgunits' in lecture:
|
||||
for orgunit in lecture['orgunits']:
|
||||
if len(orgunit) > 0:
|
||||
for orgunit in str(lecture['orgunits']['orgunit']).strip("[]").split(','):
|
||||
cleaned_orgunit = orgunit.strip().strip("'").strip("'")
|
||||
orgunit, _ = OrgUnit.objects.get_or_create(title=cleaned_orgunit)
|
||||
lecture_obj.orgunits.add(orgunit)
|
||||
|
||||
# TODO: Check xml syntax #orgunit problem
|
||||
pass
|
||||
else:
|
||||
orgunit, _ = OrgUnit.objects.get_or_create(title=orgunit)
|
||||
lecture_obj.orgunits.add(orgunit)
|
||||
|
||||
# logger.info(lecture_obj)
|
||||
# if 'dozs' in lecture:
|
||||
# lecturer_id = dict(lecture['dozs']['doz']['UnivISRef'])['@key']
|
||||
# lecture_obj = Lecture.objects.create(univis_ref=key, univis_id=univis_id, name=name, short=short,
|
||||
# type=lecture_type, lecturer_id=lecturer_id)
|
||||
writeUnivisLectureTermsInDB(lecture, lecture_obj)
|
||||
# lecture_obj.save()
|
||||
# logger.info("Lecture: {}".format(lecture_obj.short))
|
||||
# except IntegrityError as err:
|
||||
# logger.warning('Lecture already exists')
|
||||
# logger.exception(err)
|
||||
|
||||
|
||||
def showStatus(status: str):
|
||||
return "\nStatus: {status}\n\tLectures: {lectures}\n\tLecture Specifcation: {lecture_specs}\n\tLectureType: {lecture_type}\n\tOrg Unit: {orgunit}\n\n" \
|
||||
.format(
|
||||
status=status,
|
||||
lectures=Lecture.objects.count(),
|
||||
lecture_specs=LectureSpecifiaction.objects.count(),
|
||||
lecture_type=LectureType.objects.count(),
|
||||
orgunit=OrgUnit.objects.count()
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
# get food jsons
|
||||
# logger.info(showStatus("Start SoWi:"))
|
||||
# writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_SoWi)))
|
||||
# logger.info("----------------------------------------------------------------------------------------")
|
||||
#
|
||||
# logger.info(showStatus("Start GuK:"))
|
||||
# writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_GuK)))
|
||||
# logger.info("----------------------------------------------------------------------------------------")
|
||||
#
|
||||
# logger.info(showStatus("Start HuWi:"))
|
||||
# writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_HuWi)))
|
||||
# logger.info("----------------------------------------------------------------------------------------")
|
||||
|
||||
logger.info(showStatus("Start WIAI:"))
|
||||
writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_WIAI)))
|
||||
pprint("----------------------------------------------------------------------------------------")
|
||||
|
||||
logger.info(showStatus("Finished:"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
169
roofis2/roomservice/utils/migrate_data_rooms.py
Normal file
169
roofis2/roomservice/utils/migrate_data_rooms.py
Normal file
@ -0,0 +1,169 @@
|
||||
import json
|
||||
from pprint import pprint
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from roomservice.models import Room, Building, RoomType, OrgUnit, Equipment
|
||||
from .parser import univis_rooms_parser
|
||||
from .parser import univis_lectures_parser
|
||||
import ast
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# CONFIG Fakultaet
|
||||
FAKULTAET_GuK = "Fakult%E4t%20Geistes-%20und%20Kulturwissenschaften"
|
||||
FAKULTAET_SoWi = "Fakult%E4t%20Sozial-%20und%20Wirtschaftswissenschaften"
|
||||
FAKULTAET_HuWi = "Fakult%E4t%20Humanwissenschaften"
|
||||
FAKULTAET_WIAI = "Fakult%E4t%20Wirtschaftsinformatik"
|
||||
|
||||
# CONFIG Locations
|
||||
RZ = "http://univis.uni-bamberg.de/prg?search=rooms&name=rz&show=xml"
|
||||
WEBEREI = "http://univis.uni-bamberg.de/prg?search=rooms&name=we&show=xml"
|
||||
FEKI = "http://univis.uni-bamberg.de/prg?search=rooms&name=f&show=xml"
|
||||
MARKUSHAUS = "http://univis.uni-bamberg.de/prg?search=rooms&name=m&show=xml"
|
||||
UNIVERSITAET = "http://univis.uni-bamberg.de/prg?search=rooms&name=u&show=xml"
|
||||
KAPUZINERSTR = "http://univis.uni-bamberg.de/prg?search=rooms&name=k&show=xml"
|
||||
ZWINGER = "http://univis.uni-bamberg.de/prg?search=rooms&name=z&show=xml"
|
||||
AULA = "http://univis.uni-bamberg.de/prg?search=rooms&name=a&show=xml"
|
||||
|
||||
|
||||
# CONFIG ROOMS
|
||||
def univis_rooms(fakultaet):
|
||||
return "http://univis.uni-bamberg.de/prg?search=rooms&department=" + fakultaet + "&show=xml"
|
||||
|
||||
|
||||
# CONFIG LECTURES
|
||||
def univis_lectures(fakultaet):
|
||||
return "http://univis.uni-bamberg.de/prg?search=lectures&department=" + fakultaet + "&show=exml"
|
||||
|
||||
|
||||
def univis_rooms_loc(kuerzel):
|
||||
return "http://univis.uni-bamberg.de/prg?search=rooms&name=" + kuerzel + "&show=xml"
|
||||
|
||||
|
||||
def getJsonFromFile(path):
|
||||
with open(path, "r") as file:
|
||||
return json.load(file)
|
||||
|
||||
|
||||
def writeUnivisRoomDataInDB(rooms):
|
||||
for room in rooms:
|
||||
try:
|
||||
building = None
|
||||
if 'address' in room and 'buildingkey' in room:
|
||||
building_address = room['address']
|
||||
building_key = room['buildingkey']
|
||||
building, _ = Building.objects.get_or_create(key=building_key, address=building_address)
|
||||
|
||||
short = str(room['short']).split(sep='/')[-1]
|
||||
univis_id = room['id']
|
||||
univis_key = room['@key']
|
||||
|
||||
capacity = None
|
||||
if 'size' in room:
|
||||
capacity = room['size']
|
||||
|
||||
floor = None
|
||||
if 'floor' in room:
|
||||
floor = room['floor']
|
||||
|
||||
room_type = None
|
||||
if 'name' in room:
|
||||
room_type, _ = RoomType.objects.get_or_create(type=room['name'])
|
||||
|
||||
description = None
|
||||
if 'description' in room:
|
||||
description = room['description']
|
||||
|
||||
orgname = None
|
||||
if 'orgname' in room:
|
||||
orgname, _ = OrgUnit.objects.get_or_create(title=room['orgname'])
|
||||
|
||||
room_db_obj, _ = Room.objects.update_or_create(building=building,
|
||||
room_number=short,
|
||||
capacity=capacity,
|
||||
floor=floor,
|
||||
univis_id=univis_id,
|
||||
univis_key=univis_key,
|
||||
room_type=room_type,
|
||||
description=description,
|
||||
orgname=orgname)
|
||||
|
||||
equipment_options = Equipment.objects.all()
|
||||
for equipment in equipment_options:
|
||||
univis_id = equipment.univis_id.lower()
|
||||
if univis_id in room and room[univis_id] == 'ja':
|
||||
room_db_obj.equipment.add(equipment)
|
||||
|
||||
orgunits = None
|
||||
if 'orgunits' in room:
|
||||
for orgunit in room['orgunits']:
|
||||
if len(orgunit) > 0:
|
||||
for orgunit in str(room['orgunits']['orgunit']).strip("[]").split(','):
|
||||
cleaned_orgunit = orgunit.strip().strip("'").strip("'")
|
||||
orgunit, _ = OrgUnit.objects.get_or_create(title=cleaned_orgunit)
|
||||
room_db_obj.orgunits.add(orgunit)
|
||||
|
||||
# TODO: Check xml syntax #orgunit problem
|
||||
pass
|
||||
else:
|
||||
orgunit, _ = OrgUnit.objects.get_or_create(title=orgunit)
|
||||
room_db_obj.orgunits.add(orgunit)
|
||||
|
||||
# room_db_obj.save()
|
||||
logger.info('ROOM: {}'.format(room_db_obj.room_number))
|
||||
|
||||
|
||||
except IntegrityError as err:
|
||||
logger.warning(err)
|
||||
logger.warning('Room already exists')
|
||||
|
||||
|
||||
def delete():
|
||||
rooms = Room.objects.all()
|
||||
logger.info("Deleted following Rooms:")
|
||||
for room in rooms:
|
||||
logger.info("Room: {name}".format(
|
||||
name=room.short)
|
||||
)
|
||||
room.delete()
|
||||
|
||||
|
||||
def main():
|
||||
# get food jsons
|
||||
logger.info("\nStart:\nRoom: {}\nOrgunits: {}\nBuildings: {}\nRoomTypes: {}"
|
||||
.format(Room.objects.count(),
|
||||
OrgUnit.objects.count(),
|
||||
Building.objects.count(),
|
||||
RoomType.objects.count()))
|
||||
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms(FAKULTAET_GuK)))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms(FAKULTAET_SoWi)))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms(FAKULTAET_HuWi)))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms(FAKULTAET_WIAI)))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("k")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("z")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("u")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("w")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("f")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("r")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("h")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("l")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("m")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("o")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("p")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("v")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("w")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("d")))
|
||||
writeUnivisRoomDataInDB(univis_rooms_parser.parsePage(univis_rooms_loc("x")))
|
||||
|
||||
logger.info("\nFinished:\nRoom: {}\nOrgunits: {}\nBuildings: {}\nRoomTypes: {}"
|
||||
.format(Room.objects.count(),
|
||||
OrgUnit.objects.count(),
|
||||
Building.objects.count(),
|
||||
RoomType.objects.count()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
66
roofis2/roomservice/utils/migrate_data_vgn_coords.py
Normal file
66
roofis2/roomservice/utils/migrate_data_vgn_coords.py
Normal file
@ -0,0 +1,66 @@
|
||||
from apps.donar.models import VGN_Coords
|
||||
|
||||
|
||||
def migrate():
|
||||
locations = []
|
||||
locations.append(
|
||||
{'location': 'Erba', 'vgn_key': 'coord%3A4418901%3A629758%3ANAV4%3ABamberg%2C An der Weberei 5',
|
||||
'lat': '49.90316',
|
||||
'lon': '10.86932'})
|
||||
locations.append(
|
||||
{'location': 'Feki', 'vgn_key': 'coord%3A4421412%3A629361%3ANAV4%3ABamberg%2C Feldkirchenstraße 21',
|
||||
'lat': '49,9070328',
|
||||
'lon': '10,9041714'})
|
||||
locations.append(
|
||||
{'location': 'Markushaus', 'vgn_key': 'coord%3A4419902%3A630599%3ANAV4%3ABamberg%2C Markusplatz 3',
|
||||
'lat': '49.89552',
|
||||
'lon': '10.88348'})
|
||||
locations.append(
|
||||
{'location': 'Austraße', 'vgn_key': 'coord%3A4420153%3A630781%3ANAV4%3ABamberg%2C An der Universität 7',
|
||||
'lat': '49.89411',
|
||||
'lon': '10.88726'})
|
||||
locations.append(
|
||||
{'location': 'Kranen', 'vgn_key': 'coord%3A4420141%3A630965%3ANAV4%3ABamberg%2C Am Kranen 10',
|
||||
'lat': '49.89259',
|
||||
'lon': '10.88701'})
|
||||
locations.append(
|
||||
{'location': 'Kärntenstr', 'vgn_key': 'coord%3A4421130%3A628738%3ANAV4%3ABamberg%2C Kärntenstraße 7',
|
||||
'lat': '49.91256',
|
||||
'lon': '10.90028'})
|
||||
locations.append(
|
||||
{'location': 'Kapellenstr', 'vgn_key': 'coord%3A4421682%3A631169%3ANAV4%3ABamberg%2C Kapellenstraße 13',
|
||||
'lat': '49.89063',
|
||||
'lon': '10.90846'})
|
||||
locations.append(
|
||||
{'location': 'Volkspark', 'vgn_key': 'coord%3A4423077%3A629976%3ANAV4%3ABamberg%2C Pödeldorfer Straße 180',
|
||||
'lat': '49.90087',
|
||||
'lon': '10.92998'})
|
||||
locations.append(
|
||||
{'location': 'K16', 'vgn_key': 'coord%3A4420069%3A630807%3ANAV4%3ABamberg%2C Kapuzinerstraße 16',
|
||||
'lat': '48.127',
|
||||
'lon': '11.5572'})
|
||||
locations.append(
|
||||
{'location': 'Zwinger', 'vgn_key': 'coord%3A4420461%3A631411%3ANAV4%3ABamberg%2C Am Zwinger 4',
|
||||
'lat': '49.88843',
|
||||
'lon': '10.8918'})
|
||||
locations.append(
|
||||
{'location': 'AULA', 'vgn_key': 'coord%3A4420062%3A631052%3ANAV4%3ABamberg%2C Dominikanerstraße 2',
|
||||
'lat': '49.89165',
|
||||
'lon': '10.88602'})
|
||||
locations.append(
|
||||
{'location': 'Fischstr', 'vgn_key': 'coord%3A4420141%3A630930%3ANAV4%3ABamberg%2C Fischstraße 5',
|
||||
'lat': '49.89277',
|
||||
'lon': '10.88717'})
|
||||
locations.append(
|
||||
{'location': 'Fleischstr', 'vgn_key': 'coord%3A4420204%3A630739%3ANAV4%3ABamberg%2C Fleischstraße 2',
|
||||
'lat': '49.89453',
|
||||
'lon': '10.88791'})
|
||||
for location in locations:
|
||||
location_obj, created = VGN_Coords.objects.get_or_create(name=location['location'], coords=location['vgn_key'],
|
||||
latitude=location['lat'], longitude=location['lon'])
|
||||
if not created:
|
||||
print("Duplicate! Start Update: " + location['location'])
|
||||
location_obj.name = location['location']
|
||||
location_obj.coords = location['vgn_key']
|
||||
location_obj.latitude = location['lat']
|
||||
location_obj.longitude = location['lon']
|
||||
0
roofis2/roomservice/utils/parser/__init__.py
Normal file
0
roofis2/roomservice/utils/parser/__init__.py
Normal file
31
roofis2/roomservice/utils/parser/univis_lectures_parser.py
Normal file
31
roofis2/roomservice/utils/parser/univis_lectures_parser.py
Normal file
@ -0,0 +1,31 @@
|
||||
import requests
|
||||
import datetime
|
||||
import xmltodict
|
||||
import json
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
def loadPage(url: str):
|
||||
return requests.get(url).content
|
||||
|
||||
|
||||
def getDay():
|
||||
return datetime.datetime.today().strftime("%A, %d.%m.%Y")
|
||||
|
||||
|
||||
def getLectures(dict: dict):
|
||||
lectures = []
|
||||
for lecture in dict['UnivIS']['Lecture']:
|
||||
lectures.append(lecture)
|
||||
return lectures
|
||||
|
||||
|
||||
def parsePage(url):
|
||||
page = loadPage(url)
|
||||
pprint(url)
|
||||
dict = xmltodict.parse(page)
|
||||
# pprint(dict['UnivIS']['Lecture'], depth=4)
|
||||
lectures = getLectures(dict)
|
||||
return lectures
|
||||
|
||||
# parsePage( "http://univis.uni-bamberg.de/prg?search=lectures&department=Fakult%E4t%20Geistes-%20und%20Kulturwissenschaften&show=exml")
|
||||
27
roofis2/roomservice/utils/parser/univis_rooms_parser.py
Normal file
27
roofis2/roomservice/utils/parser/univis_rooms_parser.py
Normal file
@ -0,0 +1,27 @@
|
||||
import requests
|
||||
import xmltodict
|
||||
|
||||
|
||||
def loadPage(url: str):
|
||||
return requests.get(url).content
|
||||
|
||||
|
||||
def getRoom(dict: dict):
|
||||
rooms = []
|
||||
for room in dict['UnivIS']['Room']:
|
||||
rooms.append(room)
|
||||
return rooms
|
||||
|
||||
|
||||
def getPersons(dict: dict):
|
||||
persons = []
|
||||
for person in dict['UnivIS']['Person']:
|
||||
persons.append(person)
|
||||
return persons
|
||||
|
||||
|
||||
def parsePage(url):
|
||||
page = loadPage(url)
|
||||
dict = xmltodict.parse(page)
|
||||
rooms = getRoom(dict)
|
||||
return rooms
|
||||
@ -1,5 +1,5 @@
|
||||
from roomservice.models import Room, Favorite, Booking
|
||||
import datetime
|
||||
from roomservice.models import Room
|
||||
# from .forms import FavoriteForm
|
||||
from django.shortcuts import render
|
||||
from roomservice.models import Room
|
||||
import logging
|
||||
@ -9,44 +9,68 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# Create your views here.
|
||||
def search(request):
|
||||
rooms = Room.objects.all()
|
||||
return render(request, 'search.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!", "rooms": rooms})
|
||||
if request.method == 'POST':
|
||||
logger.info(request.POST)
|
||||
search_token = request.POST['search']
|
||||
rooms = Room.objects.all()
|
||||
# barrierfree = request.POST.get('barrierfree', 'off')
|
||||
# logger.info(barrierfree)
|
||||
if search_token:
|
||||
rooms = rooms.filter(room_number__contains=search_token)
|
||||
|
||||
return render(request, 'search.jinja',
|
||||
{"title": "rooF(i)S is love rooF(i)S is live!!", "rooms": rooms, "result_count": rooms.count()})
|
||||
else:
|
||||
rooms = {}
|
||||
return render(request, 'search.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!", "rooms": rooms})
|
||||
|
||||
|
||||
def booking(request):
|
||||
room_id = request.POST["room"]
|
||||
return render(request, 'booking.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!","data":room_id})
|
||||
|
||||
def booking(request, id):
|
||||
return render(request, 'booking.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!", "data": id})
|
||||
|
||||
|
||||
def admin(request):
|
||||
return render(request, 'admin.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
|
||||
|
||||
def favorites(request):
|
||||
if request.user.is_authenticated:
|
||||
favorites = Favorite.objects.filter(staff__user=request.user)
|
||||
return render(request, 'favorites.jinja',
|
||||
{"title": "rooF(i)S is love rooF(i)S is live!!", 'favorites': favorites})
|
||||
return render(request, 'favorites.jinja',
|
||||
{"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
#
|
||||
# def favorites(request):
|
||||
# if request.user.is_authenticated:
|
||||
# favorites = Favorite.objects.filter(staff__user=request.user)
|
||||
# return render(request, 'favorites.jinja',
|
||||
# {"title": "rooF(i)S is love rooF(i)S is live!!", 'favorites': favorites})
|
||||
# return render(request, 'favorites.jinja',
|
||||
# {"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
|
||||
|
||||
def add_favorites(request):
|
||||
if request.method == 'POST':
|
||||
pass
|
||||
else:
|
||||
return render(request, 'add_fav.jinja', {"title": "Add a new Favorite"})
|
||||
# def add_favorites(request):
|
||||
# if request.method == 'POST':
|
||||
# form = FavoriteForm(request.POST)
|
||||
# if form.is_valid():
|
||||
# staff = Staff.objects.get(user=request.user)
|
||||
# room = form.cleaned_data['room']
|
||||
# Favorite.objects.create(staff=staff, room=room)
|
||||
# return render(request, 'success.jinja', {})
|
||||
# else:
|
||||
# return render(request, 'error.jinja', {})
|
||||
# else:
|
||||
# form = FavoriteForm()
|
||||
# return render(request, 'add_fav.jinja', {"title": "Add a new Favorite", 'form': form})
|
||||
|
||||
|
||||
def location_based_search(request):
|
||||
return render(request, 'favorites.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
|
||||
|
||||
def success(request):
|
||||
return render(request, 'success.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
|
||||
|
||||
def error(request):
|
||||
return render(request, 'error.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
|
||||
|
||||
def filter_search(request):
|
||||
if request.method=="POST":
|
||||
if request.method == "POST":
|
||||
logger.info(request.POST)
|
||||
|
||||
|
||||
return render(request, 'search.jinja',{"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
|
||||
return render(request, 'search.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!"})
|
||||
|
||||
BIN
roofis2/static/images/dumbledore.mp4
Normal file
BIN
roofis2/static/images/dumbledore.mp4
Normal file
Binary file not shown.
BIN
roofis2/static/images/oops.mp4
Normal file
BIN
roofis2/static/images/oops.mp4
Normal file
Binary file not shown.
@ -4,10 +4,10 @@
|
||||
<div class="col-12"><h2>Add Favorite</h2></div>
|
||||
<div class="col-2"></div>
|
||||
<div class="col-8">
|
||||
<form method="post">
|
||||
<form method="post" action="{{ url('roomservice:add-fav') }}">
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||
{{ form.as_p() }}
|
||||
<button type="submit">Login</button>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-2"></div>
|
||||
|
||||
15
roofis2/templates/error.jinja
Normal file
15
roofis2/templates/error.jinja
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends 'base.jinja' %}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row text-dark">
|
||||
<div class="col-12 bg-white text-center">
|
||||
<p class="h1 text-xl-center text-danger">Fuck!</p>
|
||||
<p class="h3 text-xl-center">Error</p>
|
||||
<p>Sorry Dude!</p>
|
||||
<video src="{{ static('/images/oops.mp4' }}" loop autoplay></video>
|
||||
<br/>
|
||||
<a href="{{ url('roomservice:home') }}}" class="btn-link">Zurück zur Übersicht</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -24,4 +24,31 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
{% macro home_item_with_icon_2(icon, icon_size='fa-4x', url_id='', payload='', link='', title='') -%}
|
||||
<div class="col-12 col-sm-6 col-lg-6 col-xl-6 p-3">
|
||||
<div class="card">
|
||||
{% if url_id %}
|
||||
<a href="{{ url(url_id, args=[payload]) }}">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title text-center"><i class="fa {{ icon }} {{ icon_size }}"
|
||||
aria-hidden="true"></i></h4>
|
||||
{% if title %}
|
||||
<p class="text-center">{{ title }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ link }}">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title text-center"><i class="fa {{ icon }} {{ icon_size }}"
|
||||
aria-hidden="true"></i></h4>
|
||||
{% if title %}
|
||||
<p class="text-center">{{ title }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
@ -1,32 +1,30 @@
|
||||
{% extends 'base.jinja' %}
|
||||
{% import 'fav_macro.jinja' as macros %}
|
||||
{% block content %}
|
||||
<div class="row container">
|
||||
<div class="col-2"></div>
|
||||
<div class="col-9">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-crosshairs', icon_size='fa-4x', url_id='roomservice:location-based-search', link='', title='Localization Search', attr='') }}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-search', icon_size='fa-4x', url_id='roomservice:search', link='', title='Manual Search', attr='') }}
|
||||
</div>
|
||||
{% if request.user.is_authenticated %}
|
||||
{% for favorite in favorites %}
|
||||
<div class="col-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-star', icon_size='fa-4x', url_id='', link=favorite.room.id, title=favorite.room.room_number, attr='') }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="col-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-plus', icon_size='fa-4x', url_id='roomservice:add-fav', link='', title='Add Fav', attr='') }}
|
||||
</div>
|
||||
{% if request.user.is_superuser %}
|
||||
<div class="col-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-bar-chart', icon_size='fa-4x', url_id='', link='', title='Statistics', attr='') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div class="col-2"></div>
|
||||
<div class="col-9">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-crosshairs', icon_size='fa-4x', url_id='roomservice:location-based-search', link='', title='Localization Search', attr='') }}
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-search', icon_size='fa-4x', url_id='roomservice:search', link='', title='Manual Search', attr='') }}
|
||||
</div>
|
||||
{% if request.user.is_authenticated %}
|
||||
{% for favorite in favorites %}
|
||||
<div class="col-12 col-md-6">
|
||||
{{ macros.home_item_with_icon_2(icon='fa-star', icon_size='fa-4x', url_id='roomservice:booking', payload=favorite.room.id, link=favorite.room.id, title=favorite.room.room_number) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="col-12 col-md-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-plus', icon_size='fa-4x', url_id='roomservice:add-fav', link='', title='Add Fav', attr='') }}
|
||||
</div>
|
||||
{% if request.user.is_superuser %}
|
||||
<div class="col-12 col-md-6">
|
||||
{{ macros.home_item_with_icon(icon='fa-bar-chart', icon_size='fa-4x', url_id='', link='', title='Statistics', attr='') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -7,71 +7,91 @@
|
||||
<p>
|
||||
|
||||
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<form class="form-inline my-2 my-lg-0" action="{{ url('roomservice:search') }}" method="POST">
|
||||
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button"
|
||||
aria-expanded="false" aria-controls="collapseExample">
|
||||
Filter
|
||||
</a>
|
||||
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||
<input name="search" class="form-control mr-sm-2" type="search" placeholder="Search"
|
||||
aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<div class="collapse" id="collapseExample" style="max-width: 200px">
|
||||
<form action="{{url('roomservice:filter-search')}}" method="POST" id="FormFilter">
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||
<div class="card card-body">
|
||||
<div class="form-check form-check-inline">
|
||||
<input type="checkbox" class="form-check-input" id="checkboxbarrierfree">
|
||||
<label class="form-check-label" for="checkbox">barrierfree</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input type="checkbox" class="form-check-input" id="checkbox">
|
||||
<label class="form-check-label" for="checkbox">seating</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input type="checkbox" class="form-check-input" id="checkbox">
|
||||
<label class="form-check-label" for="checkbox">cooling</label>
|
||||
</div>
|
||||
<div class="collapse" id="collapseExample" style="max-width: 200px">
|
||||
<form action="{{ url('roomservice:filter-search') }}" method="POST" id="form">
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||
<div class="card card-body">
|
||||
<div class="form-check form-check-inline">
|
||||
<input type="checkbox" class="form-check-input" name="barrierfree"
|
||||
id="checkboxbarrierfree">
|
||||
<label class="form-check-label" for="checkbox">barrierfree</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input type="checkbox" class="form-check-input" id="checkbox" name="seating">
|
||||
<label class="form-check-label" for="checkbox">seating</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input type="checkbox" class="form-check-input" id="checkbox" name="cooling">
|
||||
<label class="form-check-label" for="checkbox">cooling</label>
|
||||
</div>
|
||||
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Capacity
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#">no selection</a>
|
||||
<a class="dropdown-item" href="#">20</a>
|
||||
<a class="dropdown-item" href="#">30</a>
|
||||
<a class="dropdown-item" href="#">60</a>
|
||||
<div class="form-group">
|
||||
<label for="sel1">Select list:</label>
|
||||
<select name="capacity" class="form-control" form="form" id="sel1">
|
||||
<option value="-1">no selection</option>
|
||||
<option value="20">20</option>
|
||||
<option value="30">30</option>
|
||||
<option value="60">60</option>
|
||||
<option value="120">120</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Use filters</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Use filters</button>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col"></div>
|
||||
<div class="col-8">
|
||||
<form action="{{ url("roomservice:booking") }}" method="POST" id="form">
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
|
||||
<div class="form-group">
|
||||
<label for="sel1">Select list:</label>
|
||||
<select multiple name="room" class="form-control" form="form" id="sel1">
|
||||
{% for room in rooms %}
|
||||
<option value="{{ room.id }}">{{ room.room_number }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" method="POST" value=" Send" class="btn btn-success" id="submit"> Submit
|
||||
</button>
|
||||
</form>
|
||||
{# <form action="{{ url("roomservice:booking") }}" method="POST" id="form">#}
|
||||
{# <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">#}
|
||||
{# <div class="form-group">#}
|
||||
{#
|
||||
{# </div>#}
|
||||
{# <button type="submit" method="POST" value=" Send" class="btn btn-success" id="submit"> Submit#}
|
||||
{# </button>#}
|
||||
{# </form>#}
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
{% if rooms %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2>Results</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{% for room in rooms %}
|
||||
<div class="col-6">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Room:{{ room.room_number }}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted">Building Name: {{ room.building.name }}</h6>
|
||||
<div class="card-text">
|
||||
<p>Capacity: {{ room.capacity }} Persons</p>
|
||||
<p>Room type: {{ room.room_type.type }}</p></div>
|
||||
<a href="{{ url('roomservice:booking', args=[room.id]) }}" class="card-link">Detail</a>
|
||||
{# <a href="#" class="card-link">Another link</a>#}
|
||||
</div>
|
||||
</div>
|
||||
<p></p></br>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<p>Results: {{ result_count }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
15
roofis2/templates/success.jinja
Normal file
15
roofis2/templates/success.jinja
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends 'base.jinja' %}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row text-dark">
|
||||
<div class="col-12 bg-white text-center">
|
||||
<p class="h1 text-xl-center text-success">Krass!</p>
|
||||
<p class="h3 text-xl-center">Success</p>
|
||||
<p>Das Formular wurde erfolgreich gespeichert!</p>
|
||||
<video src="{{ static('images/dumbledore.mp4') }}" loop autoplay></video>
|
||||
<br/>
|
||||
<a class="btn-link" href="{{ url('roomservice:home') }}">Zurück zur Übersicht</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user