Example #1
0
def edit_evento(request, slug):
    article = get_object_or_404(SubscriberEvento, slug=slug)
    form = EventoForm(request.POST or None, instance=article)
    if form.is_valid():
        evento = form.save()
        return redirect(evento)
    return render(request, 'comunidad/evento_form.html', {'form': form, 'article': article})
Example #2
0
def eventoadd(request, codigo=None):
    evento = None
    url_edit = None
    if codigo:
        evento = Evento.objects.get(pk=codigo)
    if request.method == 'POST':
        form = EventoForm(request.POST,error_class=DivErrorList, instance=evento)
        if form.is_valid():
            messages.add_message(request, messages.SUCCESS, 
                   'Registro %s exitosamente!' % ((codigo)and'Modificado'or'Grabado') )         
            if codigo:
                evento.idusuario_mod = request.user.get_profile()
                evento.fec_mod = datetime.today()
                evento.save()
                #insert_or_update_event(evento,url_edit)
                return redirect('ogcs-mantenimiento-evento-query') 
            else:
                evento = form.save(commit=False)
                evento.idusuario_creac = request.user.get_profile()
                evento.fec_creac = datetime.today()
                evento.organismo_id = evento.idusuario_creac.organismo_id
                evento.dependencia = evento.idusuario_creac.dependencia
                evento.save()
                #insert_or_update_event(evento)
            form = EventoForm()
    else:        
        form = EventoForm(instance = evento)
    return render_to_response('calendar/actividad.html',
                              {
                                  'form':form,
                                  'opcion':'add',
                                  'codigo':codigo,
                                  'evento': evento if evento else ''
                              }, context_instance=RequestContext(request))
Example #3
0
def add_evento(request):
    form = EventoForm(request.POST or None)
    if form.is_valid():
        evento = form.save(commit=False)
        evento.created_by = request.user
        evento.save()
        msg = "Evento guardado exitosamente."
        messages.success(request, msg, fail_silently=True)
        return redirect(evento)
    return render(request, 'comunidad/evento_form.html', {'form': form})
Example #4
0
def RegistrarEvento(request):
	if not request.user.is_staff:
		return HttpResponse("<h1>Acceso restringido consulte al administrador</h1>")

	eventos = Evento.objects.all()
	if request.method == 'POST':
		form = EventoForm(request.POST)
		if form.is_valid():
			form.save()

			return HttpResponseRedirect('/administracion/evento/')

	else:
		form = EventoForm()

	return render_to_response('administracion/evento.html',{'form':form, 'eventos': eventos},
		context_instance=RequestContext(request))
Example #5
0
def evento_charla_crear(request):
    if request.POST:
        charla_form = CharlaForm(request.POST)
        evento_form = EventoForm(request.POST)
        if charla_form.is_valid() and evento_form.is_valid():
            new_charla = charla_form.save(commit=False)
            new_evento = evento_form.save()
            new_charla.evento_id = new_evento.pk
            new_charla.save()
            return HttpResponseRedirect('/evento/exito')
    else:
        charla_form = CharlaForm()
        evento_form = EventoForm()

    return render(request, 'forms/form_multiple.html', {
        'titulo': 'Nueva Charla Invitada:',
        'form1' : evento_form,
        'form2' : charla_form,
        'text'  : 'Creacion de una nueva charla invitada',
        'button': 'Crear Evento',
    })
Example #6
0
def evento_sesion_crear(request):
    if request.POST:
        sesion_form = Sesion_PonenciaForm(request.POST)
        evento_form = EventoForm(request.POST)
        if sesion_form.is_valid() and evento_form.is_valid():
            new_sesion = sesion_form.save(commit=False)
            new_evento = evento_form.save()
            new_sesion.evento_id = new_evento.pk
            new_sesion.save()
            return HttpResponseRedirect('/evento/exito')
    else:
        sesion_form = Sesion_PonenciaForm()
        evento_form = EventoForm()

    return render(request, 'forms/form_multiple.html', {
        'titulo': 'Nueva Sesion de Ponencias:',
        'form1' : evento_form,
        'form2' : sesion_form,
        'text'  : 'Creacion de una nueva sesion de ponencias',
        'button': 'Crear Evento',
    })
Example #7
0
def registerEvent(request):


	if request.method == 'POST':
		form = RegistrationForm(data=request.POST)
		evento_form = EventoForm(data = request.POST)

		if form.is_valid() and evento_form.is_valid:
			user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1'])
			user.save()
			evento = evento_form.save()
			evento.save()
			usuario = auth.authenticate(username=request.POST['username'], password=request.POST['password1'])
			login(request,usuario)
			return HttpResponseRedirect('/')

	args = {}
	args.update(csrf(request))
	args['user']=RegistrationForm()
	args['evento_form']=EventoForm()

	return render(request, 'registroEvento1.html', args)
Example #8
0
def evento_taller_crear(request):
    if request.POST:
        taller_form = TallerForm(request.POST)
        evento_form = EventoForm(request.POST)
        if taller_form.is_valid() and evento_form.is_valid():
            new_taller = taller_form.save(commit=False)
            new_evento = evento_form.save()
            new_taller.evento_id = new_evento.pk
            new_taller.save()
            taller_form.save_m2m()
            return HttpResponseRedirect('/evento/exito')
    else:
        taller_form = TallerForm()
        evento_form = EventoForm()

    return render(request, 'forms/form_multiple.html', {
        'titulo': 'Nueva Taller:',
        'form1' : evento_form,
        'form2' : taller_form,
        'text'  : 'Creacion de un taller',
        'button': 'Crear Evento',
    })
Example #9
0
def novo():
    nucleos = [(c.id, c.descricao) for c in Nucleo.query.order_by(Nucleo.descricao).all()]
    
    form = EventoForm()
    form.id_nucleo.choices = nucleos
    form.id_nucleo.choices.insert(0, (0, 'Selecione...'))

    if request.method == "POST" and form.validate_on_submit():
        evento = Evento()
        form.populate_obj(evento)

        if evento.id_nucleo == 0:
            evento.id_nucleo = None

        db.session.add(evento)
        db.session.commit()
        
        flash("Evento adicionado com sucesso!", "success")
        return redirect("/evento/")

        
    return render_template("evento/form.html", form = form, menu='eventos')
Example #10
0
def editar(id):
    evento = Evento.query.get_or_404(id)   
    nucleos = [(c.id, c.descricao) for c in Nucleo.query.order_by(Nucleo.descricao).all()]

    if is_accessible() or (g.user.id_nucleo == evento.id_nucleo):
        form = EventoForm(obj=evento)

        form.id_nucleo.choices = nucleos
        form.id_nucleo.choices.insert(0, (0, "Selecione...")) 
        
        if request.method == "POST" and form.validate_on_submit():
            form.populate_obj(evento)
            
            if evento.id_nucleo == 0:
                evento.id_nucleo = None
            
            db.session.commit()

            flash(u"Evento editado com sucesso!", "success")
            return redirect("/evento/")
    else:
        abort(403)

    return render_template("evento/form.html", form = form, menu='eventos')
Example #11
0
def RegistrarEvento(request):
    if not request.user.is_staff:
        return HttpResponse(
            "<h1>Acceso restringido consulte al administrador</h1>")

    eventos = Evento.objects.all()
    if request.method == 'POST':
        form = EventoForm(request.POST)
        if form.is_valid():
            form.save()

            return HttpResponseRedirect('/administracion/evento/')

    else:
        form = EventoForm()

    return render_to_response('administracion/evento.html', {
        'form': form,
        'eventos': eventos
    },
                              context_instance=RequestContext(request))
Example #12
0
def evento_charla_crear(request):
    if request.POST:
        charla_form = CharlaForm(request.POST)
        evento_form = EventoForm(request.POST)
        if charla_form.is_valid() and evento_form.is_valid():
            new_charla = charla_form.save(commit=False)
            new_evento = evento_form.save()
            new_charla.evento_id = new_evento.pk
            new_charla.save()
            return HttpResponseRedirect('/evento/exito')
    else:
        charla_form = CharlaForm()
        evento_form = EventoForm()

    return render(
        request, 'forms/form_multiple.html', {
            'titulo': 'Nueva Charla Invitada:',
            'form1': evento_form,
            'form2': charla_form,
            'text': 'Creacion de una nueva charla invitada',
            'button': 'Crear Evento',
        })
Example #13
0
def evento_sesion_crear(request):
    if request.POST:
        sesion_form = Sesion_PonenciaForm(request.POST)
        evento_form = EventoForm(request.POST)
        if sesion_form.is_valid() and evento_form.is_valid():
            new_sesion = sesion_form.save(commit=False)
            new_evento = evento_form.save()
            new_sesion.evento_id = new_evento.pk
            new_sesion.save()
            return HttpResponseRedirect('/evento/exito')
    else:
        sesion_form = Sesion_PonenciaForm()
        evento_form = EventoForm()

    return render(
        request, 'forms/form_multiple.html', {
            'titulo': 'Nueva Sesion de Ponencias:',
            'form1': evento_form,
            'form2': sesion_form,
            'text': 'Creacion de una nueva sesion de ponencias',
            'button': 'Crear Evento',
        })
Example #14
0
def evento_taller_crear(request):
    if request.POST:
        taller_form = TallerForm(request.POST)
        evento_form = EventoForm(request.POST)
        if taller_form.is_valid() and evento_form.is_valid():
            new_taller = taller_form.save(commit=False)
            new_evento = evento_form.save()
            new_taller.evento_id = new_evento.pk
            new_taller.save()
            taller_form.save_m2m()
            return HttpResponseRedirect('/evento/exito')
    else:
        taller_form = TallerForm()
        evento_form = EventoForm()

    return render(
        request, 'forms/form_multiple.html', {
            'titulo': 'Nueva Taller:',
            'form1': evento_form,
            'form2': taller_form,
            'text': 'Creacion de un taller',
            'button': 'Crear Evento',
        })