diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index 1b97a82..f65d7c4 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 affcaa7..e0ce395 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 4bdc403..77440cd 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 354b745..e4f0366 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 9c3b770..18141de 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 097ec01..fd6f7d6 100644 --- a/core/admin.py +++ b/core/admin.py @@ -7,7 +7,7 @@ from django.utils.translation import gettext_lazy as _ from django.utils import timezone from django.utils.html import format_html import os -from .models import Profile, Truck, Shipment, Bid, Message, WhatsAppConfig, Country, City, TruckType, AppSetting, Banner, HomeSection +from .models import Profile, Truck, Shipment, Bid, Message, WhatsAppConfig, Country, City, TruckType, AppSetting, Banner, HomeSection, ContactMessage from .whatsapp import send_whatsapp_message @admin.register(Country) @@ -189,4 +189,12 @@ class HomeSectionAdmin(admin.ModelAdmin): list_display = ('title', 'section_type', 'order', 'is_active') list_editable = ('order', 'is_active') list_filter = ('section_type', 'is_active', 'background_color') - search_fields = ('title', 'title_ar', 'subtitle', 'subtitle_ar', 'content', 'content_ar') \ No newline at end of file + search_fields = ('title', 'title_ar', 'subtitle', 'subtitle_ar', 'content', 'content_ar') + +@admin.register(ContactMessage) +class ContactMessageAdmin(admin.ModelAdmin): + list_display = ('subject', 'name', 'email', 'created_at', 'is_read') + list_filter = ('is_read', 'created_at') + search_fields = ('subject', 'name', 'email', 'message') + readonly_fields = ('created_at',) + list_editable = ('is_read',) diff --git a/core/forms.py b/core/forms.py index 9f99003..df3ac14 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import Truck, Shipment, Bid, Profile, Country, OTPCode, City, TruckType, AppSetting +from .models import Truck, Shipment, Bid, Profile, Country, OTPCode, City, TruckType, AppSetting, ContactMessage from django.utils.translation import gettext_lazy as _ from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User @@ -187,4 +187,15 @@ class AppSettingForm(forms.ModelForm): 'shipper_annual_fee': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.01'}), 'truck_owner_monthly_fee': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.01'}), 'truck_owner_annual_fee': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.01'}), - } \ No newline at end of file + } + +class ContactForm(forms.ModelForm): + class Meta: + model = ContactMessage + fields = ['name', 'email', 'subject', 'message'] + widgets = { + 'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('Your Name')}), + 'email': forms.EmailInput(attrs={'class': 'form-control', 'placeholder': _('Your Email')}), + 'subject': forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('Subject')}), + 'message': forms.Textarea(attrs={'class': 'form-control', 'rows': 5, 'placeholder': _('Your Message')}), + } diff --git a/core/migrations/0023_contactmessage.py b/core/migrations/0023_contactmessage.py new file mode 100644 index 0000000..5e122b1 --- /dev/null +++ b/core/migrations/0023_contactmessage.py @@ -0,0 +1,30 @@ +# Generated by Django 5.2.7 on 2026-01-24 08:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0022_alter_truck_driver_license_back_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='ContactMessage', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100, verbose_name='Name')), + ('email', models.EmailField(max_length=254, verbose_name='Email')), + ('subject', models.CharField(max_length=200, verbose_name='Subject')), + ('message', models.TextField(verbose_name='Message')), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('is_read', models.BooleanField(default=False)), + ], + options={ + 'verbose_name': 'Contact Message', + 'verbose_name_plural': 'Contact Messages', + 'ordering': ['-created_at'], + }, + ), + ] diff --git a/core/migrations/__pycache__/0023_contactmessage.cpython-311.pyc b/core/migrations/__pycache__/0023_contactmessage.cpython-311.pyc new file mode 100644 index 0000000..eecd3b3 Binary files /dev/null and b/core/migrations/__pycache__/0023_contactmessage.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index d8c35ff..4d7d3f5 100644 --- a/core/models.py +++ b/core/models.py @@ -474,4 +474,20 @@ class Transaction(models.Model): super().save(*args, **kwargs) def __str__(self): - return f"{self.receipt_number} - {self.user.username} ({self.amount})" \ No newline at end of file + return f"{self.receipt_number} - {self.user.username} ({self.amount})" + +class ContactMessage(models.Model): + name = models.CharField(_('Name'), max_length=100) + email = models.EmailField(_('Email')) + subject = models.CharField(_('Subject'), max_length=200) + message = models.TextField(_('Message')) + created_at = models.DateTimeField(auto_now_add=True) + is_read = models.BooleanField(default=False) + + class Meta: + verbose_name = _('Contact Message') + verbose_name_plural = _('Contact Messages') + ordering = ['-created_at'] + + def __str__(self): + return f"{self.subject} - {self.name}" diff --git a/core/templates/base.html b/core/templates/base.html index f2dc547..54fdabf 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -66,6 +66,9 @@ {% endif %} {% endif %} +