Commit 97d83242 by Kálmán Viktor

dashboard: link base template of instance

Also fixing a dog issue
parent 824c85f5
...@@ -94,7 +94,13 @@ ...@@ -94,7 +94,13 @@
<dt>{% trans "Template" %}:</dt> <dt>{% trans "Template" %}:</dt>
<dd> <dd>
{% if instance.template %} {% if instance.template %}
{{ instance.template.name }} {% if can_link_template %}
<a href="{{ instance.template.get_absolute_url }}">
{{ instance.template.name }}
</a>
{% else %}
{{ instance.template.name }}
{% endif %}
{% else %} {% else %}
- -
{% endif %} {% endif %}
......
...@@ -336,7 +336,7 @@ class VmDetailView(CheckedDetailView): ...@@ -336,7 +336,7 @@ class VmDetailView(CheckedDetailView):
# resources forms # resources forms
can_edit = ( can_edit = (
instance in Instance.get_objects_with_level("owner", user) instance.has_level(user, "owner")
and self.request.user.has_perm("vm.change_resources")) and self.request.user.has_perm("vm.change_resources"))
context['resources_form'] = VmResourcesForm( context['resources_form'] = VmResourcesForm(
can_edit=can_edit, instance=instance) can_edit=can_edit, instance=instance)
...@@ -349,6 +349,12 @@ class VmDetailView(CheckedDetailView): ...@@ -349,6 +349,12 @@ class VmDetailView(CheckedDetailView):
context['can_change_resources'] = self.request.user.has_perm( context['can_change_resources'] = self.request.user.has_perm(
"vm.change_resources") "vm.change_resources")
# can link template
context['can_link_template'] = (
instance.template.has_level(user, "operator")
if instance.template else False
)
return context return context
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
......
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