poulpe/shared/static/js/api-models.js

37 lines
846 B
JavaScript
Raw Normal View History

2018-11-21 19:46:41 +01:00
/* Backbone models for the API */
"use strict";
var GE_API = new Object();
GE_API.rootUrl = "/api/";
GE_API.Event = Backbone.Model.extend({
rootUrl: GE_API.rootUrl + "event/",
});
GE_API.Events = Backbone.Collection.extend({
model: GE_API.Event,
url: GE_API.rootUrl + "event/"
});
GE_API.Place = Backbone.Model.extend({
rootUrl: function() {
if (this.get("event")) {
return GE_API.rootUrl + "event/" + this.get("event").id + "/place/";
} else {
return GE_API.rootUrl + "place/";
}
}
});
GE_API.Places = Backbone.Collection.extend({
url: function() {
if (this.event) {
return GE_API.rootUrl + "event/" + this.event + "/place/";
} else {
return GE_API.rootUrl + "place/";
}
}
});
GE_API.Places = Backbone.Collection.