diff --git a/instance/schedule.db-journal b/instance/schedule.db-journal deleted file mode 100644 index 4a39e6c..0000000 Binary files a/instance/schedule.db-journal and /dev/null differ diff --git a/models/postmodel.py b/models/postmodel.py index bdb672b..a5e5406 100644 --- a/models/postmodel.py +++ b/models/postmodel.py @@ -9,8 +9,8 @@ class Post(db.Model): id = db.Column(db.Integer, primary_key=True) content = db.Column(db.String, nullable=False) files = db.Column(db.String(300), nullable=True, unique=False) - last_updated = db.Column(db.DateTime) - scheduled_time = db.Column(db.DateTime) + last_updated = db.Column(db.DateTime(timezone=True)) + scheduled_time = db.Column(db.DateTime(timezone=True)) def __repr__(self): return "" % self.id diff --git a/scheduler/schedule_text.py b/scheduler/schedule_text.py index 30ebc90..b78cc99 100644 --- a/scheduler/schedule_text.py +++ b/scheduler/schedule_text.py @@ -1,4 +1,5 @@ from datetime import datetime +from zoneinfo import ZoneInfo from app import db from models.postmodel import Post @@ -9,10 +10,13 @@ from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError, def schedule_text(request): print(request.form["text"]) try: + text = request.form["text"] + content = f"

{text}

" + zoneinfo = ZoneInfo("Europe/Berlin") post = Post( - content=request.form["text"], - last_updated=datetime.now(), - scheduled_time=datetime.now(), + content=content, + last_updated=datetime.now().astimezone(tz=zoneinfo), + scheduled_time=datetime.now().astimezone(tz=zoneinfo), ) db.session.add(post) db.session.commit() diff --git a/start.py b/start.py index 47e7e7a..0c074d1 100644 --- a/start.py +++ b/start.py @@ -1,5 +1,5 @@ import flask_apscheduler -from flask import Flask, request +from flask import Blueprint, Flask, request from app import create_app from scheduler.schedule_text import schedule_text diff --git a/updater.py b/updater.py index a7f96f0..1cbd122 100644 --- a/updater.py +++ b/updater.py @@ -1,3 +1,5 @@ +from zoneinfo import ZoneInfo + from feedgen.feed import FeedGenerator from models.postmodel import Post @@ -5,12 +7,14 @@ from models.postmodel import Post def update_rss_feed(): fg = create_rss_feed() + zoneinfo = ZoneInfo("Europe/Berlin") posts = Post.query.all() for post in posts: fe = fg.add_entry() fe.id("http://lernfunk.de/media/654321/1") fe.title(f"Crunk website:{post.id}") fe.content(post.content) + fe.published(post.scheduled_time.astimezone(tz=zoneinfo)) fe.link(href="http://crunk.website") write_rss_feed(fg)