Ejemplo n.º 1
0
	def get_context_data(self, **kwargs):
		kwargs['potluck_items'] = self.get_potluckItem()
		if 'user_form' not in kwargs:
			kwargs['user_form'] = potluck_models.UserForm(self.request.GET or None)
		if 'potluck_form' not in kwargs:
			kwargs['potluck_form'] = potluck_models.PotluckItemForm(self.request.GET or None)
		return kwargs
Ejemplo n.º 2
0
	def post(self, request, *args, **kwargs):
		potluck_form = self.form_class(request.POST)
		user_form = potluck_models.UserForm()
		if potluck_form.is_valid():
			potluck_form.save()
			return self.render_to_response(self.get_context_data(success=True))
		else:
			return self.render_to_response(self.get_context_data(user_form=user_form,potluck_form=potluck_form))
Ejemplo n.º 3
0
	def post(self, request, *args, **kwargs):
		ctxt = {}
		if 'potluckitem' in request.POST:
			potluck_form = potluck_models.PotluckItemForm(request.POST)
			user_form = potluck_models.UserForm()
			if potluck_form.is_valid():
				potluck_form.save()
				potluck_form = potluck_models.PotluckItemForm()
				ctxt['potluck_form'] = potluck_form
				return HttpResponseRedirect('/')
			else:
				ctxt['potluck_form'] = potluck_form
		if 'deletePotluckitem' in request.POST:
			itemDict = dict(request.POST.iterlists())
			itemID = itemDict['deletePotluckitem'][0]
			potluck_form = potluck_models.PotluckItemForm(request.POST)
			self.delete(request, itemID, *args, **kwargs)
			ctxt['potluck_form'] = potluck_form
		return render(request, self.template_name, self.get_context_data(**ctxt))