Skip to content

Commit

Permalink
feat: add two commands for:
Browse files Browse the repository at this point in the history
- deleting dadbestan-name
- renaming profile-pic
  • Loading branch information
AmooHashem committed Oct 30, 2024
1 parent dd47874 commit c1e4d1f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps/fsm/management/commands/shaf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.core.management.base import BaseCommand

from apps.widgets.models.other_widgets.button import ButtonWidget
from apps.fsm.models.content_widgets import Placeholder


class Command(BaseCommand):
help = 'Delete all ButtonWidgets with a specific destination_page_url.'
help = 'Delete all Placeholder with a specific destination_page_url.'

def handle(self, *args, **kwargs):
url_to_delete = "https://ashbaria.sepid.org/program/ashbaria/"
deleted_count, _ = ButtonWidget.objects.filter(destination_page_url=url_to_delete).delete()
self.stdout.write(self.style.SUCCESS(f'Successfully deleted {deleted_count} ButtonWidgets with destination_page_url="{url_to_delete}"'))
name = "dadbestan-name"
deleted_count, _ = Placeholder.objects.filter(_object__name=name).delete()
self.stdout.write(self.style.SUCCESS(
f'Successfully deleted {deleted_count} Placeholder with destination_page_url="{name}"'))
16 changes: 16 additions & 0 deletions apps/fsm/management/commands/shaf2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.core.management.base import BaseCommand

from apps.fsm.models.content_widgets import Placeholder


class Command(BaseCommand):
help = 'Delete all Placeholder with a specific destination_page_url.'

def handle(self, *args, **kwargs):
name = "profile-pic"
placeholders = Placeholder.objects.filter(_object__name=name)
for placeholder in placeholders:
placeholder._object.name = "ashbaria-my-profile"
placeholder._object.save()
self.stdout.write(self.style.SUCCESS(
f'Successfully deleted Placeholder with destination_page_url="{name}"'))

0 comments on commit c1e4d1f

Please sign in to comment.