From a68315ae8af243db1a9c44d09b7bb0667f8ce0a0 Mon Sep 17 00:00:00 2001 From: Stefano Alberto Russo <stefano.russo@gmail.com> Date: Tue, 9 Nov 2021 19:53:05 +0100 Subject: [PATCH] Improved storage sections (naming, ordering). --- services/webapp/code/rosetta/core_app/api.py | 11 ++++++++--- services/webapp/code/rosetta/core_app/models.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/services/webapp/code/rosetta/core_app/api.py b/services/webapp/code/rosetta/core_app/api.py index 300d2ee..8595597 100644 --- a/services/webapp/code/rosetta/core_app/api.py +++ b/services/webapp/code/rosetta/core_app/api.py @@ -440,10 +440,11 @@ class FileManagerAPI(PrivateGETAPI, PrivatePOSTAPI): # Get the storage based on the "root" folder name # TODO: this is extremely weak.. storage_id = path.split('/')[1] - storage_name = storage_id.split('@')[0] try: - computing_name = storage_id.split('@')[1] + computing_name = storage_id.split(':')[0] + storage_name = storage_id.split(':')[1] except IndexError: + storage_name = storage_id computing_name = None # Get all the storages this user has access to: @@ -724,7 +725,11 @@ class FileManagerAPI(PrivateGETAPI, PrivatePOSTAPI): # Get storages storages = list(Storage.objects.filter(group=None)) + list(Storage.objects.filter(group__user=request.user)) - + + # Oder storages (re-orderded in the file manager anyway) + storages.sort(key=lambda storage: storage.id) + + # Prepare the output for storage in storages: # For now, we only support generic posix, SSH-based storages diff --git a/services/webapp/code/rosetta/core_app/models.py b/services/webapp/code/rosetta/core_app/models.py index 6c54330..0640726 100644 --- a/services/webapp/code/rosetta/core_app/models.py +++ b/services/webapp/code/rosetta/core_app/models.py @@ -364,7 +364,7 @@ class Storage(models.Model): @property def id(self): - return (self.name if not self.computing else '{}@{}'.format(self.name,self.computing.name)) + return (self.name if not self.computing else '{}:{}'.format(self.computing.name,self.name)) -- GitLab