-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1151420
commit e3f3efd
Showing
11 changed files
with
178 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
from django.utils import timezone | ||
from home.models.students import Student, LongRebate, TodayRebate, Allocation | ||
from home.models.students import Student, LongRebate, Rebate, Allocation | ||
|
||
|
||
def is_student_on_rebate(student: Student, allocation: Allocation): | ||
""" | ||
This function checks if the student is on rebate or not | ||
""" | ||
long_rebate = LongRebate.objects.filter(email=student) | ||
today = timezone.localtime().date() | ||
|
||
rebate_exists = TodayRebate.objects.filter(allocation_id=allocation.id).exists() | ||
|
||
if rebate_exists: | ||
# Check if there is a TodayRebate for the given allocation | ||
if Rebate.objects.filter( | ||
allocation_id=allocation, | ||
start_date__lte=today, | ||
end_date__gte=today, | ||
approved=True | ||
).exists(): | ||
return True | ||
|
||
for r in long_rebate: | ||
if r.start_date <= today <= r.end_date and r.approved: | ||
return True | ||
return False | ||
# Check if there is an approved LongRebate for the student within the date range | ||
return LongRebate.objects.filter( | ||
email=student, | ||
start_date__lte=today, | ||
end_date__gte=today, | ||
approved=True | ||
).exists() |
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,18 @@ | ||
# Generated by Django 5.0.8 on 2024-10-06 12:23 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('qrscan', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='meal', | ||
name='high_tea', | ||
field=models.BooleanField(default=False, help_text='This contains the high tea status'), | ||
), | ||
] |
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,22 @@ | ||
# Generated by Django 5.0.8 on 2024-10-06 13:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('qrscan', '0002_meal_high_tea'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='MessTimings', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('meal_type', models.CharField(choices=[('breakfast', 'Breakfast'), ('lunch', 'Lunch'), ('high_tea', 'High Tea'), ('dinner', 'Dinner')], help_text='This contains the meal type', max_length=10)), | ||
('start_time', models.TimeField(blank=True, help_text='This contains the start time', null=True)), | ||
('end_time', models.TimeField(blank=True, help_text='This contains the end time', null=True)), | ||
], | ||
), | ||
] |
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,25 @@ | ||
# Generated by Django 5.0.8 on 2024-10-06 13:14 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('qrscan', '0003_messtimings'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='MessTiming', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('meal_type', models.CharField(choices=[('breakfast', 'Breakfast'), ('lunch', 'Lunch'), ('high_tea', 'High Tea'), ('dinner', 'Dinner')], help_text='This contains the meal type', max_length=10, unique=True)), | ||
('start_time', models.TimeField(blank=True, help_text='This contains the start time', null=True)), | ||
('end_time', models.TimeField(blank=True, help_text='This contains the end time', null=True)), | ||
], | ||
), | ||
migrations.DeleteModel( | ||
name='MessTimings', | ||
), | ||
] |
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 |
---|---|---|
@@ -1,3 +0,0 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. | ||
Oops, something went wrong.