Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions dokuly/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import shutil

from organizations.models import Organization as OrgModel
from organizations.revision_utils import build_full_document_number
from organizations.revision_utils import increment_revision_counters, build_formatted_revision
from part_numbers.methods import get_next_part_number
Expand Down Expand Up @@ -231,14 +232,21 @@ def create_new_document(request, **kwargs):

document.save()

try:
_org = OrgModel.objects.get(id=organization_id)
doc_revision_format = _org.document_revision_format
except Exception:
doc_revision_format = "major-only"
Comment on lines +235 to +239

document.formatted_revision = build_formatted_revision(
organization_id=organization_id,
prefix=prefix.prefix,
part_number=document.part_number,
revision_count_major=document.revision_count_major,
revision_count_minor=document.revision_count_minor,
project_number=document.project.full_project_number if document.project else None,
created_at=document.created_at
created_at=document.created_at,
revision_format=doc_revision_format,
)

# Use template-based document number generation
Expand Down Expand Up @@ -996,14 +1004,21 @@ def auto_new_revision(request, pk, **kwargs):
prefix = Document_Prefix.objects.get(pk=old_revision.prefix_id) if old_revision.prefix_id and old_revision.prefix_id != -1 else None
prefix_str = prefix.prefix if prefix else ""

try:
_org = OrgModel.objects.get(id=organization_id)
doc_revision_format = _org.document_revision_format
except Exception:
doc_revision_format = "major-only"
Comment on lines +1007 to +1011

new_revision.formatted_revision = build_formatted_revision(
organization_id=organization_id,
prefix=prefix_str,
part_number=new_revision.part_number,
revision_count_major=new_revision.revision_count_major,
revision_count_minor=new_revision.revision_count_minor,
project_number=new_revision.project.full_project_number if new_revision.project else None,
created_at=new_revision.created_at
created_at=new_revision.created_at,
revision_format=doc_revision_format,
)

# Use template-based document number generation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const DocumentNumberSettings = ({ org, setRefresh }) => {
template: fullDocumentNumberTemplate,
use_number_revisions: useNumberRevisions,
start_major_revision_at_one: revisionStartAtOne,
revision_format: revisionFormat,
});

if (response.status === 200) {
Expand Down
Loading