diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index 7e66c47..affcaa7 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 a225337..ca66217 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 0f074b3..c3f9b3a 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 219f92b..a0cf697 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/forms.py b/core/forms.py index 1740dda..9f99003 100644 --- a/core/forms.py +++ b/core/forms.py @@ -166,3 +166,25 @@ class RenewSubscriptionForm(forms.Form): widget=forms.Select(attrs={'class': 'form-select'}), label=_('Subscription Plan') ) + +class AppSettingForm(forms.ModelForm): + class Meta: + model = AppSetting + fields = '__all__' + widgets = { + 'app_name': forms.TextInput(attrs={'class': 'form-control'}), + 'logo': forms.FileInput(attrs={'class': 'form-control'}), + 'slogan': forms.TextInput(attrs={'class': 'form-control'}), + 'registration_number': forms.TextInput(attrs={'class': 'form-control'}), + 'tax_number': forms.TextInput(attrs={'class': 'form-control'}), + 'contact_phone': forms.TextInput(attrs={'class': 'form-control'}), + 'contact_email': forms.EmailInput(attrs={'class': 'form-control'}), + 'contact_address': forms.Textarea(attrs={'class': 'form-control', 'rows': 2}), + 'terms_of_service': forms.Textarea(attrs={'class': 'form-control', 'rows': 5}), + 'privacy_policy': forms.Textarea(attrs={'class': 'form-control', 'rows': 5}), + 'subscription_enabled': forms.CheckboxInput(attrs={'class': 'form-check-input'}), + 'shipper_monthly_fee': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.01'}), + '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 diff --git a/core/templates/core/admin_dashboard.html b/core/templates/core/admin_dashboard.html index eecc8e1..03f7df7 100644 --- a/core/templates/core/admin_dashboard.html +++ b/core/templates/core/admin_dashboard.html @@ -355,6 +355,19 @@ +
+ +
+
+ +
+
+
{% trans 'Application Settings' %}
+ {% trans 'Control fees, logo, and legal text' %} +
+
+
+
diff --git a/core/templates/core/app_settings.html b/core/templates/core/app_settings.html new file mode 100644 index 0000000..8077554 --- /dev/null +++ b/core/templates/core/app_settings.html @@ -0,0 +1,145 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +
+
+
+
+

{% trans "Application Settings" %}

+ + {% trans "Back to Dashboard" %} + +
+ +
+ {% csrf_token %} +
+
{% trans "General Information" %}
+
+
+ + {{ form.app_name }} + {% if form.app_name.errors %}
{{ form.app_name.errors }}
{% endif %} +
+
+ + {{ form.slogan }} + {% if form.slogan.errors %}
{{ form.slogan.errors }}
{% endif %} +
+
+ + {{ form.logo }} + {% if form.logo.errors %}
{{ form.logo.errors }}
{% endif %} + {% if form.instance.logo %} +
+ Logo +
+ {% endif %} +
+
+ +
{% trans "Contact & Legal" %}
+
+
+ + {{ form.registration_number }} +
+
+ + {{ form.tax_number }} +
+
+ + {{ form.contact_phone }} +
+
+ + {{ form.contact_email }} +
+
+ + {{ form.contact_address }} +
+
+ +
{% trans "Subscription Fees" %}
+
+
+ {{ form.subscription_enabled }} + +
+
+ +
+
+
+
+
{% trans "Shipper Fees" %}
+
+ + {{ form.shipper_monthly_fee }} +
+
+ + {{ form.shipper_annual_fee }} +
+
+
+
+
+
{% trans "Truck Owner Fees" %}
+
+ + {{ form.truck_owner_monthly_fee }} +
+
+ + {{ form.truck_owner_annual_fee }} +
+
+
+
+
+ +
{% trans "Policies" %}
+
+
+ + {{ form.terms_of_service }} +
+
+ + {{ form.privacy_policy }} +
+
+
+ +
+
+
+
+ + +{% endblock %} diff --git a/core/urls.py b/core/urls.py index 23d8bc1..471f4cf 100644 --- a/core/urls.py +++ b/core/urls.py @@ -28,4 +28,5 @@ urlpatterns = [ path("receipt//", views.transaction_receipt, name="transaction_receipt"), path("admin/financials/", views.admin_financials, name="admin_financials"), path("admin/refund//", views.issue_refund, name="issue_refund"), + path("admin/settings/", views.admin_app_settings, name="admin_app_settings"), ] \ No newline at end of file diff --git a/core/views.py b/core/views.py index 454b70b..43eb66c 100644 --- a/core/views.py +++ b/core/views.py @@ -4,7 +4,10 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth import login, authenticate, logout from django.utils import timezone from .models import Profile, Truck, Shipment, Bid, Message, OTPCode, Country, City, AppSetting, Banner, HomeSection, Transaction -from .forms import TruckForm, ShipmentForm, BidForm, UserRegistrationForm, OTPVerifyForm, ShipperOfferForm, RenewSubscriptionForm +from .forms import ( + TruckForm, ShipmentForm, BidForm, UserRegistrationForm, + OTPVerifyForm, ShipperOfferForm, RenewSubscriptionForm, AppSettingForm +) from django.contrib import messages from django.utils.translation import gettext as _ from django.db.models import Q @@ -583,3 +586,20 @@ def issue_refund(request, receipt_number): messages.success(request, _("Refund issued successfully! Receipt: %(receipt)s") % {'receipt': refund.receipt_number}) return redirect('admin_financials') + +@login_required +def admin_app_settings(request): + if not (request.user.profile.role == 'ADMIN' or request.user.is_superuser): + return redirect('dashboard') + + settings_obj = AppSetting.objects.first() + if request.method == 'POST': + form = AppSettingForm(request.POST, request.FILES, instance=settings_obj) + if form.is_valid(): + form.save() + messages.success(request, _("Application settings updated successfully.")) + return redirect('admin_app_settings') + else: + form = AppSettingForm(instance=settings_obj) + + return render(request, 'core/app_settings.html', {'form': form}) \ No newline at end of file