From b9e755f1422e2d0859e6b667d66064be96f845b0 Mon Sep 17 00:00:00 2001 From: Matt Enlow Date: Fri, 18 Jul 2014 17:52:56 -0600 Subject: [PATCH] Add relationships to client models No issue - Removed tabs from tag.js (why didn't jshint catch this?) - Removed superfluous `activate` in SettingsIndexRoute - updated `UserModel` and `TagModel` to have `created_by, updated_by` be references to `user` objects. - updated `UserModel` to use `moment-date` instead of `date` --- ghost/admin/models/tag.js | 24 ++++++++++++------------ ghost/admin/models/user.js | 4 ++-- ghost/admin/routes/settings/index.js | 3 --- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/ghost/admin/models/tag.js b/ghost/admin/models/tag.js index 182c1c7a44..e9d1b22a35 100644 --- a/ghost/admin/models/tag.js +++ b/ghost/admin/models/tag.js @@ -1,15 +1,15 @@ var Tag = DS.Model.extend({ - uuid: DS.attr('string'), - name: DS.attr('string'), - slug: DS.attr('string'), - description: DS.attr('string'), - parent_id: DS.attr('number'), - meta_title: DS.attr('string'), - meta_description: DS.attr('string'), - created_at: DS.attr('date'), - created_by: DS.attr('number'), - updated_at: DS.attr('date'), - updated_by: DS.attr('number') + uuid: DS.attr('string'), + name: DS.attr('string'), + slug: DS.attr('string'), + description: DS.attr('string'), + parent_id: DS.attr('number'), + meta_title: DS.attr('string'), + meta_description: DS.attr('string'), + created_at: DS.attr('moment-date'), + created_by: DS.belongsTo('user', {async: true}), + updated_at: DS.attr('moment-date'), + updated_by: DS.belongsTo('user', {async: true}) }); -export default Tag; +export default Tag; \ No newline at end of file diff --git a/ghost/admin/models/user.js b/ghost/admin/models/user.js index 86cf4a188a..da08ab47dd 100644 --- a/ghost/admin/models/user.js +++ b/ghost/admin/models/user.js @@ -20,9 +20,9 @@ var User = DS.Model.extend(NProgressSaveMixin, ValidationEngine, { meta_description: DS.attr('string'), last_login: DS.attr('moment-date'), created_at: DS.attr('moment-date'), - created_by: DS.attr('number'), + created_by: DS.belongsTo('user', { async: true }), updated_at: DS.attr('moment-date'), - updated_by: DS.attr('number'), + updated_by: DS.belongsTo('user', { async: true }), saveNewPassword: function () { var url = this.get('ghostPaths.url').api('users', 'password'); diff --git a/ghost/admin/routes/settings/index.js b/ghost/admin/routes/settings/index.js index 6ad9a0f136..3c90352756 100644 --- a/ghost/admin/routes/settings/index.js +++ b/ghost/admin/routes/settings/index.js @@ -1,9 +1,6 @@ import {mobileQuery} from 'ghost/utils/mobile'; var SettingsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, { - activate: function () { - this._super(); - }, // redirect to general tab, unless on a mobile phone beforeModel: function () { if (!mobileQuery.matches) {