Commit af05a3bd by Kálmán Viktor

Merge branch 'issue-266' into 'master'

Link base template of instances
parents 8e3bcfa1 8bb412e3
...@@ -94,7 +94,13 @@ ...@@ -94,7 +94,13 @@
<dt>{% trans "Template" %}:</dt> <dt>{% trans "Template" %}:</dt>
<dd> <dd>
{% if instance.template %} {% if instance.template %}
{% if can_link_template %}
<a href="{{ instance.template.get_absolute_url }}">
{{ instance.template.name }} {{ 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,11 @@ class VmDetailView(CheckedDetailView): ...@@ -349,6 +349,11 @@ 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 and instance.template.has_level(user, "operator")
)
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