Beispiel #1
0
def mdl_register(request):
    form = RegisterForm()
    if request.method == "POST":
        form = RegisterForm(request.POST)
        if form.is_valid():
            #Email exits
            try:
                user = MdlUser.objects.filter(
                    email=request.POST['email']).first().id
                messages.success(
                    request, "Email : " + request.POST['email'] +
                    " already registered on this website. Please click <a href='http://www.spoken-tutorial.org/participant/login/'>here </a>to login"
                )
            except Exception, e:
                mdluser = MdlUser()
                mdluser.auth = 'manual'
                mdluser.institution = form.cleaned_data['college']
                mdluser.gender = form.cleaned_data['gender']
                mdluser.firstname = form.cleaned_data['firstname'].upper()
                mdluser.lastname = form.cleaned_data['lastname'].upper()
                mdluser.email = form.cleaned_data['email'].lower()
                mdluser.username = mdluser.email
                mdluser.password = encript_password(
                    form.cleaned_data['password'])
                mdluser.confirmed = 1
                mdluser.mnethostid = 1
                mdluser.save()
                mdluser = MdlUser.objects.get(email=mdluser.email)
                get_or_create_user(mdluser, form.cleaned_data['password'])
                messages.success(
                    request, "User " + form.cleaned_data['firstname'] + " " +
                    form.cleaned_data['lastname'] +
                    " Created!. Please click <a href='http://www.spoken-tutorial.org/participant/login/'>here </a>to login"
                )
                return HttpResponseRedirect('/participant/register/')
def create_account(w, firstname, lastname, gender, email, category):
    password_string = ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(8))
    password_encript = encript_password(password_string)

    password = password_encript
    username = email
    mdluser = None
    try:
        mdluser = MdlUser.objects.filter(email=email).first()
        mdluser.institution = w.academic_id
        mdluser.firstname = firstname
        mdluser.lastname = lastname
        mdluser.gender = gender
        mdluser.save()
    except Exception, e:
        mdluser = MdlUser()
        mdluser.auth = 'manual'
        mdluser.firstname = firstname
        mdluser.username = username
        mdluser.lastname = lastname
        mdluser.password = password
        mdluser.institution = w.academic_id
        mdluser.email = email
        mdluser.confirmed = 1
        mdluser.mnethostid = 1
        mdluser.gender = gender
        mdluser.save()
        mdluser = MdlUser.objects.filter(email=email,
                                         firstname=firstname,
                                         username=username,
                                         password=password).first()

        # send password to email
        subject = "Spoken Tutorial Online Test password"
        to = [mdluser.email]
        message = '''Hi {0},

Your account password at 'Spoken Tutorials Online Test as follows'

Your current login information is now:
username: {1}
password: {2}

Please go to this page to change your password:
{3}

In most mail programs, this should appear as a blue link
which you can just click on.  If that doesn't work,
then cut and paste the address into the address
line at the top of your web browser window.

Cheers from the 'Spoken Tutorials Online Test Center' administrator,

Admin Spoken Tutorials
'''.format(mdluser.firstname, mdluser.username, password_string,
           'http://onlinetest.spoken-tutorial.org/login/change_password.php')

        # send email
        email = EmailMultiAlternatives(subject,
                                       message,
                                       '*****@*****.**',
                                       to=to,
                                       bcc=[],
                                       cc=[],
                                       headers={
                                           'Reply-To':
                                           '*****@*****.**',
                                           "Content-type":
                                           "text/html;charset=iso-8859-1"
                                       })
        try:
            result = email.send(fail_silently=False)
        except:
            pass
def create_account(w, firstname, lastname, gender, email, category):
    password_string = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8))
    password_encript = encript_password(password_string)

    password = password_encript
    username = email
    mdluser = None
    try:
        mdluser = MdlUser.objects.filter(email = email).first()
        mdluser.institution = w.academic_id
        mdluser.firstname = firstname
        mdluser.lastname = lastname
        mdluser.gender = gender
        mdluser.save()
    except Exception, e:
        mdluser = MdlUser()
        mdluser.auth = 'manual'
        mdluser.firstname = firstname
        mdluser.username = username
        mdluser.lastname = lastname
        mdluser.password = password
        mdluser.institution = w.academic_id
        mdluser.email = email
        mdluser.confirmed = 1
        mdluser.mnethostid = 1
        mdluser.gender = gender
        mdluser.save()
        mdluser = MdlUser.objects.filter(email = email, firstname= firstname, username=username, password=password).first()
        
        # send password to email
        subject  = "Spoken Tutorial Online Test password"
        to = [mdluser.email]
        message = '''Hi {0},

Your account password at 'Spoken Tutorials Online Test as follows'

Your current login information is now:
username: {1}
password: {2}

Please go to this page to change your password:
{3}

In most mail programs, this should appear as a blue link
which you can just click on.  If that doesn't work,
then cut and paste the address into the address
line at the top of your web browser window.

Cheers from the 'Spoken Tutorials Online Test Center' administrator,

Admin Spoken Tutorials
'''.format(mdluser.firstname, mdluser.username, password_string, 'http://onlinetest.spoken-tutorial.org/login/change_password.php')

        # send email
        email = EmailMultiAlternatives(
            subject, message, '*****@*****.**',
            to = to, bcc = [], cc = [],
            headers={'Reply-To': '*****@*****.**', "Content-type":"text/html;charset=iso-8859-1"}
        )

        result = email.send(fail_silently=False)
Beispiel #4
0
def mdl_register(request):
    form = RegisterForm()
    if request.method == "POST":
        form = RegisterForm(request.POST)
        
        #Email exits
        try:
            user = MdlUser.objects.filter(email=request.POST['email']).first()
            if user:
                messages.success(request, "Email : "+request.POST['email']+" already registered on this website. Please click <a href='http://www.spoken-tutorial.org/participant/login/'>here </a>to login")
        except Exception, e:
            #print e
            pass
            
        if form.is_valid():
            mdluser = MdlUser()
            mdluser.auth = 'manual'
            mdluser.institution = form.cleaned_data['college']
            mdluser.gender = form.cleaned_data['gender']
            mdluser.firstname = form.cleaned_data['firstname']
            mdluser.lastname = form.cleaned_data['lastname']
            mdluser.email = form.cleaned_data['email']
            mdluser.username = form.cleaned_data['username']
            mdluser.password = encript_password(form.cleaned_data['password'])
            mdluser.confirmed = 1
            mdluser.mnethostid = 1
            mdluser.save()
            messages.success(request, "User " + form.cleaned_data['firstname'] +" "+form.cleaned_data['lastname']+" Created!")
            return HttpResponseRedirect('/participant/register/')