Ejemplo n.º 1
0
 def get(self, request, *args, **kwargs):
     self.DetalleFormSet = inlineformset_factory(Appoint, AppointDetail,form=AppointDetailForm, extra=0,
         fields=('tipo', 'trabajador', 'especialidad', 'cuadrilla', 'asignacion', 'nombrada'), min_num=1)
     self.object = self.get_object()
     self.appoint = Appoint.objects.get(pk=self.object.id)
     self.appointform = AppointForm(
         auto_id='appoint_%s', instance=self.appoint)
     return self.render_to_response(self.get_context_data())
Ejemplo n.º 2
0
class AppointUpdate(GenerateMixin, UpdateView):
    model = Appoint
    template_name = 'planning/appoint_edit.html'
    success_url = reverse_lazy('adm_app:core_app:system-user')

    def get(self, request, *args, **kwargs):
        self.DetalleFormSet = inlineformset_factory(Appoint, AppointDetail,form=AppointDetailForm, extra=0,
            fields=('tipo', 'trabajador', 'especialidad', 'cuadrilla', 'asignacion', 'nombrada'), min_num=1)
        self.object = self.get_object()
        self.appoint = Appoint.objects.get(pk=self.object.id)
        self.appointform = AppointForm(
            auto_id='appoint_%s', instance=self.appoint)
        return self.render_to_response(self.get_context_data())

    def post(self, request, *args, **kwargs):
        self.DetalleFormSet = inlineformset_factory(Appoint, AppointDetail,form=AppointDetailForm, extra=0,
            fields=('tipo', 'trabajador', 'especialidad', 'cuadrilla', 'asignacion', 'nombrada'),
            min_num=1)
        self.object = self.get_object()
        self.appoint = Appoint.objects.get(pk=self.object.id)
        self.appointform = AppointForm(
            request.POST, auto_id='appoint_%s', instance=self.appoint)
        self.detalleFormSet = self.DetalleFormSet(request.POST, prefix='appoint_detalle', instance=self.appoint)
        resultado = ''
        if self.detalleFormSet.is_valid():
            resultado = get_validar_nombrada(self.appoint, self.detalleFormSet)
            self.appointform.save()
        print('pase')
        print(resultado)
        return self.render_to_response(self.get_context_data())

    def get_context_data(self, **kwargs):
        context = super(AppointUpdate, self).get_context_data(**kwargs)
        context['nav'] = (
            ('Panel Mando', '/'),
            ('Nombrada', reverse_lazy('adm_app:planning_app:appoint')),
            ('Actualizar', '')
        )
        context['form'] = self.appointform
        context['detalleFormSet'] = self.DetalleFormSet(instance=self.appoint, prefix='detalle')
        return context
Ejemplo n.º 3
0
 def post(self, request, *args, **kwargs):
     self.DetalleFormSet = inlineformset_factory(Appoint, AppointDetail,form=AppointDetailForm, extra=0,
         fields=('tipo', 'trabajador', 'especialidad', 'cuadrilla', 'asignacion', 'nombrada'),
         min_num=1)
     self.object = self.get_object()
     self.appoint = Appoint.objects.get(pk=self.object.id)
     self.appointform = AppointForm(
         request.POST, auto_id='appoint_%s', instance=self.appoint)
     self.detalleFormSet = self.DetalleFormSet(request.POST, prefix='appoint_detalle', instance=self.appoint)
     resultado = ''
     if self.detalleFormSet.is_valid():
         resultado = get_validar_nombrada(self.appoint, self.detalleFormSet)
         self.appointform.save()
     print('pase')
     print(resultado)
     return self.render_to_response(self.get_context_data())