Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f7b7edeb
authored
Jun 07, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add delete view for Endpoint
parent
764d9bf6
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
7 deletions
+95
-7
circle/dashboard/static/dashboard/dashboard.js
+9
-2
circle/dashboard/static/dashboard/dashboard.less
+3
-0
circle/dashboard/tables.py
+7
-0
circle/dashboard/templates/dashboard/endpoint-edit.html
+10
-0
circle/dashboard/templates/dashboard/endpoint-list/column-endpoint-actions.html
+7
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views/storage.py
+56
-4
No files found.
circle/dashboard/static/dashboard/dashboard.js
View file @
f7b7edeb
...
@@ -29,17 +29,24 @@ $(function () {
...
@@ -29,17 +29,24 @@ $(function () {
return
false
;
return
false
;
});
});
$
(
'.group-create, .node-create, .tx-tpl-ownership, .group-delete, .node-delete, .disk-remove, .template-delete, .delete-from-group, .lease-delete'
).
click
(
function
(
e
)
{
$
(
'.group-create, .node-create, .tx-tpl-ownership, .group-delete, .node-delete, .disk-remove, .template-delete, .delete-from-group, .lease-delete
, .endpoint-delete
'
).
click
(
function
(
e
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
url
:
$
(
this
).
prop
(
'href'
),
url
:
$
(
this
).
prop
(
'href'
),
success
:
function
(
data
)
{
success
:
function
(
data
,
_
,
xhr
)
{
var
ctype
=
xhr
.
getResponseHeader
(
"content-type"
)
||
""
;
if
(
ctype
.
indexOf
(
"html"
)
>
-
1
)
{
$
(
'body'
).
append
(
data
);
$
(
'body'
).
append
(
data
);
var
modal
=
$
(
'#confirmation-modal'
);
var
modal
=
$
(
'#confirmation-modal'
);
modal
.
modal
(
'show'
);
modal
.
modal
(
'show'
);
modal
.
on
(
'hidden.bs.modal'
,
function
()
{
modal
.
on
(
'hidden.bs.modal'
,
function
()
{
modal
.
remove
();
modal
.
remove
();
});
});
}
else
if
(
ctype
.
indexOf
(
"json"
)
>
-
1
)
{
if
(
data
.
error
!==
null
&&
data
.
error
!==
undefined
)
addMessage
(
data
.
error
,
"warning"
);
}
},
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
error
:
function
(
xhr
,
textStatus
,
error
)
{
if
(
xhr
.
status
===
403
)
{
if
(
xhr
.
status
===
403
)
{
...
...
circle/dashboard/static/dashboard/dashboard.less
View file @
f7b7edeb
...
@@ -348,6 +348,9 @@ a.hover-black {
...
@@ -348,6 +348,9 @@ a.hover-black {
width: 100px;
width: 100px;
}
}
.endpoint-list-table-thin {
width: 70px;
}
.nojs-dropdown-menu
.nojs-dropdown-menu
{
{
...
...
circle/dashboard/tables.py
View file @
f7b7edeb
...
@@ -430,6 +430,13 @@ class EndpointListTable(Table):
...
@@ -430,6 +430,13 @@ class EndpointListTable(Table):
attrs
=
{
'th'
:
{
'data-sort'
:
"string"
}}
attrs
=
{
'th'
:
{
'data-sort'
:
"string"
}}
)
)
actions
=
TemplateColumn
(
verbose_name
=
_
(
"Actions"
),
template_name
=
"dashboard/endpoint-list/column-endpoint-actions.html"
,
attrs
=
{
'th'
:
{
'class'
:
'endpoint-list-table-thin'
}},
orderable
=
False
,
)
class
Meta
:
class
Meta
:
model
=
DataStore
model
=
DataStore
attrs
=
{
'class'
:
(
'table table-bordered table-striped table-hover'
attrs
=
{
'class'
:
(
'table table-bordered table-striped table-hover'
...
...
circle/dashboard/templates/dashboard/endpoint-edit.html
View file @
f7b7edeb
...
@@ -41,4 +41,14 @@
...
@@ -41,4 +41,14 @@
</div>
<!-- .panel-body -->
</div>
<!-- .panel-body -->
</div>
</div>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<a
href=
"{% url "
dashboard
.
views
.
storage-endpoint-delete
"
pk=
object.pk
%}"
class=
"btn btn-xs btn-danger pull-right endpoint-delete"
>
{% trans "Delete" %}
</a>
<h4
class=
"no-margin"
><i
class=
"fa fa-times"
></i>
{% trans "Delete endpoint" %}
</h4>
</div>
</div>
{% endblock %}
{% endblock %}
circle/dashboard/templates/dashboard/endpoint-list/column-endpoint-actions.html
0 → 100644
View file @
f7b7edeb
{% load i18n %}
<a
href=
"{% url "
dashboard
.
views
.
storage-endpoint-edit
"
pk=
record.pk%}"
id=
"endpoint-list-edit-button"
class=
"btn btn-default btn-xs"
title=
"{% trans "
Edit
"
%}"
>
<i
class=
"fa fa-edit"
></i>
</a>
<a
href=
"{% url "
dashboard
.
views
.
storage-endpoint-delete
"
pk=
record.pk
%}"
class=
"btn btn-danger btn-xs endpoint-delete"
title=
"{% trans "
Delete
"
%}"
>
<i
class=
"fa fa-times"
></i>
</a>
circle/dashboard/urls.py
View file @
f7b7edeb
...
@@ -54,7 +54,7 @@ from .views import (
...
@@ -54,7 +54,7 @@ from .views import (
NodeActivityView
,
NodeActivityView
,
UserList
,
UserList
,
StorageDetail
,
StorageList
,
StorageChoose
,
StorageCreate
,
DiskDetail
,
StorageDetail
,
StorageList
,
StorageChoose
,
StorageCreate
,
DiskDetail
,
EndpointCreate
,
EndpointList
,
EndpointEdit
,
EndpointCreate
,
EndpointList
,
EndpointEdit
,
EndpointDelete
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
)
)
from
.views.vm
import
vm_ops
,
vm_mass_ops
from
.views.vm
import
vm_ops
,
vm_mass_ops
...
@@ -251,6 +251,8 @@ urlpatterns = patterns(
...
@@ -251,6 +251,8 @@ urlpatterns = patterns(
name
=
"dashboard.views.storage-endpoint-list"
),
name
=
"dashboard.views.storage-endpoint-list"
),
url
(
r'^storage/endpoint/(?P<pk>\d+)/$'
,
EndpointEdit
.
as_view
(),
url
(
r'^storage/endpoint/(?P<pk>\d+)/$'
,
EndpointEdit
.
as_view
(),
name
=
'dashboard.views.storage-endpoint-edit'
),
name
=
'dashboard.views.storage-endpoint-edit'
),
url
(
r"^storage/endpoint/delete/(?P<pk>\d+)/$"
,
EndpointDelete
.
as_view
(),
name
=
"dashboard.views.storage-endpoint-delete"
),
url
(
r'^disk/(?P<pk>\d+)/$'
,
DiskDetail
.
as_view
(),
url
(
r'^disk/(?P<pk>\d+)/$'
,
DiskDetail
.
as_view
(),
name
=
"dashboard.views.disk-detail"
),
name
=
"dashboard.views.disk-detail"
),
...
...
circle/dashboard/views/storage.py
View file @
f7b7edeb
...
@@ -21,12 +21,16 @@ import logging
...
@@ -21,12 +21,16 @@ import logging
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext
from
django.views.generic
import
UpdateView
,
TemplateView
,
CreateView
from
django.views.generic
import
(
UpdateView
,
TemplateView
,
CreateView
,
DeleteView
)
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django_tables2
import
SingleTableView
from
django_tables2
import
SingleTableView
from
django.http
import
Http404
,
HttpResponse
from
django.http
import
(
Http404
,
HttpResponse
,
HttpResponseRedirect
,
JsonResponse
)
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
braces.views
import
SuperuserRequiredMixin
from
braces.views
import
SuperuserRequiredMixin
...
@@ -389,5 +393,53 @@ class EndpointEdit(SuperuserRequiredMixin, UpdateView):
...
@@ -389,5 +393,53 @@ class EndpointEdit(SuperuserRequiredMixin, UpdateView):
def
get_success_url
(
self
):
def
get_success_url
(
self
):
ds
=
self
.
get_object
()
ds
=
self
.
get_object
()
return
reverse
(
"dashboard.views.storage-endpoint-edit"
,
return
reverse
_lazy
(
"dashboard.views.storage-endpoint-edit"
,
kwargs
=
{
"pk"
:
ds
.
id
})
kwargs
=
{
"pk"
:
ds
.
id
})
class
EndpointDelete
(
SuperuserRequiredMixin
,
DeleteView
):
model
=
Endpoint
success_message
=
_
(
"Endpoint successfully deleted."
)
def
get_template_names
(
self
):
if
self
.
request
.
is_ajax
():
return
[
'dashboard/confirm/ajax-delete.html'
]
else
:
return
[
'dashboard/confirm/base-delete.html'
]
def
check_reference
(
self
):
object
=
self
.
get_object
()
if
object
.
datastore_set
.
count
()
!=
0
:
raise
PermissionDenied
()
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
self
.
check_reference
()
except
PermissionDenied
:
message
=
ugettext
(
"Another object references"
" to the selected object."
)
if
request
.
is_ajax
():
return
JsonResponse
({
"error"
:
message
})
else
:
messages
.
warning
(
request
,
message
)
return
redirect
(
self
.
get_success_url
())
return
super
(
EndpointDelete
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_success_url
(
self
):
return
reverse_lazy
(
"dashboard.views.storage-endpoint-list"
)
def
delete_obj
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
get_object
()
.
delete
()
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
check_reference
()
self
.
delete_obj
(
request
,
*
args
,
**
kwargs
)
if
request
.
is_ajax
():
return
HttpResponse
(
json
.
dumps
({
'message'
:
self
.
success_message
}),
content_type
=
"application/json"
,
)
else
:
messages
.
success
(
request
,
self
.
success_message
)
return
HttpResponseRedirect
(
self
.
get_success_url
())
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