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

Fixes #74

Merged
merged 4 commits into from
Aug 24, 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
1 change: 1 addition & 0 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
"start_time",
"end_time",
"active",
"show_allocated",
)
},
),
Expand Down
17 changes: 17 additions & 0 deletions home/migrations/0003_allocationform_show_allocated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.3 on 2024-08-24 05:37

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("home", "0002_remove_allocationautumn22_month_and_more"),
]

operations = [
migrations.AddField(
model_name="allocationform",
name="show_allocated",
field=models.BooleanField(default=False, verbose_name="show_allocated"),
),
]
1 change: 1 addition & 0 deletions home/models/students.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ class AllocationForm(models.Model):
_("Start Time"), default=now, null=True, blank=True
)
end_time = models.DateTimeField(_("End Time"), null=True, blank=True)
show_allocated = models.BooleanField(_("show_allocated"), default=False)

def __str__(self):
return str(self.heading)
Expand Down
16 changes: 9 additions & 7 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,19 +467,21 @@ def profile(request):
provider="google", user_id=request.user.id
)
picture = "not available"
allocation = Allocation.objects.filter(email=student).last()
allocation: Allocation | None = Allocation.objects.filter(email=student).last()
show_allocated_enabled = AllocationForm.objects.filter(
show_allocated=True, period=allocation.period
).exists()
allocation_info = {}
# improve this alignment of text to be shown on the profile section
if allocation:
if allocation and show_allocated_enabled:
allocation_info = {
"Allocation ID": allocation.student_id,
"start date": allocation.period.start_date,
"end date": allocation.period.end_date,
# "Allocation ID": allocation.student_id,
"Caterer": allocation.caterer.name,
"High Tea": "Yes" if allocation.high_tea else "No",
# "High Tea": "Yes" if allocation.high_tea else "No",
"Jain": "Yes" if allocation.jain else "No",
}
# allocation_info = "Allocation ID: " + allocation.student_id + " Caterer: " + allocation.caterer.name + " High Tea: " + str(allocation.high_tea) + " Jain: " + str(allocation.jain)
# else:
# allocation_info = "Not allocated for this period"
try:
if socialaccount_obj:
picture = socialaccount_obj[0].extra_data["picture"]
Expand Down
2 changes: 1 addition & 1 deletion 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>Your view your allocated caterer once the allocation for this period is completed. </h6>
<h6>You will be able to see your allocated caterer after the allocation process is completed </h6>
{% endif %}
<hr>
</div>
Expand Down
Loading