|
|
@ -67,46 +67,38 @@ class ProjectStatusSerializer(serializers.ModelSerializer):
|
|
|
|
fields = "__all__"
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
class ProjectSerializer(serializers.ModelSerializer):
|
|
|
|
class ProjectSerializer(serializers.ModelSerializer):
|
|
|
|
types = ProjectTypeSerializer(read_only=True, many=True, source="project_type")
|
|
|
|
#types = ProjectTypeSerializer(read_only=True, many=True, source="project_type")
|
|
|
|
members = StaffProfileSerializer(read_only=True, many=True)
|
|
|
|
#members = StaffProfileSerializer(read_only=True, many=True)
|
|
|
|
manager = StaffProfileSerializer(read_only=True, many=False)
|
|
|
|
#manager = StaffProfileSerializer(read_only=True, many=False)
|
|
|
|
statuses = ProjectStatusSerializer(read_only=True, many=True, source="projectstatus_set")
|
|
|
|
#statuses = ProjectStatusSerializer(read_only=True, many=True, source="projectstatus_set")
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
class Meta:
|
|
|
|
model = Project
|
|
|
|
model = Project
|
|
|
|
fields = "__all__"
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
def to_representation(self, instance):
|
|
|
|
#def to_representation(self, instance):
|
|
|
|
representation = super().to_representation(instance)
|
|
|
|
#representation = super().to_representation(instance)
|
|
|
|
|
|
|
|
|
|
|
|
# Exclude manager from members list
|
|
|
|
# Exclude manager from members list
|
|
|
|
manager_id = representation.get("manager", {}).get("id")
|
|
|
|
#manager_id = representation.get("manager", {}).get("id")
|
|
|
|
if manager_id:
|
|
|
|
#if manager_id:
|
|
|
|
representation["members"] = [
|
|
|
|
#representation["members"] = [
|
|
|
|
member for member in representation["members"]
|
|
|
|
#member for member in representation["members"]
|
|
|
|
if member.get("id") != manager_id
|
|
|
|
#if member.get("id") != manager_id
|
|
|
|
]
|
|
|
|
#]
|
|
|
|
return representation
|
|
|
|
#return representation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EpicSerializer(serializers.ModelSerializer):
|
|
|
|
class EpicSerializer(serializers.ModelSerializer):
|
|
|
|
project = ProjectSerializer(read_only=True)
|
|
|
|
#project = ProjectSerializer(read_only=True)
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
class Meta:
|
|
|
|
model = Epic
|
|
|
|
model = Epic
|
|
|
|
fields = "__all__"
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserStorySerializer(serializers.ModelSerializer):
|
|
|
|
|
|
|
|
project = ProjectSerializer(read_only=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = UserStory
|
|
|
|
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MileStoneSerializer(serializers.ModelSerializer):
|
|
|
|
class MileStoneSerializer(serializers.ModelSerializer):
|
|
|
|
project = ProjectSerializer(read_only=True)
|
|
|
|
#project = ProjectSerializer(read_only=True)
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
class Meta:
|
|
|
|
model = Milestone
|
|
|
|
model = Milestone
|
|
|
@ -122,32 +114,32 @@ class UserSerializer(serializers.ModelSerializer):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserStorySerializer(serializers.ModelSerializer):
|
|
|
|
class UserStorySerializer(serializers.ModelSerializer):
|
|
|
|
added_by = UserSerializer(read_only=True)
|
|
|
|
#added_by = UserSerializer(read_only=True)
|
|
|
|
milestone = MileStoneSerializer(read_only=True)
|
|
|
|
#milestone = MileStoneSerializer(read_only=True)
|
|
|
|
confirmed_date = serializers.SerializerMethodField()
|
|
|
|
#confirmed_date = serializers.SerializerMethodField()
|
|
|
|
project = ProjectSerializer(read_only=True)
|
|
|
|
#project = ProjectSerializer(read_only=True)
|
|
|
|
|
|
|
|
|
|
|
|
completed_date = serializers.SerializerMethodField()
|
|
|
|
#completed_date = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
class Meta:
|
|
|
|
model = UserStory
|
|
|
|
model = UserStory
|
|
|
|
fields = "__all__"
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
def get_confirmed_date(self, obj):
|
|
|
|
#def get_confirmed_date(self, obj):
|
|
|
|
last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
#last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
if last_task:
|
|
|
|
#if last_task:
|
|
|
|
last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
#last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
if last_point: # or "Confirmed" if that's your label
|
|
|
|
#if last_point: # or "Confirmed" if that's your label
|
|
|
|
return last_point.start_time
|
|
|
|
#return last_point.start_time
|
|
|
|
return None
|
|
|
|
#return None
|
|
|
|
|
|
|
|
|
|
|
|
def get_completed_date(self, obj):
|
|
|
|
#def get_completed_date(self, obj):
|
|
|
|
last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
#last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
if last_task:
|
|
|
|
#if last_task:
|
|
|
|
last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
#last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
if last_point: # completed means Closed
|
|
|
|
#if last_point: # completed means Closed
|
|
|
|
return last_point.end_time or last_point.start_time
|
|
|
|
#return last_point.end_time or last_point.start_time
|
|
|
|
return None
|
|
|
|
#return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PointActivitySerializer(serializers.ModelSerializer):
|
|
|
|
class PointActivitySerializer(serializers.ModelSerializer):
|
|
|
|