-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'integration-branch' into 10-transfers-access
- Loading branch information
Showing
24 changed files
with
557 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{% extends 'base.html' %} | ||
{% block body %} | ||
|
||
{% include 'partials/navbar.html' %} | ||
|
||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12"> | ||
{% if lessons %} | ||
<h1>Your upcoming lessons!</h1> | ||
<table class="table table-striped table-dark"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Date</th> | ||
<th scope="col">Duration</th> | ||
<th scope="col">Teacher</th> | ||
<th scope="col">Topic</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for lesson in lessons %} | ||
<tr> | ||
<td>{{ lesson.date }}</td> | ||
<td>{{ lesson.duration }}</td> | ||
<td>{{ lesson.teacher }}</td> | ||
<td>{{ lesson.topic }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
{% else %} | ||
<h1> There are no upcoming lessons scheduled for you yet!</h1> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"model": "lessons.lessonRequest", | ||
"pk" : 1, | ||
"fields" : { | ||
"author": 1, | ||
"availability": "Monday", | ||
"lessonNum": 3, | ||
"interval": 1, | ||
"duration": 60, | ||
"topic": "Piano", | ||
"teacher": "Mr Bob" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from django.test import TestCase | ||
from lessons.models import Student, Lesson, Invoice | ||
from lessons.forms import EditLessonForm | ||
|
||
class EditLessonFormTestCase(TestCase): | ||
"""Unit tests for lesson edit form""" | ||
|
||
fixtures = [ | ||
'lessons/tests/fixtures/admin_user.json', | ||
'lessons/tests/fixtures/default_student.json', | ||
'lessons/tests/fixtures/default_invoice.json' | ||
] | ||
|
||
def setUp(self): | ||
super(TestCase, self).setUp() | ||
self.student = Student.objects.get(email="[email protected]") | ||
self.form_input = { | ||
"date": "2023-12-03 12:00:00Z", | ||
"duration": 60, | ||
"topic": "Piano", | ||
"teacher": "Mr Bob" | ||
} | ||
|
||
self.lesson = Lesson( | ||
student = Student.objects.get(email="[email protected]"), | ||
invoice = Invoice.objects.get(invoice_number=100), | ||
date = "2022-12-03 12:00:00Z", | ||
duration = 1, | ||
topic = "Drums", | ||
teacher = "Mr Jim" | ||
) | ||
|
||
def test_lesson_edit(self): | ||
self.form_input['duration'] = 61 | ||
form = EditLessonForm(instance=self.lesson, data=self.form_input) | ||
self.assertTrue(form.is_valid()) | ||
form.save() | ||
self.assertEqual(61, self.lesson.duration) | ||
|
||
def test_form_contains_fields(self): | ||
form = EditLessonForm() | ||
self.assertIn("date", form.fields) | ||
self.assertIn("duration", form.fields) | ||
self.assertIn("topic", form.fields) | ||
self.assertIn("teacher", form.fields) | ||
|
||
def test_accept_valid_input(self): | ||
form = EditLessonForm(data = self.form_input) | ||
self.assertTrue(form.is_valid()) | ||
|
||
def test_reject_blank_date(self): | ||
self.form_input['date'] = "" | ||
form = EditLessonForm(data = self.form_input) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_reject_blank_duration(self): | ||
self.form_input['duration'] = "" | ||
form = EditLessonForm(data = self.form_input) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_reject_blank_topic(self): | ||
self.form_input['topic'] = "" | ||
form = EditLessonForm(data = self.form_input) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_reject_blank_teacher(self): | ||
self.form_input['teacher'] = "" | ||
form = EditLessonForm(data = self.form_input) | ||
self.assertFalse(form.is_valid()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,14 @@ class EditRequestFormTestCase(TestCase): | |
|
||
fixtures = [ | ||
'lessons/tests/fixtures/default_student.json', | ||
'lessons/tests/fixtures/default_lesson_request.json', | ||
] | ||
|
||
def setUp(self): | ||
super(TestCase, self).setUp() | ||
self.student = Student.objects.get(email="[email protected]") | ||
self.lessonRequest = LessonRequest.objects.get(author=1) | ||
|
||
self.form_input = { | ||
"availability": "Monday", | ||
"lessonNum": 2, | ||
|
@@ -20,16 +23,7 @@ def setUp(self): | |
"topic": "piano", | ||
"teacher": "Mr Bob" | ||
} | ||
|
||
self.lessonRequest = LessonRequest( | ||
author = self.student, | ||
availability = "Monday", | ||
lessonNum = 2, | ||
interval = 1, | ||
duration = 60, | ||
topic = "Piano", | ||
teacher = "bob" | ||
) | ||
|
||
|
||
def test_request_edit(self): | ||
self.form_input['availability'] = "Tuesday" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,20 +7,13 @@ class LessonRequestTestCase(TestCase): | |
|
||
fixtures = [ | ||
'lessons/tests/fixtures/default_student.json', | ||
'lessons/tests/fixtures/default_lesson_request.json', | ||
] | ||
|
||
def setUp(self): | ||
super(TestCase, self).setUp() | ||
self.student = Student.objects.get(email="[email protected]") | ||
self.lessonRequest = LessonRequest( | ||
author = self.student, | ||
availability = "Monday", | ||
lessonNum = 2, | ||
interval = 1, | ||
duration = 60, | ||
topic = "Piano", | ||
teacher = "bob" | ||
) | ||
self.lessonRequest = LessonRequest.objects.get(author=1) | ||
|
||
def _assert_valid_request(self): | ||
try: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.