mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
[feature] admin can delete an user
This commit is contained in:
parent
35fb991cdb
commit
f94d8feba6
@ -1,5 +1,6 @@
|
||||
# Changelog Fab Manager
|
||||
|
||||
- An administrator can delete a member
|
||||
- Improved user experience in defining slots in the calendar management
|
||||
- Improved notification email to the member when a rolling subscription is taken
|
||||
- Handle Ctrl^C in upgrade scripts
|
||||
|
@ -182,6 +182,35 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Ask for confirmation then delete the specified user
|
||||
* @param memberId {number} identifier of the user to delete
|
||||
*/
|
||||
$scope.deleteMember = function(memberId) {
|
||||
dialogs.confirm(
|
||||
{
|
||||
resolve: {
|
||||
object () {
|
||||
return {
|
||||
title: _t('confirmation_required'),
|
||||
msg: $sce.trustAsHtml(_t('confirm_delete_member') + '<br/><br/>' + _t('this_may_take_a_while_please_wait'))
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
function () { // cancel confirmed
|
||||
Member.delete(
|
||||
{ id: memberId },
|
||||
function () {
|
||||
$scope.members.splice(findItemIdxById($scope.members, memberId), 1);
|
||||
return growl.success(_t('member_successfully_deleted'));
|
||||
},
|
||||
function (error) { growl.error(_t('unable_to_delete_the_member')); }
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask for confirmation then delete the specified administrator
|
||||
* @param admins {Array} full list of administrators
|
||||
@ -203,7 +232,7 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
|
||||
Admin.delete(
|
||||
{ id: admin.id },
|
||||
function () {
|
||||
admins.splice(findAdminIdxById(admins, admin.id), 1);
|
||||
admins.splice(findItemIdxById(admins, admin.id), 1);
|
||||
return growl.success(_t('administrator_successfully_deleted'));
|
||||
},
|
||||
function (error) { growl.error(_t('unable_to_delete_the_administrator')); }
|
||||
@ -261,13 +290,13 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
|
||||
var searchTimeout = null;
|
||||
|
||||
/**
|
||||
* Iterate through the provided array and return the index of the requested admin
|
||||
* @param admins {Array} full list of users with role 'admin'
|
||||
* @param id {Number} user id of the admin to retrieve in the list
|
||||
* @returns {Number} index of the requested admin, in the provided array
|
||||
* Iterate through the provided array and return the index of the requested item
|
||||
* @param items {Array} full list of users with role 'admin'
|
||||
* @param id {Number} id of the item to retrieve in the list
|
||||
* @returns {Number} index of the requested item, in the provided array
|
||||
*/
|
||||
var findAdminIdxById = function (admins, id) {
|
||||
return (admins.map(function (admin) { return admin.id; })).indexOf(id);
|
||||
var findItemIdxById = function (items, id) {
|
||||
return (items.map(function (item) { return item.id; })).indexOf(id);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,10 @@
|
||||
<td>
|
||||
<div class="buttons">
|
||||
<button class="btn btn-default" ui-sref="app.admin.members_edit({id: m.id})">
|
||||
<i class="fa fa-edit"></i> {{ 'edit' | translate }}
|
||||
<i class="fa fa-edit"></i>
|
||||
</button>
|
||||
<button class="btn btn-danger" ng-click="deleteMember(m.id)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
<span class="label label-danger text-white" ng-show="m.need_completion" translate>{{ 'incomplete_profile' }}</span>
|
||||
</div>
|
||||
|
@ -66,7 +66,7 @@ class API::MembersController < API::ApiController
|
||||
def destroy
|
||||
authorize @member
|
||||
@member.destroy
|
||||
sign_out(@member)
|
||||
sign_out(@member) if @member.id == current_user.id
|
||||
head :no_content
|
||||
end
|
||||
|
||||
|
@ -16,15 +16,15 @@ class UserPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def show?
|
||||
user.admin? or (record.is_allow_contact and record.member?) or (user.id == record.id)
|
||||
user.admin? || (record.is_allow_contact && record.member?) || (user.id == record.id)
|
||||
end
|
||||
|
||||
def update?
|
||||
user.admin? or (user.id == record.id)
|
||||
user.admin? || (user.id == record.id)
|
||||
end
|
||||
|
||||
def destroy?
|
||||
user.id == record.id
|
||||
user.admin? || (user.id == record.id)
|
||||
end
|
||||
|
||||
def merge?
|
||||
|
@ -521,6 +521,9 @@ en:
|
||||
add_a_new_administrator: "Add a new administrator"
|
||||
groups: "Groups"
|
||||
authentication: "Authentication"
|
||||
confirm_delete_member: "Do you really want to delete this member? This cannot be undone."
|
||||
member_successfully_deleted: "Member successfully deleted."
|
||||
unable_to_delete_the_member: "Unable to delete the member."
|
||||
do_you_really_want_to_delete_this_administrator_this_cannot_be_undone: "Do you really want to delete this administrator? This cannot be undone."
|
||||
this_may_take_a_while_please_wait: "Warning: this may take a while, please be patient."
|
||||
administrator_successfully_deleted: "Administrator successfully deleted."
|
||||
|
@ -521,6 +521,9 @@ es:
|
||||
add_a_new_administrator: "Agregar un nuevo administrador"
|
||||
groups: "Grupos"
|
||||
authentication: "Autenticación"
|
||||
confirm_delete_member: "¿Desea realmente eliminar este usario? Esto no se puede deshacer."
|
||||
member_successfully_deleted: "Usario eliminado correctamente."
|
||||
unable_to_delete_the_member: "No se puede eliminar el usario."
|
||||
do_you_really_want_to_delete_this_administrator_this_cannot_be_undone: "¿Desea realmente eliminar este administrador? Esto no se puede deshacer."
|
||||
this_may_take_a_while_please_wait: "Advertencia: esto puede tomar un tiempo, por favor, tenga paciencia."
|
||||
administrator_successfully_deleted: "Administrador eliminado correctamente."
|
||||
|
@ -522,6 +522,9 @@ fr:
|
||||
add_a_new_administrator: "Ajouter un nouvel administrateur"
|
||||
groups: "Groupes"
|
||||
authentication: "Authentification"
|
||||
confirm_delete_member: "Êtes-vous sûr de vouloir supprimer ce membre ? Cette opération est irréversible."
|
||||
member_successfully_deleted: "Le membre a bien été supprimé."
|
||||
unable_to_delete_the_member: "Le membre n'a pas pu être supprimé."
|
||||
do_you_really_want_to_delete_this_administrator_this_cannot_be_undone: "Êtes-vous sûr de vouloir supprimer cet administrateur ? Cette opération est irréversible."
|
||||
this_may_take_a_while_please_wait: "Attention : ceci peut prendre un certain temps, merci de patienter."
|
||||
administrator_successfully_deleted: "L'administrateur a bien été supprimé."
|
||||
|
@ -521,6 +521,9 @@ pt:
|
||||
add_a_new_administrator: "Adicionar novo administrador"
|
||||
groups: "Grupos"
|
||||
authentication: "Autenticação"
|
||||
confirm_delete_member: "Você realmente deseja excluir este usuário? Isso não pode ser revertido."
|
||||
member_successfully_deleted: "Usuário excluído com sucesso."
|
||||
unable_to_delete_the_member: "Impossível excluir membro."
|
||||
do_you_really_want_to_delete_this_administrator_this_cannot_be_undone: "Você realmente deseja excluir este administrador? Isso não pode ser revertido."
|
||||
this_may_take_a_while_please_wait: "Atenção: Isso pode demorar um pouco, por favor, seja paciente."
|
||||
administrator_successfully_deleted: "Administrator excluído com sucesso."
|
||||
|
Loading…
x
Reference in New Issue
Block a user