Esempio n. 1
0
def profile_activate(request, encoded):
    try:
        regprofile = RegistrationProfile.objects.get(encoded=encoded)
        email, token = base64.b64decode(encoded).split('|')
        if email == regprofile.user.email and token == regprofile.token:
            regprofile.user.is_active = True
            regprofile.user.save()
            context = {'success_message': 'Perfil activado, ahora puede iniciar sesión con su correo electrónico'}
            return Render('base.html', RequestContext(request, context))
    except:
        pass
    context = {'error_message': 'Usuario ya activado o token inválido'}
    return Render('base.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 home(request):
    from profiles.forms import UserProfileForm, PasswordRecoveryForm
    context = {
        'formUserProfile': UserProfileForm(),
        'passwordRecoveryForm': PasswordRecoveryForm()
    }
    return Render('base.html', RequestContext(request, context))
Esempio n. 4
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))
Esempio n. 5
0
def profile_create(request):
    """
    GET: show profile creation form
    POST: validates and stores data
    """
    from profiles.forms import UserProfileForm
    if request.method == 'POST':
        form = UserProfileForm(request.POST)
        if form.is_valid():
            user = User()
            user.first_name = form.cleaned_data['first_name']
            user.last_name = form.cleaned_data['last_name']
            user.username = form.cleaned_data['email']
            user.email = form.cleaned_data['email']
            user.set_password(form.cleaned_data['password'])
            user.save()
            up = UserProfile.objects.get(user=user)
            up.country = form.cleaned_data['country']
            if form.cleaned_data.has_key('state'):
                up.state = form.cleaned_data['state']
            if form.cleaned_data.has_key('about'):
                up.about = form.cleaned_data['about']
            up.save()
            return HttpResponseRedirect(reverse('success-profile'))
        else:
            context = {'formUserProfile': form}
            return Render('base.html', RequestContext(request, context))
    return HttpResponseRedirect('/#inscriptions')
Esempio n. 6
0
def speaker_registration(request):
    if request.method == 'POST':
        from profiles.forms import SpeakerRegistrationForm
        form = SpeakerRegistrationForm(request.POST)
        if form.is_valid():
            user = User()
            user.first_name = form.cleaned_data['s_first_name']
            user.last_name = form.cleaned_data['s_last_name']
            user.username = form.cleaned_data['s_email']
            user.email = form.cleaned_data['s_email']
            user.set_password(form.cleaned_data['s_password'])
            user.save()
            up = UserProfile.objects.get(user=user)
            up.country = form.cleaned_data['s_country']
            if form.cleaned_data.has_key('s_state'):
                up.state = form.cleaned_data['s_state']
            up.about = form.cleaned_data['s_about']
            up.save()
            p = Presentation()
            p.name = form.cleaned_data['s_presentation_name']
            p.description = form.cleaned_data['s_presentation_description']
            p.tutorial = form.cleaned_data['s_presentation_tutorial']
            p.duration = form.cleaned_data['s_presentation_duration']
            p.requirements = forms.cleaned_data['s_presentation_requirements']
            p.save()
            p.speakers.add(user)
            p.save()
            return HttpResponseRedirect(reverse('success-profile'))
        else:
            context = {'formUserProfile': form}
            return Render('base.html', RequestContext(request, context))
    return HttpResponseRedirect('/#inscriptions')
Esempio 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))
Esempio n. 8
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. 9
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. 10
0
def sponsor_list(request):
    from hashlib import md5
    sponsors = Sponsor.objects.all()
    contributors = UserProfile.objects.filter(contributor=True)
    contributors = [{'name': c.user.get_full_name(), 'avatar': 'http://www.gravatar.com/avatar/%s'%md5(c.user.email).hexdigest(), 'twitter': c.twitter, 'what': c.what, 'pycon': c.pycon} for c in contributors]
    context = {
        'platino': sponsors.filter(sponsorship_type='pl'),
        'oro': sponsors.filter(sponsorship_type='g'),
        'plata': sponsors.filter(sponsorship_type='p'),
        'bronce': sponsors.filter(sponsorship_type='b'),
        'organizador': sponsors.filter(sponsorship_type='o'),
        'colaborador': contributors
    }
    return Render('sponsors.html', RequestContext(request, context))
Esempio 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))
Esempio 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('/')
Esempio n. 13
0
def presentation_list(request):
    context = {}
    return Render('presentation_list.html', RequestContext(request, context))
Esempio n. 14
0
def profile_success(request):
    context = {
        'success_message':
        'El perfil ha sido creado correctamente. Por favor revise su correo para validar el registro.'
    }
    return Render('base.html', RequestContext(request, context))