Beispiel #1
0
def register():
    """Register the user's details to the application"""

    form = RegisterForm()

    if form.validate_on_submit() and request.method == 'POST':

        user.Account.Register.register(registration_form=form)
        Message.display_to_gui_screen(
            'You need to verify your account to use price alerter')

    return render_template("registration/register.html", form=form)
Beispiel #2
0
def update_user(request):
    response_data = {'status' : 'failed', 'message' : 'unknown deletion error'}
    if request.is_ajax():
        if request.method == 'POST':
            form = RegisterForm(instance=request.user, data=request.POST)
            if form.is_valid():
                form.instance.username = form.instance.email
                form.save()
                response_data = {'status' : 'success', 'message' : 'updated user'}
            else:
                response_data = {'status' : 'failed', 'message' : json.dumps(form.errors)}
    return HttpResponse(json.dumps(response_data), content_type="application/json")
Beispiel #3
0
def register(request):
    response_data = {}
    if request.is_ajax():
        if request.method == 'POST':
            form = RegisterForm(request.POST)
            # Validate the form: the captcha field will automatically
            # check the input
            if form.is_valid():
                response_data = create_user(form)  # Create our store
            else:
                response_data = {'status' : 'failed', 'message' : json.dumps(form.errors)}
    else:
        response_data = {'status' : 'failure', 'message' : 'Not acceptable request made.' }
    return HttpResponse(json.dumps(response_data), content_type="application/json")
Beispiel #4
0
def redirectedregister(request):
    form = RegisterForm()
    return render(request, 'register/register.html'
    ,{
    'form': form,  
     'local_css_urls': ["css3/easy-responsive-tabs.css",
                            "css3/material-kit.min1036.css",
                            "css3/demo.css",
                            "css3/vertical-nav.css"],
        'local_js_urls': [ "core/jquery.min.js",
                           "core/popper.min.js",
                           "core/bootstrap-material-design.min.js",
                           "js3/vertical-nav.js",
                           "js3/material-kit.min1036.js",
                           "js3/demo.js",
                           "js3/buttons.js",
                           "js3/modernizr.js",                         
                           "js3/bootstrap.min.js",                           
                           "js3/plugins/moment.min.js ",
                           "js3/plugins/bootstrap-datetimepicker.js",
                           "js3/plugins/jquery.flexisel.js",
                           "js3/plugins/jquery.sharrre.js",
                           "js3/plugins/nouislider.min.js",
                           "js3/plugins/bootstrap-selectpicker.js",
                           "js3/plugins/bootstrap-tagsinput.js",
                           "js3/plugins/jasny-bootstrap.min.js"]
      
    })
Beispiel #5
0
def redirectedregister(request):
    form = RegisterForm()
    return render(
        request, 'register/register.html', {
            'local_css_urls': settings.SB_ADMIN_2020UI_CSS_LIBRARY_URLS,
            'local_js_urls': settings.SB_ADMIN_2020UI_JS_LIBRARY_URLS,
            'form': form
        })
Beispiel #6
0
def register(request, form):
    form = RegisterForm(deserialize_form(form))
    statu = 0
    context = {}
    if form.is_valid():
        name = form.cleaned_data['name']
        st_no = int(form.cleaned_data['student_number'])
        password = form.cleaned_data['password']
        try:
            user = User(username=st_no, first_name=name)
            user.set_password(password)
            user.save()
            common_user = CommonUser(user=user, student_number=st_no)
            common_user.save()
            user = auth.authenticate(username=st_no, password=password)
            if user: auth.login(request, user)
        except Exception, e:
            print e
            statu = 1
Beispiel #7
0
def register_modal(request):
    form = RegisterForm()
    return render(request, 'register/modal.html',{
        'form': form,
    })
def signup(request):
    signup_type = register_user_type
    if request.method == "POST":
        if signup_type == 'user':
            new_user_form = RegisterForm(request.POST)
            if new_user_form.is_valid():
                new_user = User.objects.create_user(
                    username=new_user_form.cleaned_data["username"],
                    password=new_user_form.cleaned_data["password"],
                    email=new_user_form.cleaned_data["email"])

                new_user.first_name = new_user_form.cleaned_data["first_name"]
                new_user.last_name = new_user_form.cleaned_data["last_name"]
                new_user.is_active = False
                new_user.save()
                user_details = UserDetails.objects.create(
                    user_id=new_user,
                    date_of_birth=request.POST["DOB"],
                    gender=request.POST["gender"],
                    phone_no=request.POST["phone_number"])
                user_type = Type.objects.create(user=new_user, ref_no=1)
                new_user.save()
                user_details.save()
                user_type.save()
                print("Form is valid")

                current_site = get_current_site(request)
                mail_subject = 'Activate your OMS user account.'
                message = render_to_string(
                    'registration/acc_active_email.html', {
                        'user': new_user,
                        'domain': current_site.domain,
                        'uid': urlsafe_base64_encode(force_bytes(new_user.pk)),
                        'token': account_activation_token.make_token(new_user),
                    })
                to_email = new_user_form.cleaned_data.get('email')
                email = EmailMessage(mail_subject, message, to=[to_email])
                email.send()
                return HttpResponse(
                    '<h1>New user created successfully</h1><br>Please confirm your email address to complete the registration'
                )

            else:
                print("User signup form Invalid")
                return render(request, 'registration/signup_page.html', {
                    "signup_form": new_user_form,
                    'signup_type': signup_type
                })
        elif signup_type == 'orphanage':
            new_user_form = RegisterForm(request.POST)
            if new_user_form.is_valid():
                new_user = User.objects.create_user(
                    username=new_user_form.cleaned_data["username"],
                    password=new_user_form.cleaned_data["password"],
                    email=new_user_form.cleaned_data["email"])
                print(request.POST["current_latitude"])
                print(request.POST["current_longitude"])
                new_user.save()
                new_orphanage_user = Orphanage.objects.create(
                    orphanage_id=User.objects.get(
                        username=new_user_form.cleaned_data["username"]),
                    orphanage_name=request.POST["orphanage_name"],
                    year_of_establishment=request.
                    POST["year_of_establishment"],
                    address=request.POST["address"],
                    phone_no=request.POST["phone_number"],
                    description=request.POST["description"],
                    image=request.FILES.get("orphanage_image"),
                    lat=float(request.POST["current_latitude"]),
                    lon=float(request.POST["current_longitude"]),
                )

                user_type = Type.objects.create(user=new_user, ref_no=2)
                new_user.is_active = False

                new_user.save()
                new_orphanage_user.save()
                user_type.save()

                current_site = get_current_site(request)
                mail_subject = 'Activate your OMS user account.'
                message = render_to_string(
                    'registration/acc_active_email.html', {
                        'user': new_user,
                        'domain': current_site.domain,
                        'uid': urlsafe_base64_encode(force_bytes(new_user.pk)),
                        'token': account_activation_token.make_token(new_user),
                    })
                to_email = new_user_form.cleaned_data.get('email')
                email = EmailMessage(mail_subject, message, to=[to_email])
                email.send()
                return HttpResponse(
                    '<h1>New orphanage user created successfully</h1><br>'
                    'Please confirm your email address to complete the registration'
                )
                # return HttpResponse("<h1>New orphanage user created successfully</h1>")
            else:
                print("Orphanage signup form Invalid")
                return render(request, 'registration/signup_page.html', {
                    "signup_form": new_user_form,
                    'signup_type': signup_type
                })
        else:
            new_form = RegisterForm()
            print("Signup type not available now.")
            return render(request, 'registration/signup_page.html', {
                "signup_form": new_form,
                'signup_type': signup_type
            })
    else:
        new_form = RegisterForm()
        print("Invalid request")
        return render(request, 'registration/signup_page.html',
                      {"signup_form": new_form})