Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3199d66f
authored
Mar 13, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show templates on UI
parent
9e76ed54
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
111 deletions
+106
-111
.idea/workspace.xml
+0
-0
circle/dashboard/templates/dashboard/index-templates.html
+0
-3
circle/dashboard/templates/dashboard/index.html
+4
-5
circle/dashboard/urls.py
+7
-6
circle/dashboard/views/index.py
+1
-3
circle/dashboard/views/template.py
+93
-93
circle/vm/models/instance.py
+1
-1
No files found.
.idea/workspace.xml
View file @
3199d66f
This diff is collapsed.
Click to expand it.
circle/dashboard/templates/dashboard/index-templates.html
View file @
3199d66f
...
@@ -48,9 +48,6 @@
...
@@ -48,9 +48,6 @@
<a
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
class=
"btn btn-primary btn-xs"
>
<a
href=
"{% url "
dashboard
.
views
.
template-list
"
%}"
class=
"btn btn-primary btn-xs"
>
<i
class=
"fa fa-chevron-circle-right"
></i>
{% trans "show all" %}
<i
class=
"fa fa-chevron-circle-right"
></i>
{% trans "show all" %}
</a>
</a>
<a
href=
"{% url "
dashboard
.
views
.
template-choose
"
%}"
class=
"btn btn-success btn-xs template-choose"
>
<i
class=
"fa fa-plus-circle"
></i>
{% trans "new" %}
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
circle/dashboard/templates/dashboard/index.html
View file @
3199d66f
...
@@ -31,11 +31,10 @@
...
@@ -31,11 +31,10 @@
{#
</div>
#}
{#
</div>
#}
{# {% endif %}#}
{# {% endif %}#}
{##}
{##}
{# {% if perms.vm.create_template %}#}
{# #TODO: check permissions for template (as well as for other resources) #}
{#
<div
class=
"col-lg-4 col-sm-6"
>
#}
<div
class=
"col-lg-4 col-sm-6"
>
{# {% include "dashboard/index-templates.html" %}#}
{% include "dashboard/index-templates.html" %}
{#
</div>
#}
</div>
{# {% endif %}#}
{##}
{##}
{# {% if perms.vm.view_statistics %}#}
{# {% if perms.vm.view_statistics %}#}
{#
<div
class=
"col-lg-4 col-sm-6"
>
#}
{#
<div
class=
"col-lg-4 col-sm-6"
>
#}
...
...
circle/dashboard/urls.py
View file @
3199d66f
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
dashboard.views.autocomplete
import
AclUserGroupAutocomplete
,
AclUserAutocomplete
from
dashboard.views.autocomplete
import
AclUserGroupAutocomplete
,
AclUserAutocomplete
from
dashboard.views.template
import
TemplateList
,
TemplateChoose
,
TemplateDetail
from
dashboard.views.vm
import
VmDetailView
,
VmList
,
VmCreate
,
vm_activity
,
vm_ops
,
FavouriteView
,
VmPlainImageCreate
from
dashboard.views.vm
import
VmDetailView
,
VmList
,
VmCreate
,
vm_activity
,
vm_ops
,
FavouriteView
,
VmPlainImageCreate
from
django.conf.urls
import
url
from
django.conf.urls
import
url
...
@@ -43,14 +44,14 @@ urlpatterns = [
...
@@ -43,14 +44,14 @@ urlpatterns = [
#
#
# url(r'^template/create/$', TemplateCreate.as_view(),
# url(r'^template/create/$', TemplateCreate.as_view(),
# name="dashboard.views.template-create"),
# name="dashboard.views.template-create"),
#
url(r'^template/choose/$', TemplateChoose.as_view(),
url
(
r'^template/choose/$'
,
TemplateChoose
.
as_view
(),
#
name="dashboard.views.template-choose"),
name
=
"dashboard.views.template-choose"
),
# url(r'template/(?P<pk>\d+)/acl/$', TemplateAclUpdateView.as_view(),
# url(r'template/(?P<pk>\d+)/acl/$', TemplateAclUpdateView.as_view(),
# name='dashboard.views.template-acl'),
# name='dashboard.views.template-acl'),
#
url(r'^template/(?P<pk>\d+)/$', TemplateDetail.as_view(),
url
(
r'^template/(?P<pk>\d+)/$'
,
TemplateDetail
.
as_view
(),
#
name='dashboard.views.template-detail'),
name
=
'dashboard.views.template-detail'
),
#
url(r"^template/list/$", TemplateList.as_view(),
url
(
r"^template/list/$"
,
TemplateList
.
as_view
(),
#
name="dashboard.views.template-list"),
name
=
"dashboard.views.template-list"
),
# url(r"^template/delete/(?P<pk>\d+)/$", TemplateDelete.as_view(),
# url(r"^template/delete/(?P<pk>\d+)/$", TemplateDelete.as_view(),
# name="dashboard.views.template-delete"),
# name="dashboard.views.template-delete"),
# url(r'^template/(?P<pk>\d+)/tx/$', TransferTemplateOwnershipView.as_view(),
# url(r'^template/(?P<pk>\d+)/tx/$', TransferTemplateOwnershipView.as_view(),
...
...
circle/dashboard/views/index.py
View file @
3199d66f
...
@@ -102,9 +102,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
...
@@ -102,9 +102,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
})
})
# template
# template
if
user
.
has_perm
(
'vm.create_template'
):
context
[
'templates'
]
=
InstanceTemplate
.
objects
.
filter
(
owner_id
=
user
.
id
)
context
[
'templates'
]
=
InstanceTemplate
.
get_objects_with_level
(
'operator'
,
user
,
disregard_superuser
=
True
)
.
all
()[:
5
]
# vxlan
# vxlan
all_vxlans
=
openstack_api
.
neutron
.
network_list_for_tenant
(
self
.
request
,
self
.
request
.
user
.
tenant_id
)
all_vxlans
=
openstack_api
.
neutron
.
network_list_for_tenant
(
self
.
request
,
self
.
request
.
user
.
tenant_id
)
...
...
circle/dashboard/views/template.py
View file @
3199d66f
...
@@ -51,8 +51,8 @@ from ..tables import TemplateListTable, LeaseListTable
...
@@ -51,8 +51,8 @@ from ..tables import TemplateListTable, LeaseListTable
from
.util
import
(
from
.util
import
(
AclUpdateView
,
FilterMixin
,
AclUpdateView
,
FilterMixin
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
#
TransferOwnershipConfirmView, TransferOwnershipView,
DeleteViewBase
,
#
DeleteViewBase,
GraphMixin
GraphMixin
)
)
...
@@ -285,18 +285,18 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
...
@@ -285,18 +285,18 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
return
qs
.
select_related
(
"lease"
,
"owner"
,
"owner__profile"
)
return
qs
.
select_related
(
"lease"
,
"owner"
,
"owner__profile"
)
#
class
TemplateDelete
(
DeleteViewBase
):
#
class TemplateDelete(DeleteViewBase):
model
=
InstanceTemplate
#
model = InstanceTemplate
success_message
=
_
(
"Template successfully deleted."
)
#
success_message = _("Template successfully deleted.")
#
def
get_success_url
(
self
):
#
def get_success_url(self):
return
reverse
(
"dashboard.views.template-list"
)
#
return reverse("dashboard.views.template-list")
#
def
delete_obj
(
self
,
request
,
*
args
,
**
kwargs
):
#
def delete_obj(self, request, *args, **kwargs):
object
=
self
.
get_object
()
#
object = self.get_object()
object
.
destroy_disks
()
#
object.destroy_disks()
object
.
delete
()
#
object.delete()
class
TemplateDetail
(
LoginRequiredMixin
,
GraphMixin
,
class
TemplateDetail
(
LoginRequiredMixin
,
GraphMixin
,
...
@@ -360,41 +360,41 @@ class TemplateDetail(LoginRequiredMixin, GraphMixin,
...
@@ -360,41 +360,41 @@ class TemplateDetail(LoginRequiredMixin, GraphMixin,
kwargs
[
'user'
]
=
self
.
request
.
user
kwargs
[
'user'
]
=
self
.
request
.
user
return
kwargs
return
kwargs
#
class
DiskRemoveView
(
DeleteViewBase
):
#
class DiskRemoveView(DeleteViewBase):
model
=
Disk
#
model = Disk
success_message
=
_
(
"Disk successfully removed."
)
#
success_message = _("Disk successfully removed.")
#
def
get_queryset
(
self
):
#
def get_queryset(self):
qs
=
super
(
DiskRemoveView
,
self
)
.
get_queryset
()
#
qs = super(DiskRemoveView, self).get_queryset()
return
qs
.
exclude
(
template_set
=
None
)
#
return qs.exclude(template_set=None)
#
def
check_auth
(
self
):
#
def check_auth(self):
disk
=
self
.
get_object
()
#
disk = self.get_object()
template
=
disk
.
template_set
.
get
()
#
template = disk.template_set.get()
if
not
template
.
has_level
(
self
.
request
.
user
,
'owner'
):
#
if not template.has_level(self.request.user, 'owner'):
raise
PermissionDenied
()
#
raise PermissionDenied()
#
def
get_context_data
(
self
,
**
kwargs
):
#
def get_context_data(self, **kwargs):
disk
=
self
.
get_object
()
#
disk = self.get_object()
template
=
disk
.
template_set
.
get
()
#
template = disk.template_set.get()
context
=
super
(
DiskRemoveView
,
self
)
.
get_context_data
(
**
kwargs
)
#
context = super(DiskRemoveView, self).get_context_data(**kwargs)
context
[
'title'
]
=
_
(
"Disk remove confirmation"
)
#
context['title'] = _("Disk remove confirmation")
context
[
'text'
]
=
_
(
"Are you sure you want to remove "
#
context['text'] = _("Are you sure you want to remove "
"<strong>
%(disk)
s</strong> from "
#
"<strong>%(disk)s</strong> from "
"<strong>
%(app)
s</strong>?"
%
{
'disk'
:
disk
,
#
"<strong>%(app)s</strong>?" % {'disk': disk,
'app'
:
template
}
#
'app': template}
)
#
)
return
context
#
return context
#
def
delete_obj
(
self
,
request
,
*
args
,
**
kwargs
):
#
def delete_obj(self, request, *args, **kwargs):
disk
=
self
.
get_object
()
#
disk = self.get_object()
template
=
disk
.
template_set
.
get
()
#
template = disk.template_set.get()
template
.
remove_disk
(
disk
)
#
template.remove_disk(disk)
disk
.
destroy
()
#
disk.destroy()
#
def
get_success_url
(
self
):
#
def get_success_url(self):
return
self
.
request
.
POST
.
get
(
"next"
)
or
"/"
#
return self.request.POST.get("next") or "/"
class
LeaseCreate
(
LoginRequiredMixin
,
PermissionRequiredMixin
,
class
LeaseCreate
(
LoginRequiredMixin
,
PermissionRequiredMixin
,
...
@@ -447,47 +447,47 @@ class LeaseDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
...
@@ -447,47 +447,47 @@ class LeaseDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
return
super
(
LeaseDetail
,
self
)
.
post
(
request
,
*
args
,
**
kwargs
)
return
super
(
LeaseDetail
,
self
)
.
post
(
request
,
*
args
,
**
kwargs
)
#
class
LeaseDelete
(
DeleteViewBase
):
#
class LeaseDelete(DeleteViewBase):
model
=
Lease
#
model = Lease
success_message
=
_
(
"Lease successfully deleted."
)
#
success_message = _("Lease successfully deleted.")
#
def
get_success_url
(
self
):
#
def get_success_url(self):
return
reverse
(
"dashboard.views.template-list"
)
#
return reverse("dashboard.views.template-list")
#
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
#
def get_context_data(self, *args, **kwargs):
c
=
super
(
LeaseDelete
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
#
c = super(LeaseDelete, self).get_context_data(*args, **kwargs)
lease
=
self
.
get_object
()
#
lease = self.get_object()
templates
=
lease
.
instancetemplate_set
#
templates = lease.instancetemplate_set
if
templates
.
count
()
>
0
:
#
if templates.count() > 0:
text
=
_
(
"You can't delete this lease because some templates "
#
text = _("You can't delete this lease because some templates "
"are still using it, modify these to proceed: "
)
#
"are still using it, modify these to proceed: ")
#
c
[
'text'
]
=
text
+
", "
.
join
(
"<strong>
%
s (#
%
d)</strong>"
#
c['text'] = text + ", ".join("<strong>%s (#%d)</strong>"
""
%
(
o
.
name
,
o
.
pk
)
#
"" % (o.name, o.pk)
for
o
in
templates
.
all
())
#
for o in templates.all())
c
[
'disable_submit'
]
=
True
#
c['disable_submit'] = True
return
c
#
return c
#
def
delete_obj
(
self
,
request
,
*
args
,
**
kwargs
):
#
def delete_obj(self, request, *args, **kwargs):
object
=
self
.
get_object
()
#
object = self.get_object()
if
object
.
instancetemplate_set
.
count
()
>
0
:
#
if object.instancetemplate_set.count() > 0:
raise
SuspiciousOperation
()
#
raise SuspiciousOperation()
object
.
delete
()
#
object.delete()
#
#
class
TransferTemplateOwnershipConfirmView
(
TransferOwnershipConfirmView
):
#
class TransferTemplateOwnershipConfirmView(TransferOwnershipConfirmView):
template
=
"dashboard/confirm/transfer-template-ownership.html"
#
template = "dashboard/confirm/transfer-template-ownership.html"
model
=
InstanceTemplate
#
model = InstanceTemplate
#
#
class
TransferTemplateOwnershipView
(
TransferOwnershipView
):
#
class TransferTemplateOwnershipView(TransferOwnershipView):
confirm_view
=
TransferTemplateOwnershipConfirmView
#
confirm_view = TransferTemplateOwnershipConfirmView
model
=
InstanceTemplate
#
model = InstanceTemplate
notification_msg
=
ugettext_noop
(
#
notification_msg = ugettext_noop(
'
%(owner)
s offered you to take the ownership of '
#
'%(owner)s offered you to take the ownership of '
'his/her template called
%(instance)
s. '
#
'his/her template called %(instance)s. '
'<a href="
%(token)
s" '
#
'<a href="%(token)s" '
'class="btn btn-success btn-small">Accept</a>'
)
#
'class="btn btn-success btn-small">Accept</a>')
token_url
=
'dashboard.views.template-transfer-ownership-confirm'
#
token_url = 'dashboard.views.template-transfer-ownership-confirm'
template
=
"dashboard/template-tx-owner.html"
#
template = "dashboard/template-tx-owner.html"
circle/vm/models/instance.py
View file @
3199d66f
...
@@ -164,11 +164,11 @@ class InstanceTemplate(TimeStampedModel):
...
@@ -164,11 +164,11 @@ class InstanceTemplate(TimeStampedModel):
def
os_type
(
self
):
def
os_type
(
self
):
"""The type of the template's operating system.
"""The type of the template's operating system.
"""
"""
return
'linux'
#TODO
if
self
.
access_method
==
'rdp'
:
if
self
.
access_method
==
'rdp'
:
return
'windows'
return
'windows'
else
:
else
:
return
'linux'
return
'linux'
#TODO
@permalink
@permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
...
...
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