This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var UserAppVersions = Backbone.Collection.extend({ | |
model: UserAppVersion, | |
url: function() { | |
return '/api/v1/user/app/' + this.id + '/versions'; | |
}, | |
parse: function(response) { | |
return response.versions; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var versions = new UserAppVersions(); | |
versions.id = appId; | |
versions.fetch({ | |
error: function() { | |
console.log('Unable to load user app versions'); | |
}, | |
success: function(versions) { | |
console.log('Versions', versions); | |
// iterate over them with the each function, or with a for loop over version.models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"versions":[ | |
{ | |
"created_at":"" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _v1_user_app(request, appid): | |
# check authentication | |
if request.method == "POST": | |
try: | |
app_parsed = json.loads(request.raw_post_data) | |
# app_parsed is now a dictionary or hash object | |
# ... | |
return HttpResponse() # OK! | |
except: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _v1_user_app(request, appid): | |
# check authentication | |
if request.method == "POST": | |
try: | |
app_parsed = json.loads(request.raw_post_data) | |
# app_parsed is now a dictionary or hash object | |
# ... | |
return HttpResponse() # OK! | |
except: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var versions = new UserAppVersions(); | |
versions.id = appId; | |
versions.fetch({ | |
error: function() { | |
console.log('Unable to load user app versions'); | |
}, | |
success: function(versions) { | |
console.log('Versions', versions); | |
// iterate over them with the each function, or with a for loop over version.models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialize: function() { | |
this._fdb = new Firebase('http://gamma.firebase.com/opencountmadison/'); | |
this._resources = this._fdb.child('resources'); | |
}, | |
// Add a new resource | |
_addResource: function(tag, name, max, count) { | |
var self = this, now = new Date(); | |
var resourceData = { | |
tag: tag, | |
name: name, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialize: function() { | |
this._fdb = new Firebase('http://gamma.firebase.com/opencountmadison/'); | |
this._resources = this._fdb.child('resources'); | |
}, | |
// Add a new resource | |
_addResource: function(tag, name, max, count) { | |
var self = this, now = new Date(); | |
var resourceData = { | |
tag: tag, | |
name: name, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bind Firebase data events | |
_bindDataEvents: function() { | |
var self = this; | |
this._resources.on('child_added', function(resourceSnapshot) { | |
$(document).trigger('resource.oneAdded', resourceSnapshot.val()); | |
}); | |
this._resources.on('child_changed', function(resourceSnapshot) { | |
var resource = resourceSnapshot.val(); |