Browse Source

Issue61 (#62)

* Check for api key before attempting to use api.

* Change to read-only so we still send data on edit.
feature/upgrade-admin-visits
Drew Larson 7 years ago
committed by GitHub
parent
commit
cf1f963e5d
  1. 2
      bikeshop_project/registration/forms.py
  2. 2
      bikeshop_project/registration/handlers.py
  3. 5
      bikeshop_project/registration/templates/edit_member_form.html
  4. 5
      bikeshop_project/registration/templates/member_form.html

2
bikeshop_project/registration/forms.py

@ -27,7 +27,7 @@ class MemberForm(ModelForm):
'involvement': CheckboxSelectMultiple(choices=Member.involvement_choices,
attrs={'class': 'mdl-checkbox__input'}),
'preferred_name': TextInput(attrs={'class': 'mdl-textfield__input'}),
'guardian_name': DateInput(attrs={'class': 'mdl-textfield__input', 'disabled': 'disabled'}),
'guardian_name': DateInput(attrs={'class': 'mdl-textfield__input', 'readonly': 'readonly'}),
'phone': TextInput(attrs={'class': 'mdl-textfield__input', 'pattern': '[0-9]*'}),
'street': TextInput(attrs={'class': 'mdl-textfield__input'}),
'city': TextInput(attrs={'class': 'mdl-textfield__input'}),

2
bikeshop_project/registration/handlers.py

@ -11,7 +11,7 @@ from registration.models import Member
@receiver(post_save, sender=Member, dispatch_uid='member.save_member')
def update_mailchimp(sender, instance, **kwargs):
if instance.email:
if instance.email and settings.MAILCHIMP_API_KEY:
involvement = {id: True for id in instance.involvement}
client = MailChimp(settings.MAILCHIMP_USERNAME, settings.MAILCHIMP_API_KEY)
try:

5
bikeshop_project/registration/templates/edit_member_form.html

@ -16,11 +16,12 @@
'YYYY/MM/DD', 'YY/MM/DD', 'DD/MM/YY', 'DD/MM/YYYY']);
if (dob.add(threshold).isAfter(moment())) {
document.getElementById('{{ form.guardian_name.id_for_label }}').disabled = false;
document.getElementById('{{ form.guardian_name.id_for_label }}').readOnly = false;
document.getElementById('{{ form.guardian_name.id_for_label }}').required = true;
document.getElementById('{{ form.guardian_name.id_for_label }}').parentNode.classList.remove('is-disabled');
document.getElementById('{{ form.guardian_name.id_for_label }}').focus();
} else {
document.getElementById('{{ form.guardian_name.id_for_label }}').disabled = true;
document.getElementById('{{ form.guardian_name.id_for_label }}').readOnly = true;
document.getElementById('{{ form.guardian_name.id_for_label }}').parentNode.classList.add('is-disabled');
}
});

5
bikeshop_project/registration/templates/member_form.html

@ -15,11 +15,12 @@
'YYYY/MM/DD', 'YY/MM/DD', 'DD/MM/YY', 'DD/MM/YYYY']);
if (dob.add(threshold).isAfter(moment())) {
document.getElementById('{{ form.guardian_name.id_for_label }}').disabled = false;
document.getElementById('{{ form.guardian_name.id_for_label }}').readOnly = false;
document.getElementById('{{ form.guardian_name.id_for_label }}').required = true;
document.getElementById('{{ form.guardian_name.id_for_label }}').parentNode.classList.remove('is-disabled');
document.getElementById('{{ form.guardian_name.id_for_label }}').focus();
} else {
document.getElementById('{{ form.guardian_name.id_for_label }}').disabled = true;
document.getElementById('{{ form.guardian_name.id_for_label }}').readOnly = true;
document.getElementById('{{ form.guardian_name.id_for_label }}').parentNode.classList.add('is-disabled');
}
});

Loading…
Cancel
Save