コード例 #1
0
ファイル: views.py プロジェクト: allanjuliani/rockranking
def register_3(request):

    if email:
        #register
        try:
            user = User.objects.get(email=email)
        except:
            ip = request.META.get('REMOTE_ADDR')
            facebook = request.POST["facebook"]
            iso = request.POST["iso"]
            name = request.POST["name"]
            user = User()
            try:
                country = Country.objects.get(iso=iso)
            except:
                country = Country.objects.get(id=1)
                user.country_error = iso
            user.username = email
            user.name = name
            user.email = email
            user.facebook = facebook
            user.country = country
            user.ip = ip
            user.date = datetime.now()
            user.confirmed = 1
            user.save()


    else:
        res = "not login"
    
    return HttpResponse(res)
コード例 #2
0
ファイル: views.py プロジェクト: allanjuliani/rockranking
def _add_user(request, email, password, band_id, facebook = "", name = "", country = ""):
    #import ipdb; ipdb.set_trace()
    key = hashlib.md5(email).hexdigest()

    try:
        country = Country.objects.get(id=country)
    except:
        country = Country.objects.get(id=1)

    if not facebook:
        confirmed = 0
        try:
            html = "Hello!"
            html = html + "<br><br>To confirm your vote "
            html = html + "<a href='http://rockranking.com/user/validate/" + key + "/'>click here</a>"
            html = html + "<br><br>If you can not access the link, please copy this"
            html = html + "<br>http://rockranking.com/user/validate/" + key + "/"
            html = html + "<br>and paste in your browser"
            html = html + "<br><br>Rock Ranking Team \m/"

            _send_email(email,html)
            email_feedback = 'sent'
        except:
            email_feedback = 'error to sent'
    else:
        confirmed = 1
        email_feedback = 'facebook login'
    try:
        user = User()
        user.username = ""
        user.name = name
        user.email = email
        user.password = hashlib.md5(password).hexdigest()
        user.email_feedback = email_feedback
        user.facebook = facebook
        user.country = country
        user.ip = request.META.get('REMOTE_ADDR')
        user.key = key
        user.date = datetime.now()
        user.action = "add_band_%s" % band_id
        user.confirmed = confirmed
        user.save()

        return True

    except:
        return False