Beispiel #1
0
def sign_up(request):
    if request.user.is_authenticated():
        return render(request, 'coplay/message.html', {
            'message': 'Already logged in',
            'rtl': 'dir="rtl"'
        })
    redirect_to = request.REQUEST.get('next', '')
    if not is_safe_url(url=redirect_to, host=request.get_host()):
        redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL)

    if request.method == 'POST':  # If the form has been submitted...
        form = AddUserForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            # Ensure the user-originating redirection url is safe.

            if False is form.cleaned_data['approved_discaimer']:
                return render(request, 'coplay/message.html', {
                    'message': 'עליך לאשר את מדיניות הפרטיות',
                    'rtl': 'dir="rtl"'
                })

            # Process the data in form.cleaned_data# Process the data in form.cleaned_data
            password = form.cleaned_data['password']
            password_confirm = form.cleaned_data['password_confirm']
            if password != password_confirm:
                return render(request, 'coplay/message.html', {
                    'message': 'אין התאמה בין שתי הסיסמאות',
                    'rtl': 'dir="rtl"'
                })

            user_name = form.cleaned_data['user_name']

            first_name = form.cleaned_data['first_name']
            last_name = form.cleaned_data['last_name']
            email = form.cleaned_data['email']

            recieve_updates = form.cleaned_data['recieve_email_updates']

            description = form.cleaned_data['description']

            location_desc = form.cleaned_data['location_desc']

            user = create_kuterless_user(user_name, password, first_name,
                                         last_name, email, recieve_updates,
                                         description, location_desc)

            user = authenticate(username=user_name, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect(redirect_to)
                    # Redirect to a success page.
                else:
                    # Return a 'disabled account' error message
                    return render(request, 'coplay/message.html', {
                        'message': 'disabled account',
                        'rtl': 'dir="rtl"'
                    })
            else:
                # Return an 'invalid login' error message.
                return render(request, 'coplay/message.html', {
                    'message': 'הכניסה נכשלה',
                    'rtl': 'dir="rtl"'
                })
        else:
            return render(request, 'coplay/message.html', {
                'message': 'הנתונים אינם מלאים',
                'rtl': 'dir="rtl"'
            })

        return HttpResponseRedirect(redirect_to)  # Redirect after POST

    else:
        form = AddUserForm()  # An unbound form

    return render(request, 'public_fulfillment/new_user.html', {
        'form': form,
        'next': redirect_to,
        'rtl': 'dir="rtl"'
    })
Beispiel #2
0
 def create_user(self):
     
     self.user = create_kuterless_user('zugu', '1234', 'john', 'doo', '*****@*****.**', False)
Beispiel #3
0
def sign_up(request):
    if request.user.is_authenticated():
        return render(request, 'coplay/message.html', 
                      {  'message'      :  'Already logged in',
                       'rtl': 'dir="rtl"'})
    redirect_to = request.REQUEST.get('next', '')
    if not is_safe_url(url=redirect_to, host=request.get_host()):
        redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL)

    if request.method == 'POST': # If the form has been submitted...
        form = AddUserForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            # Ensure the user-originating redirection url is safe.
            
            if False is form.cleaned_data['approved_discaimer']:
                return render(request, 'coplay/message.html', 
                      {  'message'      :  'עליך לאשר את מדיניות הפרטיות',
                       'rtl': 'dir="rtl"'})
                

            
            # Process the data in form.cleaned_data# Process the data in form.cleaned_data
            password = form.cleaned_data['password']
            password_confirm = form.cleaned_data['password_confirm']
            if password != password_confirm:
                return render(request, 'coplay/message.html', 
                      {  'message'      :  'אין התאמה בין שתי הסיסמאות',
                       'rtl': 'dir="rtl"'})
                
            user_name =  form.cleaned_data['user_name']
            
                
            first_name = form.cleaned_data['first_name']
            last_name =  form.cleaned_data['last_name']
            email     =  form.cleaned_data['email']

            
            recieve_updates = form.cleaned_data['recieve_email_updates']
            
            description = form.cleaned_data['description']
            
            location_desc = form.cleaned_data['location_desc']
            

            user = create_kuterless_user(  user_name, 
                                           password, 
                                           first_name, 
                                           last_name,  
                                           email, 
                                           recieve_updates, 
                                           description, 
                                           location_desc)
            
            
            user = authenticate(username=user_name, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect(redirect_to) 
                    # Redirect to a success page.
                else:
                    # Return a 'disabled account' error message
                    return render(request, 'coplay/message.html', 
                      {  'message'      :  'disabled account',
                       'rtl': 'dir="rtl"'})
            else:
                # Return an 'invalid login' error message.
                return render(request, 'coplay/message.html', 
                      {  'message'      :  'הכניסה נכשלה',
                       'rtl': 'dir="rtl"'})
        else:
            return render(request, 'coplay/message.html', 
                      {  'message'      :  'הנתונים אינם מלאים',
                       'rtl': 'dir="rtl"'})
            
        return HttpResponseRedirect(redirect_to) # Redirect after POST
        
    else:
        form = AddUserForm() # An unbound form


    return render(request, 'public_fulfillment/new_user.html', {
        'form': form,
        'next': redirect_to,
        'rtl': 'dir="rtl"'
    })
Beispiel #4
0
    def create_user(self):

        self.user = create_kuterless_user('zugu', '1234', 'john', 'doo',
                                          '*****@*****.**', False)