def commit(self): '''Process the form action''' #create product and set fields for individual products if self.cleaned_data['type'] == "IndividualProduct": prod = amod.IndividualProduct() prod.pid = self.cleaned_data['pid'] #create product and set fields for bulk products elif self.cleaned_data['type'] == "BulkProduct": prod = amod.BulkProduct() prod.quantity = self.cleaned_data['quantity'] prod.reorder_trigger = self.cleaned_data['reorder_trigger'] prod.reorder_quantity = self.cleaned_data['reorder_quantity'] #create product and set fields for rental products elif self.cleaned_data['type'] == "RentalProduct": prod = amod.RentalProduct() prod.pid = self.cleaned_data['pid'] prod.max_rental_days = self.cleaned_data['max_rental_days'] prod.retire_date = self.cleaned_data['retire_date'] #set the common fields for all products prod.name = self.cleaned_data['name'] prod.status = self.cleaned_data['status'] prod.description = self.cleaned_data['description'] prod.price = self.cleaned_data['price'] prod.category = self.cleaned_data['category'] #save the updated data for the objects prod.save()
def commit(self): if self.cleaned_data.get('type') == 'BulkProduct': product = cmod.BulkProduct() product.category = self.cleaned_data.get('category') product.type = self.cleaned_data.get('type') product.name = self.cleaned_data.get('name') product.description = self.cleaned_data.get('description') product.price = self.cleaned_data.get('price') product.quantity = self.cleaned_data.get('quantity') product.reorder_trigger = self.cleaned_data.get('reorder_trigger') product.reorder_quantity = self.cleaned_data.get( 'reorder_quantity') elif self.cleaned_data.get('type') == 'IndividualProduct': product = cmod.IndividualProduct() product.category = self.cleaned_data.get('category') product.type = self.cleaned_data.get('type') product.name = self.cleaned_data.get('name') product.description = self.cleaned_data.get('description') product.price = self.cleaned_data.get('price') product.itmeID = self.cleaned_data.get('itmeID') elif self.cleaned_data.get('type') == 'RentalProduct': product = cmod.RentalProduct() product.category = self.cleaned_data.get('category') product.type = self.cleaned_data.get('type') product.name = self.cleaned_data.get('name') product.description = self.cleaned_data.get('description') product.price = self.cleaned_data.get('price') product.itmeID = self.cleaned_data.get('itmeID') product.max_rental_days = self.cleaned_data.get('max_rental_days') product.retire_date = self.cleaned_data.get('retire_date') product.save()
def create(request): form = CreateForm() if request.method == 'POST': form = CreateForm(request.POST) if form.is_valid(): if form.cleaned_data.get('product_type') == 'Rental_Product': product = cmod.RentalProduct() product.name = form.cleaned_data.get('name') product.description = form.cleaned_data.get('description') product.image = form.cleaned_data.get('image') product.status = form.cleaned_data['status'] elif form.cleaned_data.get('product_type') == 'Individual_Product': product = cmod.IndividualProduct() product.name = form.cleaned_data.get('name') product.description = form.cleaned_data.get('description') product.image = form.cleaned_data.get('image') product.creator = form.cleaned_data['creator'] elif form.cleaned_data.get('product_type') == 'Bulk_Product': product = cmod.BulkProduct() product.name = form.cleaned_data.get('name') product.description = form.cleaned_data.get('description') product.image = form.cleaned_data.get('image') product.quantity = form.cleaned_data['quantity'] product.save() return HttpResponseRedirect('/catalog/products/') template_vars = { 'form': form, } return dmp_render_to_response(request, 'products.create.html', template_vars)
def commit(self, product): """Process the form action""" type_choice = self.cleaned_data.get('type') if self.new: if type_choice == 'BulkProduct': saveProduct = cmod.BulkProduct() elif type_choice == 'RentalProduct': saveProduct = cmod.RentalProduct() else: saveProduct = cmod.IndividualProduct() else: saveProduct = cmod.Product.objects.get( id=self.cleaned_data.get('id')) if type_choice == 'BulkProduct': saveProduct.quantity = self.cleaned_data.get('quantity') if type_choice == 'RentalProduct': saveProduct.max_rental_days = self.cleaned_data.get( 'max_rental_days') saveProduct.retire_date = self.cleaned_data.get('retire_date') saveProduct.name = self.cleaned_data.get('name') saveProduct.status = self.cleaned_data.get('status') saveProduct.description = self.cleaned_data.get('description') saveProduct.category = self.cleaned_data.get('category') saveProduct.price = self.cleaned_data.get('price') saveProduct.save()
def commit(self, request): '''Process the form action''' # get specific product info if self.cleaned_data['type'] == 'BulkProduct': product = cmod.BulkProduct() product.quantity = self.cleaned_data.get('quantity') product.reorder_trigger = self.cleaned_data.get('reorder_trigger') product.reorder_quantity = self.cleaned_data.get('reorder_quantity') if self.cleaned_data['type'] == 'IndividualProduct': product = cmod.IndividualProduct() product.pid = self.cleaned_data.get('pid') if self.cleaned_data['type'] == 'RentalProduct': product = cmod.RentalProduct() product.pid = self.cleaned_data.get('pid') product.retire_date = self.cleaned_data.get('retire_date') product.max_rental_days = self.cleaned_data.get('max_rental_days') # get the common product info product.name = self.cleaned_data.get('name') product.description = self.cleaned_data.get('description') product.price = self.cleaned_data.get('price') product.category = self.cleaned_data.get('category') product.status = self.cleaned_data.get('status') # save to database product.save()
def commit(self): # unique fields if self.cleaned_data.get('type') == '1': p = m.BulkProduct() p.unit = self.cleaned_data.get('unit') p.order_trigger = self.cleaned_data.get('order_trigger') p.order_quantity = self.cleaned_data.get('order_quantity') if self.cleaned_data.get('type') == '2': p = m.IndividualProduct() p.product_id = ''.join([ random.choice( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789012345678901234567890123456789' ) for j in range(6) ]) if self.cleaned_data.get('type') == '3': p = m.RentalProduct() p.product_id = ''.join([ random.choice( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789012345678901234567890123456789' ) for j in range(6) ]) p.rental_period = self.cleaned_data.get('rental_period') p.retire_date = self.cleaned_data.get('retire_date') p.name = self.cleaned_data.get('name') p.price = self.cleaned_data.get('price') p.status = self.cleaned_data.get('status') p.description = self.cleaned_data.get('description') p.category = self.cleaned_data.get('category') p.save() return p.id
def commit(self): if self.cleaned_data.get('type')=='BulkProduct': p1 = cmod.BulkProduct() p1.status = self.cleaned_data.get('status') p1.name = self.cleaned_data.get('name') p1.description = self.cleaned_data.get('description') p1.category = self.cleaned_data.get('category') p1.price = self.cleaned_data.get('price') p1.quantity = self.cleaned_data.get('quantity') p1.reorder_trigger = self.cleaned_data.get('reorder_trigger') p1.reorder_quantity = self.cleaned_data.get('reorder_quantity') elif self.cleaned_data.get('type')=='IndividualProduct': p1 = cmod.IndividualProduct() p1.status = self.cleaned_data.get('status') p1.name = self.cleaned_data.get('name') p1.description = self.cleaned_data.get('description') p1.category = self.cleaned_data.get('category') p1.price = self.cleaned_data.get('price') p1.pid = self.cleaned_data.get('pid') elif self.cleaned_data.get('type')=='RentalProduct': p1 = cmod.RentalProduct() p1.status = self.cleaned_data.get('status') p1.name = self.cleaned_data.get('name') p1.description = self.cleaned_data.get('description') p1.category = self.cleaned_data.get('category') p1.price = self.cleaned_data.get('price') p1.pid = self.cleaned_data.get('pid') p1.max_rental_days = self.cleaned_data.get('max_rental_days') p1.retire_date = self.cleaned_data.get('retire_date') p1.save()
def create(request): '''Creates a product''' form = CreateForm() if request.method == 'POST': # just submitted the form print('submitted form') form = CreateForm(request.POST) if form.is_valid(): if form.cleaned_data.get('product_type') == 'BP': p = mmod.BulkProduct() p.quantity = form.cleaned_data.get('quantity') elif form.cleaned_data.get('product_type') == 'IP': p = mmod.IndividualProduct() p.create_date = form.cleaned_data.get('create_date') p.creator = form.cleaned_data.get('creator') else: p = mmod.RentalProduct() p.purchase_date = form.cleaned_data.get('purchase') p.status = form.cleaned_data.get('status') # if form.cleaned_data.get('status') == 'current': # p.status = 'Rentable' # elif form.cleaned_data.get('status') == 'damaged': # p.status = 'Damaged' # elif form.cleaned_data.get('status') == 'retired': # print('>>>>>> HERE ') # p.status = 'No Longer Rentable' # else: # p.status = 'Dirty' # mydict = dict(PRODUCT_TYPE_CHOICES) # mydict[""] # george = form.cleaned_data['status'] # hey = mmod.RENTAL_STATUS_CHOICES(george) # # print('>>>>>>>' + hey) # # # Let's get the dictionary value of status # # # # george = mmod.RENTAL_STATUS_CHOICES_MAP(george) # # print('>>>>>>>' + george) p.name = form.cleaned_data.get('name') p.description = form.cleaned_data.get('description') p.image = form.cleaned_data.ge # def get_item(dictionary, key): # return dictionary.get(key) # george = form.cleaned_data['status'] # # mmod.RENTAL_STATUS_CHOICES|get_item:georget('image') p.category = mmod.Category.objects.get(id=1) p.save() return HttpResponseRedirect('/catalog/products') template_vars = { 'form': form, } return dmp_render_to_response(request, 'products.create.html', template_vars)
def commit(self): ''' Save the product if it's new. Get the product and change it if it's edit.''' # Get all the generic data type = self.cleaned_data.get('Type') category = cmod.Category.objects.get( Name=self.cleaned_data.get('Category')) name = self.cleaned_data.get('Name') description = self.cleaned_data.get('Description') price = self.cleaned_data.get('Price') status = self.cleaned_data.get('Status') qty = self.cleaned_data.get('Quantity') reorderTrigger = self.cleaned_data.get('ReorderTrigger') reorderQuantity = self.cleaned_data.get('ReorderQuantity') itemID = self.cleaned_data.get('ItemID') maxRental = self.cleaned_data.get('MaxRental') retireDate = self.cleaned_data.get('RetireDate') # Create the product if type == 'BulkProduct': if self.product_id < 0: bProduct = cmod.BulkProduct() else: bProduct = self.product bProduct.new_object(name, description, category, price, status) bProduct.Quantity = qty bProduct.ReorderTrigger = reorderTrigger bProduct.ReorderQuantity = reorderQuantity bProduct.save() if type == 'IndividualProduct': if self.product_id < 0: iProduct = cmod.IndividualProduct() else: iProduct = self.product iProduct.new_object(name, description, category, price, status) iProduct.ItemID = itemID iProduct.save() if type == 'RentalProduct': if self.product_id < 0: rProduct = cmod.RentalProduct() else: rProduct = self.product rProduct.new_object(name, description, category, price, status) rProduct.ItemID = itemID rProduct.MaxRental = maxRental rProduct.RetireDate = retireDate rProduct.save()
def commit(self): if self.cleaned_data.get('TYPE_CHOICES') == '1': b1 = cmod.BulkProduct() b1.status = self.cleaned_data.get('status') b1.name = self.cleaned_data.get('name') b1.description = self.cleaned_data.get('description') b1.category = self.cleaned_data.get('category') b1.price = self.cleaned_data.get('price') b1.reorder_quantity = self.cleaned_data.get('reorder_quantity') b1.reorder_trigger = self.cleaned_data.get('reorder_trigger') b1.quantity = self.cleaned_data.get('quantity') b1.save() elif self.cleaned_data.get('TYPE_CHOICES') == '2': i1 = cmod.IndividualProduct() i1.status = self.cleaned_data.get('status') i1.name = self.cleaned_data.get('name') i1.description = self.cleaned_data.get('description') i1.category = self.cleaned_data.get('category') i1.price = self.cleaned_data.get('price') i1.pid = self.cleaned_data.get('pid') i1.save() elif self.cleaned_data.get('TYPE_CHOICES') == '3': r1 = cmod.RentalProduct() r1.status = self.cleaned_data.get('status') r1.name = self.cleaned_data.get('name') r1.description = self.cleaned_data.get('description') r1.category = self.cleaned_data.get('category') r1.price = self.cleaned_data.get('price') r1.pid = self.cleaned_data.get('pid') r1.max_rental_days = self.cleaned_data.get('max_rental_days') r1.retire_date = self.cleaned_data.get('retire_date') r1.save() else: pass
def commit(self): type = self.cleaned_data.get('type') if type == 'IndividualProduct': self.product = cmod.IndividualProduct() self.product.create_date = self.cleaned_data.get('created_date') self.product.last_modified = self.cleaned_data.get('last_modified') self.product.name = self.cleaned_data.get('name') self.product.description = self.cleaned_data.get('description') self.product.status = self.cleaned_data.get('status') self.product.category = self.cleaned_data.get('category') self.product.price = self.cleaned_data.get('price') #unique self.product.pid = self.cleaned_data.get('pid') elif type == 'BulkProduct': self.product = cmod.BulkProduct() self.product.create_date = self.cleaned_data.get('created_date') self.product.last_modified = self.cleaned_data.get('last_modified') self.product.name = self.cleaned_data.get('name') self.product.description = self.cleaned_data.get('description') self.product.status = self.cleaned_data.get('status') self.product.category = self.cleaned_data.get('category') self.product.price = self.cleaned_data.get('price') # unique self.product.quantity = self.cleaned_data.get('quantity') self.product.reorder_trigger = self.cleaned_data.get( 'reorder_trigger') self.product.reorder_quantity = self.cleaned_data.get( 'reorder_quantity') elif type == 'RentalProduct': self.product = cmod.RentalProduct() self.product.create_date = self.cleaned_data.get('created_date') self.product.last_modified = self.cleaned_data.get('last_modified') self.product.name = self.cleaned_data.get('name') self.product.description = self.cleaned_data.get('description') self.product.status = self.cleaned_data.get('status') self.product.category = self.cleaned_data.get('category') self.product.price = self.cleaned_data.get('price') #unique self.product.pid = self.cleaned_data.get('pid') self.product.max_rental_days = self.cleaned_data.get( 'max_rental_days') self.product.retire_date = self.cleaned_data.get('retire_date') self.product.save()
def commit(self): #self.cleaned_data.title if (self.cleaned_data.get('type') == 'IndividualProduct'): myProduct = cmod.IndividualProduct() myProduct.TITLE = self.cleaned_data.get('title') myProduct.status = self.cleaned_data.get('status') myProduct.name = self.cleaned_data.get('name') myProduct.description = self.cleaned_data.get('description') myProduct.category = self.cleaned_data.get('category') myProduct.price = self.cleaned_data.get('price') myProduct.pid = self.cleaned_data.get('pid') myProduct.save() elif (self.cleaned_data.get('type') == 'RentalProduct'): myProduct = cmod.RentalProduct() myProduct.TITLE = self.cleaned_data.get('title') myProduct.status = self.cleaned_data.get('status') myProduct.name = self.cleaned_data.get('name') myProduct.description = self.cleaned_data.get('description') myProduct.category = self.cleaned_data.get('category') myProduct.price = self.cleaned_data.get('price') myProduct.max_rental_days = self.cleaned_data.get( 'max_rental_days') myProduct.retire_date = self.cleaned_data.get('retire_date') myProduct.save() else: myProduct = cmod.BulkProduct() myProduct.TITLE = self.cleaned_data.get('title') myProduct.status = self.cleaned_data.get('status') myProduct.name = self.cleaned_data.get('name') myProduct.description = self.cleaned_data.get('description') myProduct.category = self.cleaned_data.get('category') myProduct.price = self.cleaned_data.get('price') myProduct.quantity = self.cleaned_data.get('quantity') myProduct.reorder_trigger = self.cleaned_data.get( 'reorder_trigger') myProduct.reorder_quantity = self.cleaned_data.get( 'reorder_quantity') myProduct.save() HttpResponseRedirect('/catalog/templates/product.html')
def commit(self): if self.cleaned_data.get('title') == 'BulkProduct': p = cmod.BulkProduct() p.quantity = self.cleaned_data['quantity'] p.reorder_trigger = self.cleaned_data['reorder_trigger'] p.reorder_quantity = self.cleaned_data['reorder_quantity'] elif self.cleaned_data.get('title') == 'RentalProduct': p = cmod.RentalProduct() p.max_rental_days = self.cleaned_data['max_rental_days'] p.retire_date = self.cleaned_data['retire_date'] p.pid = self.cleaned_data['pid'] elif self.cleaned_data.get('title') == 'IndividualProduct': p = cmod.IndividualProduct() p.pid = self.cleaned_data['pid'] p.TITLE = self.cleaned_data['title'] p.name = self.cleaned_data['name'] p.description = self.cleaned_data['description'] p.category = self.cleaned_data['category'] p.price = self.cleaned_data['price'] p.status = self.cleaned_data['status'] p.save()
def commit(self): print(self.cleaned_data.get('type')) if self.cleaned_data.get('type') == 'BulkProduct': print('success') newProduct = cmod.BulkProduct() newProduct.name = self.cleaned_data.get('name') newProduct.category = self.cleaned_data.get('category') newProduct.description = self.cleaned_data.get('description') newProduct.price = self.cleaned_data.get('price') newProduct.status = self.cleaned_data.get('status') newProduct.quantity = self.cleaned_data.get('quantity') newProduct.reorder_trigger = self.cleaned_data.get( 'reorder_trigger') newProduct.reorder_quantity = self.cleaned_data.get( 'reorder_quantity') newProduct.save() print(newProduct.id) elif self.cleaned_data.get('type') == 'IndividualProduct': newProduct = cmod.IndividualProduct() newProduct.category = self.cleaned_data.get('category') newProduct.name = self.cleaned_data.get('name') newProduct.description = self.cleaned_data.get('description') newProduct.price = self.cleaned_data.get('price') newProduct.status = self.cleaned_data.get('status') newProduct.itemID = self.cleaned_data.get('itemID') newProduct.save() elif self.cleaned_data.get('type') == 'RentalProduct': newProduct = cmod.RentalProduct() newProduct.category = self.cleaned_data.get('category') newProduct.name = self.cleaned_data.get('name') newProduct.description = self.cleaned_data.get('description') newProduct.price = self.cleaned_data.get('price') newProduct.status = self.cleaned_data.get('status') newProduct.itemID = self.cleaned_data.get('itemID') newProduct.maxRental = self.cleaned_data.get('maxRental') newProduct.retireDate = self.cleaned_data.get('retireDate') newProduct.save()
def create(request): form = createproduct_form() if request.method == "POST": form = createproduct_form(request.POST) if form.is_valid(): if form.cleaned_data.get('productType') == 'indproduct': p = cmod.IndividualProduct() p.creationDate = form.cleaned_data.get('creationDate') p.customizationNotes = form.cleaned_data.get( 'customizationNotes') elif form.cleaned_data.get('productType') == 'bulkproduct': p = cmod.BulkProduct() p.currentBulkPrice = form.cleaned_data.get('currentBulkPrice') p.quantityAvailable = form.cleaned_data.get( 'quantityAvailable') elif form.cleaned_data.get('productType') == 'rentalprdoduct': p = cmod.RentalProduct() p.currentRentalRate = form.cleaned_data.get( 'currentRentalRate') p.available = form.cleaned_data.get('available') p.name = form.cleaned_data.get('name') p.description = form.cleaned_data.get('description') p.replacementValue = form.cleaned_data.get('replacementValue') p.photoFileName = form.cleaned_data.get('photoFileName') p.size = form.cleaned_data.get('size') p.weight = form.cleaned_data.get('weight') p.save() return HttpResponse(''' <script> window.location.reload(); </script> ''') template_vars = { 'form': form, } return dmp_render_to_response(request, 'createproduct.html', template_vars)
def commit(self): '''Process form action''' type = self.cleaned_data.get('type') # if type == 'BulkProduct': # self.product = cmod.BulkProduct() # # unique # self.product.quantity = self.cleaned_data.get('quantity') # self.product.reorder_trigger = self.cleaned_data.get('reorder_trigger') # self.product.reorder_quantity = self.cleaned_data.get('reorder_quantity') # elif type == 'IndividualProduct': # self.product = cmod.IndividualProduct() # # unique # self.product.pid = self.cleaned_data.get('pid') # elif type == 'RentalProduct': # self.product = cmod.RentalProduct() # # unique # self.product.pid = self.cleaned_data.get('pid') # self.product.max_rental_days = self.cleaned_data.get('max_rental_days') # self.product.retire_date = self.cleaned_data.get('retire_date') # # # Generic product information # self.product.create_date = self.cleaned_data.get('created_date') # self.product.last_modified = self.cleaned_data.get('last_modified') # self.product.name = self.cleaned_data.get('name') # self.product.description = self.cleaned_data.get('description') # self.product.status = self.cleaned_data.get('status') # self.product.category = self.cleaned_data.get('category') # self.product.price = self.cleaned_data.get('price') # Save # self.product.save() # Try this way? if type == 'IndividualProduct': self.product = cmod.IndividualProduct() self.product.create_date = self.cleaned_data.get('create_date') self.product.last_modified = self.cleaned_data.get('last_modified') self.product.status = self.cleaned_data.get('status') self.product.name = self.cleaned_data.get('name') self.product.description = self.cleaned_data.get('description') self.product.category = self.cleaned_data.get('category') self.product.price = self.cleaned_data.get('price') # unique fields self.product.pid = self.cleaned_data.get('pid') elif type == 'BulkProduct': self.product = cmod.BulkProduct() self.product.create_date = self.cleaned_data.get('create_date') self.product.last_modified = self.cleaned_data.get('last_modified') self.product.status = self.cleaned_data.get('status') self.product.name = self.cleaned_data.get('name') self.product.description = self.cleaned_data.get('description') self.product.category = self.cleaned_data.get('category') self.product.price = self.cleaned_data.get('price') # unique fields self.product.quantity = self.cleaned_data.get('quantity') self.product.reorder_trigger = self.cleaned_data.get('reorder_trigger') self.product.reorder_quantity = self.cleaned_data.get('reorder_quantity') elif type == 'RentalProduct': self.product = cmod.RentalProduct() self.product.create_date = self.cleaned_data.get('create_date') self.product.last_modified = self.cleaned_data.get('last_modified') self.product.status = self.cleaned_data.get('status') self.product.name = self.cleaned_data.get('name') self.product.description = self.cleaned_data.get('description') self.product.category = self.cleaned_data.get('category') self.product.price = self.cleaned_data.get('price') # unique fields self.product.pid = self.cleaned_data.get('pid') self.product.max_rental_days = self.cleaned_data.get('max_rental_days') self.product.retire_date = self.cleaned_data.get('retire_date') self.product.save()
for i in range(1, 25): p = cmod.RentalProduct() p.name = 'unset' # see image adding below p.description = 'unset' p.category = random.choice(categories) p.status = 'A' p.price = random.uniform(1, 1000) p.pid = ''.join([ random.choice( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789012345678901234567890123456789' ) for j in range(6) ]) p.max_rental_days = random.randint(1, 10) p.save() for i in range(1, 25): p = cmod.IndividualProduct() p.name = 'unset' # see image adding below p.description = 'unset' p.category = random.choice(categories) p.status = 'A' p.price = random.uniform(1, 1000) p.pid = ''.join([ random.choice( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789012345678901234567890123456789' ) for j in range(6) ]) p.save() ################################## ### Product Images
def edit(request): try: p = cmod.Product.objects.get(id=int(request.urlparams[0])) except cmod.Product.DoesNotExist as e: return HttpResponseRedirect('/catalog/products') if request.method != "POST": if request.urlparams[1] == 'indproduct': form = edit_form( initial={ 'name': p.name, 'description': p.description, 'replacementValue': p.replacementValue, 'photoFileName': p.photoFileName, 'size': p.size, 'weight': p.weight, 'creationDate': p.creationDate, 'customizationNotes': p.customizationNotes, }) ptype = 'indproduct' elif request.urlparams[1] == 'bulkproduct': form = edit_form( initial={ 'name': p.name, 'description': p.description, 'replacementValue': p.replacementValue, 'photoFileName': p.photoFileName, 'size': p.size, 'weight': p.weight, 'currentBulkPrice': p.currentBulkPrice, 'quantityAvailable': p.quantityAvailable, }) ptype = 'bulkproduct' elif request.urlparams[1] == 'rentalproduct': form = edit_form( initial={ 'name': p.name, 'description': p.description, 'replacementValue': p.replacementValue, 'photoFileName': p.photoFileName, 'size': p.size, 'weight': p.weight, 'currentRentalRate': p.currentRentalRate, 'available': p.available, }) ptype = 'rentalproduct' if request.method == "POST": form = edit_form(request.POST) if form.is_valid(): if form.cleaned_data.get('productType') == 'indproduct': p = cmod.IndividualProduct() p.creationDate = form.cleaned_data.get('creationDate') p.customizationNotes = form.cleaned_data.get( 'customizationNotes') elif form.cleaned_data.get('productType') == 'bulkproduct': p = cmod.BulkProduct() p.currentBulkPrice = form.cleaned_data.get('currentBulkPrice') p.quantityAvailable = form.cleaned_data.get( 'quantityAvailable') elif form.cleaned_data.get('productType') == 'rentalproduct': p = cmod.RentalProduct() p.currentRentalRate = form.cleaned_data.get( 'currentRentalRate') p.available = form.cleaned_data.get('available') p.name = form.cleaned_data.get('name') p.description = form.cleaned_data.get('description') p.replacementValue = form.cleaned_data.get('replacementValue') p.photoFileName = form.cleaned_data.get('photoFileName') p.size = form.cleaned_data.get('size') p.weight = form.cleaned_data.get('weight') p.save() return HttpResponseRedirect('/catalog/products') # return HttpResponse(''' # <script> # window.location.reload(); # </script> # ''') #products = cmod.Product.objects.all().order_by('last_name','first_name') template_vars = { 'form': form, 'productid': p.id, 'ptype': ptype, } return dmp_render_to_response(request, 'editproduct.html', template_vars)