from django.contrib import admin from .models import AdminWeeklyAvailability, AppointmentRequest @admin.register(AdminWeeklyAvailability) class AdminWeeklyAvailabilityAdmin(admin.ModelAdmin): list_display = ['available_days_display', 'created_at'] def available_days_display(self, obj): days_map = dict(AdminWeeklyAvailability.DAYS_OF_WEEK) return ', '.join([days_map[day] for day in obj.available_days]) available_days_display.short_description = 'Available Days' @admin.register(AppointmentRequest) class AppointmentRequestAdmin(admin.ModelAdmin): list_display = ['full_name', 'email', 'status', 'created_at', 'scheduled_datetime'] list_filter = ['status', 'created_at'] search_fields = ['first_name', 'last_name', 'email'] readonly_fields = ['created_at', 'updated_at'] actions = ['mark_as_scheduled', 'mark_as_rejected'] def mark_as_scheduled(self, request, queryset): for appointment in queryset: if appointment.status == 'pending_review': appointment.status = 'scheduled' appointment.save() mark_as_scheduled.short_description = "Mark selected as scheduled" def mark_as_rejected(self, request, queryset): for appointment in queryset: if appointment.status == 'pending_review': appointment.status = 'rejected' appointment.save() mark_as_rejected.short_description = "Mark selected as rejected"