feat(projects): support members and align rate payloads
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from django.db import transaction
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework.exceptions import ValidationError, PermissionDenied
|
||||
|
||||
from apps.clients.models import Client
|
||||
from apps.projects.models import Project, ProjectMembership
|
||||
from apps.workspaces.models import WorkspaceMembership
|
||||
|
||||
@@ -53,6 +55,10 @@ def update_project(project, **kwargs):
|
||||
if Project.objects.filter(workspace=project.workspace, name=kwargs["name"], is_deleted=False).exists():
|
||||
raise ValidationError({"name": "A project with this name already exists in the workspace."})
|
||||
|
||||
client_id = kwargs.pop("client")
|
||||
client = get_object_or_404(Client, id=client_id, is_deleted=False) if client_id else None
|
||||
kwargs["client"] = client
|
||||
|
||||
for field, value in kwargs.items():
|
||||
if hasattr(project, field) and getattr(project, field) != value:
|
||||
setattr(project, field, value)
|
||||
|
||||
Reference in New Issue
Block a user