Feat: Add script to apply subscriptions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import typing
|
||||
from datetime import datetime
|
||||
from datetime import date, datetime
|
||||
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
|
||||
@@ -153,3 +153,15 @@ class Subscription(Base):
|
||||
return ", ".join(result)
|
||||
else:
|
||||
return "Alle"
|
||||
|
||||
def valid_on(self, date: date) -> bool:
|
||||
weekday = date.weekday()
|
||||
return {
|
||||
0: self.monday,
|
||||
1: self.tuesday,
|
||||
2: self.wednesday,
|
||||
3: self.thursday,
|
||||
4: self.friday,
|
||||
5: self.saturday,
|
||||
6: self.sunday,
|
||||
}[weekday]
|
||||
|
||||
Reference in New Issue
Block a user