コード例 #1
0
ファイル: views.py プロジェクト: jptr/HipMeBeta2
def save_email(request):
    semail_text = request.POST['email_temp']
    context = {}

    if validateEmail(semail_text):
        semail = SavedEmail(email = request.POST['email_temp'], submit_date = timezone.now())
        semail.save()
        context.update({'info_message_saved_email': "Awesome, you're in.",})
        return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request))

    else:
        context.update({'error_message_saved_email': "Your email is not valid. Please try again.",})
        return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: jptr/HipMeBeta2
def register(request):
    username = request.POST['username']
    email_1 = request.POST['email_1']
    email_2 = request.POST['email_2']
    password = request.POST['password']
    context = {'username':username, 'email_1':email_1, 'email_2':email_2, 'password':password, }
    all_fields = True
    for field_key in ['username', 'email_1', 'email_2', 'password']:
        if not request.POST[field_key]:
            all_fields = False
            if 'email_2' in field_key:
                context.update({'error_message_email_2': "You must fill in all of the fields.",})
            elif 'email_1' in field_key:
                context.update({'error_message_email_1': "You must fill in all of the fields.",})
            elif 'password' in field_key:
                context.update({'error_message_password': "******",})
            else:
                context.update({'error_message_username': "******",})
    if all_fields:
        if validateUsername(username):
            if not User.objects.filter(username=username):
                if email_1==email_2:
                    if not User.objects.filter(email=email_1):
                        if validateEmail(email_1):
                            user = User.objects.create_user(username, email_1, password)
                            login_process(request)
                            messages.info(request, 'Welcome to hipme.fm!', extra_tags='welcome_message_line1')
                            messages.info(request, 'Discover great music: create mixtapes and ask your friends to put their best tracks in them...', extra_tags='welcome_message_line2')
                            messages.info(request, 'Or put tracks into their mixtapes: the more they like your recommendations, the higher you rank!', extra_tags='welcome_message_line2')
                            messages.info(request, 'First, find friends below and follow them. Then check out your stream and start playing!', extra_tags='welcome_message_line3')
                            from django.core.mail import send_mail
                            send_mail(generate_header_signup(user), generate_body_signup(user), 'hipme', [user.email], fail_silently=True)
                            return HttpResponseRedirect(reverse('hip_engine.views.suggest_profiles'))
                        else:
                            context.update({'error_message_email_1': "Your email is not valid. Please try again.",})
                            return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request))
                    else:
                        context.update({'error_message_email_1': "Email already exists. Please choose another one.",})
                        return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request)) 
                else:
                    context.update({'error_message_email_2': "Your emails do not match. Please try again.",})
                    return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request))
            else:
                context.update({'error_message_username': "******",})
                return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request))
        else:
            context.update({'error_message_username': "******",})
            return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request))
    else:
        return render_to_response('hip_engine/landing_page.html', context, context_instance=RequestContext(request))