mirror of
https://github.com/makeplane/plane
synced 2025-08-07 19:59:33 +00:00
Compare commits
1 Commits
fix/variab
...
workspace-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f633570a8 |
36
apiserver/plane/db/management/commands/delete_workspace.py
Normal file
36
apiserver/plane/db/management/commands/delete_workspace.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Django imports
|
||||
from django.core.management import BaseCommand, CommandError
|
||||
|
||||
# Module imports
|
||||
from plane.db.models import Workspace
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Delete the workspace with the given slug"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
try:
|
||||
# Get the old and new slug from console
|
||||
slug = input("Enter the slug of the workspace: ")
|
||||
|
||||
# raise error if email is not present
|
||||
if not slug:
|
||||
raise CommandError("Error: Slug is required")
|
||||
|
||||
# filter the user
|
||||
workspace = Workspace.objects.filter(slug=slug).first()
|
||||
|
||||
# Raise error if the user is not present
|
||||
if not workspace:
|
||||
raise CommandError(
|
||||
f"Error: Workspace with {slug} does not exists"
|
||||
)
|
||||
|
||||
# Activate the user
|
||||
workspace.delete()
|
||||
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS("Workspace deleted succesfully")
|
||||
)
|
||||
except Exception as e:
|
||||
raise CommandError(f"Error: {e}")
|
||||
39
apiserver/plane/db/management/commands/rename_workspace.py
Normal file
39
apiserver/plane/db/management/commands/rename_workspace.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# Django imports
|
||||
from django.core.management import BaseCommand, CommandError
|
||||
|
||||
# Module imports
|
||||
from plane.db.models import Workspace
|
||||
from plane.utils.constants import RESTRICTED_WORKSPACE_SLUGS
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Rename the workspace slug"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# Get the old and new slug from console
|
||||
old_slug = input("Enter the slug of the workspace: ")
|
||||
new_slug = input("Enter the new slug of the workspace: ")
|
||||
|
||||
# raise error if email is not present
|
||||
if not old_slug or not new_slug:
|
||||
raise CommandError("Error: Old and new slugs are required")
|
||||
|
||||
# filter the user
|
||||
workspace = Workspace.objects.filter(slug=old_slug).first()
|
||||
|
||||
# Raise error if the user is not present
|
||||
if not workspace:
|
||||
raise CommandError(
|
||||
f"Error: Workspace with {old_slug} does not exists"
|
||||
)
|
||||
|
||||
if new_slug in RESTRICTED_WORKSPACE_SLUGS:
|
||||
raise CommandError(
|
||||
f"Error: {new_slug} is a restricted workspace slug"
|
||||
)
|
||||
|
||||
# Activate the user
|
||||
workspace.slug = new_slug
|
||||
workspace.save()
|
||||
|
||||
self.stdout.write(self.style.SUCCESS("Workspace renamed succesfully"))
|
||||
Reference in New Issue
Block a user