Esempio n. 1
0
def presentation_create(request):
    """
    GET: shows the presentation registration form
    POST: saves all the information
    """
    from cms.forms import PresentationForm
    context = {}
    if request.method == 'POST':
        form = PresentationForm(request.POST)
        if form.is_valid():
            p = Presentation()
            p.name = form.cleaned_data['name']
            p.description = form.cleaned_data['description']
            p.tutorial = form.cleaned_data['tutorial']
            p.duration = form.cleaned_data['duration']
            p.requirements = form.cleaned_data['requirements']
            p.save()
            p.speakers.add(request.user)
            p.save()
            context = {'status_message': 'Charla creada'}
            return HttpResponseRedirect(reverse('success-presentation'))
        else:
            context = {'status_message': form.errors}
            return HttpResponse(status=400, content=simplejson.dumps(context))
    else:
        context = {'form': PresentationForm()}
    return Render('cms/presentation_create.html', RequestContext(request, context))
Esempio n. 2
0
def presentation_create(request):
    """
    GET: shows the presentation registration form
    POST: saves all the information
    """
    from cms.forms import PresentationForm
    context = {}
    if request.method == 'POST':
        form = PresentationForm(request.POST)
        if form.is_valid():
            p = Presentation()
            p.name = form.cleaned_data['name']
            p.description = form.cleaned_data['description']
            p.tutorial = form.cleaned_data['tutorial']
            p.duration = form.cleaned_data['duration']
            p.requirements = form.cleaned_data['requirements']
            p.save()
            p.speakers.add(request.user)
            p.save()
            context = {'status_message': 'Charla creada'}
            return HttpResponseRedirect(reverse('success-presentation'))
        else:
            context = {'status_message': form.errors}
            return HttpResponse(status=400, content=simplejson.dumps(context))
    else:
        context = {'form': PresentationForm()}
    return Render('cms/presentation_create.html',
                  RequestContext(request, context))
Esempio n. 3
0
def presentation_edit(request, presentation_id):
    """
    GET: show the presentation edit form
    POST: validates and saves all the information
    """
    from cms.forms import PresentationForm
    context = {}
    p = get404(Presentation, id=presentation_id)
    if request.method == 'POST':
        form = PresentationForm(request.POST) 
        if form.is_valid():
            #form.save()
            p.name = form.cleaned_data['name']
            p.description = form.cleaned_data['description']
            p.tutorial = form.cleaned_data['tutorial']
            p.duration = form.cleaned_data['duration']
            p.requirements = form.cleaned_data['requirements']
            p.save()
            ps = request.user.presentation_set.all()
            context = {'ps': ps, 'formSpeakerRegistration' : PresentationForm()}
            return HttpResponseRedirect(reverse('my-profile'))
            # return Render('profile.html',RequestContext(request, context))

            # context = {'status_message': 'Cambios realizados'}
            # return HttpResponse(simplejson.dumps(context))
            # if request.user in p.speakers.all():
            #     #p.speakers = form.cleaned_data['speakers']
            #     p.name = form.cleaned_data['name']
            #     p.description = form.cleaned_nada['description']
            #     p.tutorial = form.cleaned_data['tutorial']
            #     p.duration = form.cleaned_data['duration']
            #     p.requirements = form.cleaned_data['requirements']
            #     p.save()
            #     context = {'status_message': 'Cambios realizados'}
            #     return HttpResponse(simplejson.dumps(context))
            # else:
            #     context = {'status_message': 'Debes ser uno de los ponentes para editar la charla'}
            #     return HttpResponse(status=403, content=context)
        else:
            context = {'status_message': form.errors}
            return HttpResponse(status=400, content=simplejson.dumps(context))
    else:
        
        elemento = Presentation.objects.get(id=int(presentation_id))
        form = PresentationForm(instance=elemento)
        context = { 'formSpeakerRegistration' : form, 'presentation_id':elemento.id}
        data = {
            'speakers': p.speakers.all(),
            'name': p.name,
            'description': p.description,
            'tutorial': p.tutorial,
            'duration': p.duration,
            'requirements': p.requirements,
        }
        #ps = request.user.presentation_set.all()
        #context = {'data': data}
    return Render('_presentation.html', RequestContext(request, context))
Esempio n. 4
0
def profiles_myprofile(request):
    from cms.forms import PresentationForm

    ps = request.user.presentation_set.all()
    context = {'data': ps}
    context = {'formSpeakerRegistration': PresentationForm(), 'ps': ps}
    return Render('profile.html', RequestContext(request, context))
Esempio n. 5
0
def presentation_success(request):
    from cms.forms import PresentationForm
    ps = request.user.presentation_set.all()
    context = {
        'success_message': 'La presentación ha sido creado correctamente.',
        'ps': ps,
        'formSpeakerRegistration': PresentationForm()
    }
    return Render('profile.html', RequestContext(request, context))
Esempio n. 6
0
def presentation_edit(request, presentation_id):
    """
    GET: show the presentation edit form
    POST: validates and saves all the information
    """
    from cms.forms import PresentationForm
    context = {}
    p = get404(Presentation, id=presentation_id)
    if request.method == 'POST':
        form = PresentationForm(request.POST)
        if form.is_valid():
            #form.save()
            p.name = form.cleaned_data['name']
            p.description = form.cleaned_data['description']
            p.tutorial = form.cleaned_data['tutorial']
            p.duration = form.cleaned_data['duration']
            p.requirements = form.cleaned_data['requirements']
            p.save()
            ps = request.user.presentation_set.all()
            context = {'ps': ps, 'formSpeakerRegistration': PresentationForm()}
            return HttpResponseRedirect(reverse('my-profile'))
            # return Render('profile.html',RequestContext(request, context))

            # context = {'status_message': 'Cambios realizados'}
            # return HttpResponse(simplejson.dumps(context))
            # if request.user in p.speakers.all():
            #     #p.speakers = form.cleaned_data['speakers']
            #     p.name = form.cleaned_data['name']
            #     p.description = form.cleaned_nada['description']
            #     p.tutorial = form.cleaned_data['tutorial']
            #     p.duration = form.cleaned_data['duration']
            #     p.requirements = form.cleaned_data['requirements']
            #     p.save()
            #     context = {'status_message': 'Cambios realizados'}
            #     return HttpResponse(simplejson.dumps(context))
            # else:
            #     context = {'status_message': 'Debes ser uno de los ponentes para editar la charla'}
            #     return HttpResponse(status=403, content=context)
        else:
            context = {'status_message': form.errors}
            return HttpResponse(status=400, content=simplejson.dumps(context))
    else:

        elemento = Presentation.objects.get(id=int(presentation_id))
        form = PresentationForm(instance=elemento)
        context = {
            'formSpeakerRegistration': form,
            'presentation_id': elemento.id
        }
        data = {
            'speakers': p.speakers.all(),
            'name': p.name,
            'description': p.description,
            'tutorial': p.tutorial,
            'duration': p.duration,
            'requirements': p.requirements,
        }
        #ps = request.user.presentation_set.all()
        #context = {'data': data}
    return Render('_presentation.html', RequestContext(request, context))
Esempio n. 7
0
def presentation_delete(request, presentation_id):
    p = get404(Presentation, id=presentation_id)
    if request.method == 'POST':
        #p = get404(Presentation, id=presentation_id)
        if request.user in p.speakers.all():
            p.delete()
        else:
            context = {'status_message': 'Esta presentación no es tuya'}
            return HttpResponse(status=403, content=context)
        return HttpResponse(status=200)
    else:
        p.delete()
        ps = request.user.presentation_set.all()
        context = {'ps': ps, 'formSpeakerRegistration': PresentationForm()}
        #return Render('_presentation.html',RequestContext(request, context))
        return HttpResponseRedirect(reverse('my-profile'))
    return HttpResponse(status=405)