Commit 41f67637 authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos

Fixed an issue with Institution Servers proxying.

Institution Realm can be proxied only to Institution Servers with
ertype IdP or Idp/SP. Fixed a bug where this condition was not
respected. This closes #3148
parent 8c663060
......@@ -124,6 +124,17 @@ class InstRealmForm(forms.ModelForm):
class Meta:
model = InstRealm
def clean_proxyto(self):
proxied_servers = self.cleaned_data['proxyto']
if proxied_servers:
for server in proxied_servers:
if server.ertype not in [1,3]:
error_text = _('Only IdP and IdP/SP server types are allowed')
raise forms.ValidationError(error_text)
else:
raise forms.ValidationError(_('This field is required.'))
return self.cleaned_data["proxyto"]
class ServiceLocForm(forms.ModelForm):
......
......@@ -209,7 +209,7 @@ class InstRealm(models.Model):
# accept if instid.ertype: 1 (idp) or 3 (idpsp)
realm = models.CharField(max_length=160)
instid = models.ForeignKey("Institution",verbose_name="Institution")
proxyto = models.ManyToManyField("InstServer")
proxyto = models.ManyToManyField("InstServer", help_text=_("Only IdP and IdP/SP server types are allowed"))
class Meta:
verbose_name = "Institution Realm"
......
......@@ -454,7 +454,7 @@ def add_realm(request, realm_pk):
messages.add_message(request, messages.ERROR, 'You have no rights to edit this realm')
return HttpResponseRedirect(reverse("realms"))
form.fields['instid'] = forms.ModelChoiceField(queryset=Institution.objects.filter(pk=inst.pk), empty_label=None)
form.fields['proxyto'] = forms.ModelMultipleChoiceField(queryset=InstServer.objects.filter(pk__in=getInstServers(inst)))
form.fields['proxyto'] = forms.ModelMultipleChoiceField(queryset=InstServer.objects.filter(pk__in=getInstServers(inst, True)))
if realm:
edit = True
return render_to_response('edumanage/realms_edit.html', { 'form': form, 'edit': edit },
......@@ -474,7 +474,7 @@ def add_realm(request, realm_pk):
return HttpResponseRedirect(reverse("realms"))
else:
form.fields['instid'] = forms.ModelChoiceField(queryset=Institution.objects.filter(pk=inst.pk), empty_label=None)
form.fields['proxyto'] = forms.ModelMultipleChoiceField(queryset=InstServer.objects.filter(pk__in=getInstServers(inst)))
form.fields['proxyto'] = forms.ModelMultipleChoiceField(queryset=InstServer.objects.filter(pk__in=getInstServers(inst, True)))
if realm:
edit = True
return render_to_response('edumanage/realms_edit.html', { 'institution': inst, 'form': form, 'edit': edit },
......@@ -1414,8 +1414,10 @@ def getInstContacts(inst):
contact_pks.append(contact.contact.pk)
return list(set(contact_pks))
def getInstServers(inst):
def getInstServers(inst, idpsp=False):
servers = InstServer.objects.filter(instid=inst)
if idpsp:
servers = servers.filter(ertype__in=[1,3])
server_pks = []
for server in servers:
server_pks.append(server.pk)
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-12-06 18:01+0200\n"
"POT-Creation-Date: 2012-12-14 12:17+0200\n"
"PO-Revision-Date: 2012-10-23 11:29+0300\n"
"Last-Translator: Leonidas Poulopoulos <leopoul@noc.grnet.gr>\n"
"Language-Team: Greek <leopoul@noc.grnet.gr>\n"
......@@ -25,11 +25,11 @@ msgstr "Ελληνικά"
msgid "English"
msgstr "Αγγλικά"
#: settings.py:175
#: settings.py:183
msgid "Greece"
msgstr "Ελλάδα"
#: settings.py:182
#: settings.py:190
msgid "GRNET Helpdesk"
msgstr ""
......@@ -39,7 +39,7 @@ msgid "%sUser account activated"
msgstr ""
#: edumanage/forms.py:77 edumanage/forms.py:86 edumanage/forms.py:95
#: edumanage/forms.py:114
#: edumanage/forms.py:114 edumanage/forms.py:136
msgid "This field is required."
msgstr "Αυτό το πεδίο είναι απαραίτητο"
......@@ -47,11 +47,16 @@ msgstr "Αυτό το πεδίο είναι απαραίτητο"
msgid "Invalid network address/hostname format"
msgstr "Λανθασμένη IP διεύθυνση ή όνομα host"
#: edumanage/forms.py:150 edumanage/forms.py:152
#: edumanage/forms.py:133 edumanage/models.py:212
#: templates/edumanage/realms_edit.html:53
msgid "Only IdP and IdP/SP server types are allowed"
msgstr "Επιτρέπονται servers τύπου IdP ή IdP/SP"
#: edumanage/forms.py:161 edumanage/forms.py:163
msgid "Fill in at least one location name in English"
msgstr "Συμπληρώστε τουλάχιστον ένα όνομα στα Αγγλικά"
#: edumanage/forms.py:177 edumanage/forms.py:179
#: edumanage/forms.py:188 edumanage/forms.py:190
msgid "Fill in at least the info url"
msgstr "Συμπληρώστε τουλάχιστον το info url"
......@@ -143,23 +148,23 @@ msgid ""
"%(numid)s"
msgstr ""
#: edumanage/views.py:985
#: edumanage/views.py:984
msgid ""
"Your idP should release the eduPersonPrincipalName attribute towards this "
"service<br>"
msgstr ""
#: edumanage/views.py:987
#: edumanage/views.py:986
msgid ""
"Your idP should release an appropriate eduPersonEntitlement attribute "
"towards this service<br>"
msgstr ""
#: edumanage/views.py:989
#: edumanage/views.py:988
msgid "Your idP should release the mail attribute towards this service"
msgstr ""
#: edumanage/views.py:1016 edumanage/views.py:1060
#: edumanage/views.py:1015 edumanage/views.py:1059
#, python-format
msgid ""
"User account <strong>%s</strong> is pending activation. Administrators have "
......@@ -173,19 +178,19 @@ msgstr ""
"μεγάλο<br>χρονικό διάστημα, επικοινωνήστε με τον τεχνικό σας υπεύθυνο ή το "
"Helpdesk της ΕΔΕΤ"
#: edumanage/views.py:1020
#: edumanage/views.py:1019
#, python-format
msgid ""
"Something went wrong during user authentication. Contact your administrator "
"%s"
msgstr ""
#: edumanage/views.py:1024
#: edumanage/views.py:1023
#, python-format
msgid "Invalid login procedure. Error: %s"
msgstr "Λανθασμένη διαδικασία εισαγωγής στη διαχείριση. Σφάλμα: %s"
#: edumanage/views.py:1050
#: edumanage/views.py:1049
msgid ""
"Violation warning: User account is already associated with an institution."
"The event has been logged and our administrators will be notified about it"
......
......@@ -49,8 +49,8 @@
<label class="control-label" for="id_proxyto"><b>{% trans "Proxy to Servers" %}</b></label>
<div class="controls">
{{ form.proxyto }}
{% if form.proxyto.errors %} <span class="help-inline"> {{ form.proxyto.errors|join:", " }} </span>
{% endif %} <span class="help-block"> {{ form.proxyto.help_text }}</span>
{% if form.proxyto.errors %}<span class="help-inline"> {{ form.proxyto.errors|join:", " }} </span>
{% endif %}<span class="help-block">{% trans "Only IdP and IdP/SP server types are allowed" %}</span>
</div>
</div>
<div class="control-group">
......
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