Skip to content
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
5 changes: 0 additions & 5 deletions home/adapters/account_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ def should_send_confirmation_mail(self, request, email_address):

def clean_email(self, email):
RestrictedList = Student.objects.all().values_list("email")
# try:
# Student.objects.get(email=email)
# return email
# except Exception as e:
# ValidationError('You are not a registered student. Please contact admin.')
if email.endswith("iiti.ac.in"):
raise ValidationError(
"Please login with your IITI email ID through google login only."
Expand Down
2 changes: 0 additions & 2 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,6 @@ class about_Admin(admin.ModelAdmin):
"period5_bills",
"period6_bills",
),
# "description": "%s" % CATERER_BILL_DESC_TEXT,
}


Expand All @@ -1040,7 +1039,6 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
"period5_bills",
"period6_bills",
),
# "description": "%s" % CATERER_BILL_DESC_TEXT,
},
),
)
Expand Down
18 changes: 0 additions & 18 deletions home/models/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,3 @@ def __str__(self):
class Meta:
verbose_name = "Update"
verbose_name_plural = "Updates"


# class Photos(models.Model):
# """
# Stores All phtographs on the bottom of the Home page
# """
# image = models.ImageField(_("Photographs on Home page"), upload_to="static/images")
# poc = models.CharField(_("Point of Contact"), max_length=30, default='',
# help_text="This contains the name of the person in the photograph")
# occupation = models.CharField(_("Occupation"), max_length=50, default='',
# help_text="This contains the occupation of the person in the photograph")

# def __str__(self):
# return "Home Page Photographs"

# class Meta:
# verbose_name = " General Photographs"
# verbose_name_plural = " General Photographs"
7 changes: 2 additions & 5 deletions home/utils/month.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ def fill_periods(email, start_date, end_date):
print(f"Start date: {start_date}, End date: {end_date}")
current_date = start_date
days_per_period = []
student = Student.objects.filter(email=email).last()
student = Student.objects.filter(email__iexact=email).last()
for period in Period.objects.all():
if (
period.start_date <= current_date <= period.end_date
and period.start_date <= end_date
and Allocation.objects.filter(period=period, email=student).exists()
):
days_in_period = min(
(period.end_date - current_date).days + 1,
(end_date - current_date).days + 1,
)
days_in_period = (min(period.end_date, end_date) - current_date).days + 1
days_per_period.append((period, days_in_period))
current_date = current_date + timedelta(days=days_in_period)

Expand Down
6 changes: 3 additions & 3 deletions home/utils/rebate_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def count(start, end):
def is_not_duplicate(student, new_rebate_start, new_rebate_end):
"""Checks if these dates are already applied for rebate"""
try:
for short_rebate in Rebate.objects.filter(email=student).all():
for short_rebate in Rebate.objects.filter(email__iexact=student).all():
if (
short_rebate.start_date
< new_rebate_start
Expand All @@ -23,7 +23,7 @@ def is_not_duplicate(student, new_rebate_start, new_rebate_end):
< short_rebate.end_date
):
return False
for short_rebate in LeftShortRebate.objects.filter(email=student).all():
for short_rebate in LeftShortRebate.objects.filter(email__iexact=student).all():
if (
short_rebate.start_date
< new_rebate_start
Expand All @@ -34,7 +34,7 @@ def is_not_duplicate(student, new_rebate_start, new_rebate_end):
< short_rebate.end_date
):
return False
for long_rebate in LongRebate.objects.filter(email=student).all():
for long_rebate in LongRebate.objects.filter(email__iexact=student).all():
if (
long_rebate.end_date
> new_rebate_start
Expand Down
23 changes: 6 additions & 17 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,6 @@ def rules(request):
return render(request, "rules.html", params)


# def caterer(request, name):
# """
# Display the Caterer Page :model:`home.models.caterer`.

# *Template:*

# :template:`home/caterer.html`

# """
# caterer = Caterer.objects.get(name=name, visible=True)
# context = {"caterer": caterer}
# return render(request, "caterer.html", context)


def menu(request):
"""
Display the menu along with caterer information on a single page.
Expand Down Expand Up @@ -186,7 +172,7 @@ def rebate(request):
try:
period_obj = next(
period
for period in Period.objects.all()
for period in Period.objects.all().order_by("start_date")
if period.end_date > date.today() + timedelta(1)
)
allocation = Allocation.objects.filter(email=student, period=period_obj).first()
Expand All @@ -213,7 +199,7 @@ def rebate(request):
message = "Form needs to be filled atleast 2 days prior the comencement of leave."
elif not is_not_duplicate(student, start_date, end_date):
message = "You have already applied for rebate during this duration"
elif 0 < rebate_days < 2:
elif rebate_days < 2:
message = "Min no of days for rebate is 2"
else:
additional_message = ""
Expand Down Expand Up @@ -494,7 +480,8 @@ def profile(request):
socialaccount_obj = SocialAccount.objects.filter(
provider="google", user_id=request.user.id
)
picture = student.photo.url if student.photo else None
if student:
picture = student.photo.url if student.photo else None
allocation: Allocation | None = Allocation.objects.filter(email=student).last()
show_allocated_enabled = False
if allocation and allocation.period:
Expand All @@ -516,6 +503,8 @@ def profile(request):
if not picture and socialaccount_obj:
picture = socialaccount_obj[0].extra_data["picture"]
except (IndexError, KeyError):
logger.warning(socialaccount_obj[0])
logger.warning(socialaccount_obj[0].extra_data)
logger.error("No picture found")
semesters = Semester.objects.all()
context = {
Expand Down