Compare commits
3 Commits
e40bced16b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e4e55f2657 | |||
| 4fa754012d | |||
| 09a418aae9 |
@@ -64,7 +64,6 @@ class User(auth_models.AbstractUser):
|
|||||||
_("Email Address"),
|
_("Email Address"),
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
role = models.CharField(
|
role = models.CharField(
|
||||||
_("Role"),
|
_("Role"),
|
||||||
max_length=255,
|
max_length=255,
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ from . import views
|
|||||||
|
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
|
|
||||||
router.register(r"company-accounts", views.CompanyAccountCrudViewSet, "company-account-view-set") # type: ignore
|
router.register(r"company-accounts", views.CompanyAccountViewSet, "company-account-view-set") # type: ignore
|
||||||
router.register(r"company-folders", views.CompanyFolderCrudViewSet, "company-folders-view-set") # type: ignore
|
router.register(r"company-folders", views.CompanyFolderViewSet, "company-folders-view-set") # type: ignore
|
||||||
router.register(r"companies", views.CompanyCrudViewSet, "companies-view-set") # type: ignore
|
router.register(r"companies", views.CompanyCrudViewSet, "companies-view-set") # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from core.apps.companies.serializers.accounts import (
|
|||||||
# @view-set | ALL - /company-accounts
|
# @view-set | ALL - /company-accounts
|
||||||
###################################################################################
|
###################################################################################
|
||||||
@extend_schema(tags=["Company Accounts"])
|
@extend_schema(tags=["Company Accounts"])
|
||||||
class CompanyAccountCrudViewSet(BaseViewSetMixin, ModelViewSet):
|
class CompanyAccountViewSet(BaseViewSetMixin, ModelViewSet):
|
||||||
queryset = CompanyAccountModel.objects.all()
|
queryset = CompanyAccountModel.objects.all()
|
||||||
serializer_class = ListCompanyAccountSerializer
|
serializer_class = ListCompanyAccountSerializer
|
||||||
permission_classes = [AllowAny]
|
permission_classes = [AllowAny]
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from core.apps.companies.serializers import (
|
|||||||
from core.apps.contracts.serializers import (
|
from core.apps.contracts.serializers import (
|
||||||
RetrieveContractSerializer,
|
RetrieveContractSerializer,
|
||||||
BaseContractSerializer,
|
BaseContractSerializer,
|
||||||
|
RetrieveContractQuerySerializer,
|
||||||
)
|
)
|
||||||
from core.apps.contracts.models import ContractModel
|
from core.apps.contracts.models import ContractModel
|
||||||
|
|
||||||
@@ -79,18 +80,18 @@ class CompanyContractApiView(BaseApiViewMixin, GenericAPIView): # type: ignore
|
|||||||
#! TODO: status should be added.
|
#! TODO: status should be added.
|
||||||
@extend_schema(
|
@extend_schema(
|
||||||
summary="Company Contracts",
|
summary="Company Contracts",
|
||||||
description="Get List Company Contracts"
|
description="Get List Company Contracts",
|
||||||
|
parameters=[RetrieveContractQuerySerializer]
|
||||||
)
|
)
|
||||||
def get(
|
def get(self, request: HttpRequest, *args: object, **kwargs: object) -> Response:
|
||||||
self,
|
|
||||||
request: HttpRequest,
|
|
||||||
*args: object,
|
|
||||||
**kwargs: object,
|
|
||||||
) -> Response:
|
|
||||||
company = self.get_object()
|
company = self.get_object()
|
||||||
contracts = ContractModel.objects.filter(
|
contracts = (
|
||||||
|
ContractModel.objects.filter(
|
||||||
owners__legal_entity__phone=company.phone,
|
owners__legal_entity__phone=company.phone,
|
||||||
).distinct()
|
)
|
||||||
|
.select_related("owners")
|
||||||
|
.distinct()
|
||||||
|
)
|
||||||
|
|
||||||
folders_param = request.data.get("folders")
|
folders_param = request.data.get("folders")
|
||||||
if folders_param:
|
if folders_param:
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ from core.apps.companies.serializers.folders import (
|
|||||||
# @view-set | ALL - /company-folders
|
# @view-set | ALL - /company-folders
|
||||||
###################################################################################
|
###################################################################################
|
||||||
@extend_schema(tags=["Company Folders"])
|
@extend_schema(tags=["Company Folders"])
|
||||||
class CompanyFolderCrudViewSet(BaseViewSetMixin, ModelViewSet):
|
class CompanyFolderViewSet(BaseViewSetMixin, ModelViewSet):
|
||||||
queryset = CompanyFolderModel.objects.all()
|
queryset = CompanyFolderModel.objects.all()
|
||||||
|
serializer_class = ListCompanyFolderSerializer
|
||||||
permission_classes = [AllowAny]
|
permission_classes = [AllowAny]
|
||||||
|
|
||||||
action_permission_classes = { # type: ignore
|
action_permission_classes = { # type: ignore
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-08 05:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("contracts", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="contractmodel",
|
||||||
|
name="document_url",
|
||||||
|
field=models.FileField(default=1, max_length=2048, upload_to="", verbose_name="Document"),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-08 05:17
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("contracts", "0002_contractmodel_document_url"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="contractmodel",
|
||||||
|
old_name="document_url",
|
||||||
|
new_name="document",
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -9,7 +9,6 @@ from core.apps.contracts.validators.contracts import (
|
|||||||
|
|
||||||
|
|
||||||
class ContractModel(UUIDPrimaryKeyBaseModel):
|
class ContractModel(UUIDPrimaryKeyBaseModel):
|
||||||
|
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
_("name"),
|
_("name"),
|
||||||
validators=[
|
validators=[
|
||||||
@@ -17,13 +16,17 @@ class ContractModel(UUIDPrimaryKeyBaseModel):
|
|||||||
],
|
],
|
||||||
max_length=255
|
max_length=255
|
||||||
)
|
)
|
||||||
|
document = models.FileField(
|
||||||
|
_("Document"),
|
||||||
|
null=False,
|
||||||
|
blank=False,
|
||||||
|
max_length=2048,
|
||||||
|
)
|
||||||
identifier = models.CharField(
|
identifier = models.CharField(
|
||||||
_("Identifier"),
|
_("Identifier"),
|
||||||
null=False,
|
null=False,
|
||||||
blank=False
|
blank=False
|
||||||
)
|
)
|
||||||
|
|
||||||
allow_add_files = models.BooleanField(default=False)
|
allow_add_files = models.BooleanField(default=False)
|
||||||
allow_delete_files = models.BooleanField(default=False)
|
allow_delete_files = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|||||||
@@ -154,3 +154,25 @@ class CreateContractSerializer(BaseContractSerializer):
|
|||||||
attached_files.save() # type: ignore
|
attached_files.save() # type: ignore
|
||||||
|
|
||||||
return contract
|
return contract
|
||||||
|
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# Query Serializers
|
||||||
|
###########################################################
|
||||||
|
class RetrieveContractQuerySerializer(serializers.Serializer):
|
||||||
|
folders = serializers.ListField(
|
||||||
|
child=serializers.CharField(),
|
||||||
|
required=False,
|
||||||
|
help_text="Company Folders that contract should be allocated to."
|
||||||
|
)
|
||||||
|
|
||||||
|
created = serializers.BooleanField(required=False)
|
||||||
|
signed_by_counterparty = serializers.BooleanField(required=False)
|
||||||
|
signed_by_all_parts = serializers.BooleanField(required=False)
|
||||||
|
signed_by_counterparties = serializers.BooleanField(required=False)
|
||||||
|
|
||||||
|
rejected_by_counterparty = serializers.BooleanField(required=False)
|
||||||
|
rejected_by_me = serializers.BooleanField(required=False)
|
||||||
|
rejected = serializers.BooleanField(required=False)
|
||||||
|
|
||||||
|
only_my_contracts = serializers.BooleanField(required=False)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ urlpatterns: list[object] = [
|
|||||||
name="contract-owners-api-view"
|
name="contract-owners-api-view"
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
r"/contract-owners/<uuid:owner_id>/files/<uuid:file_id>",
|
r"/contracts/<uuid:pk>/files",
|
||||||
views.ContractAttachedFileApiView.as_view(),
|
views.ContractAttachedFileApiView.as_view(),
|
||||||
name="contract-attached-files-api-view"
|
name="contract-attached-files-api-view"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
from rest_framework.permissions import AllowAny, IsAdminUser, IsAuthenticated # type: ignore
|
from rest_framework.permissions import AllowAny, IsAdminUser # type: ignore
|
||||||
from rest_framework.viewsets import ModelViewSet # type: ignore
|
from rest_framework.viewsets import ModelViewSet # type: ignore
|
||||||
from rest_framework.views import APIView # type: ignore
|
|
||||||
from rest_framework.generics import GenericAPIView # type: ignore
|
from rest_framework.generics import GenericAPIView # type: ignore
|
||||||
from core.utils.views import BaseApiViewMixin
|
from rest_framework.parsers import MultiPartParser # type: ignore
|
||||||
|
|
||||||
from rest_framework.request import HttpRequest # type: ignore
|
from rest_framework.request import HttpRequest # type: ignore
|
||||||
from rest_framework.response import Response # type: ignore
|
from rest_framework.response import Response # type: ignore
|
||||||
from rest_framework import status # type: ignore
|
from rest_framework import status # type: ignore
|
||||||
|
|
||||||
from django_core.mixins import BaseViewSetMixin # type: ignore
|
from django_core.mixins import BaseViewSetMixin # type: ignore
|
||||||
|
from core.utils.views import BaseApiViewMixin
|
||||||
from core.apps.contracts.models import (
|
from core.apps.contracts.models import (
|
||||||
ContractModel,
|
ContractModel,
|
||||||
ContractAttachedFileModel,
|
ContractAttachedFileModel,
|
||||||
@@ -37,6 +36,7 @@ class ContractViewSet(BaseViewSetMixin, ModelViewSet):
|
|||||||
queryset = ContractModel.objects.all()
|
queryset = ContractModel.objects.all()
|
||||||
serializer_class = ListContractSerializer
|
serializer_class = ListContractSerializer
|
||||||
permission_classes = [AllowAny]
|
permission_classes = [AllowAny]
|
||||||
|
parser_classes = [MultiPartParser]
|
||||||
|
|
||||||
action_permission_classes = { # type: ignore
|
action_permission_classes = { # type: ignore
|
||||||
"list": [IsAdminUser],
|
"list": [IsAdminUser],
|
||||||
|
|||||||
@@ -61,11 +61,10 @@ class ContractOwnerViewSet(BaseViewSetMixin, ModelViewSet):
|
|||||||
@extend_schema(tags=["Contract Files"])
|
@extend_schema(tags=["Contract Files"])
|
||||||
class ContractOwnerAttachedFileApiView(BaseApiViewMixin, GenericAPIView): # type: ignore
|
class ContractOwnerAttachedFileApiView(BaseApiViewMixin, GenericAPIView): # type: ignore
|
||||||
permission_classes = [AllowAny]
|
permission_classes = [AllowAny]
|
||||||
|
serializer_class = ListContractOwnerSerializer
|
||||||
queryset = ContractOwnerModel.objects.all()
|
queryset = ContractOwnerModel.objects.all()
|
||||||
|
|
||||||
method_permission_classes = {
|
method_permission_classes = {"delete": [AllowAny]}
|
||||||
"delete": [AllowAny]
|
|
||||||
}
|
|
||||||
method_serializer_class = {}
|
method_serializer_class = {}
|
||||||
|
|
||||||
@extend_schema(
|
@extend_schema(
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ Testers will write `done`, `not ok` and developers will define status that is no
|
|||||||
* `PATCH /company-accounts/<uuid:pk>` — admin — ok
|
* `PATCH /company-accounts/<uuid:pk>` — admin — ok
|
||||||
* `DELETE /company-accounts/<uuid:pk>` — admin — ok
|
* `DELETE /company-accounts/<uuid:pk>` — admin — ok
|
||||||
* `POST /accounts/verify` — user — TODO
|
* `POST /accounts/verify` — user — TODO
|
||||||
|
|
||||||
* required: `phone`, `code`
|
* required: `phone`, `code`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user