Skip to content

Commit

Permalink
fix mails
Browse files Browse the repository at this point in the history
  • Loading branch information
mittal-ishaan committed Sep 28, 2024
1 parent e2ce4ac commit f9f7aae
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
24 changes: 24 additions & 0 deletions home/migrations/0005_alter_allocation_registration_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.3 on 2024-09-25 14:43

import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("home", "0004_allocation_registration_time"),
]

operations = [
migrations.AlterField(
model_name="allocation",
name="registration_time",
field=models.DateTimeField(
blank=True,
default=django.utils.timezone.now,
help_text="This contains the date and time of registration",
null=True,
verbose_name="Registration time",
),
),
]
20 changes: 20 additions & 0 deletions home/signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from datetime import datetime

from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
Expand Down Expand Up @@ -221,3 +222,22 @@ def create_catererBills(sender, instance, created, **kwargs):
caterer=caterer, semester=instance
)
caterer_bill.save()


@receiver(post_save, sender=Caterer)
def create_catererBills(sender, instance, created, **kwargs):
logger.info("Caterer created:", instance.name)
if created:
for semester in Semester.objects.all():
end_date = (
Period.objects.filter(semester=semester)
.order_by("end_date")
.last()
.end_date
)
if end_date and end_date < datetime.now().date():
continue
caterer_bill, _ = CatererBills.objects.get_or_create(
caterer=instance, semester=semester
)
caterer_bill.save()
6 changes: 6 additions & 0 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ def rebate(request):
"""
text = ""
list = []
period_obj = None
allocation_id = None
try:
student = Student.objects.filter(email__iexact=str(request.user.email))
try:
Expand All @@ -172,6 +174,10 @@ def rebate(request):
except Student.DoesNotExist:
key = "Signed in account does not does not have any allocation ID"
if request.method == "POST" and request.user.is_authenticated:
if not period_obj or not allocation_id:
text = "You are not allocated for current period, please contact the dining warden to allocate you to a caterer"
request.session["text"] = text
return redirect(request.path)

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium

Untrusted URL redirection depends on a
user-provided value
.
try:
start_date = parse_date(request.POST["start_date"])
end_date = parse_date(request.POST["end_date"])
Expand Down
4 changes: 1 addition & 3 deletions messWebsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
SECRET_KEY = env("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ["diningfee.iiti.ac.in", "127.0.0.1", "103.159.214.171"]
CSRF_TRUSTED_ORIGINS = ["http://diningfee.iiti.ac.in", "https://diningfee.iiti.ac.in"]
Expand All @@ -34,7 +34,6 @@
"django.contrib.staticfiles",
"django.contrib.sites",
"django.contrib.admindocs",

# Third-party apps
"import_export",
"django_admin_logs",
Expand All @@ -46,7 +45,6 @@
"cloudinary",
"apscheduler",
"django_apscheduler",

# Local apps
"home.apps.HomeConfig",
]
Expand Down

0 comments on commit f9f7aae

Please sign in to comment.