def vacacionUpdate(request, pk, template_name='vacacion/vacacionForm.html'): vacaciones = get_object_or_404(vacacion, pk=pk) form = vacacionForm(request.POST or None, instance=vacaciones) if form.is_valid(): object = form.save(commit=False) object.solicitante = request.user object.save() return redirect('home') return render(request, template_name, {'form': form, 'title': 'Editar solicitud de vacaciĆ³n'})
def vacacionCreate(request, template_name='vacacion/vacacionForm.html'): # print request.user.get_all_permissions() for g in request.user.groups.all(): print g.name # import ipdb; ipdb.set_trace() # print request.user.groups.all()[0].name # if request.user.groups.filter(name='rrhh').exists(): # print "El usuario pertenece a RRHH" form = vacacionForm(request.POST or None) if form.is_valid(): object = form.save(commit=False) object.solicitante = request.user object.save() return redirect('home') return render(request, template_name, {'form': form, 'title': 'Crear solicitud de vacaciĆ³n'})