update lists on list change

This commit is contained in:
j 2016-01-13 21:46:31 +05:30
parent c66433c740
commit 54d6d43fab
2 changed files with 26 additions and 8 deletions

View File

@ -200,7 +200,7 @@ class Changelog(db.Model):
if name == '':
return True
l = List.create(user.id, name)
trigger_event('addlist', {'id': l.public_id})
trigger_event('addlist', {'id': l.public_id, 'user': user.id})
return True
def action_editlist(self, user, timestamp, name, new):
@ -209,7 +209,7 @@ class Changelog(db.Model):
if 'name' in new:
l.name = new['name']
l.save()
trigger_event('editlist', {'id': l.public_id})
trigger_event('editlist', {'id': l.public_id, 'user': user.id})
return True
def action_orderlists(self, user, timestamp, lists):
@ -220,7 +220,7 @@ class Changelog(db.Model):
l.index_ = idx
l.save()
idx += 1
trigger_event('orderlists', {})
trigger_event('orderlists', {'user': user.id})
return True
def action_removelist(self, user, timestamp, name):
@ -356,7 +356,7 @@ class Changelog(db.Model):
new_id = data[2]['name']
r = revision
if old_id not in changes.get('addlist', []):
action[old_id] = [revision, timestamp, new_id]
action[old_id] = [revision, timestamp, {'name': new_id}]
r += 1
for a in ('addlist', 'addlistitems', 'removelistitems'):
if a in changes and old_id in changes[a]:
@ -448,10 +448,10 @@ class Changelog(db.Model):
if orderlists:
ids = [l.name for l in List.query.filter_by(user_id=user_id,type='static').order_by('index_') if l.name]
if len(ids) > 1:
_changes.append([-1, timestamp, ['orderlists', ids]])
_changes.append([-1, timestamp, json.dumps(['orderlists', ids])])
if _changes:
r = revision - len(_changes) + 1
for c in _changes:
r = revision
for c in reversed(_changes):
c[0] = r
r += 1
r -= 1
return _changes

View File

@ -343,10 +343,28 @@ oml.ui.folders = function() {
that.updateItems();
}
},
addlist: function(data) {
var index = Ox.getIndexById(ui._users, data.user);
if (index > -1) {
that.updateUser(index);
}
},
change: function(data) {
Ox.print('got change event')
Ox.Request.clearCache();
},
editlist: function(data) {
var index = Ox.getIndexById(ui._users, data.user);
if (index > -1) {
that.updateUser(index);
}
},
orderlists: function(data) {
var index = Ox.getIndexById(ui._users, data.user);
if (index > -1) {
that.updateUser(index);
}
},
peering: function(data, event) {
Ox.Request.clearCache('getUsers');
if (Ox.contains(['peering.accept', 'peering.remove'], event)) {