Exemplo n.º 1
0
def sn(request):
    user=""
    pwd=""
    form = account(request.POST or None)
    
    if form.is_valid():
        user = form.cleaned_data['username']
        pwd = form.cleaned_data['password']
        
        user = user.lower();
        
        
        
        try:
            listing = dbRoutine.retrieve_account_no_password(user)
        except dbRoutine.retrieve_account_no_password(user).DoesNotExist:
            listing = None
        
        if (listing == None):
            dbRoutine.create_account(user, pwd)
            user_account = User.objects.create_user(user, "", pwd)
            
            user_account_login = authenticate(username=user, password=pwd)
            login(request, user_account_login)
            
            return HttpResponseRedirect('/../home')
        else:
            return HttpResponseRedirect('/../welcome/accountexists')
        

    context={
        "form": form,
    }   
    
    return render(request, 'signup.html', context)
Exemplo n.º 2
0
 def test_link_card(self):    
     
     acc = "acc"
     pwd = "pwd"
     dbRoutine.create_account(acc, pwd)
     account = dbRoutine.retrieve_account(acc, pwd)
     dbRoutine.create_fc("biology", "q", "a")
Exemplo n.º 3
0
 def test_empty_create_acct(self):
     acc = None 
     pword = "123"
     dbRoutine.create_account(acc, pword);
        
     acc = "abc"
     pword = None
     dbRoutine.create_account(acc, pword);
Exemplo n.º 4
0
 def test_link_session(self):
     
     acc = "acc"
     pwd = "pwd"
     dbRoutine.create_account(acc, pwd)
     account = dbRoutine.retrieve_account(acc, pwd)
     dbRoutine.create_fc("biology", "q", "a")
     session = dbRoutine.create_session("biology", 17)
     dbRoutine.link_session(account.getName(), session)
     sessions = account.getSessions()
     
     self.assertEqual(1, sessions.count())
Exemplo n.º 5
0
 def test_delete_user_account(self):
     
     acc = "acc"
     pwd = "pwd"
     
     dbRoutine.create_account(acc, pwd)
     user_account = User.objects.create_user(acc, "", pwd)
     
     account = dbRoutine.retrieve_account(acc, pwd)
     #account.values().values_list('id', flat=True)
     
     account.delete()
     user_account.delete()
Exemplo n.º 6
0
 def test_retrieve_account_no_password(self):
     acc = "acc"
     pword = "pwd"
     dbRoutine.create_account(acc, pword)
     
     account = dbRoutine.retrieve_account_no_password(acc)
     
     self.assertEqual("acc", account.getName())
     
     wrong_acc = "wrong"
     
     
     account = dbRoutine.retrieve_account_no_password(wrong_acc)
     self.assertEqual(None, account )
Exemplo n.º 7
0
def register(request):  
    print ("register" + request)
    
    json_dict = json.loads(request.body.decode('utf-8'))
    
    user = json_dict['username']
    pwd = json_dict['password']     
    
    try:
        listing = dbRoutine.retrieve_account_no_password(user)
    except dbRoutine.retrieve_account_no_password(user).DoesNotExist:
        listing = None
        
    if (listing == None):
        dbRoutine.create_account(user, pwd)
        user_account = User.objects.create_user(user, "", pwd)
        
        user_account_login = authenticate(username=user, password=pwd)
        login(request, user_account_login)   
        return JsonResponse({'registration':'successful'})
    else:
        return JsonResponse({{'registration':'duplicate'}})    
Exemplo n.º 8
0
 def test_create_account(self):
     acc = "abc"
     pword = "123"
     dbRoutine.create_account(acc, pword)
     accounts = dbRoutine.retrieve_allAccount()
     self.assertEqual(1, accounts.count())