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
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
{ | |
"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
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
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 app = new UserApp(); | |
app.id = id; | |
app.save({'name': name}, { | |
success: function() { | |
console.log('Changed name of app'); | |
}, | |
error: function() { | |
console.log('Unable to change name of app'); | |
} | |
}); |
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 a = new UserApp(); | |
a.id = id; | |
a.fetch({ | |
success: function(r) { | |
var name = r.get('name'); | |
console.log('Loaded app:', name); | |
}, | |
error: function(r) { | |
console.log('Unable to load app'); | |
} |
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 UserApp = Backbone.Model.extend({ | |
urlRoot: '/api/v1/user/app' | |
}); |