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
f8bac858
authored
Aug 29, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add filter for template list
parent
15d3d135
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
3 deletions
+47
-3
circle/dashboard/forms.py
+1
-1
circle/dashboard/templates/dashboard/template-list.html
+17
-0
circle/dashboard/templates/dashboard/template-list/column-template-running.html
+1
-1
circle/dashboard/views.py
+28
-1
No files found.
circle/dashboard/forms.py
View file @
f8bac858
...
@@ -1201,5 +1201,5 @@ class TemplateListSearchForm(forms.Form):
...
@@ -1201,5 +1201,5 @@ class TemplateListSearchForm(forms.Form):
# set initial value, otherwise it would be overwritten by request.GET
# set initial value, otherwise it would be overwritten by request.GET
if
not
self
.
data
.
get
(
"stype"
):
if
not
self
.
data
.
get
(
"stype"
):
data
=
self
.
data
.
copy
()
data
=
self
.
data
.
copy
()
data
[
'stype'
]
=
"
all
"
data
[
'stype'
]
=
"
owned
"
self
.
data
=
data
self
.
data
=
data
circle/dashboard/templates/dashboard/template-list.html
View file @
f8bac858
...
@@ -16,6 +16,23 @@
...
@@ -16,6 +16,23 @@
<h3
class=
"no-margin"
><i
class=
"fa fa-puzzle-piece"
></i>
{% trans "Templates" %}
</h3>
<h3
class=
"no-margin"
><i
class=
"fa fa-puzzle-piece"
></i>
{% trans "Templates" %}
</h3>
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"col-md-offset-8 col-md-4"
id=
"template-list-search"
>
<form
action=
""
method=
"GET"
>
<div
class=
"input-group"
>
{{ search_form.s }}
<div
class=
"input-group-btn"
>
{{ search_form.stype }}
<button
type=
"submit"
class=
"btn btn-primary input-tags"
>
<i
class=
"fa fa-search"
></i>
</button>
</div>
</div>
<!-- .input-group -->
</form>
</div>
<!-- .col-md-4 #template-list-search -->
</div>
</div>
<div
class=
"panel-body"
>
{% render_table table %}
{% render_table table %}
</div>
</div>
</div>
</div>
...
...
circle/dashboard/templates/dashboard/template-list/column-template-running.html
View file @
f8bac858
<a
href=
"{% url "
dashboard
.
views
.
vm-list
"
%}?
s=
template:{{
record
.
pk
}}%
20status:running
"
>
<a
href=
"{% url "
dashboard
.
views
.
vm-list
"
%}?
s=
template:{{
record
.
pk
}}%
20status:running
"
>
{{ record.
get_running_instances.count
}}
{{ record.
running
}}
</a>
</a>
circle/dashboard/views.py
View file @
f8bac858
...
@@ -1687,6 +1687,18 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
...
@@ -1687,6 +1687,18 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
table_class
=
TemplateListTable
table_class
=
TemplateListTable
table_pagination
=
False
table_pagination
=
False
allowed_filters
=
{
'name'
:
"name__icontains"
,
'tags[]'
:
"tags__name__in"
,
'tags'
:
"tags__name__in"
,
# for search string
'owner'
:
"owner__username"
,
'ram'
:
"ram_size"
,
'ram_size'
:
"ram_size"
,
'cores'
:
"num_cores"
,
'num_cores'
:
"num_cores"
,
'access_method'
:
"access_method__iexact"
,
}
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
context
=
super
(
TemplateList
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
=
super
(
TemplateList
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
context
[
'lease_table'
]
=
LeaseListTable
(
context
[
'lease_table'
]
=
LeaseListTable
(
...
@@ -1702,11 +1714,26 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
...
@@ -1702,11 +1714,26 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
self
.
search_form
.
full_clean
()
self
.
search_form
.
full_clean
()
return
super
(
TemplateList
,
self
)
.
get
(
*
args
,
**
kwargs
)
return
super
(
TemplateList
,
self
)
.
get
(
*
args
,
**
kwargs
)
def
create_acl_queryset
(
self
,
model
):
queryset
=
super
(
TemplateList
,
self
)
.
create_acl_queryset
(
model
)
sql
=
(
"SELECT count(*) FROM vm_instance WHERE "
"vm_instance.template_id = vm_instancetemplate.id and "
"vm_instance.destroyed_at is null and "
"vm_instance.status = 'RUNNING'"
)
queryset
=
queryset
.
extra
(
select
=
{
'running'
:
sql
})
return
queryset
def
get_queryset
(
self
):
def
get_queryset
(
self
):
logger
.
debug
(
'TemplateList.get_queryset() called. User:
%
s'
,
logger
.
debug
(
'TemplateList.get_queryset() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
unicode
(
self
.
request
.
user
))
queryset
=
self
.
create_acl_queryset
(
InstanceTemplate
)
queryset
=
self
.
create_acl_queryset
(
InstanceTemplate
)
return
queryset
.
annotate
(
running
=
Count
(
'instance_set'
))
self
.
create_fake_get
()
try
:
return
queryset
.
filter
(
**
self
.
get_queryset_filters
())
.
distinct
()
except
ValueError
:
messages
.
error
(
self
.
request
,
_
(
"Error during filtering."
))
return
queryset
class
TemplateDelete
(
LoginRequiredMixin
,
DeleteView
):
class
TemplateDelete
(
LoginRequiredMixin
,
DeleteView
):
...
...
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