Beispiel #1
0
def crear_solicitud(request):
    try:
        if request.is_ajax():
            if request.method == 'POST':
                solform = SolicitudForm(request.user, request.POST)
                if solform.is_valid():
                    e = eleccion(solform.cleaned_data['tipo'].nombre, solform.cleaned_data['rubro'])
                    s = Solicitud.objects.create(
                        descripcion=solform.cleaned_data['descripcion'],
                        emisor=request.user,
                        receptor=e,
                        tipo=solform.cleaned_data['tipo'],
                        categoria=solform.cleaned_data['categoria'],
                        estado=1
                    )
                    if solform.cleaned_data['categoria'].nombre in ('incidente', 'requerimiento'):
                        s.rubro = solform.cleaned_data['rubro']
                        s.save()
                    return render_to_response("agregada.html", context_instance=RequestContext(request))
            else:
                solform = SolicitudForm(request.user, initial={'emisor': request.user.get_full_name()})
                solform.fields['emisor'].widget.attrs['readonly'] = True
                solform.fields['categoria'].widget.attrs['id'] = 'id_cat'
                solform.fields['categoria'].widget.attrs['onchange'] = 'aparecer_rubro()'
            return render_to_response("crear_solicitud.html", {'solform': solform},
                context_instance=RequestContext(request))
        else:
            print request.is_ajax()
            raise Http404
    except Exception, ex:
        print ex
        raise Http404
Beispiel #2
0
 def test_tarea_seguridad(self):
     e = eleccion('conectividad', 'Seguridad')
     self.assertEqual(e, self.e2)
Beispiel #3
0
 def test_tarea_bd(self):
     e = eleccion('base de datos', None)
     self.assertEqual(e, self.e1)