Hide the credit interface when editing a WEI registration

This commit is contained in:
Yohann D'ANELLO 2020-08-10 20:09:49 +02:00
parent 6567d2f8cc
commit 3784e97d60
3 changed files with 29 additions and 21 deletions

View File

@ -129,7 +129,8 @@ class WEIMembershipForm(forms.ModelForm):
attrs={
'api_url': '/api/wei/team/',
'placeholder': 'Équipe ...',
}
},
resetable=True,
),
}

View File

@ -16,6 +16,7 @@
{% endblock %}
{% block extrajavascript %}
{% if not object.membership %}
<script>
$(document).ready(function() {
function refreshTeams() {
@ -39,4 +40,5 @@
refreshTeams();
});
</script>
{% endif %}
{% endblock %}

View File

@ -607,6 +607,11 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
if not PermissionBackend.check_perm(
self.request.user, "wei.change_membership_" + field_name, self.object.membership):
field.widget = HiddenInput()
del membership_form.fields["credit_type"]
del membership_form.fields["credit_amount"]
del membership_form.fields["first_name"]
del membership_form.fields["last_name"]
del membership_form.fields["bank"]
context["membership_form"] = membership_form
elif not self.object.first_year and PermissionBackend.check_perm(
self.request.user, "wei.change_weiregistration_information_json", self.object):