# Path: openprocurement/tender/openua/validation.py
# def validate_complaint_document_operation_not_in_allowed_status(request):
#     if request.validated['tender_status'] not in ['active.tendering']:
#         raise_operation_error(request, 'Can\'t {} document in current ({}) tender status'.format(OPERATIONS.get(request.method), request.validated['tender_status']))


from openprocurement.api.utils import (
    upload_file,
    update_file_content_type,
    json_view,
    context_unpack,
)
from openprocurement.api.validation import (
    validate_file_update,
    validate_file_upload,
    validate_patch_document_data,
)
from openprocurement.tender.core.validation import (
    validate_complaint_document_update_not_by_author,
    validate_status_and_role_for_complaint_document_operation
)
from openprocurement.tender.core.utils import (
    save_tender, optendersresource, apply_patch
)
from openprocurement.tender.belowthreshold.views.complaint_document import TenderComplaintDocumentResource
from openprocurement.tender.openua.validation import (
    validate_complaint_document_operation_not_in_allowed_status
)
# -*- coding: utf-8 -*-


@optendersresource(name='aboveThresholdUA:Tender Complaint Documents',
                   collection_path='/tenders/{tender_id}/complaints/{complaint_id}/documents',
                   path='/tenders/{tender_id}/complaints/{complaint_id}/documents/{document_id}',
                   procurementMethodType='aboveThresholdUA',
                   description="Tender complaint documents")
class TenderUaComplaintDocumentResource(TenderComplaintDocumentResource):


# Path: openprocurement/tender/openua/validation.py
# def validate_complaint_document_operation_not_in_allowed_status(request):
#     if request.validated['tender_status'] not in ['active.tendering']:
#         raise_operation_error(request, 'Can\'t {} document in current ({}) tender status'.format(OPERATIONS.get(request.method), request.validated['tender_status']))


# Path: openprocurement/tender/openua/views/complaint_document.py
from openprocurement.api.utils import (
    upload_file,
    update_file_content_type,
    json_view,
    context_unpack,
)
from openprocurement.api.validation import (
    validate_file_update,
    validate_file_upload,
    validate_patch_document_data,
)
from openprocurement.tender.core.validation import (
    validate_complaint_document_update_not_by_author,
    validate_status_and_role_for_complaint_document_operation
)
from openprocurement.tender.core.utils import (
    save_tender, optendersresource, apply_patch
)
from openprocurement.tender.belowthreshold.views.complaint_document import TenderComplaintDocumentResource
from openprocurement.tender.openua.validation import (
    validate_complaint_document_operation_not_in_allowed_status
)

# -*- coding: utf-8 -*-


@optendersresource(name='aboveThresholdUA:Tender Complaint Documents',
                   collection_path='/tenders/{tender_id}/complaints/{complaint_id}/documents',
                   path='/tenders/{tender_id}/complaints/{complaint_id}/documents/{document_id}',
                   procurementMethodType='aboveThresholdUA',
                   description="Tender complaint documents")
class TenderUaComplaintDocumentResource(TenderComplaintDocumentResource):


    @json_view(validators=(validate_file_upload, validate_complaint_document_operation_not_in_allowed_status, validate_status_and_role_for_complaint_document_operation), permission='edit_complaint')