Commit b63173e2 by Bach Dániel

Merge branch 'issue-292' into 'master'

Template traits and tags aren't editable
parents 986920ab 86cd1095
...@@ -524,10 +524,6 @@ class TemplateForm(forms.ModelForm): ...@@ -524,10 +524,6 @@ class TemplateForm(forms.ModelForm):
value = field.widget.value_from_datadict( value = field.widget.value_from_datadict(
self.data, self.files, self.add_prefix(name)) self.data, self.files, self.add_prefix(name))
try: try:
if isinstance(field, forms.FileField):
initial = self.initial.get(name, field.initial)
value = field.clean(value, initial)
else:
value = field.clean(value) value = field.clean(value)
self.cleaned_data[name] = value self.cleaned_data[name] = value
if hasattr(self, 'clean_%s' % name): if hasattr(self, 'clean_%s' % name):
...@@ -544,13 +540,14 @@ class TemplateForm(forms.ModelForm): ...@@ -544,13 +540,14 @@ class TemplateForm(forms.ModelForm):
else: else:
self.cleaned_data[name] = getattr(old, name) self.cleaned_data[name] = getattr(old, name)
if "req_traits" not in self.allowed_fields:
self.cleaned_data['req_traits'] = self.instance.req_traits.all()
def save(self, commit=True): def save(self, commit=True):
data = self.cleaned_data data = self.cleaned_data
self.instance.max_ram_size = data.get('ram_size') self.instance.max_ram_size = data.get('ram_size')
instance = super(TemplateForm, self).save(commit=False) instance = super(TemplateForm, self).save(commit=True)
if commit:
instance.save()
# create and/or delete InterfaceTemplates # create and/or delete InterfaceTemplates
networks = InterfaceTemplate.objects.filter( networks = InterfaceTemplate.objects.filter(
......
...@@ -23,18 +23,15 @@ ...@@ -23,18 +23,15 @@
{% csrf_token %} {% csrf_token %}
{{ form.name|as_crispy_field }} {{ form.name|as_crispy_field }}
<a {% if form.parent.value %}
href="{% url "dashboard.views.template-detail" pk=form.parent.value %}" <strong>{% trans "Parent template" %}:</strong>
{% if parent %}
<a href="{% url "dashboard.views.template-detail" pk=parent.pk %}">
{{ parent.name }}
</a>
{% else %} {% else %}
disabled %} -
{% endif %} {% endif %}
class="btn btn-default pull-right" style="margin-top: 24px;">
{% trans "Visit" %}
<i class="fa fa-arrow-circle-right"></i>
</a>
<div style="width: 80%;">
{{ form.parent|as_crispy_field }}
</div>
<fieldset class="resources-sliders"> <fieldset class="resources-sliders">
<legend>{% trans "Resource configuration" %}</legend> <legend>{% trans "Resource configuration" %}</legend>
......
...@@ -300,6 +300,7 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView): ...@@ -300,6 +300,7 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
context['disks'] = obj.disks.all() context['disks'] = obj.disks.all()
context['is_owner'] = obj.has_level(self.request.user, 'owner') context['is_owner'] = obj.has_level(self.request.user, 'owner')
context['aclform'] = AclUserOrGroupAddForm() context['aclform'] = AclUserOrGroupAddForm()
context['parent'] = obj.parent
return context return context
def get_success_url(self): def get_success_url(self):
......
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