from django.core.context_processors import request
from django.template.context import RequestContext
from django.template.loader import get_template, render_to_string
-from django.utils import simplejson
+from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from django.contrib import messages
from flowspy.accounts.models import *
applier_peer_networks = request.user.get_profile().peer.networks.all()
if not applier_peer_networks:
messages.add_message(request, messages.WARNING,
- "Insufficient rights on administrative networks. Cannot add rule. Contact your administrator")
+ _("Insufficient rights on administrative networks. Cannot add rule. Contact your administrator"))
return HttpResponseRedirect(reverse("group-routes"))
if request.method == "GET":
form = RouteForm()
if not request.user.is_superuser:
form.fields['then'] = forms.ModelMultipleChoiceField(queryset=ThenAction.objects.filter(action__in=settings.UI_USER_THEN_ACTIONS).order_by('action'), required=True)
+ form.fields['protocol'] = forms.ModelMultipleChoiceField(queryset=MatchProtocol.objects.filter(protocol__in=settings.UI_USER_PROTOCOLS).order_by('protocol'), required=False)
return render_to_response('apply.html', {'form': form, 'applier': applier},
context_instance=RequestContext(request))
route_edit_applier_peer = route_edit.applier.get_profile().peer
if applier_peer != route_edit_applier_peer:
messages.add_message(request, messages.WARNING,
- "Insufficient rights to edit rule %s" %(route_slug))
+ _("Insufficient rights to edit rule %s") %(route_slug))
return HttpResponseRedirect(reverse("group-routes"))
# if route_edit.status == "ADMININACTIVE" :
# messages.add_message(request, messages.WARNING,
# return HttpResponseRedirect(reverse("group-routes"))
if route_edit.status == "PENDING" :
messages.add_message(request, messages.WARNING,
- "Cannot edit a pending rule: %s." %(route_slug))
+ _("Cannot edit a pending rule: %s.") %(route_slug))
return HttpResponseRedirect(reverse("group-routes"))
route_original = deepcopy(route_edit)
if request.POST:
form = RouteForm(dictionary)
if not request.user.is_superuser:
form.fields['then'] = forms.ModelMultipleChoiceField(queryset=ThenAction.objects.filter(action__in=settings.UI_USER_THEN_ACTIONS).order_by('action'), required=True)
+ form.fields['protocol'] = forms.ModelMultipleChoiceField(queryset=MatchProtocol.objects.filter(protocol__in=settings.UI_USER_PROTOCOLS).order_by('protocol'), required=False)
return render_to_response('apply.html', {'form': form, 'edit':True, 'applier': applier},
context_instance=RequestContext(request))
if applier_peer == requester_peer:
route.status = "PENDING"
route.expires = datetime.date.today()
+ route.applier = request.user
route.save()
route.commit_delete()
requesters_address = request.META['HTTP_X_FORWARDED_FOR']
if not mail:
error_mail = True
if error_username:
- error = "Your idP should release the HTTP_EPPN attribute towards this service<br>"
+ error = _("Your idP should release the HTTP_EPPN attribute towards this service<br>")
if error_orgname:
- error = error + "Your idP should release the HTTP_SHIB_HOMEORGANIZATION attribute towards this service<br>"
+ error = error + _("Your idP should release the HTTP_SHIB_HOMEORGANIZATION attribute towards this service<br>")
if error_entitlement:
- error = error + "Your idP should release an appropriate HTTP_SHIB_EP_ENTITLEMENT attribute towards this service<br>"
+ error = error + _("Your idP should release an appropriate HTTP_SHIB_EP_ENTITLEMENT attribute towards this service<br>")
if error_mail:
- error = error + "Your idP should release the HTTP_SHIB_INETORGPERSON_MAIL attribute towards this service"
+ error = error + _("Your idP should release the HTTP_SHIB_INETORGPERSON_MAIL attribute towards this service")
if error_username or error_orgname or error_entitlement or error_mail:
return render_to_response('error.html', {'error': error, "missing_attributes": True},
context_instance=RequestContext(request))
peer = Peer.objects.get(domain_name=organization)
up = UserProfile.objects.get_or_create(user=user,peer=peer)
except:
- error = "Your organization's domain name does not match our peers' domain names<br>Please contact Helpdesk to resolve this issue"
+ error = _("Your organization's domain name does not match our peers' domain names<br>Please contact Helpdesk to resolve this issue")
return render_to_response('error.html', {'error': error})
if not user_exists:
user_activation_notify(user)
login(request, user)
return HttpResponseRedirect(reverse("group-routes"))
else:
- error = "User account <strong>%s</strong> is pending activation. Administrators have been notified and will activate this account within the next days. <br>If this account has remained inactive for a long time contact your technical coordinator or GRNET Helpdesk" %user.username
+ error = _("User account <strong>%s</strong> is pending activation. Administrators have been notified and will activate this account within the next days. <br>If this account has remained inactive for a long time contact your technical coordinator or GRNET Helpdesk") %user.username
return render_to_response('error.html', {'error': error, 'inactive': True},
context_instance=RequestContext(request))
else:
- error = "Something went wrong during user authentication. Contact your administrator"
+ error = _("Something went wrong during user authentication. Contact your administrator")
return render_to_response('error.html', {'error': error,},
context_instance=RequestContext(request))
except Exception:
- error = "Invalid login procedure"
+ error = _("Invalid login procedure")
return render_to_response('error.html', {'error': error,},
context_instance=RequestContext(request))
# Return an 'invalid login' error message.
response_data = {}
response_data['pk'] = "%s" %then.pk
response_data['value'] = "%s:%s" %(then.action, then.action_value)
- return HttpResponse(simplejson.dumps(response_data), mimetype='application/json')
+ return HttpResponse(json.dumps(response_data), mimetype='application/json')
else:
return render_to_response('add_rate_limit.html', {'form': form,},
context_instance=RequestContext(request))
response_data = {}
response_data['value'] = "%s" %port.pk
response_data['text'] = "%s" %port.port
- return HttpResponse(simplejson.dumps(response_data), mimetype='application/json')
+ return HttpResponse(json.dumps(response_data), mimetype='application/json')
else:
return render_to_response('add_port.html', {'form': form,},
context_instance=RequestContext(request))
techmails_list = []
user_mail = "%s" %user.email
user_mail = user_mail.split(';')
- techmails = user.get_profile().peer.techc()
+ techmails = user.get_profile().peer.techc_emails.all()
if techmails:
- techmails_list = techmails.split(';')
+ for techmail in techmails:
+ techmails_list.append(techmail.email)
if settings.NOTIFY_ADMIN_MAILS:
additional_mail = settings.NOTIFY_ADMIN_MAILS
# mail.extend(user_mail)