Fix: Datetime behavioral issues.
This commit is contained in:
parent
bd909f394d
commit
c610c60dc0
4 changed files with 9 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
import functools
|
import functools
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy.schema import Column, ForeignKey
|
from sqlalchemy.schema import Column, ForeignKey
|
||||||
|
@ -80,8 +80,8 @@ class ScheduledSubmissionTask(RepeatableTask):
|
||||||
# HTML template for previewing a submitted task
|
# HTML template for previewing a submitted task
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state_user_deleted_utc(self) -> int:
|
def state_user_deleted_utc(self) -> datetime | None:
|
||||||
return self.task.enabled and 1 or None
|
return datetime.now(tz=timezone.utc) if not self.task.enabled else None
|
||||||
|
|
||||||
@functools.cached_property
|
@functools.cached_property
|
||||||
def title_html(self) -> str:
|
def title_html(self) -> str:
|
||||||
|
|
|
@ -7,6 +7,7 @@ from files.helpers.media import process_image
|
||||||
from files.helpers.wrappers import *
|
from files.helpers.wrappers import *
|
||||||
from files.routes.importstar import *
|
from files.routes.importstar import *
|
||||||
|
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
@app.get("/comment/<cid>")
|
@app.get("/comment/<cid>")
|
||||||
@app.get("/post/<pid>/<anything>/<cid>")
|
@app.get("/post/<pid>/<anything>/<cid>")
|
||||||
|
@ -334,7 +335,7 @@ def delete_comment(cid, v):
|
||||||
c = get_comment(cid, v=v)
|
c = get_comment(cid, v=v)
|
||||||
if c.state_user_deleted_utc: abort(409)
|
if c.state_user_deleted_utc: abort(409)
|
||||||
if c.author_id != v.id: abort(403)
|
if c.author_id != v.id: abort(403)
|
||||||
c.state_user_deleted_utc = time.time()
|
c.state_user_deleted_utc = datetime.now(tz=timezone.utc)
|
||||||
# TODO: update stateful counters
|
# TODO: update stateful counters
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
|
@ -4,6 +4,8 @@ import urllib.parse
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from urllib.parse import ParseResult, urlparse
|
from urllib.parse import ParseResult, urlparse
|
||||||
|
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
import gevent
|
import gevent
|
||||||
import requests
|
import requests
|
||||||
import werkzeug.wrappers
|
import werkzeug.wrappers
|
||||||
|
@ -603,7 +605,7 @@ def delete_post_pid(pid, v):
|
||||||
if post.author_id != v.id:
|
if post.author_id != v.id:
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
post.state_user_deleted_utc = datetime.now()
|
post.state_user_deleted_utc = datetime.now(tz=timezone.utc)
|
||||||
post.is_pinned = False
|
post.is_pinned = False
|
||||||
post.stickied = None
|
post.stickied = None
|
||||||
|
|
||||||
|
|
|
@ -512,7 +512,7 @@
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% elif not p.replies and p.state_user_deleted_utc == None %}
|
{% elif not p.replies and p.state_user_deleted_utc is none %}
|
||||||
<div class="comment-section text-center py-7" id="replies-of-{{p.id}}">
|
<div class="comment-section text-center py-7" id="replies-of-{{p.id}}">
|
||||||
<div class="row no-gutters" id="placeholder-comment">
|
<div class="row no-gutters" id="placeholder-comment">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue