class IssueSerializer(CustomAttributesValuesWebhookSerializerMixin, serializers.LightSerializer): id = Field() ref = Field() created_date = Field() modified_date = Field() finished_date = Field() due_date = Field() due_date_reason = Field() subject = Field() external_reference = Field() watchers = MethodField() description = Field() tags = Field() permalink = serializers.SerializerMethodField("get_permalink") project = ProjectSerializer() milestone = MilestoneSerializer() owner = UserSerializer() assigned_to = UserSerializer() status = IssueStatusSerializer() type = IssueTypeSerializer() priority = PrioritySerializer() severity = SeveritySerializer() def get_permalink(self, obj): return resolve_front_url("issue", obj.project.slug, obj.ref) def custom_attributes_queryset(self, project): return project.issuecustomattributes.all() def get_watchers(self, obj): return list(obj.get_watchers().values_list("id", flat=True))
class EpicSerializer(CustomAttributesValuesWebhookSerializerMixin, serializers.LightSerializer): id = Field() ref = Field() created_date = Field() modified_date = Field() subject = Field() watchers = MethodField() description = Field() tags = Field() permalink = serializers.SerializerMethodField("get_permalink") project = ProjectSerializer() owner = UserSerializer() assigned_to = UserSerializer() status = EpicStatusSerializer() epics_order = Field() color = Field() client_requirement = Field() team_requirement = Field() client_requirement = Field() team_requirement = Field() def get_permalink(self, obj): return resolve_front_url("epic", obj.project.slug, obj.ref) def custom_attributes_queryset(self, project): return project.epiccustomattributes.all() def get_watchers(self, obj): return list(obj.get_watchers().values_list("id", flat=True))
class TaskSerializer(CustomAttributesValuesWebhookSerializerMixin, serializers.LightSerializer): id = Field() ref = Field() created_date = Field() modified_date = Field() finished_date = Field() due_date = Field() due_date_reason = Field() subject = Field() us_order = Field() taskboard_order = Field() is_iocaine = Field() external_reference = Field() watchers = MethodField() is_blocked = Field() blocked_note = Field() description = Field() tags = Field() permalink = serializers.SerializerMethodField("get_permalink") project = ProjectSerializer() owner = UserSerializer() assigned_to = UserSerializer() status = TaskStatusSerializer() user_story = UserStorySerializer() milestone = MilestoneSerializer() def get_permalink(self, obj): return resolve_front_url("task", obj.project.slug, obj.ref) def custom_attributes_queryset(self, project): return project.taskcustomattributes.all() def get_watchers(self, obj): return list(obj.get_watchers().values_list("id", flat=True))
class NotifyPolicySerializer(serializers.ModelSerializer): project_name = serializers.SerializerMethodField("get_project_name") class Meta: model = models.NotifyPolicy fields = ('id', 'project', 'project_name', 'notify_level', 'live_notify_level', 'web_notify_level') def get_project_name(self, obj): return obj.project.name
class WikiPageSerializer(serializers.LightSerializer): id = Field() slug = Field() content = Field() created_date = Field() modified_date = Field() permalink = serializers.SerializerMethodField("get_permalink") project = ProjectSerializer() owner = UserSerializer() last_modifier = UserSerializer() def get_permalink(self, obj): return resolve_front_url("wiki", obj.project.slug, obj.slug)
class UserStorySerializer(CustomAttributesValuesWebhookSerializerMixin, serializers.LightSerializer): id = Field() ref = Field() project = ProjectSerializer() is_closed = Field() created_date = Field() modified_date = Field() finish_date = Field() due_date = Field() due_date_reason = Field() subject = Field() client_requirement = Field() team_requirement = Field() generated_from_issue = Field(attr="generated_from_issue_id") generated_from_task = Field(attr="generated_from_task_id") external_reference = Field() tribe_gig = Field() watchers = MethodField() is_blocked = Field() blocked_note = Field() description = Field() tags = Field() permalink = serializers.SerializerMethodField("get_permalink") owner = UserSerializer() assigned_to = UserSerializer() assigned_users = MethodField() points = MethodField() status = UserStoryStatusSerializer() milestone = MilestoneSerializer() def get_permalink(self, obj): return resolve_front_url("userstory", obj.project.slug, obj.ref) def custom_attributes_queryset(self, project): return project.userstorycustomattributes.all() def get_assigned_users(self, obj): """Get the assigned of an object. :return: User queryset object representing the assigned users """ return [user.id for user in obj.assigned_users.all()] def get_watchers(self, obj): return list(obj.get_watchers().values_list("id", flat=True)) def get_points(self, obj): return RolePointsSerializer(obj.role_points.all(), many=True).data
class MilestoneSerializer(serializers.LightSerializer): id = Field() name = Field() slug = Field() estimated_start = Field() estimated_finish = Field() created_date = Field() modified_date = Field() closed = Field() disponibility = Field() permalink = serializers.SerializerMethodField("get_permalink") project = ProjectSerializer() owner = UserSerializer() def get_permalink(self, obj): return resolve_front_url("taskboard", obj.project.slug, obj.slug) def to_value(self, instance): if instance is None: return None return super().to_value(instance)
class TimelineSerializer(serializers.LightSerializer): data = serializers.SerializerMethodField("get_data") id = Field() content_type = Field(attr="content_type_id") object_id = Field() namespace = Field() event_type = Field() project = Field(attr="project_id") data = MethodField() data_content_type = Field(attr="data_content_type_id") created = Field() class Meta: model = models.Timeline def get_data(self, obj): # Updates the data user info saved if the user exists if hasattr(obj, "_prefetched_user"): user = obj._prefetched_user else: User = get_user_model() userData = obj.data.get("user", None) try: user = User.objects.get(id=userData["id"]) except User.DoesNotExist: user = None if user is not None: obj.data["user"] = { "id": user.pk, "name": user.get_full_name(), "photo": get_user_photo_url(user), "big_photo": get_user_big_photo_url(user), "gravatar_id": get_user_gravatar_id(user), "username": user.username, "is_profile_visible": user.is_active and not user.is_system, "date_joined": user.date_joined } if "values_diff" in obj.data and "attachments" in obj.data["values_diff"]: [[self.parse_url(item) for item in value] for key, value in obj.data["values_diff"]["attachments"].items() if value] return obj.data def parse_url(self, item): if 'attached_file' in item: attached_file = item['attached_file'] else: # This is the case for old timeline entries file_path = urlparse(item['url']).path index = file_path.find('/attachments') attached_file = file_path[index+1:] item['url'] = default_storage.url(attached_file) if 'thumbnail_file' in item: thumb_file = item['thumbnail_file'] thumb_url = default_storage.url(thumb_file) if thumb_file else None else: thumb_url = get_thumbnail_url(attached_file, settings.THN_ATTACHMENT_TIMELINE) item['thumb_url'] = thumb_url