event + training colors
This commit is contained in:
@@ -32,4 +32,12 @@ tr:nth-child(2n) {
|
|||||||
|
|
||||||
.colwidth {
|
.colwidth {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.training {
|
||||||
|
color: #185886;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event {
|
||||||
|
color: green;
|
||||||
}
|
}
|
10
sched.py
Normal file → Executable file
10
sched.py
Normal file → Executable file
@@ -1,5 +1,9 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
from vatsched import *
|
from vatsched import *
|
||||||
|
import os
|
||||||
|
|
||||||
|
# outputdirectory, filename = os.path.split(__file__) # to place in current directory
|
||||||
|
outputdirectory = "/home/daniel/html/vatsim"
|
||||||
|
|
||||||
stations = [
|
stations = [
|
||||||
"EDWW_CTR",
|
"EDWW_CTR",
|
||||||
@@ -47,6 +51,8 @@ stations = [
|
|||||||
|
|
||||||
displaydates = EveryXWeeksFromStartdate("26.02.2021", 4, 2)
|
displaydates = EveryXWeeksFromStartdate("26.02.2021", 4, 2)
|
||||||
#displaydates = EveryWeekday(1,2) # MONDAY = 0
|
#displaydates = EveryWeekday(1,2) # MONDAY = 0
|
||||||
#displaydates = WholeWeek()
|
|
||||||
|
|
||||||
createImage(displaydates, stations, 'test.jpg')
|
createImage(displaydates, stations, outputdirectory + os.sep + 'ber-fra-shuttle.jpg')
|
||||||
|
|
||||||
|
#displaydates = WholeWeek()
|
||||||
|
#createImage(displaydates, stations, outputdirectory + os.sep + 'woche.jpg')
|
48
vatsched.py
48
vatsched.py
@@ -1,8 +1,10 @@
|
|||||||
import imgkit, requests
|
import imgkit, requests, os
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
abbreviations = {}
|
abbreviations = {}
|
||||||
|
training = 0
|
||||||
|
event = 0
|
||||||
|
|
||||||
def EveryXDaysFromStartdate(startdate, x, numberofdates = 1):
|
def EveryXDaysFromStartdate(startdate, x, numberofdates = 1):
|
||||||
startdate = parse(startdate)
|
startdate = parse(startdate)
|
||||||
@@ -33,19 +35,28 @@ def WholeWeek(shift = 0):
|
|||||||
|
|
||||||
|
|
||||||
def getDatePositionData(station, date, bookings):
|
def getDatePositionData(station, date, bookings):
|
||||||
global abbreviations
|
global abbreviations, training, event
|
||||||
text = []
|
text = []
|
||||||
for booking in bookings[station]:
|
for booking in bookings[station]:
|
||||||
|
color1 = color2 = ""
|
||||||
if date.date() == booking['starts_at'].date():
|
if date.date() == booking['starts_at'].date():
|
||||||
abbr = booking['firstname'][:2] + booking['lastname'].split(" ")[-1][:2]
|
abbr = booking['firstname'][:2] + booking['lastname'].split(" ")[-1][:2]
|
||||||
abbreviations[abbr] = booking['firstname'] + " " + booking['lastname']
|
abbreviations[abbr] = booking['firstname'] + " " + booking['lastname']
|
||||||
text.append(abbr + " " + booking['starts_at'].strftime("%H") + "-" + booking['ends_at'].strftime("%H"))
|
if(booking['event'] == 1):
|
||||||
|
color1 = "<span class='event'>"
|
||||||
|
color2 = "</span>"
|
||||||
|
event = 1
|
||||||
|
if(booking['training'] == 1):
|
||||||
|
color1 = "<span class='training'>"
|
||||||
|
color2 = "</span>"
|
||||||
|
training = 1
|
||||||
|
text.append(color1 + abbr + " " + booking['starts_at'].strftime("%H") + "-" + booking['ends_at'].strftime("%H") + color2)
|
||||||
if len(text) < 1:
|
if len(text) < 1:
|
||||||
text.append("--")
|
text.append("--")
|
||||||
return "<br>".join(text)
|
return "<br>".join(text)
|
||||||
|
|
||||||
def maketable(stations, displaydates, bookings):
|
def maketable(stations, displaydates, bookings):
|
||||||
global abbreviations
|
global abbreviations, training, event
|
||||||
text = "<table><tr><th>Stationen</th>"
|
text = "<table><tr><th>Stationen</th>"
|
||||||
|
|
||||||
for date in displaydates:
|
for date in displaydates:
|
||||||
@@ -73,10 +84,22 @@ def maketable(stations, displaydates, bookings):
|
|||||||
if i > 4:
|
if i > 4:
|
||||||
text += "</div><div class='abbreviations'>"
|
text += "</div><div class='abbreviations'>"
|
||||||
i = 0
|
i = 0
|
||||||
return text + "</div>"
|
text += "</div>"
|
||||||
|
|
||||||
|
text += "<div style='clear:both'>"
|
||||||
|
if(training == 1):
|
||||||
|
text += "<span class='training'>Training </span>"
|
||||||
|
if(event == 1):
|
||||||
|
text += "<span class='event'>Event</span>"
|
||||||
|
text += "</div>"
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def createImage(displaydates, stations, filename):
|
def createImage(displaydates, stations, filename):
|
||||||
|
global abbreviations, training, event
|
||||||
|
training = event = 0
|
||||||
|
abbreviations = {}
|
||||||
|
|
||||||
rawdata = fetchData(displaydates[0], displaydates[-1])
|
rawdata = fetchData(displaydates[0], displaydates[-1])
|
||||||
relbookings = {}
|
relbookings = {}
|
||||||
for station in stations:
|
for station in stations:
|
||||||
@@ -84,10 +107,19 @@ def createImage(displaydates, stations, filename):
|
|||||||
|
|
||||||
for datum in rawdata:
|
for datum in rawdata:
|
||||||
if datum['station']['ident'] in stations:
|
if datum['station']['ident'] in stations:
|
||||||
relbookings[datum['station']['ident']].append({'starts_at': parse(datum['starts_at']), 'ends_at': parse(datum['ends_at']), 'lastname': datum['controller']['lastname'], 'firstname': datum['controller']['firstname']})
|
relbookings[datum['station']['ident']].append({
|
||||||
|
'starts_at': parse(datum['starts_at']),
|
||||||
|
'ends_at': parse(datum['ends_at']),
|
||||||
|
'lastname': datum['controller']['lastname'],
|
||||||
|
'firstname': datum['controller']['firstname'],
|
||||||
|
'training': datum['training'],
|
||||||
|
'event': datum['event']
|
||||||
|
})
|
||||||
|
|
||||||
text = maketable(stations, displaydates, relbookings)
|
text = maketable(stations, displaydates, relbookings)
|
||||||
css = 'layout.css'
|
|
||||||
|
directory, dontcare = os.path.split(__file__)
|
||||||
|
css = directory + os.sep + 'layout.css'
|
||||||
options = {'width': (100 + 75 * len(displaydates)), 'disable-smart-width': ''}
|
options = {'width': (100 + 75 * len(displaydates)), 'disable-smart-width': ''}
|
||||||
# config = imgkit.config(wkhtmltoimage='C:/Program Files/wkhtmltopdf/bin/wkhtmltoimage.exe')
|
# config = imgkit.config(wkhtmltoimage='C:/Program Files/wkhtmltopdf/bin/wkhtmltoimage.exe')
|
||||||
config = imgkit.config(wkhtmltoimage='/usr/bin/wkhtmltoimage')
|
config = imgkit.config(wkhtmltoimage='/usr/bin/wkhtmltoimage')
|
||||||
|
Reference in New Issue
Block a user