Skip to content

Commit

Permalink
Fixes (#73)
Browse files Browse the repository at this point in the history
* update ssl certs docker ignore

* few fixes

---------

Co-authored-by: Ishaan Mittal <[email protected]>
  • Loading branch information
mittal-ishaan and ishaan-tf authored Aug 24, 2024
1 parent 57f4a05 commit 949559e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,11 @@ def get_queryset(self, request):

@admin.display(description="email")
def email(self, obj):
return obj.email.email
return obj.email.email if obj.email else ""

@admin.display(description="name")
def name(self, obj):
return obj.email.name
return obj.email.name if obj.email else ""

actions = ["export_as_csv", "correct_bills", "fix_issue"]

Expand Down
16 changes: 7 additions & 9 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ def allocationForm(request):
alloc_form = AllocationForm.objects.filter(active=True).last()
try:
student = Student.objects.filter(email__iexact=str(request.user.email)).last()
if not student:
raise Exception("Student not found")
text = ""
message = ""
if (alloc_form.start_time and alloc_form.start_time > now()) or (
Expand All @@ -372,13 +374,7 @@ def allocationForm(request):
elif Allocation.objects.filter(
email=student, period=alloc_form.period
).exists():
allocation_id = Allocation.objects.filter(
email=student, period=alloc_form.period
).last()
message = (
"You have already filled the form for this period. with first preference:"
+ allocation_id.first_pref
)
message = "You have filled the form for this period. Please visit the profile page after the allocation process is completed to check your allocated caterer"
elif request.method == "POST" and request.user.is_authenticated:
try:
period_obj = alloc_form.period
Expand Down Expand Up @@ -444,8 +440,8 @@ def allocationForm(request):
if text != "":
del request.session["text"]
except Exception as e:
print(e)
message = "Signed in account can not fill the allocation form"
logger.error(e)
message = "Signed in account can not fill the allocation form. Please inform the dining Office to add your email ID to the database"
text = ""
context = {
"text": text,
Expand Down Expand Up @@ -524,6 +520,8 @@ def rebate_data(request):
semester = request.GET.get("semester")
semester_obj = Semester.objects.get(name=semester)
rebate = StudentBills.objects.filter(email=student, semester=semester_obj).last()
if not rebate:
return JsonResponse({"semester": semester, "period": sno, "data": []})
rebate_bills = get_rebate_bills(rebate, sno)
rebate_data = {"semester": semester, "period": sno, "data": rebate_bills}
return JsonResponse(rebate_data)
11 changes: 8 additions & 3 deletions templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h6>{{ key }}</h6>
</div>
{% endfor %}
{% else %}
<h6>You have not been allotted a caterer for this period yet.</h6>
<h6>Your view your allocated caterer once the allocation for this period is completed. </h6>
{% endif %}
<hr>
</div>
Expand Down Expand Up @@ -123,7 +123,6 @@ <h5 class="card-title">Rebate Bills</h5>
return;
}
var semester = $('#semester-select').val();
console.log(period);
$.ajax({
url: "{% url 'rebate_data' %}",
type: "GET",
Expand All @@ -132,8 +131,14 @@ <h5 class="card-title">Rebate Bills</h5>
'period': period
},
success: function(response) {
console.log(response);
var data = response.data;
if(data.length == 0) {
$('#short').html('');
$('#long').html('');
$('#high_tea').html('');
$('#bills').html('');
return;
}
var short = document.getElementById('short');
var long = document.getElementById('long');
var high_tea = document.getElementById('high_tea');
Expand Down

0 comments on commit 949559e

Please sign in to comment.