add/remove item can not depend on timestamp

This commit is contained in:
j 2015-12-01 09:55:43 +01:00
parent fb95a1ec55
commit 49763389be
1 changed files with 9 additions and 10 deletions

View File

@ -128,12 +128,12 @@ class Changelog(db.Model):
def action_additem(self, user, timestamp, itemid, info):
from item.models import Item
i = Item.get(itemid)
if i and i.timestamp > timestamp:
if i:
if user not in i.users:
i.users.append(user)
i.update()
return True
if not i:
else:
i = Item.get_or_create(itemid, info)
i.modified = ts2datetime(timestamp)
if user not in i.users:
@ -173,14 +173,13 @@ class Changelog(db.Model):
def action_removeitem(self, user, timestamp, itemid):
from item.models import Item
i = Item.get(itemid)
if not i or i.timestamp > timestamp:
return True
if user in i.users:
i.users.remove(user)
if i.users:
i.update()
else:
i.delete()
if i:
if user in i.users:
i.users.remove(user)
if i.users:
i.update()
else:
i.delete()
return True
def action_addlist(self, user, timestamp, name, query=None):