Fixed members of Session for frontend usage
This commit is contained in:
parent
03aefbb35a
commit
7aba295e45
|
@ -22,11 +22,16 @@ class Session(db.Model, ModelSerializeMixin):
|
|||
lifetime: int = db.Column(db.Integer)
|
||||
browser: str = db.Column(db.String(30))
|
||||
platform: str = db.Column(db.String(30))
|
||||
userid: str = ""
|
||||
|
||||
_id = db.Column("id", db.Integer, primary_key=True)
|
||||
_user: User = db.relationship("User", back_populates="_sessions")
|
||||
_user_id = db.Column("user_id", db.Integer, db.ForeignKey("user.id"))
|
||||
|
||||
@property
|
||||
def userid(self):
|
||||
return self._user.userid
|
||||
|
||||
def refresh(self):
|
||||
"""Update the Timestamp
|
||||
|
||||
|
|
|
@ -469,7 +469,9 @@ def update_job_slot(event_id, slot_id, job_type, current_session: Session):
|
|||
try:
|
||||
user = userController.get_user(data["user"]["userid"])
|
||||
value = data["user"]["value"]
|
||||
if (user == current_session._user and not user.has_permission(permissions.ASSIGN)) or (user != current_session._user and not current_session._user.has_permission(permissions.ASSIGN_OTHER)):
|
||||
if (user == current_session._user and not user.has_permission(permissions.ASSIGN)) or (
|
||||
user != current_session._user and not current_session._user.has_permission(permissions.ASSIGN_OTHER)
|
||||
):
|
||||
raise Forbidden
|
||||
event_controller.assign_job(slot, user, value)
|
||||
except (KeyError, ValueError):
|
||||
|
|
|
@ -157,7 +157,9 @@ def remove_event_slot(event, slot_id):
|
|||
|
||||
|
||||
def get_job_slot(event_slot_id, job_type):
|
||||
jt = JobSlot.query.filter(JobSlot._type_id == job_type).filter(JobSlot._event_slot_id == event_slot_id).one_or_none()
|
||||
jt = (
|
||||
JobSlot.query.filter(JobSlot._type_id == job_type).filter(JobSlot._event_slot_id == event_slot_id).one_or_none()
|
||||
)
|
||||
if jt is None:
|
||||
raise NotFound
|
||||
return jt
|
||||
|
|
|
@ -57,7 +57,7 @@ class JobSlot(db.Model, ModelSerializeMixin):
|
|||
|
||||
event_slot_ = db.relationship("EventSlot", back_populates="jobs")
|
||||
|
||||
__table_args__ = (UniqueConstraint('type_id', 'event_slot_id', name='_type_event_slot_uc'),)
|
||||
__table_args__ = (UniqueConstraint("type_id", "event_slot_id", name="_type_event_slot_uc"),)
|
||||
|
||||
|
||||
##########
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import datetime
|
||||
from backports.datetime_fromisoformat import MonkeyPatch
|
||||
|
||||
MonkeyPatch.patch_fromisoformat()
|
||||
|
||||
|
||||
def from_iso_format(date_str):
|
||||
"""Z-suffix aware version of `datetime.datetime.fromisoformat`"""
|
||||
time = datetime.datetime.fromisoformat(date_str.replace('Z', '+00:00'))
|
||||
time = datetime.datetime.fromisoformat(date_str.replace("Z", "+00:00"))
|
||||
if time.tzinfo:
|
||||
return time.astimezone(datetime.timezone.utc)
|
||||
return time.replace(tzinfo=datetime.timezone.utc)
|
||||
|
|
Loading…
Reference in New Issue