Commit c290cae3 by Kálmán Viktor

dashboard: merge same activites

parent 99df6972
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
</span> </span>
<strong{% if user.is_superuser and a.result %} title="{{ a.result }}"{% endif %}> <strong{% if user.is_superuser and a.result %} title="{{ a.result }}"{% endif %}>
{% if user.is_superuser %}<a href="{{ a.get_absolute_url }}">{% endif %} {% if user.is_superuser %}<a href="{{ a.get_absolute_url }}">{% endif %}
{% if a.times > 1 %}({{ a.times }}x){% endif %}
{{ a.get_readable_name }}{% if user.is_superuser %}</a>{% endif %} {{ a.get_readable_name }}{% if user.is_superuser %}</a>{% endif %}
</strong> </strong>
{{ a.started|date:"Y-m-d H:i" }}{% if a.user %}, {{ a.started|date:"Y-m-d H:i" }}{% if a.user %},
......
...@@ -270,7 +270,8 @@ class VmDetailView(CheckedDetailView): ...@@ -270,7 +270,8 @@ class VmDetailView(CheckedDetailView):
}) })
# activity data # activity data
context['activities'] = self.object.get_activities(self.request.user) context['activities'] = self.object.get_merged_activities(
self.request.user)
context['vlans'] = Vlan.get_objects_with_level( context['vlans'] = Vlan.get_objects_with_level(
'user', self.request.user 'user', self.request.user
...@@ -2103,7 +2104,7 @@ def vm_activity(request, pk): ...@@ -2103,7 +2104,7 @@ def vm_activity(request, pk):
if only_status == "false": # instance activity if only_status == "false": # instance activity
context = { context = {
'instance': instance, 'instance': instance,
'activities': instance.get_activities(request.user), 'activities': instance.get_merged_activities(request.user),
'ops': get_operations(instance, request.user), 'ops': get_operations(instance, request.user),
} }
......
...@@ -927,6 +927,23 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin, ...@@ -927,6 +927,23 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
user=user) user=user)
return acts return acts
def get_merged_activities(self, user=None):
acts = list(self.get_activities(user))
merged_acts = []
latest = None
for a in acts:
if (latest == a.activity_code and
merged_acts[-1].result == a.result and
(merged_acts[-1].finished - a.finished).days < 7):
merged_acts[-1].times += 1
else:
merged_acts.append(a)
merged_acts[-1].times = 1
latest = a.activity_code
return merged_acts
def get_screenshot(self, timeout=5): def get_screenshot(self, timeout=5):
queue_name = self.get_remote_queue_name('vm') queue_name = self.get_remote_queue_name('vm')
return vm_tasks.screenshot.apply_async(args=[self.vm_name], return vm_tasks.screenshot.apply_async(args=[self.vm_name],
......
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