Ejemplo n.º 1
0
def register(request):    
    if request.method == 'POST': # If the form has been submitted...        
        form = RegisterForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            clamuser = form.save()
            send_mail('[' + settings.DOMAIN + '] Registration request from ' + clamuser.username + ' pending approval' , 'The following new account is pending approval:\n\nUsername: '******'\nFull name: '  +clamuser.fullname + '\nInstitution: ' + clamuser.institution + '\nMail: ' + clamuser.mail + '\n\nTo approve this user go to: ' + settings.BASEURL + 'activate/' + str(clamuser.pk), settings.FROMMAIL, [ x[1] for x in settings.ADMINS ] , fail_silently=False)
            return render_to_response('submitted.html')            
    else:
        c = RequestContext(request)
        c.update(csrf(request))
        form = RegisterForm() # An unbound form
        return render_to_response('register.html', {'form': form},context_instance=c)
Ejemplo n.º 2
0
def register(request):
    if request.method == 'POST': # If the form has been submitted...
        form = RegisterForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            try:
                clamuser = form.save()
            except IntegrityError:
                return HttpResponseForbidden("That username is already registered (1)", content_type="text/plain")
            if autoactivate(clamuser):
                clamuser = CLAMUsers(username=clamuser.username, password=clamuser.password,fullname=clamuser.fullname, institution=clamuser.institution, mail=clamuser.mail,active=True)
                try:
                    clamuser.save()
                except IntegrityError:
                    return HttpResponseForbidden("That username is already registered (2)", content_type="text/plain")
                send_mail('[' + settings.DOMAIN + '] Registration request from ' + clamuser.username + ' automatically approved' , 'The following new account has been automatically approved, no further action is required:\n\nUsername: '******'\nFull name: '  +clamuser.fullname + '\nInstitution: ' + clamuser.institution + '\nMail: ' + clamuser.mail + '\n\n', settings.FROMMAIL, [ x[1] for x in settings.ADMINS ] , fail_silently=False)
                return render_to_response('activated.html')
            else:
                send_mail('[' + settings.DOMAIN + '] Registration request from ' + clamuser.username + ' pending approval' , 'The following new account is pending approval:\n\nUsername: '******'\nFull name: '  +clamuser.fullname + '\nInstitution: ' + clamuser.institution + '\nMail: ' + clamuser.mail + '\n\nTo approve this user go to: ' + settings.BASEURL + 'activate/' + str(clamuser.pk), settings.FROMMAIL, [ x[1] for x in settings.ADMINS ] , fail_silently=False)
                return render_to_response('submitted.html')
    else:
        c = RequestContext(request)
        c.update(csrf(request))
        form = RegisterForm() # An unbound form
        return render_to_response('register.html', {'form': form},context_instance=c)
Ejemplo n.º 3
0
def register(request):
    if request.method == 'POST':  # If the form has been submitted...
        form = RegisterForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            try:
                clamuser = form.save()
            except IntegrityError:
                return HttpResponseForbidden(
                    "That username is already registered (1)",
                    content_type="text/plain")
            if autoactivate(clamuser):
                clamuser = CLAMUsers(username=clamuser.username,
                                     password=clamuser.password,
                                     fullname=clamuser.fullname,
                                     institution=clamuser.institution,
                                     mail=clamuser.mail,
                                     active=True)
                try:
                    clamuser.save()
                except IntegrityError:
                    return HttpResponseForbidden(
                        "That username is already registered (2)",
                        content_type="text/plain")
                send_mail(
                    '[' + settings.DOMAIN + '] Registration request from ' +
                    clamuser.username + ' automatically approved',
                    'The following new account has been automatically approved, no further action is required:\n\nUsername: '******'\nFull name: ' + clamuser.fullname +
                    '\nInstitution: ' + clamuser.institution + '\nMail: ' +
                    clamuser.mail + '\n\n',
                    settings.FROMMAIL, [x[1] for x in settings.ADMINS],
                    fail_silently=False)
                return render_to_response('activated.html')
            else:
                send_mail(
                    '[' + settings.DOMAIN + '] Registration request from ' +
                    clamuser.username + ' pending approval',
                    'The following new account is pending approval:\n\nUsername: '******'\nFull name: ' + clamuser.fullname +
                    '\nInstitution: ' + clamuser.institution + '\nMail: ' +
                    clamuser.mail + '\n\nTo approve this user go to: ' +
                    settings.BASEURL + 'activate/' + str(clamuser.pk),
                    settings.FROMMAIL, [x[1] for x in settings.ADMINS],
                    fail_silently=False)
                return render_to_response('submitted.html')
        else:
            return HttpResponseForbidden(
                "One or more entered fields were not valid, please go back and try again",
                content_type="text/plain")
    else:
        form = RegisterForm()  # An unbound form
        return render(request, 'register.html', {'form': form})