diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index af6442b..184ee40 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/context_processors.cpython-311.pyc b/core/__pycache__/context_processors.cpython-311.pyc index e9a897c..6b18c43 100644 Binary files a/core/__pycache__/context_processors.cpython-311.pyc and b/core/__pycache__/context_processors.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 485f75a..3fa3578 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 aadbeb1..ac7f5f7 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 c9914ce..f76bffb 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 40daf30..9cc410d 100644 --- a/core/admin.py +++ b/core/admin.py @@ -4,7 +4,7 @@ from django.shortcuts import render from django.http import HttpResponseRedirect from django.contrib import messages from django.utils.translation import gettext_lazy as _ -from .models import Profile, Truck, Shipment, Bid, Message, WhatsAppConfig, Country, City, TruckType +from .models import Profile, Truck, Shipment, Bid, Message, WhatsAppConfig, Country, City, TruckType, AppSetting from .whatsapp import send_whatsapp_message @admin.register(Country) @@ -86,4 +86,14 @@ class WhatsAppConfigAdmin(admin.ModelAdmin): title=_("Send Test WhatsApp Message"), opts=self.model._meta, ) - return render(request, "admin/core/whatsapp_test.html", context) \ No newline at end of file + return render(request, "admin/core/whatsapp_test.html", context) + +@admin.register(AppSetting) +class AppSettingAdmin(admin.ModelAdmin): + list_display = ('app_name', 'contact_phone', 'contact_email') + + def has_add_permission(self, request): + # Only allow one configuration record + if self.model.objects.exists(): + return False + return super().has_add_permission(request) diff --git a/core/context_processors.py b/core/context_processors.py index 0bf87c3..e23f85c 100644 --- a/core/context_processors.py +++ b/core/context_processors.py @@ -1,13 +1,16 @@ import os import time +from .models import AppSetting def project_context(request): """ - Adds project-specific environment variables to the template context globally. + Adds project-specific environment variables and app settings to the template context globally. """ + app_settings = AppSetting.objects.first() return { "project_description": os.getenv("PROJECT_DESCRIPTION", ""), "project_image_url": os.getenv("PROJECT_IMAGE_URL", ""), # Used for cache-busting static assets "deployment_timestamp": int(time.time()), - } + "app_settings": app_settings, + } \ No newline at end of file diff --git a/core/migrations/0014_appsetting.py b/core/migrations/0014_appsetting.py new file mode 100644 index 0000000..d8ebf96 --- /dev/null +++ b/core/migrations/0014_appsetting.py @@ -0,0 +1,33 @@ +# Generated by Django 5.2.7 on 2026-01-23 17:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0013_alter_truck_registration_back_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='AppSetting', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('app_name', models.CharField(max_length=100, verbose_name='App Name')), + ('logo', models.ImageField(blank=True, null=True, upload_to='app/', verbose_name='Logo')), + ('slogan', models.CharField(blank=True, max_length=255, verbose_name='Slogan')), + ('registration_number', models.CharField(blank=True, max_length=100, verbose_name='Registration Number')), + ('tax_number', models.CharField(blank=True, max_length=100, verbose_name='Tax Number')), + ('contact_phone', models.CharField(blank=True, max_length=20, verbose_name='Contact Phone')), + ('contact_email', models.EmailField(blank=True, max_length=254, verbose_name='Contact Email')), + ('contact_address', models.TextField(blank=True, verbose_name='Contact Address')), + ('terms_of_service', models.TextField(blank=True, verbose_name='Terms of Service')), + ('privacy_policy', models.TextField(blank=True, verbose_name='Privacy Policy')), + ], + options={ + 'verbose_name': 'App Setting', + 'verbose_name_plural': 'App Settings', + }, + ), + ] diff --git a/core/migrations/__pycache__/0014_appsetting.cpython-311.pyc b/core/migrations/__pycache__/0014_appsetting.cpython-311.pyc new file mode 100644 index 0000000..3a8dd15 Binary files /dev/null and b/core/migrations/__pycache__/0014_appsetting.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index aa235a7..b5918c4 100644 --- a/core/models.py +++ b/core/models.py @@ -229,6 +229,25 @@ class WhatsAppConfig(models.Model): def __str__(self): return str(_("WhatsApp Configuration")) +class AppSetting(models.Model): + app_name = models.CharField(_('App Name'), max_length=100) + logo = models.ImageField(_('Logo'), upload_to='app/', blank=True, null=True) + slogan = models.CharField(_('Slogan'), max_length=255, blank=True) + registration_number = models.CharField(_('Registration Number'), max_length=100, blank=True) + tax_number = models.CharField(_('Tax Number'), max_length=100, blank=True) + contact_phone = models.CharField(_('Contact Phone'), max_length=20, blank=True) + contact_email = models.EmailField(_('Contact Email'), blank=True) + contact_address = models.TextField(_('Contact Address'), blank=True) + terms_of_service = models.TextField(_('Terms of Service'), blank=True) + privacy_policy = models.TextField(_('Privacy Policy'), blank=True) + + class Meta: + verbose_name = _('App Setting') + verbose_name_plural = _('App Settings') + + def __str__(self): + return self.app_name + @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: @@ -257,4 +276,4 @@ def sync_user_groups(sender, instance, **kwargs): instance.user.groups.remove(*other_groups) # Add user to the correct group - instance.user.groups.add(group) + instance.user.groups.add(group) \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index dd4cbe8..dcaac55 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -6,7 +6,7 @@
-