Commit 6304d38c authored by Gottfried Gaisbauer's avatar Gottfried Gaisbauer
Browse files

renaming

parent 74998bcf
......@@ -9,7 +9,7 @@ import datetime
from sqlalchemy import orm, func, Boolean, Column, DateTime, Integer, String, ForeignKey, ForeignKeyConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.sql.expression import false
from libraries.database.database import db
from libraries.database.database import DB
from libraries.enum.scheduleentrytype import ScheduleEntryType
......@@ -21,17 +21,17 @@ class AuraDatabaseModel:
def store(self, add=False, commit=False):
if add:
db.session.add(self)
DB.session.add(self)
if commit:
db.session.commit()
DB.session.commit()
def delete(self, commit=False):
current_db_sessions = db.session.object_session(self)
current_db_sessions = DB.session.object_session(self)
current_db_sessions.delete(self)
return
db.session.delete(self)
DB.session.delete(self)
if commit:
db.session.commit()
DB.session.commit()
def _asdict(self):
return self.__dict__
......@@ -42,14 +42,14 @@ class AuraDatabaseModel:
manualschedule.show_name = "Manual Show"
self.logger.debug("Recreating Database...")
db.drop_all()
DB.drop_all()
self.logger.debug("all dropped. creating...")
db.create_all()
DB.create_all()
self.logger.debug("inserting manual scheduling possibility and fallback trackservice schedule")
db.session.add(manualschedule)
DB.session.add(manualschedule)
# db.session.add(fallback_trackservice_schedule)
self.logger.debug("all created. commiting...")
db.session.commit()
DB.session.commit()
self.logger.debug("Database recreated!")
if systemexit:
......@@ -57,7 +57,7 @@ class AuraDatabaseModel:
# ------------------------------------------------------------------------------------------ #
class Schedule(db.Model, AuraDatabaseModel):
class Schedule(DB.Model, AuraDatabaseModel):
"""
One specific Schedule for a show on a timeslot
"""
......@@ -94,7 +94,7 @@ class Schedule(db.Model, AuraDatabaseModel):
# ------------------------------------------------------------------------------------------ #
class ScheduleEntry(db.Model, AuraDatabaseModel):
class ScheduleEntry(DB.Model, AuraDatabaseModel):
"""
One schedule can have multiple entries
"""
......@@ -151,7 +151,7 @@ class ScheduleEntry(db.Model, AuraDatabaseModel):
@staticmethod
def select_all():
# fetching all entries
all_entries = db.session.query(ScheduleEntry).filter(ScheduleEntry.is_fallback == false()).order_by(ScheduleEntry.entry_start).all()
all_entries = DB.session.query(ScheduleEntry).filter(ScheduleEntry.is_fallback == false()).order_by(ScheduleEntry.entry_start).all()
cnt = 0
for entry in all_entries:
......@@ -163,7 +163,7 @@ class ScheduleEntry(db.Model, AuraDatabaseModel):
@staticmethod
def select_next_manual_entry_num():
max_manual_entry_num = db.session.query(func.max(ScheduleEntry.entry_num)).filter(ScheduleEntry.schedule_id == 0).first()
max_manual_entry_num = DB.session.query(func.max(ScheduleEntry.entry_num)).filter(ScheduleEntry.schedule_id == 0).first()
if max_manual_entry_num[0] is None:
return 0
......@@ -173,13 +173,13 @@ class ScheduleEntry(db.Model, AuraDatabaseModel):
# ------------------------------------------------------------------------------------------ #
@staticmethod
def upcoming(datefrom=datetime.datetime.now()):
upcomingtracks = db.session.query(ScheduleEntry).filter(ScheduleEntry.start > datefrom).all()
upcomingtracks = DB.session.query(ScheduleEntry).filter(ScheduleEntry.start > datefrom).all()
return upcomingtracks
# ------------------------------------------------------------------------------------------ #
@staticmethod
def select_one(playlist_id, entry_num):
return db.session.query(ScheduleEntry).filter(ScheduleEntry.playlist_id == playlist_id, ScheduleEntry.entry_num == entry_num).first()
return DB.session.query(ScheduleEntry).filter(ScheduleEntry.playlist_id == playlist_id, ScheduleEntry.entry_num == entry_num).first()
# ------------------------------------------------------------------------------------------ #
def __str__(self):
......@@ -187,7 +187,7 @@ class ScheduleEntry(db.Model, AuraDatabaseModel):
# ------------------------------------------------------------------------------------------ #
class TrackService(db.Model, AuraDatabaseModel):
class TrackService(DB.Model, AuraDatabaseModel):
__tablename__ = 'trackservice'
trackservice_id = Column(Integer, primary_key=True, autoincrement=True)
......@@ -207,7 +207,7 @@ class TrackService(db.Model, AuraDatabaseModel):
@staticmethod
def select_one(trackservice_id):
return db.session.query(TrackService).filter(TrackService.trackservice_id == trackservice_id).first()
return DB.session.query(TrackService).filter(TrackService.trackservice_id == trackservice_id).first()
# ------------------------------------------------------------------------------------------ #
# class TrackServiceSchedule(db.Model, AuraDatabaseModel):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment