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
9 changes: 2 additions & 7 deletions apps/api/plane/api/serializers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
from rest_framework import serializers

# Module imports
from plane.db.models import (
Project,
ProjectIdentifier,
WorkspaceMember,
State,
Estimate,
)
from plane.db.models import Project, ProjectIdentifier, WorkspaceMember, State, Estimate

from plane.utils.content_validator import (
validate_html_content,
Expand Down Expand Up @@ -123,6 +117,7 @@ def validate(self, data):

def create(self, validated_data):
identifier = validated_data.get("identifier", "").strip().upper()

if identifier == "":
raise serializers.ValidationError(detail="Project Identifier is required")

Expand Down
2 changes: 2 additions & 0 deletions apps/api/plane/api/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ def post(self, request, slug):
"""
try:
workspace = Workspace.objects.get(slug=slug)

serializer = ProjectCreateSerializer(data={**request.data}, context={"workspace_id": workspace.id})

if serializer.is_valid():
serializer.save()

Expand Down
2 changes: 1 addition & 1 deletion apps/api/plane/app/serializers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ProjectIdentifier,
DeployBoard,
ProjectPublicMember,
IssueSequence
IssueSequence,
)
from plane.utils.content_validator import (
validate_html_content,
Expand Down
13 changes: 13 additions & 0 deletions apps/api/plane/db/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class Project(BaseModel):
external_source = models.CharField(max_length=255, null=True, blank=True)
external_id = models.CharField(max_length=255, blank=True, null=True)

def __init__(self, *args, **kwargs):
# Track if timezone is provided, if so, don't override it with the workspace timezone when saving
self.is_timezone_provided = kwargs.get("timezone") is not None
super().__init__(*args, **kwargs)

@property
def cover_image_url(self):
# Return cover image url
Expand Down Expand Up @@ -155,7 +160,15 @@ class Meta:
ordering = ("-created_at",)

def save(self, *args, **kwargs):
from plane.db.models import Workspace

self.identifier = self.identifier.strip().upper()
is_creating = self._state.adding

if is_creating and not self.is_timezone_provided:
workspace = Workspace.objects.get(id=self.workspace_id)
self.timezone = workspace.timezone

Comment thread
pablohashescobar marked this conversation as resolved.
return super().save(*args, **kwargs)


Expand Down
Loading