diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index f8c2ac2..b2f91d2 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index 4543ff8..b0b499d 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 57e069a..bc4e4a0 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index a3863d8..ca26a2f 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Profile, Parcel, Country, Governate, City +from .models import Profile, Parcel, Country, Governate, City, PlatformProfile @admin.register(Country) class CountryAdmin(admin.ModelAdmin): @@ -29,4 +29,14 @@ class ParcelAdmin(admin.ModelAdmin): list_display = ('tracking_number', 'shipper', 'carrier', 'status', 'payment_status', 'created_at') list_filter = ('status', 'payment_status', 'pickup_country', 'delivery_country') search_fields = ('tracking_number', 'shipper__username', 'carrier__username', 'receiver_name') - readonly_fields = ('tracking_number', 'created_at', 'updated_at') \ No newline at end of file + readonly_fields = ('tracking_number', 'created_at', 'updated_at') + +@admin.register(PlatformProfile) +class PlatformProfileAdmin(admin.ModelAdmin): + list_display = ('name', 'phone_number', 'registration_number') + + def has_add_permission(self, request): + # Allow adding only if no instance exists + if self.model.objects.exists(): + return False + return super().has_add_permission(request) diff --git a/core/forms.py b/core/forms.py index 030dfac..f9b7273 100644 --- a/core/forms.py +++ b/core/forms.py @@ -31,6 +31,11 @@ class UserRegistrationForm(forms.ModelForm): self.fields['country'].queryset = Country.objects.all().order_by(name_field) + # Default Country logic + oman = Country.objects.filter(name_en='Oman').first() + if oman: + self.fields['country'].initial = oman + if 'country' in self.data: try: country_id = int(self.data.get('country')) @@ -39,6 +44,8 @@ class UserRegistrationForm(forms.ModelForm): pass elif self.instance.pk and hasattr(self.instance, 'profile') and self.instance.profile.country: self.fields['governate'].queryset = self.instance.profile.country.governate_set.order_by(name_field) + elif oman: + self.fields['governate'].queryset = Governate.objects.filter(country=oman).order_by(name_field) if 'governate' in self.data: try: @@ -122,6 +129,12 @@ class ParcelForm(forms.ModelForm): # Set querysets for countries self.fields['pickup_country'].queryset = Country.objects.all().order_by(name_field) self.fields['delivery_country'].queryset = Country.objects.all().order_by(name_field) + + # Default Country logic + oman = Country.objects.filter(name_en='Oman').first() + if oman: + self.fields['pickup_country'].initial = oman + self.fields['delivery_country'].initial = oman # Pickup self.fields['pickup_governate'].queryset = Governate.objects.none() @@ -133,6 +146,8 @@ class ParcelForm(forms.ModelForm): self.fields['pickup_governate'].queryset = Governate.objects.filter(country_id=country_id).order_by(name_field) except (ValueError, TypeError): pass + elif oman: + self.fields['pickup_governate'].queryset = Governate.objects.filter(country=oman).order_by(name_field) if 'pickup_governate' in self.data: try: @@ -151,10 +166,12 @@ class ParcelForm(forms.ModelForm): self.fields['delivery_governate'].queryset = Governate.objects.filter(country_id=country_id).order_by(name_field) except (ValueError, TypeError): pass + elif oman: + self.fields['delivery_governate'].queryset = Governate.objects.filter(country=oman).order_by(name_field) if 'delivery_governate' in self.data: try: gov_id = int(self.data.get('delivery_governate')) self.fields['delivery_city'].queryset = City.objects.filter(governate_id=gov_id).order_by(name_field) except (ValueError, TypeError): - pass + pass \ No newline at end of file diff --git a/core/migrations/0007_platformprofile.py b/core/migrations/0007_platformprofile.py new file mode 100644 index 0000000..61890a5 --- /dev/null +++ b/core/migrations/0007_platformprofile.py @@ -0,0 +1,30 @@ +# Generated by Django 5.2.7 on 2026-01-25 10:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0006_alter_city_name_ar_alter_city_name_en_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='PlatformProfile', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100, verbose_name='Platform Name')), + ('logo', models.ImageField(blank=True, null=True, upload_to='platform_logos/', verbose_name='Logo')), + ('slogan', models.CharField(blank=True, max_length=255, verbose_name='Slogan')), + ('address', models.TextField(blank=True, verbose_name='Address')), + ('phone_number', models.CharField(blank=True, max_length=50, verbose_name='Phone Number')), + ('registration_number', models.CharField(blank=True, max_length=100, verbose_name='Registration Number')), + ('vat_number', models.CharField(blank=True, max_length=100, verbose_name='VAT Number')), + ], + options={ + 'verbose_name': 'Platform Profile', + 'verbose_name_plural': 'Platform Profile', + }, + ), + ] diff --git a/core/migrations/__pycache__/0007_platformprofile.cpython-311.pyc b/core/migrations/__pycache__/0007_platformprofile.cpython-311.pyc new file mode 100644 index 0000000..6ffa3fe Binary files /dev/null and b/core/migrations/__pycache__/0007_platformprofile.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 7c76838..46898f0 100644 --- a/core/models.py +++ b/core/models.py @@ -144,4 +144,20 @@ class Parcel(models.Model): class Meta: verbose_name = _('Parcel') - verbose_name_plural = _('Parcels') \ No newline at end of file + verbose_name_plural = _('Parcels') + +class PlatformProfile(models.Model): + name = models.CharField(_('Platform Name'), max_length=100) + logo = models.ImageField(_('Logo'), upload_to='platform_logos/', blank=True, null=True) + slogan = models.CharField(_('Slogan'), max_length=255, blank=True) + address = models.TextField(_('Address'), blank=True) + phone_number = models.CharField(_('Phone Number'), max_length=50, blank=True) + registration_number = models.CharField(_('Registration Number'), max_length=100, blank=True) + vat_number = models.CharField(_('VAT Number'), max_length=100, blank=True) + + def __str__(self): + return self.name + + class Meta: + verbose_name = _('Platform Profile') + verbose_name_plural = _('Platform Profile') diff --git a/core/templates/base.html b/core/templates/base.html index cc5425d..0ed9cdf 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -19,7 +19,11 @@ {% endif %} - + {% if lang.direction == 'rtl' %} + + {% else %} + + {% endif %} @@ -28,20 +32,9 @@ {% if lang.direction == 'rtl' %} {% endif %} diff --git a/core/templates/core/register.html b/core/templates/core/register.html index 58735ff..6985e83 100644 --- a/core/templates/core/register.html +++ b/core/templates/core/register.html @@ -49,7 +49,7 @@ document.addEventListener('DOMContentLoaded', function() { citySelect.innerHTML = ''; if (countryId) { - fetch(`/ajax/get-governates/?country_id=${countryId}`) + fetch(`{% url 'get_governates' %}?country_id=${countryId}`) .then(response => response.json()) .then(data => { data.forEach(gov => { @@ -67,7 +67,7 @@ document.addEventListener('DOMContentLoaded', function() { citySelect.innerHTML = ''; if (governateId) { - fetch(`/ajax/get-cities/?governate_id=${governateId}`) + fetch(`{% url 'get_cities' %}?governate_id=${governateId}`) .then(response => response.json()) .then(data => { data.forEach(city => { diff --git a/core/templates/core/shipment_request.html b/core/templates/core/shipment_request.html index 5afb913..dafbb21 100644 --- a/core/templates/core/shipment_request.html +++ b/core/templates/core/shipment_request.html @@ -11,15 +11,114 @@