1
0
mirror of https://github.com/fspc/workstand.git synced 2025-04-04 10:03:22 -04:00
Drew Larson 49f37ed492 Add member notes (#35)
* Linting.

* Clean up.

* Hope this makes installs better.

* Rework edit member form with notes and banned and suspended.

* Add slack notifications.

* Display new member statuses.

* Update docker run command

migrate, collectstatic, and rebuild_index

* Formatting and only push when master.

* Don’t need this for an edit page.

* More meaningful action.

* Add testing requirements.

* Run tests during build.

* Use prod settings for testing.

* Nail down the order of those tests.
2017-02-16 22:53:49 -06:00

53 lines
2.6 KiB
Python

from django.forms import ModelForm, EmailInput, TextInput, DateInput, CheckboxInput, BooleanField, Textarea
from django.utils import timezone
from registration.models import Member
class MemberForm(ModelForm):
waiver_substitute = BooleanField(required=False, label='I have read and agree to the above terms & conditions.',
widget=CheckboxInput(attrs={'class': 'mdl-checkbox__input'}))
class Meta:
model = Member
exclude = ('waiver',)
fields = ['email', 'email_consent', 'first_name', 'last_name', 'preferred_name', 'date_of_birth',
'guardian_name', 'phone', 'street', 'city', 'province', 'country', 'post_code', 'waiver',
'banned', 'suspended', 'notes']
widgets = {
'email': EmailInput(attrs={'class': 'mdl-textfield__input'}),
'email_consent': CheckboxInput(attrs={'class': 'mdl-checkbox__input'}),
'first_name': TextInput(attrs={'class': 'mdl-textfield__input'}),
'last_name': TextInput(attrs={'class': 'mdl-textfield__input'}),
'preferred_name': TextInput(attrs={'class': 'mdl-textfield__input'}),
'date_of_birth': DateInput(attrs={'class': 'mdl-textfield__input'}),
'guardian_name': DateInput(attrs={'class': 'mdl-textfield__input', 'disabled': 'disabled'}),
'phone': TextInput(attrs={'class': 'mdl-textfield__input', 'pattern': '[0-9]*'}),
'street': TextInput(attrs={'class': 'mdl-textfield__input'}),
'city': TextInput(attrs={'class': 'mdl-textfield__input'}),
'province': TextInput(attrs={'class': 'mdl-textfield__input'}),
'country': TextInput(attrs={'class': 'mdl-textfield__input'}),
'post_code': TextInput(attrs={'class': 'mdl-textfield__input',
'pattern': '[A-Za-z][0-9][A-Za-z] [0-9][A-Za-z][0-9]'}),
'notes': Textarea(attrs={'class': 'mdl-textfield__input'}),
'suspended': CheckboxInput(attrs={'class': 'mdl-checkbox__input'}),
'banned': CheckboxInput(attrs={'class': 'mdl-checkbox__input'}),
}
labels = {
'email_consent': 'I consent to receiving digital communication from the BCBC.'
}
def clean(self):
super(MemberForm, self).clean()
def save(self, *args, **kwargs):
commit = kwargs.pop('commit', True)
instance = super(MemberForm, self).save(*args, commit=False, **kwargs)
if self.cleaned_data['waiver_substitute']:
instance.waiver = timezone.now()
if commit:
instance.save()
return instance