|
|
|
@ -118,30 +118,71 @@ class UserSerializer(serializers.ModelSerializer):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserStorySerializer(serializers.ModelSerializer):
|
|
|
|
|
project = ProjectSerializer(read_only=True)
|
|
|
|
|
added_by = UserSerializer(read_only=True)
|
|
|
|
|
milestone = MileStoneSerializer(read_only=True)
|
|
|
|
|
confirmed_date = serializers.SerializerMethodField()
|
|
|
|
|
completed_date = serializers.SerializerMethodField()
|
|
|
|
|
#added_by = UserSerializer(read_only=True)
|
|
|
|
|
#milestone = MileStoneSerializer(read_only=True)
|
|
|
|
|
#confirmed_date = serializers.SerializerMethodField()
|
|
|
|
|
#completed_date = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
model = UserStory
|
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
def get_confirmed_date(self, obj):
|
|
|
|
|
last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
|
if last_task:
|
|
|
|
|
last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
|
if last_point: # or "Confirmed" if that's your label
|
|
|
|
|
return last_point.start_time
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def get_completed_date(self, obj):
|
|
|
|
|
last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
|
if last_task:
|
|
|
|
|
last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
|
if last_point: # completed means Closed
|
|
|
|
|
return last_point.end_time or last_point.start_time
|
|
|
|
|
return None
|
|
|
|
|
#def get_confirmed_date(self, obj):
|
|
|
|
|
#last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
|
#if last_task:
|
|
|
|
|
#last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
|
#if last_point: # or "Confirmed" if that's your label
|
|
|
|
|
#return last_point.start_time
|
|
|
|
|
#return None
|
|
|
|
|
|
|
|
|
|
#def get_completed_date(self, obj):
|
|
|
|
|
#last_task = Task.objects.filter(userstory=obj).order_by("-id").first()
|
|
|
|
|
#if last_task:
|
|
|
|
|
#last_point = PointActivity.objects.filter(point__task=last_task).order_by("-start_time").first()
|
|
|
|
|
#if last_point: # completed means Closed
|
|
|
|
|
#return last_point.end_time or last_point.start_time
|
|
|
|
|
#return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PointActivitySerializer(serializers.ModelSerializer):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
model = PointActivity
|
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PointSerializer(serializers.ModelSerializer):
|
|
|
|
|
activities = PointActivitySerializer(read_only=True, many=True, source="pointactivity_set")
|
|
|
|
|
duration = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Point
|
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
def get_duration(self, obj):
|
|
|
|
|
hours, minutes, seconds = obj.total_activity_time()
|
|
|
|
|
return f"{str(hours).zfill(2)}:{str(minutes).zfill(2)}:{str(seconds).zfill(2)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TaskSerializer(serializers.ModelSerializer):
|
|
|
|
|
project = ProjectSerializer(read_only=True)
|
|
|
|
|
assigned_to = StaffProfileSerializer(read_only=True)
|
|
|
|
|
user_story = UserSerializer(read_only=True)
|
|
|
|
|
milestone = MileStoneSerializer(read_only=True)
|
|
|
|
|
duration = serializers.SerializerMethodField()
|
|
|
|
|
points = PointSerializer(read_only=True, many=True, source="point_set")
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Task
|
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_duration(self, obj):
|
|
|
|
|
hours, minutes, seconds = obj.total_task_time()
|
|
|
|
|
return f"{str(hours).zfill(2)}:{str(minutes).zfill(2)}:{str(seconds).zfill(2)}"
|