Commit 17eb2798 authored by Dionysis Grigoropoulos's avatar Dionysis Grigoropoulos Committed by Christos Stavrakakis
Browse files

django: Add a RemoveCommand class

* Add a new class for snf-manage *-remove commands
parent caec4fa6
......@@ -39,6 +39,8 @@ from django.core.exceptions import FieldError
from import utils
from snf_django.lib.astakos import UserCache
import distutils
class SynnefoCommand(BaseCommand):
option_list = BaseCommand.option_list + (
......@@ -328,3 +330,29 @@ class ListCommand(BaseCommand):
for field in self.object_class._meta.fields:
table.append((, field.verbose_name, field.help_text))
utils.pprint_table(self.stdout, table, headers)
class RemoveCommand(BaseCommand):
help = "Generic remove command"
option_list = BaseCommand.option_list + (
"-f", "--force",
help="Do not prompt for confirmation"),
def confirm_deletion(self, force, resource='', args=''):
if force is True:
return True
ids = ', '.join(args)
self.stdout.write("Are you sure you want to delete %s %s?"
" [Y/N]\n" % (resource, ids))
answer = distutils.util.strtobool(raw_input())
if answer != 1:
raise CommandError("Aborting deletion")
except ValueError:
raise CommandError("Invalid Y/N value, aborting")
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