Skip to content

Commit

Permalink
admin page ready for caterers dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mittal-ishaan committed Jan 29, 2024
1 parent 0b4193c commit 4e3a971
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,9 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
list_per_page = 500
resource_class = AllocationNewResource
model = Allocation
search_fields = ("email__name","email__roll_no","email__hostel","email__email","student_id", "caterer__name", "high_tea",)
list_filter = ("period", "caterer", "high_tea","jain","email__hostel","email__degree","email__department",)
list_display = ("student_id","name","email","period", "caterer", "high_tea","jain")
search_fields = ("email__name","email__roll_no","email__hostel","email__email","student_id", "caterer__name")
list_filter = ("period", "caterer", "jain","email__hostel","email__degree","email__department",)
list_display = ("student_id","name","email","period", "caterer", "jain")
fieldsets = ((None,
{
"fields": (
Expand All @@ -884,6 +884,15 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
}
,),)

def get_queryset(self, request):
qs = super().get_queryset(request)
if request.user.is_superuser:
return qs
semester = Semester.objects.get(name="Spring 2024")
print(request.user.email)
return qs.filter(period__semester=semester).filter(period__Sno=2).filter(caterer__name=request.user.username)


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

0 comments on commit 4e3a971

Please sign in to comment.