diff --git a/inventory/urls.py b/inventory/urls.py index c83dc2ee..6a7b02a9 100644 --- a/inventory/urls.py +++ b/inventory/urls.py @@ -1290,6 +1290,10 @@ urlpatterns = [ path('/schedules/calendar/', views.schedule_calendar, name='schedule_calendar'), + # staff profile + path('/staff/detail/', views.StaffDetailView.as_view(), name='staff_detail'), + + ] handler404 = "inventory.views.custom_page_not_found_view" diff --git a/inventory/views.py b/inventory/views.py index 3335af8c..f87b5c89 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -2197,6 +2197,35 @@ class DealerUpdateView( def get_success_url(self): return reverse("dealer_detail", kwargs={"slug": self.object.slug}) + +class StaffDetailView(LoginRequiredMixin, DetailView): + """ + Represents a detailed view for a Dealer model. + + This class extends Django's `DetailView` to provide a detailed view of a dealer. + It includes additional context data such as the count of staff members, cars + associated with the dealer, available car makes, and dynamically fetched quotas. + The class also ensures that users must be logged in to access the detailed view. + + :ivar model: The model associated with this view (Dealer model). + :type model: django.db.models.Model + :ivar template_name: Path to the template used to render the view. + :type template_name: str + :ivar context_object_name: The name used to refer to the object in the template context. + :type context_object_name: str + """ + + model = models.Staff + template_name = "staff/staff_detail.html" + context_object_name = "staff" + + + +def dealer_vat_rate_update(request, slug): + dealer = get_object_or_404(models.Dealer, slug=slug) + models.VatRate.objects.filter(dealer=dealer).update(rate=request.POST.get("rate")) + messages.success(request, _("VAT rate updated successfully")) + return redirect("dealer_detail", slug=slug) class CustomerListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): diff --git a/templates/header.html b/templates/header.html index a79de5b6..941a4f44 100644 --- a/templates/header.html +++ b/templates/header.html @@ -504,7 +504,7 @@ {% else %} {% endif %} {% if request.is_dealer %} @@ -530,7 +530,7 @@ {% if request.is_staff %} {% endif %} diff --git a/templates/staff/staff_detail.html b/templates/staff/staff_detail.html new file mode 100644 index 00000000..c8cba830 --- /dev/null +++ b/templates/staff/staff_detail.html @@ -0,0 +1,107 @@ +{% extends 'base.html' %} +{% load i18n static custom_filters crispy_forms_filters %} +{% block title %} + {% trans 'Profile' %} {% endblock %} + {% block content %} +
+
+
+

{% trans 'Profile' %}

+ +
+ +
+
+
+
+
+
+
+
+ + +
+ +
+

{{ staff.get_local_name }}

+

{{staff.user.groups.name}}

+

{% trans 'Joined' %} {{ staff.created|timesince }} {% trans 'ago' %}

+
+
+
+
+
+
+
{% trans 'last login'|capfirst %}
+

{{ staff.user.last_login|date:"D M d, Y H:i" }}

+
+ +
+
+
+
+
+
+
+
+

{% trans 'Default Address' %}

+
+
+
+
+
{% trans 'Address' %}
+
+
+

{{ staff.address }}

+
+
+
+
+
+
+
{% trans 'Email' %}
+
+
{{ staff.user.email }}
+
+
+
+
{% trans 'Phone' %}
+
+
{{ staff.phone_number }}
+
+
+
+
+
+
+ +
+ {% endblock %} + + + \ No newline at end of file diff --git a/templates/users/user_detail.html b/templates/users/user_detail.html index a1a980e8..cd3da0bf 100644 --- a/templates/users/user_detail.html +++ b/templates/users/user_detail.html @@ -98,7 +98,7 @@ + href="{% url 'staff_password_reset' request.dealer.slug %}"> {{ _("Reset Password") }}