Skip to content

Commit

Permalink
PHRAS-4062: admin users delete and request improvement (#4509)
Browse files Browse the repository at this point in the history
PHRAS-4062 clean registration when user delete

PHRAS-4062 delete user's access requests

PHRAS-4062 generate translation
  • Loading branch information
aynsix authored Jun 11, 2024
1 parent b878685 commit 99de0c0
Show file tree
Hide file tree
Showing 12 changed files with 332 additions and 248 deletions.
24 changes: 24 additions & 0 deletions lib/Alchemy/Phrasea/Controller/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,30 @@ public function displayRegistrationsAction()
]);
}

public function deleteUserRegistrationAction(Request $request)
{
/** @var EntityManager $manager */
$manager = $this->app['orm.em'];
/** @var RegistrationRepository $registrationRepository */
$registrationRepository = $this->app['repo.registrations'];

/** @var UserRepository $userRepository */
$userRepository = $this->app['repo.users'];
$registrations = $registrationRepository->findBy(['user' => $userRepository->find($request->request->get('userId'))]);

if (empty($registrations)) {
return $this->app->json(['success' => false, 'message' => 'registration not found']);
}

foreach ($registrations as $registration) {
$manager->remove($registration);
}

$manager->flush();

return $this->app->json(['success' => true]);
}

public function displayAuthFailureAction(Request $request)
{
return $this->render('admin/auth-failure.html.twig', [
Expand Down
2 changes: 2 additions & 0 deletions lib/Alchemy/Phrasea/ControllerProvider/Admin/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function connect(Application $app)
->bind('users_display_registrations');
$controllers->post('/registrations/', 'controller.admin.users:submitRegistrationAction')
->bind('users_submit_registrations');
$controllers->post('/registrations/delete/', 'controller.admin.users:deleteUserRegistrationAction')
->bind('delete_user_registrations');
$controllers->get('/import/file/', 'controller.admin.users:displayImportFileAction')
->bind('users_display_import_file');
$controllers->post('/import/file/', 'controller.admin.users:submitImportFileAction')
Expand Down
10 changes: 10 additions & 0 deletions lib/Alchemy/Phrasea/Model/Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ private function cleanProperties(User $user)
$this->cleanOauthApplication($user);
$this->cleanLazarets($user);
$this->cleanUsrList($user);
$this->cleanRegistration($user);
}

private function cleanLazarets(User $user)
Expand Down Expand Up @@ -295,6 +296,15 @@ private function cleanRights(User $user)
$stmt->closeCursor();
}
}

private function cleanRegistration(User $user)
{
$registrations = $this->objectManager->getRepository('Phraseanet:Registration')->findBy(['user' => $user]);
foreach ($registrations as $registration) {
$this->objectManager->remove($registration);
}
}

private function cleanOauthApplication(User $user)
{
$accounts = $this->objectManager->getRepository('Phraseanet:ApiAccount')->findByUser($user);
Expand Down
131 changes: 68 additions & 63 deletions resources/locales/messages.de.xlf

Large diffs are not rendered by default.

131 changes: 68 additions & 63 deletions resources/locales/messages.en.xlf

Large diffs are not rendered by default.

131 changes: 68 additions & 63 deletions resources/locales/messages.fr.xlf

Large diffs are not rendered by default.

115 changes: 60 additions & 55 deletions resources/locales/messages.nl.xlf

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/locales/validators.de.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2024-06-05T12:43:29Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<file date="2024-06-07T03:59:03Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.en.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2024-06-05T12:43:51Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<file date="2024-06-07T03:59:21Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.fr.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2024-06-05T12:44:17Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<file date="2024-06-07T03:59:42Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.nl.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2024-06-05T12:44:47Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<file date="2024-06-07T04:00:05Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
Expand Down
28 changes: 28 additions & 0 deletions templates/web/admin/user/registrations.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,31 @@
$form.submit();
});
$("#registrations").on('click', '.cancel-user-request', function() {
if(confirm('Do you want to delete this user request ?')) {
$.ajax({
type: "POST",
url: "/admin/users/registrations/delete/",
data: {
userId : $(this).attr('data-user-id'),
},
success: function (data) {
if (data.success == true) {
$.ajax({
type: "GET",
url: "/admin/users/registrations/",
success: function (data) {
}
});
}
}
});
} else {
return false;
}
});
});
</script>

Expand Down Expand Up @@ -263,6 +288,9 @@
{% endfor %}
</select>
</td>
<td>
<button data-user-id="{{ user.getId() }}" class="btn btn-danger cancel-user-request">{{ 'admin:: cancel user request' | trans }}</button>
</td>
</tr>
</table>
</div>
Expand Down

0 comments on commit 99de0c0

Please sign in to comment.