2014-03-05 12:55:47 -05:00
|
|
|
define [
|
2014-03-07 06:24:11 -05:00
|
|
|
"models/User"
|
2014-03-05 12:55:47 -05:00
|
|
|
"libs/backbone"
|
2014-03-07 06:24:11 -05:00
|
|
|
], (User)->
|
2014-03-05 12:55:47 -05:00
|
|
|
Change = Backbone.Model.extend
|
|
|
|
parse: (change) ->
|
2014-03-11 08:13:46 -04:00
|
|
|
model = {
|
2014-03-05 12:55:47 -05:00
|
|
|
start_ts: change.meta.start_ts
|
|
|
|
end_ts: change.meta.end_ts
|
2014-03-11 14:01:14 -04:00
|
|
|
fromVersion: change.fromV
|
|
|
|
toVersion: change.toV
|
2014-03-11 08:13:46 -04:00
|
|
|
}
|
2014-03-11 14:01:14 -04:00
|
|
|
model.users = []
|
|
|
|
for user in change.meta.users or []
|
|
|
|
model.users.push User.findOrBuild(user.id, user)
|
|
|
|
if model.users.length == 0
|
|
|
|
model.users.push User.getAnonymousUser()
|
2014-03-11 08:13:46 -04:00
|
|
|
return model
|