diff --git a/contributors/templates/contributors/personal_page.html b/contributors/templates/contributors/personal_page.html index fe76f74d559f5c686fee97f003dba48b2d2fd208..3c340b2aaaa486d544f01c802b135eabf6465927 100644 --- a/contributors/templates/contributors/personal_page.html +++ b/contributors/templates/contributors/personal_page.html @@ -62,9 +62,18 @@ {% if contributor.rank > 0 %} <section> <h1>Your SciPost Account</h1> - <ul> - <li><a href="{% url 'contributors:change_password' %}">Change your password</a></li> - </ul> + <div class="row"> + <div class="col-6"> + <ul> + <li><a href="{% url 'contributors:update_personal_data' %}">Update your personal data</a></li> + </ul> + </div> + <div class="col-6"> + <ul> + <li><a href="{% url 'contributors:change_password' %}">Change your password</a></li> + </ul> + </div> + </div> <hr> <div class="row"> <div class="col-3"> diff --git a/contributors/templates/contributors/update_personal_data.html b/contributors/templates/contributors/update_personal_data.html new file mode 100644 index 0000000000000000000000000000000000000000..9ee3a82a002907d86c9534f0c16d70fe98aa194a --- /dev/null +++ b/contributors/templates/contributors/update_personal_data.html @@ -0,0 +1,20 @@ +{% extends 'scipost/base.html' %} + +{% block pagetitle %}: update personal data{% endblock pagetitle %} + +{% block bodysup %} + +<section> + <h1>Update your personal data</h1> + <form action="{% url 'contributors:update_personal_data' %}" method="post"> + {% csrf_token %} + <table> + <ul> + {{ form.as_table }} + </ul> + </table> + <input type="submit" value="Update" /> + </form> +</section> + +{% endblock bodysup %} diff --git a/contributors/templates/contributors/update_personal_data_ack.html b/contributors/templates/contributors/update_personal_data_ack.html new file mode 100644 index 0000000000000000000000000000000000000000..4c42437590e4fea48f3717e74f5d811ee1d29959 --- /dev/null +++ b/contributors/templates/contributors/update_personal_data_ack.html @@ -0,0 +1,11 @@ +{% extends 'scipost/base.html' %} + +{% block pagetitle %}: personal data updated{% endblock pagetitle %} + +{% block bodysup %} + +<section> + <h1>Your personal data has been updated</h1> +</section> + +{% endblock bodysup %} diff --git a/contributors/urls.py b/contributors/urls.py index 812c540708a8972adeecfea37a0bcb6ccefed1b7..3c1ef889f69d70543a8d267b6c96d63412f965bd 100644 --- a/contributors/urls.py +++ b/contributors/urls.py @@ -14,4 +14,6 @@ urlpatterns = [ url(r'^personal_page$', views.personal_page, name='personal_page'), url(r'^change_password$', views.change_password, name='change_password'), url(r'^change_password_ack$', views.change_password_ack, name='change_password_ack'), + url(r'^update_personal_data$', views.update_personal_data, name='update_personal_data'), + url(r'^update_personal_data_ack$', views.update_personal_data_ack, name='update_personal_data_ack'), ] diff --git a/contributors/views.py b/contributors/views.py index f7b5b0949724fdf0b9a1731d5bab94013829043d..25b6ff76de6b095115aac667cedebbb083d10350 100644 --- a/contributors/views.py +++ b/contributors/views.py @@ -50,12 +50,13 @@ def register(request): contributor = Contributor ( user=user, title = form.cleaned_data['title'], + orcid_id = form.cleaned_data['orcid_id'], address = form.cleaned_data['address'], affiliation = form.cleaned_data['affiliation'], personalwebpage = form.cleaned_data['personalwebpage'], ) contributor.save() - email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\n Your request for registration to the SciPost publication portal has been received, and will be processed soon. Many thanks for your interest. \n\n The SciPost Team.' + email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour request for registration to the SciPost publication portal has been received, and will be processed soon. Many thanks for your interest. \n\nThe SciPost Team.' emailmessage = EmailMessage('SciPost registration request received', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) emailmessage.send(fail_silently=False) return HttpResponseRedirect('thanks_for_registering') @@ -88,12 +89,12 @@ def vet_registration_request_ack(request, contributor_id): if form.cleaned_data['promote_to_rank_1']: contributor.rank = 1 contributor.save() - email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\n Your registration to the SciPost publication portal has been accepted. You can now login and contribute. \n\n The SciPost Team.' + email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour registration to the SciPost publication portal has been accepted. You can now login and contribute. \n\nThe SciPost Team.' emailmessage = EmailMessage('SciPost registration accepted', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) emailmessage.send(fail_silently=False) else: ref_reason = int(form.cleaned_data['refusal_reason']) - email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\n Your registration to the SciPost publication portal has been turned down, the reason being: ' + reg_ref_dict[ref_reason] + '. You can however still view all SciPost contents, just not submit papers, comments or votes. We nonetheless thank you for your interest. \n\n The SciPost Team.' + email_text = 'Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour registration to the SciPost publication portal has been turned down, the reason being: ' + reg_ref_dict[ref_reason] + '. You can however still view all SciPost contents, just not submit papers, comments or votes. We nonetheless thank you for your interest. \n\nThe SciPost Team.' if form.cleaned_data['email_response_field']: email_text += '\n\nFurther explanations: ' + form.cleaned_data['email_response_field'] emailmessage = EmailMessage('SciPost registration: unsuccessful', email_text, 'registration@scipost.org', [contributor.user.email, 'registration@scipost.org'], reply_to=['registration@scipost.org']) @@ -178,3 +179,33 @@ def change_password(request): @csrf_protect def change_password_ack(request): return render (request, 'contributors/change_password_ack.html') + +@csrf_protect +def update_personal_data(request): + if request.user.is_authenticated: + contributor = Contributor.objects.get(user=request.user) + if request.method == 'POST': + form = UpdatePersonalDataForm(request.POST) + if form.is_valid(): + request.user.email = form.cleaned_data['email'] + request.user.first_name = form.cleaned_data['first_name'] + request.user.last_name = form.cleaned_data['last_name'] + request.user.contributor.title = form.cleaned_data['title'] + request.user.contributor.orcid = form.cleaned_data['orcid_id'] + request.user.contributor.address = form.cleaned_data['address'] + request.user.contributor.affiliation = form.cleaned_data['affiliation'] + request.user.contributor.personalwebpage = form.cleaned_data['personalwebpage'] + request.user.save() + request.user.contributor.save() + return render(request, 'contributors/update_personal_data_ack.html') + else: + form = UpdatePersonalDataForm() + return render(request, 'contributors/update_personal_data.html', {'form': form, 'contributor': contributor}) + else: + form = AuthenticationForm() + return render(request, 'contributors/login.html', {'form': form}) + +@csrf_protect +def update_personal_data_ack(request): + return render (request, 'contributors/update_personal_data_ack.html') +