add db to repo

This commit is contained in:
aminhashemi92 2025-08-27 10:27:30 +03:30
parent f2fc2362a7
commit 9b3973805e
7 changed files with 97 additions and 55 deletions

5
.gitignore vendored
View file

@ -9,8 +9,8 @@
*.pyc *.pyc
__pycache__/ __pycache__/
local_settings.py local_settings.py
*.sqlite3 # *.sqlite3
db.sqlite3 # db.sqlite3
db.sqlite3-journal db.sqlite3-journal
media media
#static #static
@ -21,6 +21,7 @@ profile_images
# in your Git repository. Update and uncomment the following line accordingly. # in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/ # <django-project-name>/staticfiles/
# db.sqlite3
### Django.Python Stack ### ### Django.Python Stack ###
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
*.py[cod] *.py[cod]

View file

@ -1,18 +1,54 @@
{% extends '_base.html' %} {% extends '_base.html' %}
{% load static %} {% load static %}
{% load processes_tags %}
{% load humanize %}
{% block content %} {% block sidebar %}
<div class="container-xxl flex-grow-1 container-p-y"> {% include 'sidebars/admin.html' %}
<div class="d-flex align-items-center justify-content-between mb-3"> {% endblock sidebar %}
{% block navbar %}
{% include 'navbars/admin.html' %}
{% endblock navbar %}
{% block title %}{{ step.name }} - درخواست {{ instance.code }}{% endblock %}
{% block style %}
<link rel="stylesheet" href="{% static 'assets/vendor/libs/bs-stepper/bs-stepper.css' %}">
<!-- Persian Date Picker CSS -->
<link rel="stylesheet" href="https://unpkg.com/persian-datepicker@latest/dist/css/persian-datepicker.min.css">
<style>
@media print {
.no-print { display: none !important; }
}
</style>
{% endblock %}
{% block content %}
{% include '_toasts.html' %}
{% csrf_token %}
<div class="container-xxl flex-grow-1 container-p-y">
<div class="row">
<div class="col-12 mb-4">
<div class="d-flex align-items-center justify-content-between mb-3 no-print">
<div> <div>
<h4 class="mb-1">گواهی نهایی</h4> <h4 class="mb-1">{{ step.name }}: {{ instance.process.name }}</h4>
<small class="text-muted d-block">کد درخواست: {{ instance.code }}</small> <small class="text-muted d-block">
اشتراک آب: {{ instance.well.water_subscription_number|default:"-" }}
| نماینده: {{ instance.representative.profile.national_code|default:"-" }}
</small>
</div> </div>
<div class="d-flex gap-2"> <div class="d-flex gap-2">
<a class="btn btn-outline-secondary" target="_blank" href="{% url 'certificates:certificate_print' instance.id %}"><i class="bx bx-printer"></i> پرینت</a> <a class="btn btn-outline-secondary" target="_blank" href="{% url 'certificates:certificate_print' instance.id %}"><i class="bx bx-printer"></i> پرینت</a>
<a href="{% url 'processes:request_list' %}" class="btn btn-outline-secondary">بازگشت</a>
</div> </div>
</div> </div>
<div class="bs-stepper wizard-vertical vertical mt-2 no-print">
{% stepper_header instance step %}
<div class="bs-stepper-content">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="text-center mb-3"> <div class="text-center mb-3">
@ -47,7 +83,11 @@
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</div>
</div>
{% endblock %} {% endblock %}

View file

@ -45,7 +45,7 @@ def _render_template(template: CertificateTemplate, instance: ProcessInstance):
@login_required @login_required
def certificate_step(request, instance_id, step_id): def certificate_step(request, instance_id, step_id):
instance = get_object_or_404(ProcessInstance, id=instance_id) instance = get_object_or_404(ProcessInstance, id=instance_id)
step = get_object_or_404(instance.process.steps, id=step_id)
# Ensure all previous steps are completed and invoice settled # Ensure all previous steps are completed and invoice settled
prior_steps = instance.process.steps.filter(order__lt=instance.current_step.order if instance.current_step else 9999) prior_steps = instance.process.steps.filter(order__lt=instance.current_step.order if instance.current_step else 9999)
incomplete = StepInstance.objects.filter(process_instance=instance, step__in=prior_steps).exclude(status='completed').exists() incomplete = StepInstance.objects.filter(process_instance=instance, step__in=prior_steps).exclude(status='completed').exists()
@ -97,6 +97,7 @@ def certificate_step(request, instance_id, step_id):
'cert': cert, 'cert': cert,
'previous_step': previous_step, 'previous_step': previous_step,
'next_step': next_step, 'next_step': next_step,
'step': step,
}) })

BIN
db.sqlite3 Normal file

Binary file not shown.

View file

@ -127,7 +127,7 @@
{% endif %} {% endif %}
</div> </div>
{% else %} {% else %}
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data" id="installation-report-form">
{% csrf_token %} {% csrf_token %}
<div class="mb-3"> <div class="mb-3">
<div class=""> <div class="">
@ -285,7 +285,7 @@
<span></span> <span></span>
{% endif %} {% endif %}
<div class="d-flex gap-2"> <div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">ثبت گزارش</button> <button type="submit" class="btn btn-primary" form="installation-report-form">ثبت گزارش</button>
{% if next_step %} {% if next_step %}
<a href="{% url 'processes:step_detail' instance.id next_step.id %}" class="btn btn-success">بعدی</a> <a href="{% url 'processes:step_detail' instance.id next_step.id %}" class="btn btn-success">بعدی</a>
{% endif %} {% endif %}

View file

@ -62,7 +62,7 @@ def installation_report_step(request, instance_id, step_id):
assignment = InstallationAssignment.objects.filter(process_instance=instance).first() assignment = InstallationAssignment.objects.filter(process_instance=instance).first()
existing_report = InstallationReport.objects.filter(assignment=assignment).order_by('-created').first() existing_report = InstallationReport.objects.filter(assignment=assignment).order_by('-created').first()
edit_mode = True if request.GET.get('edit') == '1' else False edit_mode = True if request.GET.get('edit') == '1' else False
print("edit_mode", edit_mode)
# current quote items baseline # current quote items baseline
quote = Quote.objects.filter(process_instance=instance).first() quote = Quote.objects.filter(process_instance=instance).first()
quote_items = list(quote.items.select_related('item').all()) if quote else [] quote_items = list(quote.items.select_related('item').all()) if quote else []

View file

@ -566,11 +566,11 @@ def approve_final_invoice(request, instance_id, step_id):
invoice = get_object_or_404(Invoice, process_instance=instance) invoice = get_object_or_404(Invoice, process_instance=instance)
# Block approval when there is any remaining (positive or negative) # Block approval when there is any remaining (positive or negative)
invoice.calculate_totals() invoice.calculate_totals()
if invoice.remaining_amount != 0: # if invoice.remaining_amount != 0:
return JsonResponse({ # return JsonResponse({
'success': False, # 'success': False,
'message': f"تا زمانی که مانده فاکتور صفر نشده امکان تایید نیست (مانده فعلی: {invoice.remaining_amount})" # 'message': f"تا زمانی که مانده فاکتور صفر نشده امکان تایید نیست (مانده فعلی: {invoice.remaining_amount})"
}) # })
# mark step completed # mark step completed
step_instance, _ = StepInstance.objects.get_or_create(process_instance=instance, step=step) step_instance, _ = StepInstance.objects.get_or_create(process_instance=instance, step=step)
step_instance.status = 'completed' step_instance.status = 'completed'