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
4444e2b1
authored
Apr 20, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement favorite vms on index page
parent
ebb4929a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
15 deletions
+12
-15
.idea/workspace.xml
+0
-0
circle/circle/db.sqlite3
+0
-0
circle/dashboard/templates/dashboard/index-vm.html
+1
-1
circle/dashboard/views/index.py
+11
-14
No files found.
.idea/workspace.xml
View file @
4444e2b1
This diff is collapsed.
Click to expand it.
circle/circle/db.sqlite3
View file @
4444e2b1
No preview for this file type
circle/dashboard/templates/dashboard/index-vm.html
View file @
4444e2b1
...
...
@@ -37,7 +37,7 @@
<small
class=
"text-muted index-vm-list-host"
>
{{ i.short_hostname }}
</small>
<div
class=
"pull-right dashboard-vm-favourite"
data-vm=
"{{ i.
pk
}}"
>
<div
class=
"pull-right dashboard-vm-favourite"
data-vm=
"{{ i.
id
}}"
>
{% if i.fav %}
<i
class=
"fa fa-star text-primary title-favourite"
title=
"{% trans "
Unfavourite
"
%}"
></i>
{% else %}
...
...
circle/dashboard/views/index.py
View file @
4444e2b1
...
...
@@ -20,7 +20,7 @@ import logging
import
openstack_api
from
braces.views
import
LoginRequiredMixin
from
dashboard.models
import
GroupProfile
from
dashboard.models
import
GroupProfile
,
Favourite
from
django.conf
import
settings
from
django.contrib.auth.models
import
Group
,
User
from
django.core.cache
import
cache
...
...
@@ -44,24 +44,21 @@ class IndexView(LoginRequiredMixin, TemplateView):
instances
=
openstack_api
.
nova
.
server_list
(
self
.
request
)[
0
]
#TODO: flatten?
quotas
=
openstack_api
.
nova
.
tenant_quota_get
(
self
.
request
,
user
.
project_id
)
# instances
favs
=
[
f
.
instance
for
f
in
Favourite
.
objects
.
filter
(
user
=
user
.
id
)]
fav_instances
=
[
i
for
i
in
instances
if
i
.
id
in
favs
]
display
=
list
(
fav_instances
)
+
list
(
set
(
instances
)
-
set
(
fav_instances
))
for
d
in
display
:
d
.
fav
=
True
if
d
in
fav_instances
else
False
context
.
update
({
'instances'
:
instances
[:
5
],
'instances'
:
display
[:
5
],
'more_instances'
:
len
(
instances
)
-
len
(
instances
[:
5
]),
'max_instances'
:
quotas
.
get
(
"instances"
)
.
limit
})
# instances
# favs = Instance.objects.filter(favourite__user=self.request.user)
# instances = Instance.get_objects_with_level(
# 'user', user, disregard_superuser=True).filter(destroyed_at=None)
# display = list(favs) + list(set(instances) - set(favs))
# for d in display:
# d.fav = True if d in favs else False
# context.update({
# 'instances': display[:5],
# 'more_instances': instances.count() - len(instances[:5])
# })
running
=
[
i
for
i
in
instances
if
i
.
status
==
"ACTIVE"
]
stopped
=
[
i
for
i
in
instances
if
i
.
status
!=
"ACTIVE"
]
...
...
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