summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprathamesh2014-06-06 15:20:45 +0530
committerprathamesh2014-06-06 15:20:45 +0530
commit77caf5d44ab14d56efd4acbc65a6dd2d78c1c1a6 (patch)
tree2279f7d4da3a84d83f3532a9d1fb7e2136e8e5a8
parentc5115d98867504076daacc093d09489033c6a584 (diff)
downloadonline_test-77caf5d44ab14d56efd4acbc65a6dd2d78c1c1a6.tar.gz
online_test-77caf5d44ab14d56efd4acbc65a6dd2d78c1c1a6.tar.bz2
online_test-77caf5d44ab14d56efd4acbc65a6dd2d78c1c1a6.zip
changes made as per comments.
-rw-r--r--testapp/myauthentication/README2
-rw-r--r--testapp/myauthentication/backend.py25
-rw-r--r--testapp/myauthentication/models_spoken_tutorial.py (renamed from testapp/myauthentication/models_spoken.py)2
-rw-r--r--testapp/myauthentication/router.py2
-rw-r--r--testapp/myauthentication/tests.py17
-rw-r--r--testapp/settings.py2
6 files changed, 20 insertions, 30 deletions
diff --git a/testapp/myauthentication/README b/testapp/myauthentication/README
index 6d1a7b4..4aef3c5 100644
--- a/testapp/myauthentication/README
+++ b/testapp/myauthentication/README
@@ -3,7 +3,7 @@ To use authentication from external source, follow the instructions given below:
1. In settings.py,
Uncomment AUTHENTICATION_BACKENDS = ('myauthentication.backend.MyBackend',)
Uncomment AUTHENTICATION_BACKENDS = ('myauthentication.backend.MyBackend',)
- Enter database name, username and password for the spoken database.
+ Enter database name, username and password for the spoken tutorial database.
2. From login.html template comment 'New User? Sign-Up' link.
This is to be done so that user will register only from external
diff --git a/testapp/myauthentication/backend.py b/testapp/myauthentication/backend.py
index d82f11a..721fe54 100644
--- a/testapp/myauthentication/backend.py
+++ b/testapp/myauthentication/backend.py
@@ -1,6 +1,7 @@
import hashlib
from django.contrib.auth.models import User, check_password
-from models_spoken import MdlUser
+from models_spoken_tutorial import MoodleUser
+
class MyBackend:
supports_object_permissions = False
@@ -14,24 +15,24 @@ class MyBackend:
and authenticates the user.
'''
try:
- user = MdlUser.objects.get(username=username)
+ user = MoodleUser.objects.get(username=username)
pwd = user.password
uid = user.id
firstname = user.firstname
lastname = user.lastname
email_id = user.email
p = hashlib.md5(password)
- pwd_valid = (pwd == p.hexdigest())
+ pwd_valid = (pwd == p.hexdigest())
if user and pwd_valid:
- try:
- user = User.objects.get(username=username)
- return user
- except Exception, e:
- user=User(id=uid, username=username, password=pwd,\
- first_name=firstname, last_name=lastname,\
- email=email_id)
- user.save()
- return user
+ try:
+ user = User.objects.get(username=username)
+ return user
+ except Exception, e:
+ user = User(id=uid, username=username, password=pwd,
+ first_name=firstname, last_name=lastname,
+ email=email_id)
+ user.save()
+ return user
except Exception, e:
return None
diff --git a/testapp/myauthentication/models_spoken.py b/testapp/myauthentication/models_spoken_tutorial.py
index 2526a0e..d333400 100644
--- a/testapp/myauthentication/models_spoken.py
+++ b/testapp/myauthentication/models_spoken_tutorial.py
@@ -9,7 +9,7 @@
from django.db import models
-class MdlUser(models.Model):
+class MoodleUser(models.Model):
id = models.BigIntegerField(primary_key=True)
username = models.CharField(unique=True, max_length=300)
password = models.CharField(max_length=96)
diff --git a/testapp/myauthentication/router.py b/testapp/myauthentication/router.py
index eeb4cdb..3d9c330 100644
--- a/testapp/myauthentication/router.py
+++ b/testapp/myauthentication/router.py
@@ -8,5 +8,5 @@ class MyDatabaseRouter(object):
database.
"""
if model._meta.app_label == 'myauthentication':
- return 'spoken'
+ return 'spoken_tutorial'
return None
diff --git a/testapp/myauthentication/tests.py b/testapp/myauthentication/tests.py
index 501deb7..4103038 100644
--- a/testapp/myauthentication/tests.py
+++ b/testapp/myauthentication/tests.py
@@ -1,16 +1,5 @@
-"""
-This file demonstrates writing tests using the unittest module. These will pass
-when you run "manage.py test".
+#This file demonstrates writing tests using the unittest module. These will pass
+#when you run "manage.py test".
-Replace this with more appropriate tests for your application.
-"""
+#Write appropriate tests for the application.
-from django.test import TestCase
-
-
-class SimpleTest(TestCase):
- def test_basic_addition(self):
- """
- Tests that 1 + 1 always equals 2.
- """
- self.assertEqual(1 + 1, 2)
diff --git a/testapp/settings.py b/testapp/settings.py
index cc84095..f1ef0ba 100644
--- a/testapp/settings.py
+++ b/testapp/settings.py
@@ -49,7 +49,7 @@ DATABASES = {
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
},
- 'spoken' : {
+ 'spoken_tutorial' : {
'ENGINE' : 'django.db.backends.mysql',
'NAME' : 'YOUR DATABASE',
'USER' : 'YOUR USERNAME',