diff --git a/www/web/warpauth/templates/warpauth/profile/information.html b/www/web/warpauth/templates/warpauth/profile/information.html index 6e5622a91a783a218f64fe3a6140fd96ee28dd95..bb9771a4e758568ec0923cdc0d9b5e79754e5110 100644 --- a/www/web/warpauth/templates/warpauth/profile/information.html +++ b/www/web/warpauth/templates/warpauth/profile/information.html @@ -7,7 +7,7 @@ <div class="panel panel-default"> <div class="panel-body"> {% if error_info %} - <div class="alert alert-danger">{{ error_info }}</div><br> + <div class="alert alert-danger">{% trans error_info %}</div><br> {% endif %} {% if success_info %} <div class="alert alert-success">{% trans "information_changed_successfully" %}</div><br> diff --git a/www/web/warpauth/views/profile.py b/www/web/warpauth/views/profile.py index c4d3868faea3a0061be31e73280722ef1704cfde..3505b7e1904b6da83a6812497548a9d70503cdae 100644 --- a/www/web/warpauth/views/profile.py +++ b/www/web/warpauth/views/profile.py @@ -44,16 +44,28 @@ def change_information(request): if request.method != 'POST': return redirect("profile_index") + user = LdapUser.objects.get(uid=str(request.user)) - first_name = request.POST["first_name"] - last_name = request.POST["last_name"] + if "first_name" in request.POST: + first_name = request.POST["first_name"] + if "last_name" in request.POST: + last_name = request.POST["last_name"] + + if "card_id" in request.POST: + card_id = request.POST["card_id"] + else: + card_id = 0 + + if "email" not in request.POST: + page_context["error_info"] = "err_invalid_email" + return HttpResponse(render(request, 'warpauth/profile.html', page_context)) + email = request.POST["email"] - card_id = request.POST["card_id"] f = forms.EmailField() try: f.clean(email) except ValidationError as e: - page_context["error_info"] = "Invalid Email" + page_context["error_info"] = "err_invalid_email" return HttpResponse(render(request, 'warpauth/profile.html', page_context)) cn = first_name + " " + last_name cn = cn.strip()