Skip to content

Commit

Permalink
Merge branch 'bug/49'
Browse files Browse the repository at this point in the history
Conflicts:
	CHANGES
  • Loading branch information
wjdp committed Nov 9, 2014
2 parents 00ebbd1 + b8e2080 commit 74b3b98
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Change notes should be geared towards the managers of xSACdb instances.
[bug] Pool sheets with undefined lessons would cause server error
[feature] `Award SDC` page implemented, allows awarding a single SDC to multiple trainees
[feature] Can have multiple lessons per trainee per session. Works on individual and group selections. Trainees in session list are now sorted by last name. (Trainees added individually cannot be added multiple times in the same selection, the process must be repeated.)
[bug] Deleting member present in a session without assigned lessons caused server error

# nu-6 - 2014/10/27

Expand Down
7 changes: 3 additions & 4 deletions xsd_members/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,13 @@ def no_expiry_data(self):
if self.club_expiry==None and self.bsac_expiry==None and self.medical_form_expiry==None:
return True
else: return False
def performed_lessons_for_qualification(self, qualification):
pass
def performed_lesson_ramble(self):
# TODO: A good comment here would be ideal!
pls = PerformedLesson.objects.filter(trainee=self.user)
pls = PerformedLesson.objects.filter(trainee=self.user).order_by('date')
ret = ""
for pl in pls:
ret += pl.lesson.code+' - '+str(pl.date)+'<br />'
if pl.lesson:
ret += pl.lesson.code+' - '+str(pl.date)+'<br />'
return ret[:len(ret)-6]

PERSONAL_FIELDS = ['address','postcode','home_phone','mobile_phone','next_of_kin_name','next_of_kin_relation','next_of_kin_phone']
Expand Down
85 changes: 77 additions & 8 deletions xsd_members/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@

from django.test import TestCase
from django.contrib.auth.models import User

from xsd_members.models import MemberProfile
from xsd_training.models import Lesson, PerformedLesson

class PresetUser(TestCase):
USERNAME = 'bob'
EMAIL = '[email protected]'
PASSWORD = 'correcthorsebatterystaple'

fixtures = ['local_files/test1.json']

def setUp(self):
self.make_user()
self.make_pls()

class MPFunctionality(TestCase):
def test_create_user(self):
def make_user(self):
self.u = User.objects.create_user(
username='bob',
email='[email protected]',
password='correcthorsebatterystaple',
username=self.USERNAME,
email=self.EMAIL,
password=self.PASSWORD,
)
self.u.first_name='Bob'
self.u.last_name='Blobby'
Expand All @@ -18,11 +30,66 @@ def test_create_user(self):
self.mp = self.u.memberprofile
self.mp.save()

def make_pls(self):
PLS = [
{
'trainee': self.u,
'lesson': Lesson.objects.get(code='OO3'),
'completed': False,
'partially_complted': False,
'public_notes': 'Note',
'private_notes': 'Note',
},
{
'trainee': self.u,
'lesson': Lesson.objects.get(code='OO3'),
'completed': True,
'partially_complted': False,
'public_notes': 'Note',
'private_notes': 'Note',
},
{
'trainee': self.u,
'lesson': Lesson.objects.get(code='OO3'),
'completed': False,
'partially_complted': True,
'public_notes': 'Note',
'private_notes': 'Note',
},
{
'trainee': self.u,
'lesson': None,
'completed': False,
'partially_complted': False,
'public_notes': 'Note',
'private_notes': 'Note',
},
{
'trainee': self.u,
'lesson': None,
'completed': False,
'partially_complted': False,
'public_notes': '',
'private_notes': '',
}
]
for PL in PLS:
new_pl = PerformedLesson()
new_pl.trainee = PL['trainee']
new_pl.lesson = PL['lesson']
new_pl.completed = PL['completed']
new_pl.partially_complted = PL['partially_complted']
new_pl.public_notes = PL['public_notes']
new_pl.private_notes = PL['private_notes']
new_pl.save()


class MPFunctionality(PresetUser):

def test_u_mp_relationship(self):
self.assertEqual(self.mp, self.u.memberprofile)

def test_age(self):
self.test_create_user()

test_age = 21
today = datetime.date.today()
t_years_ago = datetime.date(
Expand All @@ -35,7 +102,6 @@ def test_age(self):
self.assertEqual(self.mp.age(),test_age)

def test_personal_fields(self):
self.test_create_user()
# We have missing personal fields
self.assertEqual(self.mp.missing_personal_details(), True)
# Set all of them
Expand All @@ -50,6 +116,9 @@ def test_personal_fields(self):
# We now shouldn't have any
self.assertEqual(self.mp.missing_personal_details(), False)

def test_performed_lesson_ramble(self):
out = self.mp.performed_lesson_ramble()
self.assertTrue('OO3' in out)

def test_caching(self):
pass

0 comments on commit 74b3b98

Please sign in to comment.