editing: fix can_edit function and add type hints
parent
e978cbf16c
commit
444c7157d3
|
@ -1,12 +1,12 @@
|
|||
import random
|
||||
from operator import *
|
||||
from typing import Union
|
||||
from typing import Any, Union
|
||||
|
||||
import pyotp
|
||||
from sqlalchemy import Column, ForeignKey
|
||||
from sqlalchemy.orm import aliased, deferred
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.sql.expression import not_, and_, or_
|
||||
from sqlalchemy.sql.expression import not_, and_, or_, ColumnOperators
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
|
@ -415,9 +415,9 @@ class User(Base):
|
|||
return self.offsitementions or self.admin_level >= PERMS['NOTIFICATIONS_REDDIT']
|
||||
|
||||
@lazy
|
||||
def can_edit(self, target):
|
||||
def can_edit(self, target:Union[Submission, Comment]) -> Union[bool, ColumnOperators[Any]]:
|
||||
if isinstance(target, Comment) and not target.post: return False
|
||||
if self.id == target.id: return True
|
||||
if self.id == target.author_id: return True
|
||||
if not isinstance(target, Submission): return False
|
||||
return self.admin_level >= PERMS['POST_EDITING']
|
||||
|
||||
|
|
Loading…
Reference in New Issue