Commit 0e014c4a authored by Samuel GAIST's avatar Samuel GAIST

[database][commands] Add root_folder information to output

This patch also add a small filter that allows to "clean"
the folder part up to after the text given if found in
the root_folder field.
parent 59891ea8
Pipeline #32532 passed with stage
in 18 minutes and 10 seconds
......@@ -25,35 +25,40 @@
# #
###############################################################################
import logging
from django.core.management.base import BaseCommand
from ...models import Database
logger = logging.getLogger("beat.web")
class Command(BaseCommand):
help = "Prints the list of databases with access level and user information"
def handle(self, *ignored, **options):
def add_arguments(self, parser):
parser.add_argument(
"--folder-filter",
action="store",
dest="folder_filter",
default=None,
help="Path element up to which the the string must be cleaned",
)
# Setup this command's logging level
global logger
verbosity = int(options["verbosity"])
if verbosity >= 1:
if verbosity == 1:
logger.setLevel(logging.INFO)
elif verbosity >= 2:
logger.setLevel(logging.DEBUG)
def handle(self, *ignored, **options):
self.stdout.write("name, access, user")
self.stdout.write("name, access, folder, user")
for database in Database.objects.all():
db_info = "{}, {}".format(
database.fullname(), database.get_sharing_display()
folder = database.declaration["root_folder"]
folder_filter = options["folder_filter"]
if folder_filter:
try:
start = folder.rindex(folder_filter) + len(folder_filter)
except ValueError:
start = 0
folder = folder[start:]
db_info = "{}, {}, {}".format(
database.fullname(), database.get_sharing_display(), folder
)
for user in [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment