def get(self, request, *args, **kwargs): self.object = self.get_object() self.employee = Employee.objects.get(pk=self.object.id) self.form_employee_qualification = EmployeeQualificationForm( auto_id='employee_qualification_%s', instance=self.employee) self.qualification_quantity = constant_employee.QUALIFICATION_LIST return self.render_to_response(self.get_context_data())
class EmployeeQualificationUpdate(GenerateMixin, UpdateView): template_name = 'administrator/employee_qualification/employee_qualification_create_update.html' model = Employee success_url = reverse_lazy('adm_app:employee_app:employee-qualification') def get(self, request, *args, **kwargs): self.object = self.get_object() self.employee = Employee.objects.get(pk=self.object.id) self.form_employee_qualification = EmployeeQualificationForm( auto_id='employee_qualification_%s', instance=self.employee) self.qualification_quantity = constant_employee.QUALIFICATION_LIST return self.render_to_response(self.get_context_data()) def post(self, request, *args, **kwargs): self.object = self.get_object() self.employee = Employee.objects.get(pk=self.object.id) self.form_employee_qualification = EmployeeQualificationForm( request.POST, auto_id='employee_qualification_%s', instance=self.employee) self.qualification_quantity = constant_employee.QUALIFICATION_LIST if self.form_employee_qualification.is_valid(): self.form_employee_qualification.save() return self.render_to_response(self.get_context_data()) def get_context_data(self, **kwargs): context = super(EmployeeQualificationUpdate, self).get_context_data( **kwargs) context['nav'] = ( ('Panel Mando', '/'), ('Calificación', reverse_lazy('adm_app:employee_app:employee-qualification')), (self.employee.get_full_name(), '') ) context['employee_qualification'] = self.form_employee_qualification context['employee'] = self.employee context['qualification_quantity'] = self.qualification_quantity return context