diff --git a/commentaries/templates/commentaries/commentary_detail.html b/commentaries/templates/commentaries/commentary_detail.html index 48ff4b50d9db16dff60c67b88b573df09eebc498..e108dfefb16a5fab1eecb3750c66be91a5cedd39 100644 --- a/commentaries/templates/commentaries/commentary_detail.html +++ b/commentaries/templates/commentaries/commentary_detail.html @@ -4,19 +4,17 @@ {% block headsup %} -<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> --> - - <script> - $(document).ready(function(){ - $("#commentsbutton").click(function(){ - $("#commentslist").toggle(); - }); - $("#ratingsbutton").click(function() { - $(".ratings").toggle(); - $(".ratingsinput").toggle(); - }); - }); - </script> +<script> + $(document).ready(function(){ + $("#commentsbutton").click(function(){ + $("#commentslist").toggle(); + }); + $("#ratingsbutton").click(function() { + $(".ratings").toggle(); + $(".ratingsinput").toggle(); + }); + }); +</script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script> <script type="text/javascript">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}});</script> diff --git a/scipost/forms.py b/scipost/forms.py index fceb784338b8161c302d2f80175725fb436f8f98..f2906fd2a946d133e137357d2e5a6cbce7a04b3f 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -72,6 +72,7 @@ class UpdatePersonalDataForm(forms.ModelForm): class VetRegistrationForm(forms.Form): promote_to_rank_1 = forms.BooleanField(required=False) + refuse = forms.BooleanField(required=False) refusal_reason = forms.ChoiceField(choices=REGISTRATION_REFUSAL_CHOICES, required=False) email_response_field = forms.CharField(widget=forms.Textarea(), label='Justification (optional)', required=False) diff --git a/scipost/global_methods.py b/scipost/global_methods.py index bbdf43ddd0b6ecd9dcfd8fdfc74560ebc31ad73e..1115ac33f4b96fe12074bb93def181aad67ebee1 100644 --- a/scipost/global_methods.py +++ b/scipost/global_methods.py @@ -5,5 +5,5 @@ from .models import * class Global(object): @classmethod - def get_user(cls, request): + def get_contributor(cls, request): Contributor.objects.get(user=request.user) diff --git a/scipost/templates/scipost/vet_registration_requests.html b/scipost/templates/scipost/vet_registration_requests.html index e0c10b5c1f30ae1d7cb14901a799989fdfbe6309..02de43b1498961e3637b877d4c67111b3b6d2618 100644 --- a/scipost/templates/scipost/vet_registration_requests.html +++ b/scipost/templates/scipost/vet_registration_requests.html @@ -3,6 +3,47 @@ {% block pagetitle %}: registrations to vet{% endblock pagetitle %} {% block bodysup %} +<script> + +$( document ).ready(function() { + function toggleBoxes(specificTarget){ + if (typeof specificTarget === 'undefined') { + $('select#id_refusal_reason').parent().toggle(); + $('textarea#id_email_response_field').parent().toggle(); + } else { + for (i = 0; i < specificTarget.length; i++){ + $(specificTarget[i]).toggle() + } + } + } + toggleBoxes() + + $("input:checkbox").on('click', function(event) { + var clickedBox = $(this) + var boxes = $(this).closest('div').find('input:checkbox') + var specificTarget = $(this).closest('div').find('p').slice(2,4) + if (!clickedBox.is(":checked")){ + if ( clickedBox.prop('name') == 'refuse' && $(specificTarget[0]).is(":visible") ){ + toggleBoxes(specificTarget) + } + } + else { + if (clickedBox.attr("name") == "promote_to_rank_1"){ + $(boxes[1]).prop('checked', false); + if ($(specificTarget[0]).is(":visible")){ + toggleBoxes(specificTarget) + } + } + else if (clickedBox.attr("name") == "refuse"){ + $(boxes[0]).prop('checked', false); + if (!$(specificTarget[0]).is(":visible")){ + toggleBoxes(specificTarget) + } + } + } + }) +}); +</script> <section> {% if not contributor_to_vet %} diff --git a/scipost/views.py b/scipost/views.py index 7de287c1d33f55e383fec5804184d24b16853238..f7db831a58fea9c6b398976ba2e80bae74bb0e03 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -199,16 +199,11 @@ def already_activated(request): def vet_registration_requests(request): contributor = Contributor.objects.get(user=request.user) contributor_to_vet = Contributor.objects.filter(user__is_active=True, rank=0).first() # limit to one at a time - #if contributor_to_vet is not None: form = VetRegistrationForm() - context = {'contributor': contributor, 'contributor_to_vet': contributor_to_vet, 'form': form } + context = {'contributor_to_vet': contributor_to_vet, 'form': form } return render(request, 'scipost/vet_registration_requests.html', context) - #return render (request, 'scipost/no_registration_req_to_vet.html') -#def no_registration_req_to_vet(request): -# return render(request, 'scipost/no_registration_req_to_vet.html') - def vet_registration_request_ack(request, contributor_id): # process the form if request.method == 'POST': @@ -245,7 +240,8 @@ def login_view(request): login(request, user) contributor = Contributor.objects.get(user=request.user) context = {'contributor': contributor } - return render(request, 'scipost/personal_page.html', context) + #return render(request, 'scipost/personal_page.html', context) + return HttpResponseRedirect('/personal_page') else: return render(request, 'scipost/disabled_account.html') else: @@ -295,16 +291,12 @@ def change_password(request): if request.user.is_authenticated and request.method == 'POST': form = PasswordChangeForm(request.POST) if form.is_valid(): - # verify existing password: if not request.user.check_password(form.cleaned_data['password_prev']): return render(request, 'scipost/change_password.html', {'form': form, 'errormessage': 'The currently existing password you entered is incorrect'}) - # check for mismatching new passwords if form.cleaned_data['password_new'] != form.cleaned_data['password_verif']: return render(request, 'scipost/change_password.html', {'form': form, 'errormessage': 'Your new password entries must match'}) - # otherwise simply change the pwd: request.user.set_password(form.cleaned_data['password_new']) request.user.save() - #return render(request, 'scipost/change_password_ack.html') context = {'acknowledgment': True, 'form': PasswordChangeForm()} return render(request, 'scipost/change_password.html', context) else: @@ -312,10 +304,6 @@ def change_password(request): return render (request, 'scipost/change_password.html', {'form': form}) -#def change_password_ack(request): -# return render (request, 'scipost/change_password_ack.html') -# - def update_personal_data(request): if request.user.is_authenticated: contributor = Contributor.objects.get(user=request.user)