Ejemplo n.º 1
0
def profile_edit(request):
    """
    GET: show profile edit form with current data
    POST: validate and store new data
    """
    from profiles.forms import ProfileEditForm
    profile = get404(UserProfile, user=request.user)
    if request.method == 'POST':
        form = ProfileEditForm(request.POST)
        if form.is_valid():
            user = request.user
            user.first_name = form.cleaned_data['first_name']
            user.last_name = form.cleaned_data['last_name']
            up = UserProfile.objects.get(user=user)
            up.country = form.cleaned_data['country']
            up.state = form.cleaned_data['state']
            up.about = form.cleaned_data['about']
            user.save()
            up.save()
            messages.success(request, 'Perfil actualizado satisfactoriamente')
            return HttpResponseRedirect(reverse('my-profile'))
        else:
            context = {'status_message': form.errors}
            return HttpResponse(status=400, content=simplejson.dumps(context))
    data = {
        'first_name': request.user.first_name,
        'last_name': request.user.last_name,
        'email': request.user.email,
        'country': profile.country,
        'about': profile.about,
        'state': profile.state,
    }
    context = {'form': ProfileEditForm(data)}
    return Render('profile_edit.html', RequestContext(request, context))
Ejemplo n.º 2
0
def profile_edit(request):
    """
    GET: show profile edit form with current data
    POST: validate and store new data
    """
    from profiles.forms import ProfileEditForm
    profile = get404(UserProfile, user=request.user)
    if request.method == 'POST':
        form = ProfileEditForm(request.POST)
        if form.is_valid():
            user = request.user
            user.first_name = form.cleaned_data['first_name']
            user.last_name = form.cleaned_data['last_name']
            up = UserProfile.objects.get(user=user)
            up.country = form.cleaned_data['country']
            up.state = form.cleaned_data['state']
            up.about = form.cleaned_data['about']
            user.save()
            up.save()
            messages.success(request, 'Perfil actualizado satisfactoriamente')
            return HttpResponseRedirect(reverse('my-profile'))
        else:
            context = {'status_message': form.errors}
            return HttpResponse(status=400, content=simplejson.dumps(context))
    data = {
        'first_name': request.user.first_name,
        'last_name': request.user.last_name,
        'email': request.user.email,
        'country': profile.country,
        'about': profile.about,
        'state': profile.state,
    }
    context = {'form': ProfileEditForm(data)}
    return Render('profile_edit.html', RequestContext(request, context))
Ejemplo 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))
Ejemplo n.º 4
0
def index(request):
    usuario = request.user
    cliente = get404(Cliente, user=usuario)
    lista_productos = Producto.objects.filter(id_cliente=cliente)
    lista_afilia_prepago = Afilia.objects.filter(id_producto__in=lista_productos, vigente_afilia=True, id_plan__tipo_plan="prepago")
   
    lista_afilia_postpago = Afilia.objects.filter(id_producto__in=lista_productos, vigente_afilia=True, id_plan__tipo_plan="postpago")
    lista_producto_postpago = []
    for afilia in lista_afilia_postpago:
	lista_producto_postpago.append(afilia.id_producto)
    lista_factura = Factura.objects.filter(id_producto__in=lista_producto_postpago) 	

    a = '418-3137818'
    facts = []
    
    for p in lista_producto_postpago:
	i = p.id_producto
    	dum = []
    	for b in Factura.objects.raw('SELECT * FROM mocel_factura where id_producto_id=%s ORDER BY fecha_factura',[i]):
		dum.append(b)
	dum = dum[:1]
	facts.append(dum[0])
   
    print facts
    return Render(request, 'mocel/index.html', locals())
Ejemplo n.º 5
0
def presentation_vote(request, presentation_id):
    context = {}
    if request.method == 'POST':
        p = get404(Presentation, id=presentation_id)
        p.votes += 1
        p.save()
        context = {'status_message': 'Voto agregado con éxito'}
        return HttpResponse(simplejson.dumps(context))
    return HttpResponse(status=405)
Ejemplo n.º 6
0
def presentation_vote(request, presentation_id):
    context = {}
    if request.method == 'POST':
        p = get404(Presentation, id=presentation_id)
        p.votes += 1
        p.save()
        context = {'status_message': 'Voto agregado con éxito'}
        return HttpResponse(simplejson.dumps(context))
    return HttpResponse(status=405)
Ejemplo n.º 7
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))
Ejemplo n.º 8
0
def presentation_view(request, presentation_id):
    import hashlib
    from profiles.models import UserProfile
    p = get404(Presentation, id=presentation_id)
    s = p.speakers.all()[0]
    profile = UserProfile.objects.get(user=s)
    context = {
        'avatar':'http://www.gravatar.com/avatar/%s'%hashlib.md5(s.email).hexdigest(),
        'presentation': p,
        'speaker': s.get_full_name(),
        'about': profile.about,
        'country': profile.country,
        'state': profile.state,
    }
    return Render('presentation_detail.html', RequestContext(request, context))
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
def presentation_view(request, presentation_id):
    import hashlib
    from profiles.models import UserProfile
    p = get404(Presentation, id=presentation_id)
    s = p.speakers.all()[0]
    profile = UserProfile.objects.get(user=s)
    context = {
        'avatar':
        'http://www.gravatar.com/avatar/%s' % hashlib.md5(s.email).hexdigest(),
        'presentation':
        p,
        'speaker':
        s.get_full_name(),
        'about':
        profile.about,
        'country':
        profile.country,
        'state':
        profile.state,
    }
    return Render('presentation_detail.html', RequestContext(request, context))
Ejemplo n.º 12
0
def profile_password_reset(request, encoded):
    from profiles.forms import PasswordResetForm
    pr = get404(PasswordRecovery, encoded=encoded)
    if not pr.consumed:
        email, token = base64.b64decode(encoded).split('|')
        if email == pr.user.email and token == pr.token:
            if request.method == 'POST':
                form = PasswordResetForm(request.POST)
                if form.is_valid():
                    password = form.cleaned_data['new_password']
                    pr.user.set_password(password)
                    pr.consumed = True
                    pr.user.save()
                    pr.delete()
                    messages.success(request, 'Contraseña modificada satisfactoriamente')
                    return HttpResponseRedirect('/')
                return HttpResponse(status=400, content=simplejson.dumps(form.errors))
            context = {'form': PasswordResetForm()}
            return Render('password_reset.html', RequestContext(request, context))
    mesasges.error(request, 'Token inválido o previamente consumido')
    return HttpResponseRedirect('/')
Ejemplo n.º 13
0
def profile_password_reset(request, encoded):
    from profiles.forms import PasswordResetForm
    pr = get404(PasswordRecovery, encoded=encoded)
    if not pr.consumed:
        email, token = base64.b64decode(encoded).split('|')
        if email == pr.user.email and token == pr.token:
            if request.method == 'POST':
                form = PasswordResetForm(request.POST)
                if form.is_valid():
                    password = form.cleaned_data['new_password']
                    pr.user.set_password(password)
                    pr.consumed = True
                    pr.user.save()
                    pr.delete()
                    messages.success(request, 'Contraseña modificada satisfactoriamente')
                    return HttpResponseRedirect('/')
                return HttpResponse(status=400, content=simplejson.dumps(form.errors))
            context = {'form': PasswordResetForm()}
            return Render('password_reset.html', RequestContext(request, context))
    mesasges.error(request, 'Token inválido o previamente consumido')
    return HttpResponseRedirect('/')
Ejemplo n.º 14
0
def index(request):
    usuario = request.user
    cliente = get404(Cliente, user=usuario)
    lista_productos = Producto.objects.filter(id_cliente=cliente)
    print lista_productos
    return Render(request, 'mocel/index.html', locals())