mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-13 07:29:39 +00:00
Add object and object_ref properties
This commit is contained in:
parent
e4a5e10d02
commit
aeec154a3d
@ -16,12 +16,15 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from werkzeug.datastructures import ImmutableDict
|
||||
|
||||
from indico.core.db.sqlalchemy import db, UTCDateTime
|
||||
from indico.util.date_time import now_utc
|
||||
from indico.util.string import return_ascii
|
||||
from indico.util.struct.enum import IndicoEnum
|
||||
|
||||
from indico_livesync.models.agents import LiveSyncAgent
|
||||
from indico_livesync.util import obj_deref
|
||||
|
||||
|
||||
class ChangeType(int, IndicoEnum):
|
||||
@ -101,6 +104,17 @@ class LiveSyncQueueEntry(db.Model):
|
||||
backref=db.backref('queue', cascade='all, delete-orphan', lazy='dynamic')
|
||||
)
|
||||
|
||||
@property
|
||||
def object(self):
|
||||
"""Returns the changed object"""
|
||||
return obj_deref(self.object_ref)
|
||||
|
||||
@property
|
||||
def object_ref(self):
|
||||
"""Returns the reference of the changed object"""
|
||||
return ImmutableDict(type=self.type, category_id=self.category_id, event_id=self.event_id,
|
||||
contrib_id=self.contrib_id, subcontrib_id=self.subcontrib_id)
|
||||
|
||||
@return_ascii
|
||||
def __repr__(self):
|
||||
return '<LiveSyncQueueEntry({}, {}, {}, {})>'.format(self.agent, self.id, ChangeType(self.change).name,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user