Best Python code snippet using django-test-plus_python
views - class based.py
Source:views - class based.py
...24 model = DIM_GST25 fields = ['id', 'code','description', 'percentage_claimable', 'percentage_chargeable']26 template_name = 'retail/edit.html'27 28 def get_success_url(self):29 return reverse('gst_list')30 31 def get_context_data(self, **kwargs):32 context = super(CreateGSTView, self).get_context_data(**kwargs)33 context['action'] = reverse('gst_new')34 35 return context36 37class UpdateGSTView(UpdateView):38 model = DIM_GST39 title = "Edit GST"40 fields = ['id', 'code','description', 'percentage_claimable', 'percentage_chargeable']41 template_name = 'retail/edit.html'42 43 success_url = 'gst_list'44 45 def get_success_url(self):46 return reverse(self.success_url)47 48 def get_context_data(self, **kwargs):49 context = super(UpdateGSTView, self).get_context_data(**kwargs)50 context['action'] = reverse('gst_edit', kwargs={'pk': self.get_object().id})51 return context52class DeleteGSTView(DeleteView):53 model = DIM_GST54 fields = ['id', 'code','description', 'percentage_claimable', 'percentage_chargeable']55 template_name = 'retail/delete.html'56 success_url = 'gst_list'57 def get_success_url(self):58 return reverse(self.success_url)59 60#DIM_Unit61class ListUnitView(TemplateView):62 title = "Unit List"63 64 template_name = 'retail/unit_list.html'65 def Units(self):66 return DIM_Unit.objects.all()67 68class CreateUnitView(CreateView):69 model = DIM_Unit70 fields = ['id', 'code','description']71 template_name = 'retail/edit.html'72 73 def get_success_url(self):74 return reverse('unit_list')75 76 def get_context_data(self, **kwargs):77 context = super(CreateUnitView, self).get_context_data(**kwargs)78 context['action'] = reverse('unit_new')79 80 return context81 82class UpdateUnitView(UpdateView):83 model = DIM_Unit84 title = "Edit Unit"85 fields = ['id', 'code','description']86 template_name = 'retail/edit.html'87 88 success_url = 'unit_list'89 90 def get_success_url(self):91 return reverse(self.success_url)92 93 def get_context_data(self, **kwargs):94 context = super(UpdateUnitView, self).get_context_data(**kwargs)95 context['action'] = reverse('unit_edit', kwargs={'pk': self.get_object().id})96 return context97class DeleteUnitView(DeleteView):98 model = DIM_Unit99 fields = ['id', 'code','description']100 template_name = 'retail/unit_delete.html'101 success_url = 'unit_list'102 def get_success_url(self):103 return reverse(self.success_url)104#TAX105class ListTaxView(TemplateView):106 title = "Tax List"107 108 template_name = 'retail/tax_list.html'109 def Taxs(self):110 return Tax.objects.all()111 112class CreateTaxView(CreateView):113 model = Tax114 fields = ['id', 'code', 'unit_price', 'eff_datetime', 'exp_datetime', 'inventory', 'gst']115 template_name = 'retail/edit.html'116 117 def get_success_url(self):118 return reverse('tax_list')119 120 def get_context_data(self, **kwargs):121 context = super(CreateTaxView, self).get_context_data(**kwargs)122 context['action'] = reverse('tax_new')123 124 return context125 126class UpdateTaxView(UpdateView):127 model = Tax128 title = "Edit Tax"129 fields = ['id', 'code', 'unit_price', 'eff_datetime', 'exp_datetime', 'inventory', 'gst']130 template_name = 'retail/edit.html'131 132 success_url = 'tax_list'133 134 def get_success_url(self):135 return reverse(self.success_url)136 137 def get_context_data(self, **kwargs):138 context = super(UpdateTaxView, self).get_context_data(**kwargs)139 context['action'] = reverse('tax_edit', kwargs={'pk': self.get_object().id})140 return context141class DeleteTaxView(DeleteView):142 model = Tax143 fields = ['id', 'code', 'unit_price', 'eff_datetime', 'exp_datetime', 'inventory', 'gst']144 template_name = 'retail/tax_delete.html'145 success_url = 'tax_list'146 def get_success_url(self):147 return reverse(self.success_url)148#DIM_Contact_Type149class ListContactTypeView(TemplateView):150 title = "Contact Type List"151 152 template_name = 'retail/contact_type_list.html'153 def ContactTypes(self):154 print(DIM_Contact_Type.objects.all().query)155 test_filter = self.request.session.get('test')156 if test_filter:157 print("found")158 return DIM_Contact_Type.objects.filter(pk=test_filter)159 160 print("not found")161 return DIM_Contact_Type.objects.all()162 163 164 165class CreateContactTypeView(CreateView):166 model = DIM_Contact_Type167 168 fields = ['id', 'code','description']169 template_name = 'retail/edit.html'170 success_url = 'contact_type_list'171 def get_success_url(self):172 return reverse(self.success_url)173 174 def get_context_data(self, **kwargs):175 context = super(CreateContactTypeView, self).get_context_data(**kwargs)176 context['action'] = reverse('contact_type_new')177 178 return context179 180class UpdateContactTypeView(UpdateView):181 model = DIM_Contact_Type182 183 title = "Edit Contact Type"184 fields = ['id', 'code','description']185 186 template_name = 'retail/edit.html'187 188 success_url = 'contact_type_list'189 190 def get_success_url(self):191 return reverse(self.success_url)192 193 def get_context_data(self, **kwargs):194 context = super(UpdateContactTypeView, self).get_context_data(**kwargs)195 context['action'] = reverse('contact_type_edit', kwargs={'pk': self.get_object().id})196 return context197 198class DeleteContactTypeView(DeleteView):199 model = DIM_Contact_Type200 fields = ['id', 'code','description']201 template_name = 'retail/contact_type_delete.html'202 success_url = 'contact_type_list'203 def get_success_url(self):204 return reverse(self.success_url)205#DIM_Promotion206class ListPromotionView(TemplateView):207 title = "Promotion List"208 209 template_name = 'retail/promotion_list.html'210 def Promotions(self):211 return DIM_Promotion.objects.all()212 213class CreatePromotionView(CreateView):214 model = DIM_Promotion215 fields = ['id', 'code','description', 'promo_cond', 'promo_percent', 'promo_amt', 'inventory']216 template_name = 'retail/edit.html'217 success_url = 'promotion_list'218 219 def get_success_url(self):220 return reverse(self.success_url)221 222 def get_context_data(self, **kwargs):223 context = super(CreatePromotionView, self).get_context_data(**kwargs)224 context['action'] = reverse('promotion_new')225 226 return context227 228class UpdatePromotionView(UpdateView):229 model = DIM_Promotion230 title = "Edit Promotion"231 fields = ['id', 'code','description', 'promo_cond', 'promo_percent', 'promo_amt', 'inventory']232 template_name = 'retail/edit.html'233 234 success_url = 'promotion_list'235 236 def get_success_url(self):237 return reverse(self.success_url)238 239 def get_context_data(self, **kwargs):240 context = super(UpdatePromotionView, self).get_context_data(**kwargs)241 context['action'] = reverse('promotion_edit', kwargs={'pk': self.get_object().id})242 return context243class DeletePromotionView(DeleteView):244 model = DIM_Promotion245 fields = ['id', 'code','description', 'promo_cond', 'promo_percent', 'promo_amt', 'inventory']246 template_name = 'retail/promotion_delete.html'247 success_url = 'promotion_list'248 def get_success_url(self):249 return reverse(self.success_url)250#Contact_Info251class ListContactInfoView(TemplateView):252 title = "Contact Info List"253 254 template_name = 'retail/contact_info_list.html'255 def ContactInfos(self):256 return Contact_Info.objects.all()257 258def contactinfo_new(request, contacttype_id):259 print('test')260 ct = DIM_Contact_Type.objects.get(pk=contacttype_id)261 usr=User.objects.get(username='fai')262 print(ct.description)263 form = Contact_InfoForm(initial={'contacttype':ct,'info':'-2-', 'user':usr})264 return render(request, 'retail/edit.html', {'form': form})265 266def contactinfo_view(request, pk):267 print('test22')268 ci = Contact_Info.objects.get(pk=pk)269 print('test33')270 print(ci.info)271 form = Contact_InfoForm(instance=ci)272 return render(request, 'retail/edit.html', {'form': form})273class CreateContactInfoView(CreateView):274 model = Contact_Info275 #fields = ['id', 'info', 'eff_date', 'exp_date', 'user', 'contacttype']276 template_name = 'retail/edit.html'277 success_url = 'contact_info_list'278 title = "New Contact Info"279 form_class = Contact_InfoForm280 281 def get_success_url(self):282 return reverse(self.success_url)283 284 def get_context_data(self, **kwargs):285 print("create contact info" + ' test' + ': ' + self.kwargs['contacttype_id'])286 ct_id=self.kwargs['contacttype_id']287 ct = DIM_Contact_Type.objects.get(pk=self.kwargs['contacttype_id'])288 Contact_Info.contacttype=ct289 context = super(CreateContactInfoView, self).get_context_data(**kwargs)290 context['action'] = reverse('contact_info_new')291 292 return context293 294 '''295 This view allows a user to edit details of a project.296def EditProject(request, project_id=None):297 title = u'Unirac - Edit Project'298 project = Project.objects.get(id=4)299 if request.method == 'POST':300 form = ProjectForm(request.POST)301 if form.is_valid():302 # save form303 form.save()304 else:305 return render_to_response('edit_project.html', {306 'title': title,307 'form': form,308 }, RequestContext(request))309 else:310 form = ProjectForm(instance=project)311 return render_to_response('edit_project.html', {312 'title': title,313 'form': form,314 }, RequestContext(request))315 316 def get_context_data(self, **kwargs):317 print("create contact info" + ' test' + ': ' + self.kwargs['contacttype_id'])318 ct_id=self.kwargs['contacttype_id']319 ct = DIM_Contact_Type.objects.get(pk=self.kwargs['contacttype_id'])320 Contact_Info.contacttype=ct321 context = super(CreateContactInfoView, self).get_context_data(**kwargs)322 context['action'] = reverse('contact_info_new')323 324 return context325'''326 327class UpdateContactInfoView(UpdateView):328 model = Contact_Info329 title = "Edit Contact Info"330 fields = ['id', 'info', 'eff_date', 'exp_date', 'user', 'contacttype']331 template_name = 'retail/edit.html'332 333 success_url = 'contact_info_list'334 title = "Edit Contact Info"335 336 def get_success_url(self):337 return reverse(self.success_url)338 339 def get_context_data(self, **kwargs):340 context = super(UpdateContactInfoView, self).get_context_data(**kwargs)341 context['action'] = reverse('contact_info_edit', kwargs={'pk': self.get_object().id})342 return context343class DeleteContactInfoView(DeleteView):344 model = Contact_Info345 fields = ['id', 'info', 'eff_date', 'exp_date', 'user', 'contacttype']346 template_name = 'retail/contact_info_delete.html'347 success_url = 'contact_info_list'348 title = "Delete Contact Info"349 def get_success_url(self):350 return reverse(self.success_url)351#REVIEW352class ListReviewView(TemplateView):353 title = "Review List"354 355 template_name = 'retail/review_list.html'356 def Reviews(self):357 return Review.objects.all()358 359class CreateReviewView(CreateView):360 model = Review361 fields = ['id', 'description', 'inventory']362 template_name = 'retail/edit.html'363 success_url = 'review_list'364 title = "New Review"365 366 def get_success_url(self):367 return reverse(self.success_url)368 369 def get_context_data(self, **kwargs):370 context = super(CreateReviewView, self).get_context_data(**kwargs)371 context['action'] = reverse('review_new')372 373 return context374 375class UpdateReviewView(UpdateView):376 model = Review377 title = "Edit Review"378 fields = ['id', 'description', 'inventory']379 template_name = 'retail/edit.html'380 381 success_url = 'review_list'382 title = "Edit Review"383 384 def get_success_url(self):385 return reverse(self.success_url)386 387 def get_context_data(self, **kwargs):388 context = super(UpdateReviewView, self).get_context_data(**kwargs)389 context['action'] = reverse('review_edit', kwargs={'pk': self.get_object().id})390 return context391class DeleteReviewView(DeleteView):392 model = Review393 fields = ['id', 'description', 'inventory']394 template_name = 'retail/review_delete.html'395 success_url = 'review_list'396 title = "Delete Review"397 def get_success_url(self):398 return reverse(self.success_url)399 400#INVENTORY401class ListInventoryView(TemplateView):402 title = "Inventory List"403 404 template_name = 'retail/Inventory_list.html'405 def Inventorys(self):406 return Inventory.objects.all()407 408class CreateInventoryView(CreateView):409 model = Inventory410 fields = ['id', 'code','description', 'remark', 'dim_unit']411 template_name = 'retail/edit.html'412 413 def get_success_url(self):414 return reverse('inventory_list')415 416 def get_context_data(self, **kwargs):417 context = super(CreateInventoryView, self).get_context_data(**kwargs)418 context['action'] = reverse('inventory_new')419 420 return context421 422class UpdateInventoryView(UpdateView):423 model = Inventory424 title = "Edit Inventory"425 fields = ['id', 'code','description', 'remark', 'dim_unit']426 template_name = 'retail/edit.html'427 428 success_url = 'inventory_list'429 430 def get_success_url(self):431 return reverse(self.success_url)432 433 def get_context_data(self, **kwargs):434 context = super(UpdateInventoryView, self).get_context_data(**kwargs)435 context['action'] = reverse('inventory_edit', kwargs={'pk': self.get_object().id})436 return context437class DeleteInventoryView(DeleteView):438 model = Inventory439 fields = ['id', 'code','description', 'remark', 'dim_unit']440 template_name = 'retail/inventory_delete.html'441 success_url = 'inventory_list'442 def get_success_url(self):443 return reverse(self.success_url)444#PRICE445class ListPriceView(TemplateView):446 title = "Price List"447 448 template_name = 'retail/price_list.html'449 def Prices(self):450 return Price.objects.all()451 452class CreatePriceView(CreateView):453 model = Price454 fields = ['id', 'code','unit_price', 'eff_datetime', 'exp_datetime', 'inventory']455 template_name = 'retail/edit.html'456 457 def get_success_url(self):458 return reverse('price_list')459 460 def get_context_data(self, **kwargs):461 context = super(CreatePriceView, self).get_context_data(**kwargs)462 context['action'] = reverse('price_new')463 464 return context465 466class UpdatePriceView(UpdateView):467 model = Price468 title = "Edit Price"469 fields = ['id', 'code','unit_price', 'eff_datetime', 'exp_datetime', 'inventory']470 template_name = 'retail/edit.html'471 472 success_url = 'price_list'473 474 def get_success_url(self):475 return reverse(self.success_url)476 477 def get_context_data(self, **kwargs):478 context = super(UpdatePriceView, self).get_context_data(**kwargs)479 context['action'] = reverse('price_edit', kwargs={'pk': self.get_object().id})480 return context481class DeletePriceView(DeleteView):482 model = Price483 fields = ['id', 'code','unit_price', 'eff_date', 'exp_date', 'inventory']484 template_name = 'retail/price_delete.html'485 success_url = 'price_list'486 def get_success_url(self):487 return reverse(self.success_url)488 489#SUPPLIER490class ListSupplierView(TemplateView):491 title = "Supplier List"492 493 template_name = 'retail/supplier_list.html'494 def Suppliers(self):495 return Supplier.objects.all()496 497class CreateSupplierView(CreateView):498 model = Supplier499 fields = ['code','fullname', 'license_no', 'business_nature']500 template_name = 'retail/edit.html'501 success_url = 'supplier_list'502 def get_success_url(self):503 return reverse(self.success_url)504 505 def get_context_data(self, **kwargs):506 context = super(CreateSupplierView, self).get_context_data(**kwargs)507 context['action'] = reverse('supplier_new')508 509 return context510 511class UpdateSupplierView(UpdateView):512 model = Supplier513 title = "Edit Supplier"514 fields = ['code','fullname', 'license_no', 'business_nature']515 template_name = 'retail/edit.html'516 success_url = 'supplier_list'517 def get_success_url(self):518 return reverse(self.success_url)519 520 def get_context_data(self, **kwargs):521 context = super(UpdateSupplierView, self).get_context_data(**kwargs)522 context['action'] = reverse('supplier_edit', kwargs={'pk': self.get_object().id})523 return context524class DeleteSupplierView(DeleteView):525 model = Supplier526 fields = ['code','fullname', 'license_no', 'business_nature']527 template_name = 'retail/supplier_delete.html'528 success_url = 'supplier_list'529 def get_success_url(self):530 return reverse(self.success_url)531#PURCHASES532class ListPurchaseView(ListView):533 title = "Purchase List"534 model = Purchase535 536 template_name = 'retail/purchase_list.html'537 538class CreatePurchaseView(CreateView):539 model = Purchase540 fields = ['pi_no', 'supplier', 'description', 'purchase_date', 'doc_amt', 'doc_gst_amt', 'doc_promotion_amt', 'remark']541 template_name = 'retail/edit.html'542 success_url = 'purchase_list'543 def get_success_url(self):544 return reverse(self.success_url)545 546 def get_context_data(self, **kwargs):547 context = super(CreatePurchaseView, self).get_context_data(**kwargs)548 context['action'] = reverse('purchase_new')549 550 return context551 552class UpdatePurchaseView(UpdateView):553 model = Purchase554 title = "Edit Purchase"555 fields = ['pi_no', 'supplier', 'description', 'purchase_date', 'doc_amt', 'doc_gst_amt', 'doc_promotion_amt', 'remark']556 template_name = 'retail/edit.html'557 success_url = 'purchase_list'558 def get_success_url(self):559 return reverse(self.success_url)560 561 def get_context_data(self, **kwargs):562 print(kwargs)563 context = super(UpdatePurchaseView, self).get_context_data(**kwargs)564 context['action'] = reverse('purchase_edit', kwargs={'pk': self.get_object().id})565 return context566class DeletePurchaseView(DeleteView):567 model = Purchase568 fields = ['pi_no', 'supplier', 'description', 'purchase_date', 'doc_amt', 'doc_gst_amt', 'doc_promotion_amt', 'remark']569 template_name = 'retail/purchase_delete.html'570 success_url = 'purchase_list'571 def get_success_url(self):572 return reverse(self.success_url)573 574#PURCHASE_DET575class ListPurchaseDetView(TemplateView):576 title = "Purchase Detail List"577 578 template_name = 'retail/purchase_det_list.html'579 def PurchaseDets(self):580 return Purchase_Det.objects.all()581 582class CreatePurchaseDetView(CreateView):583 model = Purchase_Det584 fields = ['purchase', 'seq', 'qty', 'gst_amt', 'det_amt', 'inventory', 'promotion']585 template_name = 'retail/edit.html'586 success_url = 'purchase_det_list'587 def get_success_url(self):588 return reverse(self.success_url)589 590 def get_context_data(self, **kwargs):591 context = super(CreatePurchaseDetView, self).get_context_data(**kwargs)592 context['action'] = reverse('purchase_det_new')593 594 return context595 596class UpdatePurchaseDetView(UpdateView):597 model = Purchase_Det598 title = "Edit Purchase Detail"599 fields = ['purchase', 'seq', 'qty', 'gst_amt', 'det_amt', 'inventory', 'promotion']600 template_name = 'retail/edit.html'601 success_url = 'purchase_det_list'602 def get_success_url(self):603 return reverse(self.success_url)604 605 def get_context_data(self, **kwargs):606 context = super(UpdatePurchaseDetView, self).get_context_data(**kwargs)607 context['action'] = reverse('purchase_det_edit', kwargs={'pk': self.get_object().id})608 return context609class DeletePurchaseDetView(DeleteView):610 model = Purchase_Det611 fields = ['purchase', 'seq', 'qty', 'gst_amt', 'det_amt', 'inventory', 'promotion']612 template_name = 'retail/purchase_det_delete.html'613 success_url = 'purchase_det_list'614 def get_success_url(self):615 return reverse(self.success_url)616#CUSTOMER617class ListCustomerView(TemplateView):618 title = "Customer List"619 620 template_name = 'retail/customer_list.html'621 def Customers(self):622 return Customer.objects.all()623 624class CreateCustomerView(CreateView):625 model = Customer626 fields = ['code','fullname', 'license_no', 'business_nature']627 template_name = 'retail/edit.html'628 success_url = 'customer_list'629 def get_success_url(self):630 return reverse(self.success_url)631 632 def get_context_data(self, **kwargs):633 context = super(CreateCustomerView, self).get_context_data(**kwargs)634 context['action'] = reverse('customer_new')635 636 return context637 638class UpdateCustomerView(UpdateView):639 model = Customer640 title = "Edit Customer"641 fields = ['code','fullname', 'license_no', 'business_nature']642 template_name = 'retail/edit.html'643 success_url = 'customer_list'644 def get_success_url(self):645 return reverse(self.success_url)646 647 def get_context_data(self, **kwargs):648 context = super(UpdateCustomerView, self).get_context_data(**kwargs)649 context['action'] = reverse('customer_edit', kwargs={'pk': self.get_object().id})650 return context651class DeleteCustomerView(DeleteView):652 model = Customer653 fields = ['code','fullname', 'license_no', 'business_nature']654 template_name = 'retail/customer_delete.html'655 success_url = 'customer_list'656 def get_success_url(self):657 return reverse(self.success_url)658#SALES659class ListSalesView(ListView):660 title = "Sales List"661 model = Sales662 template_name = 'retail/sales_list.html'663 def SalesDets(self, id):664 print('here1')665 return Sales_Det.objects.filter(sales=id)666 '''667 def Sales(self):668 print('here sales')669 return Sales.objects.all()670 671 '''672 673class CreateSalesView(CreateView):674 model = Sales675 title = "New Sales"676 #success_url = 'sales_list'677 fields = ['si_no', 'customer', 'description', 'sales_date', 'doc_amt', 'doc_gst_amt', 'doc_promotion_amt', 'remark']678 #template_name = 'retail/sales_edit.html'679'''680 def get_success_url(self):681 return reverse(self.success_url)682 683 def get_context_data(self, **kwargs):684 print('ok')685 context = super(CreateSalesView, self).get_context_data(**kwargs)686 print('ok')687 print(Sales_Det.objects.count())688 context['salesdetlst'] = Sales_Det.objects.all()689 context['action'] = reverse('sales_new')690 691 return context692''' 693'''694 def SalesDets(self):695 print('test')696 return Sales_Det.objects.all()697'''698class UpdateSalesView(UpdateView):699 model = Sales700 title = "Edit Sales"701 fields = ['si_no', 'customer', 'description', 'sales_date', 'doc_amt', 'doc_gst_amt', 'doc_promotion_amt', 'remark']702 #template_name = 'retail/sales_edit.html'703 #success_url = 'sales_list'704 #def get_success_url(self):705 # return reverse(self.success_url)706 '''707 def get_context_data(self, **kwargs):708 print(self.get_object().id)709 print('ok')710 #print(Sales_det.count())711 context = super(UpdateSalesView, self).get_context_data(**kwargs)712 #context['salesdetlst'] = Sales_Det.objects.all()713 #context['salesdetlst'] = self.get_object.description714 context['action'] = reverse('sales_edit', kwargs={'pk': self.get_object().id})715 return context716 def SalesDets(self):717 print('test')718 return Sales_Det.objects.filter(sales=self.get_object().id)719 '''720class DeleteSalesView(DeleteView):721 model = Sales722 fields = ['si_no', 'customer', 'description', 'sales_date', 'doc_amt', 'doc_gst_amt', 'doc_promotion_amt', 'remark']723 template_name = 'retail/sales_delete.html'724 success_url = 'sales_list'725 def get_success_url(self):726 return reverse(self.success_url)727#SALES_DET728class ListSalesDetView(DetailView):729 title = "Sales Detail List"730 model = Sales731 template_name = 'retail/sales_det_list.html'732'''733 def SalesDets(self):734 print('test')735 return Sales_Det.objects.all()736 737 def GSTDets(self):738 return DIM_GST.objects.all()739 740 def InvDets(self):741 return Inventory.objects.all()742'''743class CreateSalesDetView(CreateView):744 model = Sales_Det745 fields = ['sales', 'seq', 'qty', 'gst_amt', 'det_amt', 'inventory', 'promotion']746 template_name = 'retail/sales_det_edit.html'747 success_url = 'sales_det_list'748 def get_success_url(self):749 return reverse(self.success_url)750 751 def get_context_data(self, **kwargs):752 print( )753 754 for kwarg in kwargs:755 print(kwarg)756 757 context = super(CreateSalesDetView, self).get_context_data(**kwargs)758 context['action'] = reverse('sales_det_new')759 760 return context761 762class UpdateSalesDetView(UpdateView):763 model = Sales_Det764 title = "Edit Sales Detail"765 fields = ['sales', 'seq', 'qty', 'gst_amt', 'det_amt', 'inventory', 'promotion']766 template_name = 'retail/sales_det_edit.html'767 success_url = 'sales_det_list'768 def get_success_url(self):769 return reverse(self.success_url)770 771 def get_context_data(self, **kwargs):772 print("updateview")773 context = super(UpdateSalesDetView, self).get_context_data(**kwargs)774 context['action'] = reverse('sales_det_edit', kwargs={'pk': self.get_object().id})775 return context776class DeleteSalesDetView(DeleteView):777 model = Sales_Det778 fields = ['sales', 'seq', 'qty', 'gst_amt', 'det_amt', 'inventory', 'promotion']779 template_name = 'retail/sales_det_delete.html'780 success_url = 'sales_det_list'781 def get_success_url(self):782 return reverse(self.success_url)...
views.py
Source:views.py
...52 form = Tiporeserva53 fields = "__all__"54 success_message ='Tiporeserva creada correctamente'55 56 def get_success_url(self): 57 return reverse('leer') # Redireccionamos a la vista principal 'leer'58class TiporeservaDetalle (DetailView):59 model =Tiporeserva60class TiporeservaActualizar(SuccessMessageMixin,UpdateView):61 model = Tiporeserva62 form = Tiporeserva63 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 64 success_message = 'Tiporeserva Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 65 def get_success_url(self): 66 return reverse('leer') # Redireccionamos a la vista principal 'leer'67class TiporeservaEliminar(SuccessMessageMixin, DeleteView): 68 model = Tiporeserva 69 form = Tiporeserva70 fields = "__all__" 71 72 # Redireccionamos a la página principal luego de eliminar un registro o postre73 def get_success_url(self): 74 success_message = 'Tiporeserva Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 75 messages.success (self.request, (success_message)) 76 return reverse('leer') # Redireccionamos a la vista principal 'leer'77#78class ListadoComentarios(ListView):79 model = Comentarios80 81 82class ComentariosCrear(SuccessMessageMixin, CreateView):83 model = Comentarios84 form = Comentarios85 fields = "__all__"86 success_message =' Comentarios creada correctamente'87 88 def get_success_url(self): 89 return reverse('leer') # Redireccionamos a la vista principal 'leer'90class ComentariosDetalle (DetailView):91 model = Comentarios92class ComentariosActualizar(SuccessMessageMixin,UpdateView):93 model = Comentarios94 form = Comentarios95 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 96 success_message = ' Comentarios Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 97 def get_success_url(self): 98 return reverse('leer') # Redireccionamos a la vista principal 'leer'99class ComentariosEliminar(SuccessMessageMixin, DeleteView): 100 model = Comentarios 101 form = Comentarios102 fields = "__all__" 103 104 # Redireccionamos a la página principal luego de eliminar un registro o postre105 def get_success_url(self): 106 success_message = ' Comentarios Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 107 messages.success (self.request, (success_message)) 108 return reverse('leer') # Redireccionamos a la vista principal 'leer'109#110class ListadoRutas(ListView):111 model = Rutas112 113 114class RutasCrear(SuccessMessageMixin, CreateView):115 model = Rutas116 form = Rutas117 fields = "__all__"118 success_message =' Rutas creada correctamente'119 120 def get_success_url(self): 121 return reverse('leer') # Redireccionamos a la vista principal 'leer'122class RutasDetalle (DetailView):123 model = Rutas124class RutasActualizar(SuccessMessageMixin,UpdateView):125 model = Rutas126 form = Rutas127 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 128 success_message = ' Rutas Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 129 def get_success_url(self): 130 return reverse('leer') # Redireccionamos a la vista principal 'leer'131class RutasEliminar(SuccessMessageMixin, DeleteView): 132 model = Rutas133 form = Rutas134 fields = "__all__" 135 136 # Redireccionamos a la página principal luego de eliminar un registro o postre137 def get_success_url(self): 138 success_message = ' Rutas Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 139 messages.success (self.request, (success_message)) 140 return reverse('leer') # Redireccionamos a la vista principal 'leer'141#142class ListadoTipolugar(ListView):143 model = Tipolugar144 145 146class TipolugarCrear(SuccessMessageMixin, CreateView):147 model =Tipolugar148 form = Tipolugar149 fields = "__all__"150 success_message ='Tipolugar creada correctamente'151 152 def get_success_url(self): 153 return reverse('leer') # Redireccionamos a la vista principal 'leer'154class TipolugarDetalle (DetailView):155 model =Tipolugar156class TipolugarActualizar(SuccessMessageMixin,UpdateView):157 model = Tipolugar158 form = Tipolugar159 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 160 success_message = 'Tipolugar Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 161 def get_success_url(self): 162 return reverse('leer') # Redireccionamos a la vista principal 'leer'163class TipolugarEliminar(SuccessMessageMixin, DeleteView): 164 model = Tipolugar 165 form = Tipolugar166 fields = "__all__" 167 168 # Redireccionamos a la página principal luego de eliminar un registro o postre169 def get_success_url(self): 170 success_message = 'Tipolugar Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 171 messages.success (self.request, (success_message)) 172 return reverse('leer') # Redireccionamos a la vista principal 'leer'173# 174class ListadoEmpresa(ListView):175 model = Empresa176 177 178class EmpresaCrear(SuccessMessageMixin, CreateView):179 model =Empresa180 form = Empresa181 fields = "__all__"182 success_message ='Empresa creada correctamente'183 184 def get_success_url(self): 185 return reverse('leer') # Redireccionamos a la vista principal 'leer'186class EmpresaDetalle (DetailView):187 model =Empresa188class EmpresaActualizar(SuccessMessageMixin,UpdateView):189 model = Empresa190 form = Empresa191 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 192 success_message = 'Empresa Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 193 def get_success_url(self): 194 return reverse('leer') # Redireccionamos a la vista principal 'leer'195class EmpresaEliminar(SuccessMessageMixin, DeleteView): 196 model = Empresa 197 form = Empresa198 fields = "__all__" 199 200 # Redireccionamos a la página principal luego de eliminar un registro o postre201 def get_success_url(self): 202 success_message = 'Empresa Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 203 messages.success (self.request, (success_message)) 204 return reverse('leer') # Redireccionamos a la vista principal 'leer'205#206class ListadoEstadocliente(ListView):207 model = Estadocliente208 209 210class EstadoclienteCrear(SuccessMessageMixin, CreateView):211 model =Estadocliente212 form = Estadocliente213 fields = "__all__"214 success_message ='Estadocliente creada correctamente'215 216 def get_success_url(self): 217 return reverse('leer') # Redireccionamos a la vista principal 'leer'218class EstadoclienteDetalle (DetailView):219 model =Estadocliente220class EstadoclienteActualizar(SuccessMessageMixin,UpdateView):221 model = Estadocliente222 form = Estadocliente223 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 224 success_message = 'Estadocliente Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 225 def get_success_url(self): 226 return reverse('leer') # Redireccionamos a la vista principal 'leer'227class EstadoclienteEliminar(SuccessMessageMixin, DeleteView): 228 model = Estadocliente 229 form = Estadocliente230 fields = "__all__" 231 232 # Redireccionamos a la página principal luego de eliminar un registro o postre233 def get_success_url(self): 234 success_message = 'Estadocliente Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 235 messages.success (self.request, (success_message)) 236 return reverse('leer') # Redireccionamos a la vista principal 'leer'237#238class ListadoTipodocumento(ListView):239 model = Tipodocumento240 241 242class TipodocumentoCrear(SuccessMessageMixin, CreateView):243 model =Tipodocumento244 form = Tipodocumento245 fields = "__all__"246 success_message ='Tipodocumento creada correctamente'247 248 def get_success_url(self): 249 return reverse('leer') # Redireccionamos a la vista principal 'leer'250class TipodocumentoDetalle (DetailView):251 model =Tipodocumento252class TipodocumentoActualizar(SuccessMessageMixin,UpdateView):253 model = Tipodocumento254 form = Tipodocumento255 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 256 success_message = 'Tipodocumento Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 257 def get_success_url(self): 258 return reverse('leer') # Redireccionamos a la vista principal 'leer'259class TipodocumentoEliminar(SuccessMessageMixin, DeleteView): 260 model = Tipodocumento 261 form = Tipodocumento262 fields = "__all__" 263 264 # Redireccionamos a la página principal luego de eliminar un registro o postre265 def get_success_url(self): 266 success_message = 'Tipodocumento Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 267 messages.success (self.request, (success_message)) 268 return reverse('leer') # Redireccionamos a la vista principal 'leer'269#270class ListadoReservas(ListView):271 model = Reservas272 273 274class ReservasCrear(SuccessMessageMixin, CreateView):275 model =Reservas276 form = Reservas277 fields = "__all__"278 success_message ='Reservas creada correctamente'279 280 def get_success_url(self): 281 return reverse('leer') # Redireccionamos a la vista principal 'leer'282class ReservasDetalle (DetailView):283 model =Reservas284class ReservasActualizar(SuccessMessageMixin,UpdateView):285 model = Reservas286 form = Reservas287 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 288 success_message = 'Reservas Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 289 def get_success_url(self): 290 return reverse('leer') # Redireccionamos a la vista principal 'leer'291class ReservasEliminar(SuccessMessageMixin, DeleteView): 292 model = Reservas 293 form = Reservas294 fields = "__all__" 295 296 # Redireccionamos a la página principal luego de eliminar un registro o postre297 def get_success_url(self): 298 success_message = 'Reservas Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 299 messages.success (self.request, (success_message)) 300 return reverse('leer') # Redireccionamos a la vista principal 'leer'301 302#303class ListadoServiciotour(ListView):304 model = Serviciotour305 306 307class ServiciotourCrear(SuccessMessageMixin, CreateView):308 model =Serviciotour309 form = Serviciotour310 fields = "__all__"311 success_message ='Serviciotour creada correctamente'312 313 def get_success_url(self): 314 return reverse('leer') # Redireccionamos a la vista principal 'leer'315class ServiciotourDetalle (DetailView):316 model =Serviciotour317class ServiciotourActualizar(SuccessMessageMixin,UpdateView):318 model = Serviciotour319 form = Serviciotour320 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 321 success_message = 'Serviciotour Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 322 def get_success_url(self): 323 return reverse('leer') # Redireccionamos a la vista principal 'leer'324class ServiciotourEliminar(SuccessMessageMixin, DeleteView): 325 model = Serviciotour 326 form = Serviciotour327 fields = "__all__" 328 329 # Redireccionamos a la página principal luego de eliminar un registro o postre330 def get_success_url(self): 331 success_message = 'Serviciotour Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 332 messages.success (self.request, (success_message)) 333 return reverse('leer') # Redireccionamos a la vista principal 'leer'334 335#336class ListadoOfertas(ListView):337 model = Ofertas338 339 340class OfertasCrear(SuccessMessageMixin, CreateView):341 model = Ofertas342 form = Ofertas343 fields = "__all__"344 success_message =' Ofertas creada correctamente'345 346 def get_success_url(self): 347 return reverse('leer') # Redireccionamos a la vista principal 'leer'348class OfertasDetalle (DetailView):349 model = Ofertas350class OfertasActualizar(SuccessMessageMixin,UpdateView):351 model = Ofertas352 form = Ofertas353 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 354 success_message = ' Ofertas Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 355 def get_success_url(self): 356 return reverse('leer') # Redireccionamos a la vista principal 'leer'357class OfertasEliminar(SuccessMessageMixin, DeleteView): 358 model = Ofertas 359 form = Ofertas360 fields = "__all__" 361 362 # Redireccionamos a la página principal luego de eliminar un registro o postre363 def get_success_url(self): 364 success_message = ' Ofertas Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 365 messages.success (self.request, (success_message)) 366 return reverse('leer') # Redireccionamos a la vista principal 'leer'367#368class ListadoLugar(ListView):369 model = Lugar370 371 372class LugarCrear(SuccessMessageMixin, CreateView):373 model =Lugar374 form = Lugar375 fields = "__all__"376 success_message ='Lugar creada correctamente'377 378 def get_success_url(self): 379 return reverse('leer') # Redireccionamos a la vista principal 'leer'380class LugarDetalle (DetailView):381 model =Lugar382class LugarActualizar(SuccessMessageMixin,UpdateView):383 model = Lugar384 form = Lugar385 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 386 success_message = 'Lugar Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 387 def get_success_url(self): 388 return reverse('leer') # Redireccionamos a la vista principal 'leer'389class LugarEliminar(SuccessMessageMixin, DeleteView): 390 model = Lugar 391 form = Lugar392 fields = "__all__" 393 394 # Redireccionamos a la página principal luego de eliminar un registro o postre395 def get_success_url(self): 396 success_message = 'Lugar Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 397 messages.success (self.request, (success_message)) 398 return reverse('leer') # Redireccionamos a la vista principal 'leer'399 400#401class ListadoEventos(ListView):402 model = Eventos403 404 405class EventosCrear(SuccessMessageMixin, CreateView):406 model =Eventos407 form = Eventos408 fields = "__all__"409 success_message ='Eventos creada correctamente'410 411 def get_success_url(self): 412 return reverse('leer') # Redireccionamos a la vista principal 'leer'413class EventosDetalle (DetailView):414 model =Eventos415class EventosActualizar(SuccessMessageMixin,UpdateView):416 model = Eventos417 form = Eventos418 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 419 success_message = 'Eventos Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 420 def get_success_url(self): 421 return reverse('leer') # Redireccionamos a la vista principal 'leer'422class EventosEliminar(SuccessMessageMixin, DeleteView): 423 model = Eventos 424 form = Eventos425 fields = "__all__" 426 427 # Redireccionamos a la página principal luego de eliminar un registro o postre428 def get_success_url(self): 429 success_message = 'Eventos Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 430 messages.success (self.request, (success_message)) 431 return reverse('leer') # Redireccionamos a la vista principal 'leer'432 433#434class ListadoPersona(ListView):435 model = Persona436 437 438class PersonaCrear(SuccessMessageMixin, CreateView):439 model =Persona440 form = Persona441 fields = "__all__"442 success_message ='Persona creada correctamente'443 444 def get_success_url(self): 445 return reverse('leer') # Redireccionamos a la vista principal 'leer'446class PersonaDetalle (DetailView):447 model =Persona448class PersonaActualizar(SuccessMessageMixin,UpdateView):449 model = Persona450 form = Persona451 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 452 success_message = 'Persona Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 453 def get_success_url(self): 454 return reverse('leer') # Redireccionamos a la vista principal 'leer'455class PersonaEliminar(SuccessMessageMixin, DeleteView): 456 model = Persona 457 form = Persona458 fields = "__all__" 459 460 # Redireccionamos a la página principal luego de eliminar un registro o postre461 def get_success_url(self): 462 success_message = 'Persona Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 463 messages.success (self.request, (success_message)) 464 return reverse('leer') # Redireccionamos a la vista principal 'leer'465#466class ListadoTipoeventos(ListView):467 model = Tipoeventos468 469 470class TipoeventosCrear(SuccessMessageMixin, CreateView):471 model =Tipoeventos472 form = Tipoeventos473 fields = "__all__"474 success_message ='Tipoeventos creada correctamente'475 476 def get_success_url(self): 477 return reverse('leer') # Redireccionamos a la vista principal 'leer'478class TipoeventosDetalle (DetailView):479 model =Tipoeventos480class TipoeventosActualizar(SuccessMessageMixin,UpdateView):481 model = Tipoeventos482 form = Tipoeventos483 fields = "__all__" # Le decimos a Django que muestre todos los campos de la tabla 'postres' de nuestra Base de Datos 484 success_message = 'Tipoeventos Actualizado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 485 def get_success_url(self): 486 return reverse('leer') # Redireccionamos a la vista principal 'leer'487class TipoeventosEliminar(SuccessMessageMixin, DeleteView): 488 model = Tipoeventos 489 form = Tipoeventos490 fields = "__all__" 491 492 # Redireccionamos a la página principal luego de eliminar un registro o postre493 def get_success_url(self): 494 success_message = 'Tipoeventos Eliminado Correctamente !' # Mostramos este Mensaje luego de Editar un Postre 495 messages.success (self.request, (success_message)) 496 return reverse('leer') # Redireccionamos a la vista principal 'leer...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!