Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mails #80

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"""
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 @@
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)
Dismissed Show dismissed Hide dismissed
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
Loading