record changes with old timestamp
This commit is contained in:
parent
9cf8417c30
commit
980e68ccc6
2 changed files with 20 additions and 2 deletions
|
@ -61,6 +61,22 @@ class Changelog(db.Model):
|
||||||
#if state.nodes:
|
#if state.nodes:
|
||||||
# state.nodes.queue('peered', 'pushChanges', [c.json()])
|
# state.nodes.queue('peered', 'pushChanges', [c.json()])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def record_ts(cls, user, ts, action, *args):
|
||||||
|
# fixme remove
|
||||||
|
c = cls()
|
||||||
|
c.created = datetime.utcnow()
|
||||||
|
c.timestamp = datetime2ts(ts)
|
||||||
|
c.user_id = user.id
|
||||||
|
c.revision = cls.query.filter_by(user_id=user.id).count()
|
||||||
|
c.data = json.dumps([action] + list(args), ensure_ascii=False)
|
||||||
|
_data = str(c.revision) + str(c.timestamp) + c.data
|
||||||
|
_data = _data.encode()
|
||||||
|
state.db.session.add(c)
|
||||||
|
state.db.session.commit()
|
||||||
|
#if state.nodes:
|
||||||
|
# state.nodes.queue('peered', 'pushChanges', [c.json()])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def apply_changes(cls, user, changes):
|
def apply_changes(cls, user, changes):
|
||||||
trigger = changes
|
trigger = changes
|
||||||
|
@ -144,6 +160,8 @@ class Changelog(db.Model):
|
||||||
def action_edititem(self, user, timestamp, itemid, meta):
|
def action_edititem(self, user, timestamp, itemid, meta):
|
||||||
from item.models import Item
|
from item.models import Item
|
||||||
i = Item.get(itemid)
|
i = Item.get(itemid)
|
||||||
|
if itemid == 'RDWQN35QAY6VW2UQEINOTQXLUCOFKIZK':
|
||||||
|
return True
|
||||||
if not i:
|
if not i:
|
||||||
logger.debug('ignore edititem for unknown item %s %s', timestamp, itemid)
|
logger.debug('ignore edititem for unknown item %s %s', timestamp, itemid)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -285,7 +285,7 @@ class Item(db.Model):
|
||||||
self.save()
|
self.save()
|
||||||
user = state.user()
|
user = state.user()
|
||||||
if record and user in self.users:
|
if record and user in self.users:
|
||||||
Changelog.record(user, 'edititem', self.id, record)
|
Changelog.record_ts(user, 'edititem', modified, self.id, record)
|
||||||
|
|
||||||
def update_primaryid(self, key=None, id=None, scrape=True, modified=None):
|
def update_primaryid(self, key=None, id=None, scrape=True, modified=None):
|
||||||
if key is None and id is None:
|
if key is None and id is None:
|
||||||
|
@ -325,7 +325,7 @@ class Item(db.Model):
|
||||||
f.move()
|
f.move()
|
||||||
user = state.user()
|
user = state.user()
|
||||||
if user in self.users:
|
if user in self.users:
|
||||||
Changelog.record(user, 'edititem', self.id, record)
|
Changelog.record_ts(user, 'edititem', modified, self.id, record)
|
||||||
|
|
||||||
def edit_metadata(self, data):
|
def edit_metadata(self, data):
|
||||||
Scrape.query.filter_by(item_id=self.id).delete()
|
Scrape.query.filter_by(item_id=self.id).delete()
|
||||||
|
|
Loading…
Reference in a new issue