Commit 4444e2b1 by Szabolcs Gelencser

Implement favorite vms on index page

parent ebb4929a
......@@ -3,10 +3,8 @@
<component name="ChangeListManager">
<list default="true" id="1fbec8af-5a7c-40f9-b994-83ac07d1ae1d" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/circle/circle/db.sqlite3" afterPath="$PROJECT_DIR$/circle/circle/db.sqlite3" />
<change beforePath="$PROJECT_DIR$/circle/dashboard/models.py" afterPath="$PROJECT_DIR$/circle/dashboard/models.py" />
<change beforePath="$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail.html" afterPath="$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail.html" />
<change beforePath="$PROJECT_DIR$/circle/dashboard/views/vm.py" afterPath="$PROJECT_DIR$/circle/dashboard/views/vm.py" />
<change beforePath="$PROJECT_DIR$/circle/dashboard/templates/dashboard/index-vm.html" afterPath="$PROJECT_DIR$/circle/dashboard/templates/dashboard/index-vm.html" />
<change beforePath="$PROJECT_DIR$/circle/dashboard/views/index.py" afterPath="$PROJECT_DIR$/circle/dashboard/views/index.py" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
......@@ -36,31 +34,21 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="vm.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/vm.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="1396" column="0" lean-forward="false" selection-start-line="1396" selection-start-column="0" selection-end-line="1396" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="index-vm.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/index-vm.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="185">
<caret line="41" column="55" lean-forward="false" selection-start-line="41" selection-start-column="54" selection-end-line="41" selection-end-column="55" />
<state relative-caret-position="180">
<caret line="39" column="28" lean-forward="false" selection-start-line="39" selection-start-column="28" selection-end-line="39" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="vm-detail.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail.html">
<file leaf-file-name="index.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/index.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="214">
<caret line="75" column="96" lean-forward="false" selection-start-line="75" selection-start-column="96" selection-end-line="75" selection-end-column="96" />
<state relative-caret-position="129">
<caret line="53" column="46" lean-forward="false" selection-start-line="53" selection-start-column="46" selection-end-line="53" selection-end-column="46" />
<folding />
</state>
</provider>
......@@ -105,9 +93,9 @@
<find>instance_id</find>
<find>favor</find>
<find>interface</find>
<find>favourite</find>
<find>favouritev</find>
<find>v</find>
<find>favourite</find>
</findStrings>
<replaceStrings>
<replace>'ACTIVE'</replace>
......@@ -155,7 +143,6 @@
<option value="$PROJECT_DIR$/circle/request/models.py" />
<option value="$PROJECT_DIR$/circle/request/views.py" />
<option value="$PROJECT_DIR$/circle/circle/middleware.py" />
<option value="$PROJECT_DIR$/circle/dashboard/templates/dashboard/index-vm.html" />
<option value="$PROJECT_DIR$/circle/manage.py" />
<option value="$PROJECT_DIR$/circle/openstack_auth/urls.py" />
<option value="$PROJECT_DIR$/circle/dashboard/templates/auth/login.html" />
......@@ -165,7 +152,6 @@
<option value="$PROJECT_DIR$/circle/dashboard/validators.py" />
<option value="$PROJECT_DIR$/requirements/circlestack.txt" />
<option value="$PROJECT_DIR$/circle/vm/models/instance.py" />
<option value="$PROJECT_DIR$/circle/dashboard/views/index.py" />
<option value="$PROJECT_DIR$/circle/dashboard/tables.py" />
<option value="$PROJECT_DIR$/circle/vm/models/activity.py" />
<option value="$PROJECT_DIR$/circle/vm/models/__init__.py" />
......@@ -180,6 +166,8 @@
<option value="$PROJECT_DIR$/circle/dashboard/models.py" />
<option value="$PROJECT_DIR$/circle/dashboard/views/vm.py" />
<option value="$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail.html" />
<option value="$PROJECT_DIR$/circle/dashboard/templates/dashboard/index-vm.html" />
<option value="$PROJECT_DIR$/circle/dashboard/views/index.py" />
</list>
</option>
</component>
......@@ -269,7 +257,7 @@
<property name="settings.editor.selected.configurable" value="watcher.settings" />
<property name="NewWatcherDialog.advanced.open" value="true" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="SearchEverywhereHistoryKey" value="vm-de&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/vm-detail.html&#10;index-v&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/index-vm.html&#10;detailvi&#9;null&#9;null&#10;network&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/vm-detail/network.html&#10;nova.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/os_policies/nova_policy.json&#10;operation&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/operations.py&#10;base&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/settings/base.py&#10;indev&#9;null&#9;null&#10;vmdeta&#9;null&#9;null&#10;indexview&#9;null&#9;null&#10;operatio&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/operations.py&#10;vxlanc&#9;null&#9;null&#10;plain&#9;null&#9;null&#10;base.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/settings/base.py&#10;local&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/settings/local.py&#10;views.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/openstack_auth/views.py&#10;login.html&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/auth/login.html&#10;LoginVi&#9;null&#9;null&#10;indexv&#9;null&#9;null&#10;index-vm&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/index-vm.html&#10;index.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/views/index.py&#10;index&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/index.html&#10;bas&#9;FILE&#9;file:///home/h3yduck/cloud/circle/openstack_api/base.py&#10;save&#9;null&#9;null&#10;plainc&#9;null&#9;null&#10;templatedet&#9;null&#9;null&#10;instancetemp&#9;null&#9;null&#10;instancetem&#9;null&#9;null&#10;url&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/urls.py&#10;vmcreate&#9;null&#9;null&#10;opera&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/operations.py&#10;operations&#9;FILE&#9;file:///home/h3yduck/cloud/circle/common/operations.py&#10;templat&#9;null&#9;null&#10;vmadd&#9;null&#9;null&#10;vmdetail&#9;null&#9;null&#10;addinterfa&#9;null&#9;null&#10;addin&#9;null&#9;null&#10;server&#9;null&#9;null&#10;Instance&#9;null&#9;null&#10;instance&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/models/instance.py&#10;operat&#9;null&#9;null&#10;ins&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/models/instance.py&#10;vmdetai&#9;null&#9;null&#10;operationvi&#9;null&#9;null&#10;ser&#9;null&#9;null&#10;server.&#9;FILE&#9;file:///home/h3yduck/.virtualenvs/cloud/local/lib/python2.7/site-packages/novaclient/v2/servers.py&#10;resources.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/request/templates/request/initials/resources.html&#10;vxla&#9;null&#9;null&#10;urls&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/urls.py&#10;create&#9;FILE&#9;file:///home/h3yduck/cloud/circle/network/templates/network/vxlan-create.html" />
<property name="SearchEverywhereHistoryKey" value="indexvi&#9;null&#9;null&#10;vmdeta&#9;null&#9;null&#10;vm-de&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/vm-detail.html&#10;index-v&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/index-vm.html&#10;detailvi&#9;null&#9;null&#10;network&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/vm-detail/network.html&#10;nova.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/os_policies/nova_policy.json&#10;operation&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/operations.py&#10;base&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/settings/base.py&#10;indev&#9;null&#9;null&#10;indexview&#9;null&#9;null&#10;operatio&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/operations.py&#10;vxlanc&#9;null&#9;null&#10;plain&#9;null&#9;null&#10;base.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/settings/base.py&#10;local&#9;FILE&#9;file:///home/h3yduck/cloud/circle/circle/settings/local.py&#10;views.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/openstack_auth/views.py&#10;login.html&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/auth/login.html&#10;LoginVi&#9;null&#9;null&#10;indexv&#9;null&#9;null&#10;index-vm&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/index-vm.html&#10;index.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/views/index.py&#10;index&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/templates/dashboard/index.html&#10;bas&#9;FILE&#9;file:///home/h3yduck/cloud/circle/openstack_api/base.py&#10;save&#9;null&#9;null&#10;plainc&#9;null&#9;null&#10;templatedet&#9;null&#9;null&#10;instancetemp&#9;null&#9;null&#10;instancetem&#9;null&#9;null&#10;url&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/urls.py&#10;vmcreate&#9;null&#9;null&#10;opera&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/operations.py&#10;operations&#9;FILE&#9;file:///home/h3yduck/cloud/circle/common/operations.py&#10;templat&#9;null&#9;null&#10;vmadd&#9;null&#9;null&#10;vmdetail&#9;null&#9;null&#10;addinterfa&#9;null&#9;null&#10;addin&#9;null&#9;null&#10;server&#9;null&#9;null&#10;Instance&#9;null&#9;null&#10;instance&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/models/instance.py&#10;operat&#9;null&#9;null&#10;ins&#9;FILE&#9;file:///home/h3yduck/cloud/circle/vm/models/instance.py&#10;vmdetai&#9;null&#9;null&#10;operationvi&#9;null&#9;null&#10;ser&#9;null&#9;null&#10;server.&#9;FILE&#9;file:///home/h3yduck/.virtualenvs/cloud/local/lib/python2.7/site-packages/novaclient/v2/servers.py&#10;resources.&#9;FILE&#9;file:///home/h3yduck/cloud/circle/request/templates/request/initials/resources.html&#10;vxla&#9;null&#9;null&#10;urls&#9;FILE&#9;file:///home/h3yduck/cloud/circle/dashboard/urls.py" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
......@@ -415,7 +403,6 @@
</component>
<component name="ToolWindowManager">
<frame x="-2" y="-1" width="1370" height="751" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32980973" sideWeight="0.4978701" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.7097792" sideWeight="0.51283985" order="7" side_tool="true" content_ui="tabs" />
......@@ -430,7 +417,7 @@
<window_info id="SciView" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.7097792" sideWeight="0.48716012" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.7097792" sideWeight="0.48716012" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
......@@ -521,7 +508,7 @@
</properties>
</breakpoint>
</default-breakpoints>
<option name="time" value="334" />
<option name="time" value="336" />
</breakpoint-manager>
<watches-manager />
</component>
......@@ -941,14 +928,6 @@ certifi.where()</expression-string>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/index.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="52">
<caret line="67" column="13" lean-forward="true" selection-start-line="67" selection-start-column="13" selection-end-line="67" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file:///usr/lib/python2.7/SocketServer.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
......@@ -1015,26 +994,34 @@ certifi.where()</expression-string>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/index-vm.html">
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="185">
<caret line="41" column="55" lean-forward="false" selection-start-line="41" selection-start-column="54" selection-end-line="41" selection-end-column="55" />
<state relative-caret-position="214">
<caret line="75" column="96" lean-forward="false" selection-start-line="75" selection-start-column="96" selection-end-line="75" selection-end-column="96" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail.html">
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/vm.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="214">
<caret line="75" column="96" lean-forward="false" selection-start-line="75" selection-start-column="96" selection-end-line="75" selection-end-column="96" />
<state relative-caret-position="-308">
<caret line="94" column="6" lean-forward="false" selection-start-line="94" selection-start-column="6" selection-end-line="94" selection-end-column="6" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/vm.py">
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/index-vm.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="39" column="28" lean-forward="false" selection-start-line="39" selection-start-column="28" selection-end-line="39" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/index.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="1396" column="0" lean-forward="false" selection-start-line="1396" selection-start-column="0" selection-end-line="1396" selection-end-column="0" />
<state relative-caret-position="129">
<caret line="53" column="46" lean-forward="false" selection-start-line="53" selection-start-column="46" selection-end-line="53" selection-end-column="46" />
<folding />
</state>
</provider>
......
No preview for this file type
......@@ -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 %}
......
......@@ -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"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment