Skip to main content

django-edocs

PyPI version Python Django License: MIT

django-edocs — Django loyihalari uchun professional elektron hujjat generatsiyasi, Word (.docx) shablon dvijogi, dinamik jadvallar, PDF konvertatsiyasi, QR-kodli tekshiruv va E-IMZO orqali ko'p tomonlama imzolash ish jarayoni (workflow) tizimi.


🌟 Asosiy Imkoniyatlar (Features)

  1. Smart Word (.docx) Shablon Dvijogi:

    • Jinja2 ({{ var }}) hamda rasmiy davlat shartnomalaridagi dollar-skobka (${var}) sintaksislarini to'liq qo'llab-quvvatlaydi.
    • Microsoft Word matnni bo'lib yuborgan holatlarda XML teglarni avtomatik tuzatadi va ulaydi.
    • Dinamik jadvallar (Auto Table Loops): Jadvaldagi {{ items.name }} yoki ${items.name} o'zgaruvchilarini avtomatik aniqlab, qatorlarni takrorlanuvchi tsiklga o'raydi.
    • None yoki "null" qiymatlarni avtomatik bo'sh qatorga ("") aylantiradi.
  2. PDF Konvertatsiya va QR-Kodli Xavfsizlik:

    • Word fayllarini avtomatik tarzda yuqori sifatli PDF formatiga o'tkazadi (headless LibreOffice orqali).
    • Har bir hujjatga takrorlanmas 4 xonali xavfsizlik kodi va SHA-256 hesh biriktiriladi.
    • Hujjatning pastki yoki burchak qismiga vertikal kodli dinamik QR-kod generatsiya qilinadi.
  3. Ko'p Bosqichli E-IMZO Imzolash Ketma-ketligi:

    • Ketma-ket imzolash navbati (masalan: 1-tomon -> 2-tomon -> 3-tomon).
    • Navbat kelmaguncha keyingi shaxs imzo qo'ya olmaydi.
    • Hujjatni ko'rish, imzolash, Rad etish (izoh bilan) va Bekor qilish imkoniyati.
  4. Tayyor REST API & Brauzer E-IMZO Mijozi:

    • Django REST Framework uchun tayyor Challenge, Sign, Reject, Cancel va PDF Preview endpointlari.
    • Brauzerdagi mahalliy E-IMZO moduli (port 64443) bilan ishlovchi tayyor eimzo-client.js kutubxonasi.
    • QR-kod skaner qilinganda mobil qurilmalarda ochiluvchi chiroyli ommaviy tekshiruv sahifasi.

📦 O'rnatish (Installation)

pip install django-edocs

Tizimda Word fayllarni PDF ga o'girish uchun LibreOffice o'rnatilgan bo'lishi kerak:

# Ubuntu / Debian
sudo apt-get update && sudo apt-get install -y libreoffice fonts-dejavu

# Dockerfile uchun
RUN apt-get update && apt-get install -y libreoffice fonts-dejavu && rm -rf /var/lib/apt/lists/*

🚀 Tezkor Boshlash (Quickstart)

1. settings.py sozlamalari

INSTALLED_APPS ro'yxatiga 'edocs' va 'rest_framework' ni qo'shing:

INSTALLED_APPS = [
    # ...
    'rest_framework',
    'edocs',
    # ...
]

Ixtiyoriy sozlamalar:

# settings.py

# 1. E-IMZO PKCS#7 imzoni tekshirish uchun server manzili (Production uchun):
# O'zingizning tashkilotingiz yoki provayderingizning E-IMZO tekshirish URL manzilini ko'rsating.
# EIMZO_VERIFY_URL nomi bilan ham ko'rsatish mumkin.
EDOCS_VERIFY_URL = "https://<sizning-e-imzo-serveringiz>/backend/pkcs7/verify/attached"
# yoki:
# EIMZO_VERIFY_URL = "https://<sizning-e-imzo-serveringiz>/backend/pkcs7/verify/attached"

# 2. Rivojlantirish muhitida (DEBUG=True) tashqi server ulanmasa avtomatik lokal fallback qilish:
EDOCS_ENABLE_LOCAL_FALLBACK = True  # Standart holatda settings.DEBUG ga teng

# 3. QR kod skaner qilinganda yo'naltiriladigan tashqi frontend URL (ixtiyoriy, ko'rsatilmasa ichki /api/edocs/verify/<guid>/ sahifasi ishlatiladi):
EDOCS_VERIFY_FRONTEND_URL = "https://<sizning-frontend-saytingiz>/edocs/verify"

# 4. Word fayllarni PDF ga o'giruvchi LibreOffice manzili:
EDOCS_LIBREOFFICE_PATH = "libreoffice"  # yoki "/usr/bin/libreoffice"

# 5. Imzolovchilar modeli (User, Xodim, Rol):
EDOCS_SIGNER_MODEL = "auth.User"

2. Ma'lumotlar bazasini yangilang

python manage.py migrate

3. URL marshrutlarini ulang

Loyiha urls.py fayliga:

from django.urls import path, include

urlpatterns = [
    # ...
    path("api/edocs/", include("edocs.api.urls")),
    # ...
]

4. O'z modelingizga hujjat biriktirish

Shartnoma, dalolatnoma yoki ma'lumotnoma modelingizni AbstractDocumentBase dan meros qilib oling:

from django.db import models
from edocs.models import AbstractDocumentBase

class Contract(AbstractDocumentBase):
    number = models.CharField(max_length=50)
    client_name = models.CharField(max_length=255)
    total_amount = models.DecimalField(max_digits=12, decimal_places=2)

    def __str__(self):
        return f"Shartnoma #{self.number}"

5. Hujjat generatsiya qilish

from edocs.services import DocumentEngine
from myapp.models import Contract

# 1. Shartnomani saqlash
contract = Contract.objects.create(
    number="12/2026",
    client_name="Agro Tech MCHJ",
    total_amount=50000000
)

# 2. Hujjatni Word shabloni asosida generatsiya qilish
document = DocumentEngine.generate_document(
    template_code="standard_contract",
    context_data={
        "contract_number": contract.number,
        "client_name": contract.client_name,
        "total_amount": str(contract.total_amount),
        "items": [
            {"num": 1, "name": "Mahsulot A", "qty": 10, "price": "2000000"},
            {"num": 2, "name": "Mahsulot B", "qty": 5, "price": "6000000"},
        ]
    },
    related_object=contract,
    signers=[
        {"signer": user_director, "title": "Direktor", "tin": "123456789"},
        {"signer": user_client, "title": "Haridor", "tin": "987654321"},
    ]
)

# 3. Hujjatni shartnomaga biriktirish
contract.document = document
contract.save()

🔑 Brauzerda E-IMZO bilan imzolash (Frontend)

Paket ichida rasmiy E-IMZO WebSocket drayverlari va tayyor eimzo-client.js mavjud:

<script src="/static/edocs/js/e-imzo.js"></script>
<script src="/static/edocs/js/e-imzo-client.js"></script>
<script src="/static/edocs/js/eimzo-client.js"></script>
<script>
  // 1. E-IMZO moduli ochiqligini tekshirish (WebSocket 64646 / 64443)
  EImzoClient.checkAgent().then(isOnline => {
    if (!isOnline) {
      alert("Iltimos, kompyuteringizda E-IMZO dasturini ishga tushiring!");
      return;
    }

    // 2. Sertifikatlar ro'yxatini olish
    EImzoClient.listCertificates().then(certs => {
      console.log("Mavjud kalitlar:", certs);
      
      // 3. Tanlangan kalit bilan hujjatni imzolash
      const chosenCert = certs[0];
      EImzoClient.signDocument("DOCUMENT-GUID-HERE", chosenCert)
        .then(res => {
          alert("Hujjat muvaffaqiyatli imzolandi!");
          window.location.reload();
        })
        .catch(err => alert("Xatolik: " + err.message));
    });
  });
</script>

📡 Signallar (Signals)

Hujjat holati o'zgarganda bildirishnoma (Telegram bot, SMS, WebSocket) yuborish uchun Django signallaridan foydalaning:

from django.dispatch import receiver
from edocs.signals import document_fully_signed, document_rejected

@receiver(document_fully_signed)
def on_document_fully_signed(sender, document, related_object, **kwargs):
    print(f"Hujjat to'liq imzolandi: {document.guid}, Obyekt: {related_object}")

@receiver(document_rejected)
def on_document_rejected(sender, document, signer, note, related_object, **kwargs):
    print(f"Hujjat rad etildi! Sabab: {note}")

📄 Litsenziya (License)

Ushbu kutubxona MIT License asosida ochiq manbali tarzda tarqatiladi.

Metadata

Release files for django-edocs 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-edocs 0.1.2
File Size Uploaded Provenance Actions
django_edocs-0.1.2.tar.gz 39.4 kB With provenance Details for django_edocs-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-edocs 0.1.2
File Interpreter ABI Platform Actions
django_edocs-0.1.2-py3-none-any.whl Python 3 none any Details for django_edocs-0.1.2-py3-none-any.whl

Total release size: 81.4 kB

Release files / django_edocs-0.1.2.tar.gz

Download URL django_edocs-0.1.2.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1ad09b66f8d39de70804fda259e20838de25667dfb1ec66dd39ad54367afaafc
BLAKE2b-256 checksum
How to use checksums
be8ddbc6b9345909e2fc5de8cb334e3258bbbc3debd96e0056092340543528c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / django_edocs-0.1.2-py3-none-any.whl

Download URL django_edocs-0.1.2-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e7bfb5bd8abeafe3e3190261b2b4ec06277186bf5f0a78ed3909894166fa4d4
BLAKE2b-256 checksum
How to use checksums
e3251afb9099d69e229a15a63766595cee79353a3b21f216d6d16d24e8584664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for django-edocs 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_edocs-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page