1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

privacy policy: fixed admin view after update + display last update date

This commit is contained in:
Sylvain 2019-04-23 12:58:01 +02:00
parent d0f0a293f3
commit c0c9b2a980
9 changed files with 28 additions and 6 deletions

View File

@ -12,8 +12,8 @@
*/
'use strict';
Application.Controllers.controller('SettingsController', ['$scope', '$uibModal', 'Setting', 'growl', 'settingsPromise', 'privacyDraftsPromise', 'cgvFile', 'cguFile', 'logoFile', 'logoBlackFile', 'faviconFile', 'profileImageFile', 'CSRF', '_t',
function ($scope, $uibModal, Setting, growl, settingsPromise, privacyDraftsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t) {
Application.Controllers.controller('SettingsController', ['$scope', '$filter', '$uibModal', 'Setting', 'growl', 'settingsPromise', 'privacyDraftsPromise', 'cgvFile', 'cguFile', 'logoFile', 'logoBlackFile', 'faviconFile', 'profileImageFile', 'CSRF', '_t',
function ($scope, $filter, $uibModal, Setting, growl, settingsPromise, privacyDraftsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t) {
/* PUBLIC SCOPE */
// timepickers steps configuration
@ -191,11 +191,16 @@ Application.Controllers.controller('SettingsController', ['$scope', '$uibModal',
// reset history
$scope.privacyDraftsHistory = [];
data.setting.history.forEach(function (draft) {
$scope.privacyDraftsHistory.push({ id: draft.id, name: _t('settings.privacy.draft_from_USER_DATE', { USER: draft.user, DATE: draft.created_at }), content: draft.value });
$scope.privacyDraftsHistory.push({ id: draft.id, name: _t('settings.privacy.draft_from_USER_DATE', { USER: draft.user.name, DATE: draft.created_at }), content: draft.value });
});
if (type === 'privacy_draft') {
// FIXME
$scope.privacyPolicy.version = data.setting.history[data.setting.history.length - 1].id;
const orderedHistory = $filter('orderBy')(data.setting.history, 'created_at');
const last = orderedHistory[orderedHistory.length - 1];
if (last) {
$scope.privacyPolicy.version = last.id;
}
} else {
$scope.privacyPolicy.version = null;
}
})
});

View File

@ -420,6 +420,10 @@
}
.last-update {
text-align: right;
margin-bottom: 2em;
}
}

View File

@ -9,6 +9,10 @@
<div class="row padder">
<div class="col-sm-offset-1 col-md-offset-3 col-sm-7 col-md-5 col-lg-4 m-b-lg">
<div class="last-update text-gray">
<span translate>{{ 'privacy.last_update' }}</span>
<span>{{ privacyBody.last_update | amDateFormat:'LL' }}</span>
</div>
<span ng-bind-html="privacyBody.value"></span>
</div>

View File

@ -53,6 +53,11 @@ class Setting < ActiveRecord::Base
last_value&.value
end
def last_update
last_value = history_values.order(HistoryValue.arel_table['created_at'].desc).first
last_value&.created_at
end
def value=(val)
admin = User.admins.first
save && history_values.create(user: admin, value: val)

View File

@ -1 +1 @@
json.extract! setting, :name, :value
json.extract! setting, :name, :value, :last_update

View File

@ -123,6 +123,7 @@ en:
privacy:
title: "Privacy policy"
dpo: "Data protection officer"
last_update: "Last update,"
home:
# home page

View File

@ -122,6 +122,7 @@ es:
privacy:
title: "Política de privacidad"
dpo: "Oficial de protección de datos"
last_update: "Última actualización,"
home:
# home page

View File

@ -123,6 +123,7 @@ fr:
privacy:
title: "Politique de confidentialité"
dpo: "Délégué à la protection des données"
last_update: "Dernière mise à jour,"
home:
# page d'accueil

View File

@ -123,6 +123,7 @@ pt:
privacy:
title: "Política de privacidade"
dpo: "Oficial de proteção de dados"
last_update: "Última atualização,"
home:
# home page