2013-02-22 15:41:12 -05:00
|
|
|
/**
|
|
|
|
Our data model for determining whether there's a new version of Discourse
|
2013-02-20 13:15:50 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
@class VersionCheck
|
|
|
|
@extends Discourse.Model
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.VersionCheck = Discourse.Model.extend({
|
|
|
|
upToDate: function() {
|
2013-03-05 18:14:51 -05:00
|
|
|
return this.get('missing_versions_count') === 0;
|
|
|
|
}.property('missing_versions_count'),
|
|
|
|
|
|
|
|
behindByOneVersion: function() {
|
|
|
|
return this.get('missing_versions_count') === 1;
|
|
|
|
}.property('missing_versions_count'),
|
2013-02-21 14:09:28 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
gitLink: function() {
|
|
|
|
return "https://github.com/discourse/discourse/tree/" + this.get('installed_sha');
|
|
|
|
}.property('installed_sha'),
|
2013-02-21 15:03:43 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
shortSha: function() {
|
|
|
|
return this.get('installed_sha').substr(0,10);
|
|
|
|
}.property('installed_sha')
|
|
|
|
});
|
2013-02-21 15:03:43 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
Discourse.VersionCheck.reopenClass({
|
|
|
|
find: function() {
|
|
|
|
var promise = new RSVP.Promise();
|
2013-03-05 15:39:21 -05:00
|
|
|
$.ajax({
|
2013-02-22 15:41:12 -05:00
|
|
|
url: '/admin/version_check',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(json) {
|
|
|
|
promise.resolve(Discourse.VersionCheck.create(json));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return promise;
|
|
|
|
}
|
|
|
|
});
|