Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ServiceBusinessCreationForm(forms.ModelForm):
- """ Form class that can display and validate information necessary for the creation of a ServiceBusiness object. """
- class Meta:
- """ Meta class, defines model to use and resticts fields. """
- model = ServiceBusiness
- fields = ('email', 'businessName', 'serviceTypes', 'address1',
- 'address2', 'city', 'province', 'postalCode', 'phoneNumber',
- 'website', 'description', 'additionalInfo', 'image')
- help_texts = {
- 'image': _('For best results, use an image with a height of 200 pixels. '),
- }
- def save(self, p, commit=True):
- """ Save the service business into the database.
- :param p: The person that is creating the service business
- :type p: Person.
- :returns: The newly created ServiceBusiness object
- """
- sb = super(ServiceBusinessCreationForm, self).save(commit=commit)
- # creator is added to BusinessStaff by default
- newStaff = BusinessStaff(serviceBusiness=sb, person=p,
- superStaff=True)
- if commit:
- newStaff.save()
- return sb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement