Merge branch 'master' of /media/data_1/www/gogs/gogs-repositories/michigg/ofu-app
This commit is contained in:
commit
9002f44c5d
@ -1,3 +1,7 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from apps.donar.models import Room, Lecture, Lecture_Terms, VGN_Coords
|
||||
# Register your models here.
|
||||
admin.site.register(Room)
|
||||
admin.site.register(Lecture)
|
||||
admin.site.register(Lecture_Terms)
|
||||
admin.site.register(VGN_Coords)
|
||||
14
ofu_app/apps/donar/management/commands/import_lectures.py
Normal file
14
ofu_app/apps/donar/management/commands/import_lectures.py
Normal file
@ -0,0 +1,14 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from apps.donar.models import Room
|
||||
from apps.donar.utils import migrate_data_lectures
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Imports Lectures from UnivIS PRG. Requires Room import"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **options):
|
||||
migrate_data_lectures.main()
|
||||
self.stdout.write(self.style.SUCCESS('Successfully migrate data'))
|
||||
@ -1,6 +1,6 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from apps.donar.models import Room
|
||||
from apps.donar.utils import migrate_data
|
||||
from apps.donar.utils import migrate_data_rooms
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@ -10,5 +10,5 @@ class Command(BaseCommand):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **options):
|
||||
migrate_data.main()
|
||||
migrate_data_rooms.main()
|
||||
self.stdout.write(self.style.SUCCESS('Successfully migrate data'))
|
||||
|
||||
11
ofu_app/apps/donar/management/commands/import_vgn_coords.py
Normal file
11
ofu_app/apps/donar/management/commands/import_vgn_coords.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from apps.donar.utils import migrate_data_vgn_coords
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Imports Rooms from Univis PRG"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **options):
|
||||
migrate_data_vgn_coords.migrate()
|
||||
@ -1,8 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.6 on 2017-10-25 21:40
|
||||
# Generated by Django 1.11.2 on 2017-10-29 23:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -13,6 +15,25 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Lecture',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('univis_ref', models.CharField(max_length=60, unique=True)),
|
||||
('univis_id', models.CharField(max_length=60, unique=True)),
|
||||
('name', models.CharField(max_length=60)),
|
||||
('short', models.CharField(max_length=60)),
|
||||
('type', models.CharField(max_length=60)),
|
||||
('lecturer_id', models.CharField(max_length=60)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Lecture_Terms',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('starttime', models.TimeField(default=datetime.datetime(2017, 10, 29, 23, 28, 46, 228504, tzinfo=utc))),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Room',
|
||||
fields=[
|
||||
@ -38,4 +59,14 @@ class Migration(migrations.Migration):
|
||||
('latitude', models.CharField(max_length=60, unique=True)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='lecture_terms',
|
||||
name='room',
|
||||
field=models.ManyToManyField(blank=True, to='donar.Room'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='lecture',
|
||||
name='term',
|
||||
field=models.ManyToManyField(to='donar.Lecture_Terms'),
|
||||
),
|
||||
]
|
||||
|
||||
22
ofu_app/apps/donar/migrations/0002_auto_20171030_0029.py
Normal file
22
ofu_app/apps/donar/migrations/0002_auto_20171030_0029.py
Normal file
@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-10-29 23:29
|
||||
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', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='lecture_terms',
|
||||
name='starttime',
|
||||
field=models.TimeField(default=datetime.datetime(2017, 10, 29, 23, 29, 23, 775652, tzinfo=utc)),
|
||||
),
|
||||
]
|
||||
@ -1,4 +1,5 @@
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
MAX_LENGTH = 60
|
||||
|
||||
@ -16,10 +17,39 @@ class Room(models.Model):
|
||||
size = models.CharField(max_length=MAX_LENGTH, default="")
|
||||
description = models.CharField(max_length=200, default="")
|
||||
|
||||
def __str__(self):
|
||||
return "%s - size: %s" % (self.short, str(self.size))
|
||||
|
||||
|
||||
class VGN_Coords(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=MAX_LENGTH, unique=True)
|
||||
coords = models.CharField(max_length=MAX_LENGTH, unique=True)
|
||||
longitude = models.CharField(max_length=MAX_LENGTH, unique=True)
|
||||
latitude = models.CharField(max_length=MAX_LENGTH, unique=True)
|
||||
latitude = models.CharField(max_length=MAX_LENGTH, unique=True)
|
||||
|
||||
def __str__(self):
|
||||
return "%s" % self.name
|
||||
|
||||
|
||||
class Lecture(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
univis_ref = models.CharField(max_length=MAX_LENGTH, unique=True)
|
||||
univis_id = models.CharField(max_length=MAX_LENGTH, unique=True)
|
||||
name = models.CharField(max_length=MAX_LENGTH)
|
||||
short = models.CharField(max_length=MAX_LENGTH)
|
||||
type = models.CharField(max_length=MAX_LENGTH)
|
||||
lecturer_id = models.CharField(max_length=MAX_LENGTH)
|
||||
term = models.ManyToManyField('Lecture_Terms', blank=False)
|
||||
|
||||
def __str__(self):
|
||||
return "%s - Type: %s" % (self.short, str(self.type))
|
||||
|
||||
|
||||
class Lecture_Terms(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
starttime = models.TimeField(blank=False, default=timezone.now())
|
||||
room = models.ManyToManyField('Room', blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return "%s" % self.starttime.strftime("%Y-%m-%d")
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
import json
|
||||
from pprint import pprint
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from apps.donar.models import Room
|
||||
from apps.donar.utils.parser import univis_rooms_parser
|
||||
|
||||
# CONFIG
|
||||
UNIVIS_RPG_GuK = "http://univis.uni-bamberg.de/prg?search=rooms&department=Fakult%E4t%20Geistes-%20und%20Kulturwissenschaften&show=xml"
|
||||
UNIVIS_RPG_SoWi = "http://univis.uni-bamberg.de/prg?search=rooms&department=Fakult%E4t%20Sozial-%20und%20Wirtschaftswissenschaften&show=xml"
|
||||
UNIVIS_RPG_HuWi = "http://univis.uni-bamberg.de/prg?search=rooms&department=Fakult%E4t%20Humanwissenschaften&show=xml"
|
||||
UNIVIS_RPG_WIAI = "http://univis.uni-bamberg.de/prg?search=rooms&department=Fakult%E4t%20Wirtschaftsinformatik&show=xml"
|
||||
|
||||
|
||||
def getJsonFromFile(path):
|
||||
with open(path, "r") as file:
|
||||
return json.load(file)
|
||||
|
||||
|
||||
def writeFekideDataInDB(data):
|
||||
for room in data:
|
||||
try:
|
||||
key = ""
|
||||
address = ""
|
||||
building_key = ""
|
||||
floor = ""
|
||||
name = ""
|
||||
orgname = ""
|
||||
short = ""
|
||||
size = ""
|
||||
description = ""
|
||||
if '@key' in room:
|
||||
key = room['@key']
|
||||
if 'address' in room:
|
||||
address = room['address']
|
||||
if 'buildingkey' in room:
|
||||
building_key = room['buildingkey']
|
||||
if 'floor' in room:
|
||||
floor = room['floor']
|
||||
if 'name' in room:
|
||||
name = room['name']
|
||||
if 'short' in room:
|
||||
short = room['short']
|
||||
if 'size' in room:
|
||||
size = room['size']
|
||||
if 'description' in room:
|
||||
description = room['description']
|
||||
|
||||
Room.objects.create(key=key, address=address, building_key=building_key, floor=floor, name=name,
|
||||
orgname=orgname, short=short, size=size, description=description)
|
||||
except IntegrityError:
|
||||
# ignored
|
||||
break
|
||||
|
||||
|
||||
def main():
|
||||
# get food jsons
|
||||
writeFekideDataInDB(univis_rooms_parser.parsePage(UNIVIS_RPG_GuK))
|
||||
writeFekideDataInDB(univis_rooms_parser.parsePage(UNIVIS_RPG_SoWi))
|
||||
writeFekideDataInDB(univis_rooms_parser.parsePage(UNIVIS_RPG_HuWi))
|
||||
writeFekideDataInDB(univis_rooms_parser.parsePage(UNIVIS_RPG_WIAI))
|
||||
pprint("Room: " + str(Room.objects.count()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
124
ofu_app/apps/donar/utils/migrate_data_lectures.py
Normal file
124
ofu_app/apps/donar/utils/migrate_data_lectures.py
Normal file
@ -0,0 +1,124 @@
|
||||
from apps.donar.models import Room, Lecture_Terms, Lecture
|
||||
from datetime import datetime
|
||||
import json
|
||||
from pprint import pprint
|
||||
from django.db.utils import IntegrityError
|
||||
from apps.donar.utils.parser import univis_lectures_parser
|
||||
|
||||
# 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:
|
||||
for term in lecture['terms']['term']:
|
||||
try:
|
||||
term_obj = Lecture_Terms.objects.create()
|
||||
starttime = "00:00"
|
||||
if 'starttime' in term:
|
||||
starttime = term['starttime']
|
||||
term_obj.starttime = datetime.strptime(starttime, "%H:%M")
|
||||
if 'room' in term:
|
||||
room_id = term['room']['UnivISRef']['@key']
|
||||
term_obj.room = [Room.objects.get(key=room_id)]
|
||||
term_obj.save()
|
||||
lecture_obj.term.add(term_obj)
|
||||
except IntegrityError as err:
|
||||
print(err.args)
|
||||
|
||||
else:
|
||||
try:
|
||||
term_obj = Lecture_Terms.objects.create()
|
||||
univis_starttime = "00:00"
|
||||
if 'starttime' in lecture['terms']['term']:
|
||||
univis_starttime = lecture['terms']['term']['starttime']
|
||||
term_obj.starttime = datetime.strptime(univis_starttime, '%H:%M')
|
||||
if 'room' in lecture['terms']['term']:
|
||||
room_id = lecture['terms']['term']['room']['UnivISRef']['@key']
|
||||
pprint("Room: " + room_id)
|
||||
Room.objects.get(key=room_id)
|
||||
term_obj.room = [Room.objects.get(key=room_id)]
|
||||
|
||||
term_obj.save()
|
||||
lecture_obj.term.add(term_obj)
|
||||
except IntegrityError as err:
|
||||
print(err.args)
|
||||
|
||||
|
||||
def writeUnivisLectureDataInDB(data):
|
||||
for lecture in data:
|
||||
try:
|
||||
key = ''
|
||||
name = ''
|
||||
orgname = ''
|
||||
short = ''
|
||||
lecture_type = ''
|
||||
lecturer_id = ''
|
||||
|
||||
if '@key' in lecture:
|
||||
key = lecture['@key']
|
||||
if 'name' in lecture:
|
||||
# TODO Fix name bug
|
||||
name = lecture['name']
|
||||
if 'id' in lecture:
|
||||
univis_id = lecture['id']
|
||||
if 'orgname' in lecture:
|
||||
orgname = lecture['orgname']
|
||||
if 'short' in lecture:
|
||||
short = lecture['short']
|
||||
if 'type' in lecture:
|
||||
lecture_type = lecture['type']
|
||||
if 'dozs' in lecture:
|
||||
lecturer_id = dict(lecture['dozs']['doz']['UnivISRef'])['@key']
|
||||
print("Lecture: " + name)
|
||||
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()
|
||||
except IntegrityError as err:
|
||||
print(err.args)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def showStatus(status: str):
|
||||
print(status)
|
||||
pprint("Lectures: " + str(Lecture.objects.count()))
|
||||
pprint("Lecture Terms: " + str(Lecture_Terms.objects.count()))
|
||||
pprint("Room: " + str(Room.objects.count()))
|
||||
|
||||
|
||||
def main():
|
||||
# get food jsons
|
||||
showStatus("Start with:")
|
||||
# writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_SoWi)))
|
||||
showStatus("After SoWi:")
|
||||
# writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_GuK)))
|
||||
showStatus("After GuK:")
|
||||
writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_HuWi)))
|
||||
showStatus("After HuWi:")
|
||||
writeUnivisLectureDataInDB(univis_lectures_parser.parsePage(univis_lectures(FAKULTAET_WIAI)))
|
||||
showStatus("After WIAI:")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
108
ofu_app/apps/donar/utils/migrate_data_rooms.py
Normal file
108
ofu_app/apps/donar/utils/migrate_data_rooms.py
Normal file
@ -0,0 +1,108 @@
|
||||
import json
|
||||
from pprint import pprint
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from apps.donar.models import Room, Lecture_Terms, Lecture
|
||||
from apps.donar.utils.parser import univis_rooms_parser
|
||||
from apps.donar.utils.parser import univis_lectures_parser
|
||||
|
||||
# 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"
|
||||
ZWINGER = "http://univis.uni-bamberg.de/prg?search=rooms&name=k&show=xml"
|
||||
ZWINGER = "http://univis.uni-bamberg.de/prg?search=rooms&name=k&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(data):
|
||||
for room in data:
|
||||
try:
|
||||
key = ""
|
||||
address = ""
|
||||
building_key = ""
|
||||
floor = ""
|
||||
name = ""
|
||||
orgname = ""
|
||||
short = ""
|
||||
size = ""
|
||||
description = ""
|
||||
if '@key' in room:
|
||||
key = room['@key']
|
||||
if 'address' in room:
|
||||
address = room['address']
|
||||
if 'buildingkey' in room:
|
||||
building_key = room['buildingkey']
|
||||
if 'floor' in room:
|
||||
floor = room['floor']
|
||||
if 'name' in room:
|
||||
name = room['name']
|
||||
if 'short' in room:
|
||||
short = room['short']
|
||||
if 'size' in room:
|
||||
size = room['size']
|
||||
if 'description' in room:
|
||||
description = room['description']
|
||||
|
||||
Room.objects.create(key=key, address=address, building_key=building_key, floor=floor, name=name,
|
||||
orgname=orgname, short=short, size=size, description=description)
|
||||
except IntegrityError as err:
|
||||
pprint(err.args)
|
||||
|
||||
|
||||
def main():
|
||||
# get food jsons
|
||||
pprint("Begin: Room: " + str(Room.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")))
|
||||
|
||||
pprint("Now: Room: " + str(Room.objects.count()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@ -1,8 +1,7 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from apps.donar.models import VGN_Coords
|
||||
|
||||
|
||||
def migrate_locations():
|
||||
def migrate():
|
||||
locations = []
|
||||
locations.append(
|
||||
{'location': 'Erba', 'vgn_key': 'coord%3A4418901%3A629758%3ANAV4%3ABamberg%2C An der Weberei 5',
|
||||
@ -65,13 +64,3 @@ def migrate_locations():
|
||||
location_obj.coords = location['vgn_key']
|
||||
location_obj.latitude = location['lat']
|
||||
location_obj.longitude = location['lon']
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Imports Rooms from Univis PRG"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **options):
|
||||
migrate_locations()
|
||||
29
ofu_app/apps/donar/utils/parser/univis_lectures_parser.py
Normal file
29
ofu_app/apps/donar/utils/parser/univis_lectures_parser.py
Normal file
@ -0,0 +1,29 @@
|
||||
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)
|
||||
dict = xmltodict.parse(page)
|
||||
lectures = getLectures(dict)
|
||||
return lectures
|
||||
|
||||
# parsePage( "http://univis.uni-bamberg.de/prg?search=lectures&department=Fakult%E4t%20Geistes-%20und%20Kulturwissenschaften&show=exml")
|
||||
@ -1,6 +1,6 @@
|
||||
from django.shortcuts import render, redirect
|
||||
|
||||
from apps.donar.models import Room
|
||||
from django.db.models import Min
|
||||
from apps.donar.models import Room, Lecture, Lecture_Terms
|
||||
from apps.donar.models import VGN_Coords
|
||||
|
||||
|
||||
@ -15,11 +15,12 @@ def all_rooms(request):
|
||||
|
||||
|
||||
def search_room(request):
|
||||
id = request.GET.get('search_room', None)
|
||||
if id:
|
||||
token = request.GET.get('search_room', None)
|
||||
if token:
|
||||
# create a form instance and populate it with data from the request:
|
||||
rooms = Room.objects.filter(short__contains=id)
|
||||
return render(request, 'donar/search_rooms.jinja', {'id': id, 'rooms': rooms})
|
||||
rooms_by_id = Room.objects.filter(short__contains=token)
|
||||
lectures = Lecture.objects.annotate(min_starttime=Min('term__starttime')).filter(name__contains=token).order_by('min_starttime')
|
||||
return render(request, 'donar/search_rooms.jinja', {'id': token, 'rooms': rooms_by_id, 'lectures': lectures})
|
||||
|
||||
return render(request, 'donar/search_rooms.jinja', {})
|
||||
|
||||
|
||||
@ -129,13 +129,13 @@ def main():
|
||||
|
||||
# deleteUnivisObjects()
|
||||
# events, rooms, persons = univis_eventpage_parser.parsePage(UNIVIS_RPG_HuWi)
|
||||
# writeUnivisDataInDB(events, rooms, persons)
|
||||
# writeUnivisRoomDataInDB(events, rooms, persons)
|
||||
# events, rooms, persons = univis_eventpage_parser.parsePage(UNIVIS_RPG_SoWi)
|
||||
# writeUnivisDataInDB(events, rooms, persons)
|
||||
# writeUnivisRoomDataInDB(events, rooms, persons)
|
||||
# events, rooms, persons = univis_eventpage_parser.parsePage(UNIVIS_RPG_GuK)
|
||||
# writeUnivisDataInDB(events, rooms, persons)
|
||||
# writeUnivisRoomDataInDB(events, rooms, persons)
|
||||
# events, rooms, persons = univis_eventpage_parser.parsePage(UNIVIS_RPG_WIAI)
|
||||
# writeUnivisDataInDB(events, rooms, persons)
|
||||
# writeUnivisRoomDataInDB(events, rooms, persons)
|
||||
|
||||
writeFekideDataInDB(fekide_eventpage_parser.parsePage())
|
||||
|
||||
|
||||
@ -2,10 +2,11 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
from apps.food.models import SingleFood, Menu, HappyHour
|
||||
from apps.food.models import SingleFood, Menu, HappyHour, UserRating
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(SingleFood)
|
||||
admin.site.register(Menu)
|
||||
admin.site.register(HappyHour)
|
||||
admin.site.register(UserRating)
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-10-25 23:47
|
||||
# Generated by Django 1.11.2 on 2017-10-29 23:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
@ -11,6 +13,7 @@ class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
@ -50,14 +53,18 @@ class Migration(migrations.Migration):
|
||||
('price_guest', models.CharField(blank=True, max_length=10, null=True)),
|
||||
('image', models.ImageField(blank=True, upload_to='food/%Y/%m/')),
|
||||
('rating', models.FloatField(default=0)),
|
||||
('first_star', models.SmallIntegerField(default=0)),
|
||||
('second_star', models.SmallIntegerField(default=0)),
|
||||
('third_star', models.SmallIntegerField(default=0)),
|
||||
('fourth_star', models.SmallIntegerField(default=0)),
|
||||
('fifth_star', models.SmallIntegerField(default=0)),
|
||||
('allergens', models.ManyToManyField(blank=True, to='food.Allergene')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='UserRating',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('rating', models.FloatField(default=0)),
|
||||
('food', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='food.SingleFood')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='menu',
|
||||
name='menu',
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
from __future__ import unicode_literals
|
||||
from django.utils import timezone
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
MAX_LENGTH = 60
|
||||
|
||||
@ -28,11 +29,6 @@ class SingleFood(models.Model):
|
||||
price_guest = models.CharField(max_length=10, blank=True, null=True)
|
||||
image = models.ImageField(upload_to='food/%Y/%m/', blank=True)
|
||||
rating = models.FloatField(default=0)
|
||||
first_star = models.SmallIntegerField(default=0)
|
||||
second_star = models.SmallIntegerField(default=0)
|
||||
third_star = models.SmallIntegerField(default=0)
|
||||
fourth_star = models.SmallIntegerField(default=0)
|
||||
fifth_star = models.SmallIntegerField(default=0)
|
||||
allergens = models.ManyToManyField("Allergene", blank=True)
|
||||
|
||||
def __str__(self):
|
||||
@ -60,3 +56,13 @@ class HappyHour(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return "Date: %s, Location: %s" % (self.date.strftime("%Y.%m.%d"), self.location)
|
||||
|
||||
|
||||
class UserRating(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, unique=False)
|
||||
food = models.ForeignKey(SingleFood)
|
||||
rating = models.FloatField(default=0)
|
||||
|
||||
def __str__(self):
|
||||
return "User: %s - Rating: %s" % (self.user.username, self.rating)
|
||||
|
||||
@ -5,7 +5,7 @@ import datetime
|
||||
|
||||
from django.shortcuts import render
|
||||
|
||||
from apps.food.models import Menu, HappyHour, SingleFood
|
||||
from apps.food.models import Menu, HappyHour, SingleFood, UserRating
|
||||
from django.http import HttpResponse
|
||||
from rest_framework import viewsets, generics
|
||||
from rest_framework import status
|
||||
@ -80,29 +80,27 @@ def food(request):
|
||||
|
||||
|
||||
def food_rating(request):
|
||||
food_id = request.GET.get('food_id', None)
|
||||
rating = request.GET.get('rating', None)
|
||||
if food_id and rating:
|
||||
print("ID: %s, RATING: %s" % (food_id, rating))
|
||||
food = SingleFood.objects.get(id=food_id)
|
||||
if rating == str(1):
|
||||
food.first_star = food.first_star + 1
|
||||
if rating == str(2):
|
||||
food.second_star += 1
|
||||
if rating == str(3):
|
||||
food.third_star += 1
|
||||
if rating == str(4):
|
||||
food.fourth_star += 1
|
||||
if rating == str(5):
|
||||
food.fifth_star += 1
|
||||
global_count = food.first_star + food.second_star + food.third_star + food.fourth_star + food.fifth_star
|
||||
sum = food.first_star * 1 + food.second_star * 2 + food.third_star * 3 + food.fourth_star * 4 + food.fifth_star * 5
|
||||
food.rating = sum / global_count
|
||||
print("SUMME: " + str(sum / global_count))
|
||||
food.save()
|
||||
return HttpResponse(status=200)
|
||||
if (request.user.is_authenticated):
|
||||
food_id = request.GET.get('food_id', None)
|
||||
rating = request.GET.get('rating', None)
|
||||
if food_id and rating:
|
||||
food = SingleFood.objects.get(id=food_id)
|
||||
user_rating, created = UserRating.objects.get_or_create(user=request.user,
|
||||
food=food)
|
||||
user_rating.rating = rating
|
||||
user_rating.save()
|
||||
|
||||
return HttpResponse(status=404)
|
||||
food_user_ratings = UserRating.objects.all().filter(food=food)
|
||||
sum = 0
|
||||
for food_user_rating in food_user_ratings:
|
||||
sum += food_user_rating.rating
|
||||
|
||||
food.rating = sum / food_user_ratings.count()
|
||||
food.save()
|
||||
return HttpResponse(status=200)
|
||||
return HttpResponse(status=404)
|
||||
|
||||
return HttpResponse(status=403)
|
||||
|
||||
|
||||
def food_image(request):
|
||||
|
||||
0
ofu_app/apps/registration/__init__.py
Normal file
0
ofu_app/apps/registration/__init__.py
Normal file
3
ofu_app/apps/registration/admin.py
Normal file
3
ofu_app/apps/registration/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
ofu_app/apps/registration/apps.py
Normal file
5
ofu_app/apps/registration/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class RegistrationConfig(AppConfig):
|
||||
name = 'apps.registration'
|
||||
11
ofu_app/apps/registration/forms.py
Normal file
11
ofu_app/apps/registration/forms.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class SignUpForm(UserCreationForm):
|
||||
email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'email', 'password1', 'password2', )
|
||||
27
ofu_app/apps/registration/migrations/0001_initial.py
Normal file
27
ofu_app/apps/registration/migrations/0001_initial.py
Normal file
@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-10-29 11:07
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Profile',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('email_confirmed', models.BooleanField(default=False)),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
ofu_app/apps/registration/migrations/__init__.py
Normal file
0
ofu_app/apps/registration/migrations/__init__.py
Normal file
17
ofu_app/apps/registration/models.py
Normal file
17
ofu_app/apps/registration/models.py
Normal file
@ -0,0 +1,17 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
||||
class Profile(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
email_confirmed = models.BooleanField(default=False)
|
||||
# other fields...
|
||||
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def update_user_profile(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
Profile.objects.create(user=instance)
|
||||
instance.profile.save()
|
||||
3
ofu_app/apps/registration/tests.py
Normal file
3
ofu_app/apps/registration/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
11
ofu_app/apps/registration/tokens.py
Normal file
11
ofu_app/apps/registration/tokens.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||
from django.utils import six
|
||||
|
||||
class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
|
||||
def _make_hash_value(self, user, timestamp):
|
||||
return (
|
||||
six.text_type(user.pk) + six.text_type(timestamp) +
|
||||
six.text_type(user.profile.email_confirmed)
|
||||
)
|
||||
|
||||
account_activation_token = AccountActivationTokenGenerator()
|
||||
9
ofu_app/apps/registration/urls.py
Normal file
9
ofu_app/apps/registration/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.conf.urls import url
|
||||
from apps.registration import views as core_views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', core_views.signup, name='signup'),
|
||||
url(r'^account_activation_sent/$', core_views.account_activation_sent, name='account_activation_sent'),
|
||||
url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
|
||||
core_views.activate, name='activate'),
|
||||
]
|
||||
58
ofu_app/apps/registration/views.py
Normal file
58
ofu_app/apps/registration/views.py
Normal file
@ -0,0 +1,58 @@
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.shortcuts import render, redirect
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.http import urlsafe_base64_encode
|
||||
from django.template.loader import render_to_string
|
||||
from apps.registration.forms import SignUpForm
|
||||
from apps.registration.tokens import account_activation_token
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.http import urlsafe_base64_decode
|
||||
from django.core.mail import send_mail
|
||||
from django.shortcuts import HttpResponse
|
||||
|
||||
|
||||
def signup(request):
|
||||
if request.method == 'POST':
|
||||
form = SignUpForm(request.POST)
|
||||
if form.is_valid():
|
||||
user = form.save(commit=False)
|
||||
user.is_active = False
|
||||
user.save()
|
||||
current_site = request.META['HTTP_HOST']
|
||||
subject = 'Activate Your MySite Account'
|
||||
message = render_to_string('registration/account_activation_email.jinja', {
|
||||
'user': user,
|
||||
'domain': current_site,
|
||||
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
|
||||
'token': account_activation_token.make_token(user),
|
||||
})
|
||||
|
||||
send_mail(from_email="signup.basta@gmail.com", recipient_list=[user.email], subject=subject,
|
||||
message=message)
|
||||
return redirect('account_activation_sent')
|
||||
else:
|
||||
form = SignUpForm()
|
||||
return render(request, 'registration/signup.jinja', {'form': form})
|
||||
|
||||
|
||||
def activate(request, uidb64, token):
|
||||
try:
|
||||
uid = force_text(urlsafe_base64_decode(uidb64))
|
||||
user = User.objects.get(pk=uid)
|
||||
except (TypeError, ValueError, OverflowError, User.DoesNotExist):
|
||||
user = None
|
||||
|
||||
if user is not None and account_activation_token.check_token(user, token):
|
||||
user.is_active = True
|
||||
user.profile.email_confirmed = True
|
||||
user.save()
|
||||
login(request, user)
|
||||
return render(request, 'registration/account_activation_success.jinja')
|
||||
else:
|
||||
return render(request, 'registration/account_activation_invalid.jinja')
|
||||
|
||||
|
||||
def account_activation_sent(request):
|
||||
return render(request, 'registration/account_activation_sent.jinja', {})
|
||||
BIN
ofu_app/ofu_app/__pycache__/settings.cpython-35.pyc
Normal file
BIN
ofu_app/ofu_app/__pycache__/settings.cpython-35.pyc
Normal file
Binary file not shown.
BIN
ofu_app/ofu_app/__pycache__/urls.cpython-35.pyc
Normal file
BIN
ofu_app/ofu_app/__pycache__/urls.cpython-35.pyc
Normal file
Binary file not shown.
0
ofu_app/ofu_app/models.py
Normal file
0
ofu_app/ofu_app/models.py
Normal file
@ -34,14 +34,18 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.sites',
|
||||
'django_jinja',
|
||||
'apps.food',
|
||||
'apps.events',
|
||||
'apps.donar',
|
||||
'apps.registration',
|
||||
'rest_framework',
|
||||
'analytical',
|
||||
]
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.IsAdminUser',
|
||||
@ -59,7 +63,6 @@ REST_FRAMEWORK = {
|
||||
# ]
|
||||
|
||||
ROOT_URLCONF = 'ofu_app.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django_jinja.backend.Jinja2',
|
||||
@ -162,5 +165,19 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# monitoring
|
||||
PIWIK_DOMAIN_PATH = 'mg-server.ddns.net/piwik'
|
||||
PIWIK_SITE_ID = '1'
|
||||
|
||||
LOGIN_REDIRECT_URL = 'home'
|
||||
|
||||
# Sign Up E-Mail authentication
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
EMAIL_HOST = 'smtp.gmail.com'
|
||||
EMAIL_HOST_USER = 'signup.basta@gmail.com'
|
||||
EMAIL_HOST_PASSWORD = '1\SL^QzlSuP<`8gkP4Fd'
|
||||
EMAIL_PORT = '587'
|
||||
EMAIL_USE_TLS = True
|
||||
|
||||
ACCOUNT_EMAIL_UNIQUE = True
|
||||
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = True
|
||||
|
||||
@ -15,10 +15,15 @@ Including another URLconf
|
||||
"""
|
||||
from django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import views as auth_views
|
||||
from ofu_app import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^login/$', auth_views.login, {'template_name': 'registration/login.jinja'}, name='login'),
|
||||
url(r'^logout/$', auth_views.logout, {'next_page': '/'}, name='logout'),
|
||||
url(r'^admin/', admin.site.urls),
|
||||
# url(r'^signup/$', core_views.signup, name='signup'),
|
||||
url(r"^account/", include("apps.registration.urls")),
|
||||
|
||||
url(r'^$', views.home, name="home"),
|
||||
# -- Apps --
|
||||
|
||||
@ -55,12 +55,7 @@
|
||||
|
||||
#menu-button {
|
||||
text-align: center;
|
||||
margin-top: 12px;;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#menu-button i {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ function add_Stars() {
|
||||
var rating = $(this).data('rating');
|
||||
console.log("ITEM: " + $(this) + " FOOD-ID: " + food + " FOOD-RATING: " + rating);
|
||||
for (var i = 0; i < 5; i++) {
|
||||
$(this).find('.rating-wrapper').addClass('food-' + food);
|
||||
$(this).find('.rating-wrapper').append('<i class="star-' + (i + 1) + '-' + food + ' fa fa-star-o star" aria-hidden="true"></i>');
|
||||
}
|
||||
buildRating(food, rating);
|
||||
@ -78,9 +79,22 @@ function sendRating(obj) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
console.log("sent");
|
||||
}
|
||||
if (this.readyState == 4 && this.status == 403) {
|
||||
console.log("ERROR");
|
||||
ratingError('food-' + food_id);
|
||||
}
|
||||
};
|
||||
console.log(url + "?rating=" + rating + "&food_id=" + food_id);
|
||||
xhttp.open("GET", url + "?rating=" + rating + "&food_id=" + food_id, true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
function ratingError(obj) {
|
||||
console.log("Show in " + obj);
|
||||
$('.' + obj).append('<p class="rating-error">Please Log in to use the Rating function</p>');
|
||||
setTimeout(function () {
|
||||
$('.rating-error').remove();
|
||||
}, 1500);
|
||||
}
|
||||
@ -40,51 +40,56 @@
|
||||
<body>
|
||||
|
||||
{% block body %}
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
|
||||
</div>
|
||||
<div class="col-8">
|
||||
{% block headline %}{% endblock %}</div>
|
||||
<div class="col-2">
|
||||
<div id="menu-button"><i class="fa fa-bars" aria-hidden="true"></i>
|
||||
{{ nav.main_nav() }}
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-2 text-center m-auto">
|
||||
{% if request.user.is_authenticated() %}
|
||||
<a href="{{ url('logout') }}"><i class="fa fa-user" aria-hidden="true"></i></a>
|
||||
{% else %}
|
||||
<a href="{{ url('login') }}"><i class="fa fa-sign-in" aria-hidden="true"></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-8 pt-2">
|
||||
{% block headline %}{% endblock %}</div>
|
||||
<div class="col-2 text-center m-auto">
|
||||
<div id="menu-button"><i class="fa fa-bars" aria-hidden="true"></i>
|
||||
{{ nav.main_nav() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% block bottom_nav %}{% endblock %}
|
||||
<div class="container-fluid bg-dark text-white">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
{% block test %}
|
||||
<div class="text-center bg-warning pb-2" style="font-size: 12px !important;">
|
||||
<p>Hinweis: Diese Seite dient <strong>nur</strong> zu Testzwecken.
|
||||
Wir garantieren weder die Vollständigkeit, noch
|
||||
die Korrektheit der dargestellten Daten.</p>
|
||||
<div class="row">{% block bottom_nav %}{% endblock %}</div>
|
||||
<div class="test row bg-dark text-white">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block footer %}
|
||||
<footer>
|
||||
<div class="container-fluid bg-dark text-white">
|
||||
<div class="row pt-2 text-center">
|
||||
<div class="col">
|
||||
<p class="text-right"><a href="{{ url('impressum') }}#bug-report">Bug Report</a></p>
|
||||
{% block test %}
|
||||
<div class="row text-center bg-warning pb-2 pl-3 pr-3" style="font-size: 12px !important;">
|
||||
<div class="col-12 text-center">
|
||||
Hinweis: Diese Seite dient <strong>nur</strong> zu Testzwecken.
|
||||
Wir garantieren weder die Vollständigkeit, noch
|
||||
die Korrektheit der dargestellten Daten.
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block footer %}
|
||||
<footer>
|
||||
<div class="row bg-dark text-white">
|
||||
<div class="col-6">
|
||||
<p class="text-right mb-0"><a href="{{ url('impressum') }}#bug-report">Bug Report</a></p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="text-left"><a href="{{ url('impressum') }}">Impressum</a></p>
|
||||
<div class="col-6">
|
||||
<p class="text-left mb-0"><a href="{{ url('impressum') }}">Impressum</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="row text-center bg-dark text-white pb-2">
|
||||
<div class="col">
|
||||
© Copyright 2017, Michael Götz
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
{% endblock %}
|
||||
</footer>
|
||||
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
<!-- Optional JavaScript -->
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
|
||||
@ -7,24 +7,45 @@
|
||||
<div class="row pt-5">
|
||||
<form type="get" action="{{ url('search-rooms') }}" style="margin: 0">
|
||||
<input id="search_room" type="text" name="search_room" placeholder="Search...">
|
||||
<button id="search_submit" type="submit">Submit</button>
|
||||
<button id="search_submit" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
{% if id %}
|
||||
{% if id %}
|
||||
<div class="row mt-4">
|
||||
<h2>Ergebnisse für: {{ id }}</h2>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="row">
|
||||
{% if rooms %}
|
||||
{% for room in rooms %}
|
||||
<div class="col-12 p-1">
|
||||
<div class="p-2 border border-dark rounded-3 border border-dark rounded bg-light text-dark">
|
||||
<a href="{{ url('show-room', args=[room.short]) }}"><p><strong>Short:</strong> {{ room.short }}</p></a>
|
||||
</div>
|
||||
<div class="row">
|
||||
{% if rooms %}
|
||||
<h3>Ergebnisse Räume:</h3>
|
||||
{% for room in rooms %}
|
||||
<div class="col-12 p-1">
|
||||
<div class="p-2 border border-dark rounded-3 border border-dark rounded bg-light text-dark">
|
||||
<a href="{{ url('show-room', args=[room.short]) }}"><p>
|
||||
<strong>Raum:</strong> {{ room.short }}</p></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="row">
|
||||
{% if lectures %}
|
||||
<h3>Ergebnisse Lehrveranstaltungen:</h3>
|
||||
{% for lecture in lectures %}
|
||||
<div class="col-12 p-1">
|
||||
<div class="p-2 border border-dark rounded-3 border border-dark rounded bg-light text-dark">
|
||||
<h5>{{ lecture.name }}</h5>
|
||||
{% for term in lecture.term.all() %}
|
||||
<small>Start: {{ term.starttime.strftime("%H:%M") }}</small>
|
||||
{% for room in term.room.all() %}
|
||||
<a href="{{ url('show-room', args=[room.short]) }}"><p>
|
||||
<strong>Raum:</strong> {{ room.short }}</p></a>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<p class="text-center">Day: {{ day.strftime("%d.%m.%Y") }}</p>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
{{ macros.day_menu(title='Feki', location_menu=feki_menu, fail_text='Die Feki Mensa hat heute geschlossen.', css_id="feki") }}
|
||||
{{ macros.day_menu(title='Austraße', location_menu=austr_menu, fail_text='Die Austr Mensa hat heute geschlossen.', css_id="austr") }}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
{% endblock %}
|
||||
{% block bottom_nav %}
|
||||
<nav id="food-nav" class="navbar navbar-default bg-light">
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<a class="nav-link" href="{{ url('daily-food') }}"> Daily </a>
|
||||
<a class="nav-link" href="{{ url('weekly-food') }}"> Weekly </a>
|
||||
</div>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<p class="text-center">Week: {{ day.strftime("%d.%m.%Y") }} - {{ lastday.strftime("%d.%m.%Y") }}</p>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
{{ macros.week_menu(title='Feki', location_menus=feki_menu, fail_text='Die Feki Mensa hat heute geschlossen.') }}
|
||||
{{ macros.week_menu(title='Austraße', location_menus=austr_menu, fail_text='Die Austr Mensa hat heute geschlossen.') }}
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
{% import '/macros/overview_pages.jinja' as macros %}
|
||||
{% block headline %}
|
||||
<header class="">
|
||||
<h1 class="text-center" style="font-size: 20px">BaStA</h1>
|
||||
<h1 class="text-center mb-0" style="font-size: 20px">BaStA</h1>
|
||||
<p class="text-center">Bamberger Studierenden App</p>
|
||||
</header>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="container text-dark">
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
<div class="row text-dark">
|
||||
{{ macros.home_item_with_icon(icon='fa-cutlery', url_id='daily-food', title='Food') }}
|
||||
{{ macros.home_item_with_icon(icon='fa-calendar-o', url_id='day-events', title='Events') }}
|
||||
{{ macros.home_item_with_icon(icon='fa-compass', url_id='donar', title='Nav') }}
|
||||
|
||||
@ -83,9 +83,9 @@
|
||||
<div class="col-sm-12 col-md-5 col-lg-5 col-xl-5">{{ happy_hour.description }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>Leider gibt es heute keine Happy Hours :(</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
@ -0,0 +1,10 @@
|
||||
{% autoescape off %}
|
||||
Hi {{ user.username }},
|
||||
|
||||
Please click on the link below to confirm your registration:
|
||||
http://{{ domain }}{{ url('activate', args=[uid, token]) }}
|
||||
|
||||
|
||||
And a great welcome
|
||||
The BaStA Team
|
||||
{% endautoescape %}
|
||||
@ -0,0 +1,11 @@
|
||||
{% extends 'base.jinja' %}
|
||||
|
||||
{% block headline %}<h3 class="text-center">BaStA Login</h3>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-12 text-center p-3 bg-light text-dark">
|
||||
<h3>Fail</h3>
|
||||
<p>Your user account couldn't be activated</p>
|
||||
<p>Please try it again or inform the Administrator.</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
12
ofu_app/templates/registration/account_activation_sent.jinja
Normal file
12
ofu_app/templates/registration/account_activation_sent.jinja
Normal file
@ -0,0 +1,12 @@
|
||||
{% extends 'base.jinja' %}
|
||||
|
||||
{% block headline %}<h3 class="text-center">BaStA Login</h3>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-12 text-center p-3 bg-light text-dark">
|
||||
<h3>Sent</h3>
|
||||
<p>Your user account was created and the confirmation mail was sent</p>
|
||||
<p>Please confirm your email address.</p>
|
||||
<a href="{{ url('home') }}">Back to Home</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -0,0 +1,11 @@
|
||||
{% extends 'base.jinja' %}
|
||||
|
||||
{% block headline %}<h3 class="text-center">BaStA Login</h3>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-12 text-center p-3 bg-light text-dark">
|
||||
<h3>Success</h3>
|
||||
<p>Your user account is now activated.</p>
|
||||
<a href="{{ url('home') }}">Click here to show home</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
34
ofu_app/templates/registration/login.jinja
Normal file
34
ofu_app/templates/registration/login.jinja
Normal file
@ -0,0 +1,34 @@
|
||||
{% extends 'base.jinja' %}
|
||||
|
||||
{% block headline %}<h3 class="text-center">BaStA Login</h3>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-12 text-center p-3 bg-light text-dark">
|
||||
<h3>Login</h3>
|
||||
<form method="post" action="{{ url('login') }}">
|
||||
{% csrf_token %}
|
||||
{% if form.errors %}
|
||||
<div class="message is-danger">
|
||||
<div class="message-body">
|
||||
Your username and password didn't match. Please try again.
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<label for="id_username" class="label">Username:</label>
|
||||
<p class="control">
|
||||
<input id="id_username" class="input" maxlength="254" name="username" type="text">
|
||||
</p>
|
||||
<label for="id_password" class="label">Password:</label>
|
||||
<p class="control">
|
||||
<input id="id_password" class="input" name="password" type="password">
|
||||
</p>
|
||||
<input type="submit" class="button is-pulled-right" value="Login"/>
|
||||
<input type="hidden" name="next" value="{{ next }}"/>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-12 text-center p-3 bg-light text-dark">
|
||||
<p>Du hast noch keinen Account? <a href="{{ url('signup') }}">Hier</a> geht's zur Registrierung</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
50
ofu_app/templates/registration/signup.jinja
Normal file
50
ofu_app/templates/registration/signup.jinja
Normal file
@ -0,0 +1,50 @@
|
||||
{% extends 'base.jinja' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-12 text-left p-3 bg-light text-dark">
|
||||
<h2>Sign up</h2>
|
||||
<form method="post" action="{{ url('signup') }}">
|
||||
{% csrf_token %}
|
||||
<label for="username" class="label">Username:</label>
|
||||
<p>
|
||||
<input id="username" type="text" name="username" required autofocus maxlength="150" id="id_username"/>
|
||||
<small style="color: grey">Erforderlich. 150 Zeichen oder weniger. Nur Buchstaben, Ziffern und
|
||||
@/./+/-/_.
|
||||
</small>
|
||||
</p>
|
||||
|
||||
<label for="email" class="label">E-Mail:</label>
|
||||
<p>
|
||||
<input id="email" type="email" name="email" required maxlength="254" id="id_email"/>
|
||||
<small style="color: grey">Required. Inform a valid email address.</small>
|
||||
</p>
|
||||
|
||||
<label for="password1" class="label">Password:</label>
|
||||
<p>
|
||||
<input id="password1" type="password" name="password1" required id="id_password1"/>
|
||||
<small style="color: grey">
|
||||
<ul>
|
||||
<li>Das Passwort darf nicht zu ähnlich zu Ihren anderen
|
||||
persönlichen Informationen sein.
|
||||
</li>
|
||||
<li>Das Passwort muss mindestens 8 Zeichen
|
||||
enthalten.
|
||||
</li>
|
||||
<li>Das Passwort darf nicht allgemein üblich sein.</li>
|
||||
<li>Das
|
||||
Passwort darf nicht komplett aus Ziffern bestehen.
|
||||
</li>
|
||||
</ul>
|
||||
</small>
|
||||
</p>
|
||||
<label for="password2" class="label">Retype Password:</label>
|
||||
<p>
|
||||
<input id="password2" type="password" name="password2" required id="id_password2"/>
|
||||
<small style="color: grey">Bitte das selbe Passwort zur Bestätigung erneut eingeben.</small>
|
||||
</p>
|
||||
|
||||
<input type="submit" class="button is-pulled-right" value="Sign up"/>
|
||||
<input type="hidden" name="next" value="{{ next }}"/>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user