Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. class ServiceBusinessCreationForm(forms.ModelForm):
  2.  
  3.     """ Form class that can display and validate information necessary for the creation of a ServiceBusiness object. """
  4.  
  5.     class Meta:
  6.         """ Meta class, defines model to use and resticts fields. """
  7.         model = ServiceBusiness
  8.         fields = ('email', 'businessName', 'serviceTypes', 'address1',
  9.                   'address2', 'city', 'province', 'postalCode', 'phoneNumber',
  10.                   'website', 'description', 'additionalInfo', 'image')
  11.         help_texts = {
  12.             'image': _('For best results, use an image with a height of 200 pixels. '),
  13.             }
  14.  
  15.     def save(self, p, commit=True):
  16.         """ Save the service business into the database.
  17.  
  18.     :param p: The person that is creating the service business
  19.     :type p: Person.
  20.  
  21.     :returns: The newly created ServiceBusiness object
  22.  
  23.     """
  24.         sb = super(ServiceBusinessCreationForm, self).save(commit=commit)
  25.  
  26.         # creator is added to BusinessStaff by default
  27.         newStaff = BusinessStaff(serviceBusiness=sb, person=p,
  28.                                  superStaff=True)
  29.         if commit:
  30.             newStaff.save()
  31.         return sb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement