Merge branch 'master' of ssh://git.wiai.de:22222/mgoetz/roofis2
This commit is contained in:
commit
cf6a9fa3d6
@ -1,6 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from .models import Staff, Room, RoomType, BookingGroup, Booking, Equipment, Location, Building, NumEquipment, \
|
||||
AccessPoint
|
||||
AccessPoint, Favorite
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(Staff)
|
||||
@ -13,3 +13,4 @@ admin.site.register(Location)
|
||||
admin.site.register(Building)
|
||||
admin.site.register(NumEquipment)
|
||||
admin.site.register(AccessPoint)
|
||||
admin.site.register(Favorite)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from roomservice.models import RoomType, Room, NumEquipment, Building, Location, Equipment, Booking, BookingGroup, \
|
||||
Staff, AccessPoint
|
||||
Staff, AccessPoint, Favorite
|
||||
from django.contrib.auth.models import User
|
||||
import logging
|
||||
import random
|
||||
@ -56,6 +56,10 @@ def create():
|
||||
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:
|
||||
@ -142,3 +146,8 @@ def create_access_point():
|
||||
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()))
|
||||
|
||||
@ -99,3 +99,11 @@ class AccessPoint(models.Model):
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user