phiron

Exemplo de abstração máxima usando o ClassBasedView e herança de classes.

Jan 17th, 2021
727
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class CreatePlanoContasView(LoginRequiredMixin,AjaxableResponseMixin,CreateView):
  2.     '''
  3.    Cria o plano de contas
  4.    '''
  5.     model = PlanoContas
  6.     fields = ['nome','descricao','arquivo']
  7.     def get_context_data(self,*args,**kwargs):
  8.         context = super(CreatePlanoContasView, self).get_context_data(*args,**kwargs)
  9.         context['file_upload'] = True
  10.         return context
  11.  
  12. criar_plano_contas = gzip_page(CreatePlanoContasView.as_view())
  13.  
  14. class EditarPlanoContasView(LoginRequiredMixin,AjaxableResponseMixin,UpdateView):
  15.     '''
  16.    Atualiza o plano de contas
  17.    '''
  18.     model = PlanoContas
  19.     fields = ['nome','descricao','arquivo','visivel']
  20.     def get_context_data(self,*args,**kwargs):
  21.         context = super(EditarPlanoContasView, self).get_context_data(*args,**kwargs)
  22.         context['file_upload'] = True
  23.         return context
  24.  
  25. editar_plano_contas = gzip_page(EditarPlanoContasView.as_view())
  26.  
  27. class ApagarPlanoContasView(LoginRequiredMixin,AjaxableResponseMixin,DeleteViewMixin,DeleteView):
  28.     '''
  29.    Apaga o plano de contas
  30.    '''
  31.     model = PlanoContas
RAW Paste Data