diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index 76d369c..6364bac 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index c579a65..a682bb2 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index ad9397a..9911f8c 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 63cc71d..54f6b0f 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User -from .models import Profile, Parcel, Country, Governate, City, PlatformProfile, Testimonial +from .models import Profile, Parcel, Country, Governate, City, PlatformProfile, Testimonial, DriverRating from django.utils.translation import gettext_lazy as _ from django.urls import path, reverse from django.shortcuts import render @@ -18,9 +18,25 @@ class ProfileInline(admin.StackedInline): model = Profile can_delete = False verbose_name_plural = _('Profiles') + fieldsets = ( + (None, {'fields': ('role', 'is_approved', 'phone_number', 'profile_picture', 'address')}), + (_('Driver Info'), {'fields': ('license_front_image', 'license_back_image', 'car_plate_number'), 'classes': ('collapse',)}), + (_('Location'), {'fields': ('country', 'governate', 'city'), 'classes': ('collapse',)}), + ) class CustomUserAdmin(UserAdmin): inlines = (ProfileInline,) + list_display = ('username', 'email', 'get_role', 'get_approval_status', 'is_active', 'is_staff') + list_filter = ('is_active', 'is_staff', 'profile__role', 'profile__is_approved') + + def get_role(self, obj): + return obj.profile.get_role_display() + get_role.short_description = _('Role') + + def get_approval_status(self, obj): + return obj.profile.is_approved + get_approval_status.short_description = _('Approved') + get_approval_status.boolean = True def get_inline_instances(self, request, obj=None): if not obj: @@ -171,6 +187,4 @@ admin.site.register(Governate) admin.site.register(City) admin.site.register(PlatformProfile, PlatformProfileAdmin) admin.site.register(Testimonial, TestimonialAdmin) - -# Set custom admin index template - using default 'admin/index.html' which we have overridden -# admin.site.index_template = 'admin/dashboard.html' +admin.site.register(DriverRating) \ No newline at end of file diff --git a/core/migrations/0020_profile_is_approved.py b/core/migrations/0020_profile_is_approved.py new file mode 100644 index 0000000..7c1f894 --- /dev/null +++ b/core/migrations/0020_profile_is_approved.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.7 on 2026-01-28 00:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0019_profile_car_plate_number_profile_license_back_image_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='profile', + name='is_approved', + field=models.BooleanField(default=False, help_text='Designates whether this user is approved to use the platform (mainly for drivers).', verbose_name='Approved'), + ), + ] diff --git a/core/migrations/__pycache__/0020_profile_is_approved.cpython-311.pyc b/core/migrations/__pycache__/0020_profile_is_approved.cpython-311.pyc new file mode 100644 index 0000000..bbfac88 Binary files /dev/null and b/core/migrations/__pycache__/0020_profile_is_approved.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index db45946..5f44e60 100644 --- a/core/models.py +++ b/core/models.py @@ -82,6 +82,9 @@ class Profile(models.Model): governate = models.ForeignKey(Governate, on_delete=models.SET_NULL, null=True, blank=True, verbose_name=_('Governate')) city = models.ForeignKey(City, on_delete=models.SET_NULL, null=True, blank=True, verbose_name=_('City')) + # Approval Status + is_approved = models.BooleanField(_('Approved'), default=False, help_text=_("Designates whether this user is approved to use the platform (mainly for drivers).")) + def __str__(self): return f"{self.user.username} - {self.get_role_display()}" @@ -275,4 +278,4 @@ class DriverRating(models.Model): class Meta: verbose_name = _('Driver Rating') - verbose_name_plural = _('Driver Ratings') + verbose_name_plural = _('Driver Ratings') \ No newline at end of file diff --git a/core/templates/core/driver_dashboard.html b/core/templates/core/driver_dashboard.html index 641c04f..e732c42 100644 --- a/core/templates/core/driver_dashboard.html +++ b/core/templates/core/driver_dashboard.html @@ -10,6 +10,16 @@ + {% if not is_approved %} + + {% endif %} +