SHOW:
|
|
- or go back to the newest paste.
| 1 | class BusinessRegisterView(BaseView): | |
| 2 | ||
| 3 | """ View used to create a new service business. """ | |
| 4 | ||
| 5 | template_name = 'registration/business_register.html' | |
| 6 | ||
| 7 | def get(self, request, *args, **kwargs): | |
| 8 | """ Render the HTML template for GET requests. Displays the service business creation form. | |
| 9 | ||
| 10 | :parem request: The HTTP request object | |
| 11 | :type request: HttpRequest. | |
| 12 | ||
| 13 | :returns: HttpResponse -- HttpResponse containing a rendered HTML page | |
| 14 | ||
| 15 | """ | |
| 16 | self.context['state'] = 'Enter your information below:' | |
| 17 | self.context['form'] = ServiceBusinessCreationForm() | |
| 18 | return super(BusinessRegisterView, self).get(request, *args, **kwargs) | |
| 19 | ||
| 20 | def post(self, request, *args, **kwargs): | |
| 21 | """ Render the HTML template for POST requests. Saves the new service business to the database. | |
| 22 | ||
| 23 | :parem request: The HTTP request object | |
| 24 | :type request: HttpRequest. | |
| 25 | ||
| 26 | :returns: HttpResponse -- HttpResponse containing a rendered HTML page | |
| 27 | ||
| 28 | """ | |
| 29 | form = ServiceBusinessCreationForm(request.POST, request.FILES) | |
| 30 | if form.is_valid(): | |
| 31 | form.save(request.user, commit=True) | |
| 32 | return HttpResponseRedirect("/accounts/business/view/")
| |
| 33 | self.context['form'] = form | |
| 34 | return self.render_to_response(self.context) |