Adding compatibility stuff for themes
During our migration to federation some interfaces were changed. We should not have done that so fast. Provide a compatibility layer so that old themes work
This commit is contained in:
parent
06d70c4b96
commit
65805ffb0d
@ -586,6 +586,16 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin):
|
|||||||
## TODO
|
## TODO
|
||||||
# fail_error
|
# fail_error
|
||||||
|
|
||||||
|
@property
|
||||||
|
def get_uploader(self):
|
||||||
|
# for compatibility
|
||||||
|
return self.get_actor
|
||||||
|
|
||||||
|
@property
|
||||||
|
def uploader(self):
|
||||||
|
# for compatibility
|
||||||
|
return self.actor
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def collections(self):
|
def collections(self):
|
||||||
""" Get any collections that this MediaEntry is in """
|
""" Get any collections that this MediaEntry is in """
|
||||||
@ -608,9 +618,9 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin):
|
|||||||
query = query.order_by(Comment.added.asc())
|
query = query.order_by(Comment.added.asc())
|
||||||
else:
|
else:
|
||||||
query = query.order_by(Comment.added.desc())
|
query = query.order_by(Comment.added.desc())
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def url_to_prev(self, urlgen):
|
def url_to_prev(self, urlgen):
|
||||||
"""get the next 'newer' entry by this user"""
|
"""get the next 'newer' entry by this user"""
|
||||||
media = MediaEntry.query.filter(
|
media = MediaEntry.query.filter(
|
||||||
@ -941,7 +951,7 @@ class MediaTag(Base):
|
|||||||
class Comment(Base):
|
class Comment(Base):
|
||||||
"""
|
"""
|
||||||
Link table between a response and another object that can have replies.
|
Link table between a response and another object that can have replies.
|
||||||
|
|
||||||
This acts as a link table between an object and the comments on it, it's
|
This acts as a link table between an object and the comments on it, it's
|
||||||
done like this so that you can look up all the comments without knowing
|
done like this so that you can look up all the comments without knowing
|
||||||
whhich comments are on an object before hand. Any object can be a comment
|
whhich comments are on an object before hand. Any object can be a comment
|
||||||
@ -952,7 +962,7 @@ class Comment(Base):
|
|||||||
__tablename__ = "core__comment_links"
|
__tablename__ = "core__comment_links"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
|
|
||||||
# The GMR to the object the comment is on.
|
# The GMR to the object the comment is on.
|
||||||
target_id = Column(
|
target_id = Column(
|
||||||
Integer,
|
Integer,
|
||||||
@ -981,7 +991,18 @@ class Comment(Base):
|
|||||||
|
|
||||||
# When it was added
|
# When it was added
|
||||||
added = Column(DateTime, nullable=False, default=datetime.datetime.utcnow)
|
added = Column(DateTime, nullable=False, default=datetime.datetime.utcnow)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def get_author(self):
|
||||||
|
# for compatibility
|
||||||
|
return self.comment().get_actor # noqa
|
||||||
|
|
||||||
|
def __getattr__(self, attr):
|
||||||
|
try:
|
||||||
|
return getattr(self.comment(), attr) # noqa
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
raise
|
||||||
|
|
||||||
class TextComment(Base, TextCommentMixin, CommentingMixin):
|
class TextComment(Base, TextCommentMixin, CommentingMixin):
|
||||||
"""
|
"""
|
||||||
@ -1015,7 +1036,7 @@ class TextComment(Base, TextCommentMixin, CommentingMixin):
|
|||||||
if target is None:
|
if target is None:
|
||||||
target = {}
|
target = {}
|
||||||
else:
|
else:
|
||||||
target = target.serialize(request, show_comments=False)
|
target = target.serialize(request, show_comments=False)
|
||||||
|
|
||||||
|
|
||||||
author = self.get_actor
|
author = self.get_actor
|
||||||
@ -1043,7 +1064,7 @@ class TextComment(Base, TextCommentMixin, CommentingMixin):
|
|||||||
if "location" in data:
|
if "location" in data:
|
||||||
Location.create(data["location"], self)
|
Location.create(data["location"], self)
|
||||||
|
|
||||||
|
|
||||||
# Handle changing the reply ID
|
# Handle changing the reply ID
|
||||||
if "inReplyTo" in data:
|
if "inReplyTo" in data:
|
||||||
# Validate that the ID is correct
|
# Validate that the ID is correct
|
||||||
@ -1074,7 +1095,7 @@ class TextComment(Base, TextCommentMixin, CommentingMixin):
|
|||||||
link.target = media
|
link.target = media
|
||||||
link.comment = self
|
link.comment = self
|
||||||
link.save()
|
link.save()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class Collection(Base, CollectionMixin, CommentingMixin):
|
class Collection(Base, CollectionMixin, CommentingMixin):
|
||||||
@ -1273,7 +1294,7 @@ class Notification(Base):
|
|||||||
seen = Column(Boolean, default=lambda: False, index=True)
|
seen = Column(Boolean, default=lambda: False, index=True)
|
||||||
user = relationship(
|
user = relationship(
|
||||||
User,
|
User,
|
||||||
backref=backref('notifications', cascade='all, delete-orphan'))
|
backref=backref('notifications', cascade='all, delete-orphan'))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<{klass} #{id}: {user}: {subject} ({seen})>'.format(
|
return '<{klass} #{id}: {user}: {subject} ({seen})>'.format(
|
||||||
@ -1318,7 +1339,7 @@ class Report(Base):
|
|||||||
which points to the reported object.
|
which points to the reported object.
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'core__reports'
|
__tablename__ = 'core__reports'
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
reporter_id = Column(Integer, ForeignKey(User.id), nullable=False)
|
reporter_id = Column(Integer, ForeignKey(User.id), nullable=False)
|
||||||
reporter = relationship(
|
reporter = relationship(
|
||||||
@ -1346,7 +1367,7 @@ class Report(Base):
|
|||||||
|
|
||||||
resolved = Column(DateTime)
|
resolved = Column(DateTime)
|
||||||
result = Column(UnicodeText)
|
result = Column(UnicodeText)
|
||||||
|
|
||||||
object_id = Column(Integer, ForeignKey(GenericModelReference.id), nullable=True)
|
object_id = Column(Integer, ForeignKey(GenericModelReference.id), nullable=True)
|
||||||
object_helper = relationship(GenericModelReference)
|
object_helper = relationship(GenericModelReference)
|
||||||
obj = association_proxy("object_helper", "get_object",
|
obj = association_proxy("object_helper", "get_object",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user