Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
17eb2798
Commit
17eb2798
authored
Nov 21, 2013
by
Dionysis Grigoropoulos
Committed by
Christos Stavrakakis
Nov 25, 2013
Browse files
django: Add a RemoveCommand class
* Add a new class for snf-manage *-remove commands
parent
caec4fa6
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-django-lib/snf_django/management/commands/__init__.py
View file @
17eb2798
...
...
@@ -39,6 +39,8 @@ from django.core.exceptions import FieldError
from
snf_django.management
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
.
name
,
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
+
(
make_option
(
"-f"
,
"--force"
,
dest
=
"force"
,
action
=
"store_true"
,
default
=
False
,
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
))
try
:
answer
=
distutils
.
util
.
strtobool
(
raw_input
())
if
answer
!=
1
:
raise
CommandError
(
"Aborting deletion"
)
except
ValueError
:
raise
CommandError
(
"Invalid Y/N value, aborting"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment