Commit c0a7e245 authored by Zenon Mousmoulas's avatar Zenon Mousmoulas

Merge branch 'bugfix'

Fixes a logical issue that could be caused by editing InstServer properties
parents c7a225e2 1f0f08cc
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
<h4>{% if edit %}{{form.instance.get_name}} ({% trans "edit" %}){% else %}{% trans "Add Server" %}{% endif %}</h4> <h4>{% if edit %}{{form.instance.get_name}} ({% trans "edit" %}){% else %}{% trans "Add Server" %}{% endif %}</h4>
<hr> <hr>
<form method="POST" class="form-horizontal"> <form method="POST" class="form-horizontal">
{% csrf_token %}
{% if form.non_field_errors %} {% if form.non_field_errors %}
<p class="error"> <ul>
{{ form.non_field_errors}} {% for error in form.non_field_errors %}
</p> <li class="alert-danger"><strong>{{ error }}</strong></li>
{% endfor %}
</ul>
{% endif %} {% endif %}
{% csrf_token %}
<div style="display: none"> <div style="display: none">
{{form.instid}} {{form.instid}}
</div> </div>
......
...@@ -9,6 +9,7 @@ from django.core import exceptions ...@@ -9,6 +9,7 @@ from django.core import exceptions
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django import forms from django import forms
from django.core.exceptions import ValidationError
class MultiSelectFormField(forms.MultipleChoiceField): class MultiSelectFormField(forms.MultipleChoiceField):
...@@ -261,6 +262,19 @@ class InstServer(models.Model): ...@@ -261,6 +262,19 @@ class InstServer(models.Model):
return self.name return self.name
return self.host return self.host
# If a server is a proxy for a realm, can not change type to SP
def clean(self):
if self.ertype == 2:
realms = InstRealm.objects.filter(proxyto=self)
if len(realms) > 0:
text = str()
for realm in realms:
text = text + ' ' + realm.realm
raise ValidationError(
'You cannot change this server to SP (it is used by realms %s)' %
', '.join([r.realm for r in realms])
)
class InstRealmMon(models.Model): class InstRealmMon(models.Model):
''' '''
......
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 to comment