diff --git a/accounts/forms.py b/accounts/forms.py index 76beb31..7654a13 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -90,19 +90,6 @@ class CustomerForm(forms.ModelForm): return national_code def save(self, commit=True): - def _compute_completed(cleaned): - try: - first_ok = bool((cleaned.get('first_name') or '').strip()) - last_ok = bool((cleaned.get('last_name') or '').strip()) - nc_ok = bool((cleaned.get('national_code') or '').strip()) - phone_ok = bool((cleaned.get('phone_number_1') or '').strip() or (cleaned.get('phone_number_2') or '').strip()) - addr_ok = bool((cleaned.get('address') or '').strip()) - bank_ok = bool(cleaned.get('bank_name')) - card_ok = bool((cleaned.get('card_number') or '').strip()) - acc_ok = bool((cleaned.get('account_number') or '').strip()) - return all([first_ok, last_ok, nc_ok, phone_ok, addr_ok, bank_ok, card_ok, acc_ok]) - except Exception: - return False # Check if this is an update (instance exists) if self.instance and self.instance.pk: # Update existing profile @@ -121,18 +108,6 @@ class CustomerForm(forms.ModelForm): profile.affairs = current_user_profile.affairs profile.county = current_user_profile.county profile.broker = current_user_profile.broker - # Set completion flag based on provided form data - profile.is_completed = _compute_completed({ - 'first_name': user.first_name, - 'last_name': user.last_name, - 'national_code': self.cleaned_data.get('national_code'), - 'phone_number_1': self.cleaned_data.get('phone_number_1'), - 'phone_number_2': self.cleaned_data.get('phone_number_2'), - 'address': self.cleaned_data.get('address'), - 'bank_name': self.cleaned_data.get('bank_name'), - 'card_number': self.cleaned_data.get('card_number'), - 'account_number': self.cleaned_data.get('account_number'), - }) if commit: profile.save() @@ -167,18 +142,6 @@ class CustomerForm(forms.ModelForm): profile.affairs = current_user_profile.affairs profile.county = current_user_profile.county profile.broker = current_user_profile.broker - # Set completion flag based on provided form data - profile.is_completed = _compute_completed({ - 'first_name': user.first_name, - 'last_name': user.last_name, - 'national_code': self.cleaned_data.get('national_code'), - 'phone_number_1': self.cleaned_data.get('phone_number_1'), - 'phone_number_2': self.cleaned_data.get('phone_number_2'), - 'address': self.cleaned_data.get('address'), - 'bank_name': self.cleaned_data.get('bank_name'), - 'card_number': self.cleaned_data.get('card_number'), - 'account_number': self.cleaned_data.get('account_number'), - }) if commit: profile.save() diff --git a/accounts/templates/accounts/customer_list.html b/accounts/templates/accounts/customer_list.html index 1b7e103..2d00356 100644 --- a/accounts/templates/accounts/customer_list.html +++ b/accounts/templates/accounts/customer_list.html @@ -172,19 +172,12 @@ {% empty %} - +
هیچ کاربری یافت نشد
- - - - - - - {% endfor %} diff --git a/accounts/templates/accounts/login.html b/accounts/templates/accounts/login.html index e43800d..e5791f3 100644 --- a/accounts/templates/accounts/login.html +++ b/accounts/templates/accounts/login.html @@ -16,9 +16,6 @@ layout-wide customizer-hide {% endblock style %} {% block content %} - -{% include '_toasts.html' %} -
@@ -72,7 +69,7 @@ layout-wide customizer-hide {% csrf_token %}
- +
diff --git a/accounts/urls.py b/accounts/urls.py index 7c79207..ac5119d 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -4,7 +4,7 @@ from accounts.views import login_view, dashboard, customer_list, add_customer_aj app_name = "accounts" urlpatterns = [ - path('', login_view, name='login'), + path('login/', login_view, name='login'), path('logout/', logout_view, name='logout'), path('dashboard/', dashboard, name='dashboard'), path('customers/', customer_list, name='customer_list'), diff --git a/accounts/views.py b/accounts/views.py index c5bec75..6a4f23c 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -8,9 +8,7 @@ from django import forms from django.contrib.auth.decorators import login_required from accounts.models import Profile from accounts.forms import CustomerForm -from processes.utils import scope_customers_queryset from common.consts import UserRoles -from common.decorators import allowed_roles # Create your views here. @@ -19,9 +17,6 @@ def login_view(request): renders login page and authenticating user POST requests to log user in """ - # If already authenticated, go straight to request list - if request.user.is_authenticated: - return redirect("processes:request_list") if request.method == "POST": username = request.POST.get("username") password = request.POST.get("password") @@ -40,11 +35,9 @@ def dashboard(request): @login_required -@allowed_roles([UserRoles.ADMIN, UserRoles.BROKER, UserRoles.MANAGER, UserRoles.ACCOUNTANT]) def customer_list(request): # Get all profiles that have customer role - base = Profile.objects.filter(roles__slug=UserRoles.CUSTOMER.value, is_deleted=False).select_related('user') - customers = scope_customers_queryset(request.user, base) + customers = Profile.objects.filter(roles__slug=UserRoles.CUSTOMER.value, is_deleted=False).select_related('user') form = CustomerForm() return render(request, "accounts/customer_list.html", { @@ -54,8 +47,6 @@ def customer_list(request): @require_POST -@login_required -@allowed_roles([UserRoles.ADMIN, UserRoles.BROKER, UserRoles.MANAGER, UserRoles.ACCOUNTANT]) def add_customer_ajax(request): """AJAX endpoint for adding customers""" form = CustomerForm(request.POST, request.FILES) @@ -94,8 +85,6 @@ def add_customer_ajax(request): @require_POST -@login_required -@allowed_roles([UserRoles.ADMIN, UserRoles.BROKER, UserRoles.MANAGER, UserRoles.ACCOUNTANT]) def edit_customer_ajax(request, customer_id): customer = get_object_or_404(Profile, id=customer_id) form = CustomerForm(request.POST, request.FILES, instance=customer) @@ -133,7 +122,6 @@ def edit_customer_ajax(request, customer_id): }) @require_GET -@login_required def get_customer_data(request, customer_id): customer = get_object_or_404(Profile, id=customer_id) @@ -174,7 +162,6 @@ def get_customer_data(request, customer_id): }) -@login_required def logout_view(request): """Log out current user and redirect to login page.""" logout(request) diff --git a/certificates/models.py b/certificates/models.py index 1b3dcaf..64d53f9 100644 --- a/certificates/models.py +++ b/certificates/models.py @@ -1,7 +1,6 @@ from django.db import models from django.contrib.auth import get_user_model from common.models import BaseModel -from _helpers.utils import jalali_converter2 User = get_user_model() @@ -36,7 +35,4 @@ class CertificateInstance(BaseModel): def __str__(self): return f"گواهی {self.process_instance.code}" - def jissued_at(self): - return jalali_converter2(self.issued_at) - diff --git a/certificates/templates/certificates/print.html b/certificates/templates/certificates/print.html index d5ef11f..5bd26c2 100644 --- a/certificates/templates/certificates/print.html +++ b/certificates/templates/certificates/print.html @@ -1,71 +1,28 @@ - - - - - - تاییدیه - {{ instance.code }} - {% load static %} +{% extends '_base.html' %} - - - - - - - - - - - - - - -
- -
-
-
شماره درخواست: {{ instance.code }}
-
تاریخ: {{ cert.jissued_at }}
-
-
- - -
- {% if template.company and template.company.logo %} - logo +{% block content %} +
+
+ {% if template.company and template.company.logo %} + logo + {% endif %} +

{{ cert.rendered_title }}

+ {% if template.company %}
{{ template.company.name }}
{% endif %} +
+
+ {{ cert.rendered_body|safe }} +
+
+
تاریخ: {{ cert.issued_at }}
+
+ {% if template.company and template.company.signature %} + seal {% endif %} -

{{ cert.rendered_title }}

- {% if template.company %} -
{{ template.company.name }}
- {% endif %} -
- - -
- {{ cert.rendered_body|safe }} -
- - -
-
-
مهر و امضای تایید کننده
-
{{ template.company.name }}
- {% if template.company and template.company.signature %} - seal - {% endif %} -
+
مهر و امضای شرکت
+
+ +{% endblock %} + - - - diff --git a/certificates/templates/certificates/step.html b/certificates/templates/certificates/step.html index 0027d18..b8923c2 100644 --- a/certificates/templates/certificates/step.html +++ b/certificates/templates/certificates/step.html @@ -18,49 +18,40 @@ + {% endblock %} {% block content %} {% include '_toasts.html' %} - - - {% instance_info_modal instance %} - {% csrf_token %}
-
+

{{ step.name }}: {{ instance.process.name }}

- {% instance_info instance %} + اشتراک آب: {{ instance.well.water_subscription_number|default:"-" }} + | نماینده: {{ instance.representative.profile.national_code|default:"-" }}
-
+
{% stepper_header instance step %}
-
-
-
شماره درخواست: {{ instance.code }}
-
تاریخ: {{ cert.jissued_at }}
-
-
{% if template.company and template.company.logo %} logo @@ -71,22 +62,21 @@
{{ cert.rendered_body|safe }}
-
+
+
+
تاریخ صدور: {{ cert.issued_at }}
+
-
مهر و امضای تایید کننده
-
{{ template.company.name }}
{% if template.company and template.company.signature %} - seal + seal {% endif %} +
مهر و امضای شرکت