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