[Backport] Removing descriptions from list API
parent
5eb8a27f6f
commit
3d6d162997
|
@ -123,6 +123,9 @@ class IssueViewSet(OCCResourceMixin, HistoryResourceMixin, WatchedResourceMixin,
|
||||||
if self.action in ["retrieve", "by_ref"]:
|
if self.action in ["retrieve", "by_ref"]:
|
||||||
return serializers.IssueNeighborsSerializer
|
return serializers.IssueNeighborsSerializer
|
||||||
|
|
||||||
|
if self.action == "list":
|
||||||
|
return serializers.IssueListSerializer
|
||||||
|
|
||||||
return serializers.IssueSerializer
|
return serializers.IssueSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|
|
@ -63,6 +63,13 @@ class IssueSerializer(WatchersValidator, serializers.ModelSerializer):
|
||||||
return getattr(obj, "votes_count", 0)
|
return getattr(obj, "votes_count", 0)
|
||||||
|
|
||||||
|
|
||||||
|
class IssueListSerializer(IssueSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Issue
|
||||||
|
read_only_fields = ('id', 'ref', 'created_date', 'modified_date')
|
||||||
|
exclude=("description", "description_html")
|
||||||
|
|
||||||
|
|
||||||
class IssueNeighborsSerializer(NeighborsSerializerMixin, IssueSerializer):
|
class IssueNeighborsSerializer(NeighborsSerializerMixin, IssueSerializer):
|
||||||
def serialize_neighbor(self, neighbor):
|
def serialize_neighbor(self, neighbor):
|
||||||
return NeighborIssueSerializer(neighbor).data
|
return NeighborIssueSerializer(neighbor).data
|
||||||
|
|
|
@ -46,6 +46,9 @@ class TaskViewSet(OCCResourceMixin, HistoryResourceMixin, WatchedResourceMixin,
|
||||||
if self.action in ["retrieve", "by_ref"]:
|
if self.action in ["retrieve", "by_ref"]:
|
||||||
return serializers.TaskNeighborsSerializer
|
return serializers.TaskNeighborsSerializer
|
||||||
|
|
||||||
|
if self.action == "list":
|
||||||
|
return serializers.TaskListSerializer
|
||||||
|
|
||||||
return serializers.TaskSerializer
|
return serializers.TaskSerializer
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
|
|
|
@ -66,6 +66,13 @@ class TaskSerializer(WatchersValidator, serializers.ModelSerializer):
|
||||||
return obj.status.is_closed
|
return obj.status.is_closed
|
||||||
|
|
||||||
|
|
||||||
|
class TaskListSerializer(TaskSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Task
|
||||||
|
read_only_fields = ('id', 'ref', 'created_date', 'modified_date')
|
||||||
|
exclude=("description", "description_html")
|
||||||
|
|
||||||
|
|
||||||
class TaskNeighborsSerializer(NeighborsSerializerMixin, TaskSerializer):
|
class TaskNeighborsSerializer(NeighborsSerializerMixin, TaskSerializer):
|
||||||
def serialize_neighbor(self, neighbor):
|
def serialize_neighbor(self, neighbor):
|
||||||
return NeighborTaskSerializer(neighbor).data
|
return NeighborTaskSerializer(neighbor).data
|
||||||
|
|
|
@ -61,6 +61,9 @@ class UserStoryViewSet(OCCResourceMixin, HistoryResourceMixin, WatchedResourceMi
|
||||||
if self.action in ["retrieve", "by_ref"]:
|
if self.action in ["retrieve", "by_ref"]:
|
||||||
return serializers.UserStoryNeighborsSerializer
|
return serializers.UserStoryNeighborsSerializer
|
||||||
|
|
||||||
|
if self.action == "list":
|
||||||
|
return serializers.UserStoryListSerializer
|
||||||
|
|
||||||
return serializers.UserStorySerializer
|
return serializers.UserStorySerializer
|
||||||
|
|
||||||
# Specific filter used for filtering neighbor user stories
|
# Specific filter used for filtering neighbor user stories
|
||||||
|
|
|
@ -96,6 +96,14 @@ class UserStorySerializer(WatchersValidator, serializers.ModelSerializer):
|
||||||
return mdrender(obj.project, obj.description)
|
return mdrender(obj.project, obj.description)
|
||||||
|
|
||||||
|
|
||||||
|
class UserStoryListSerializer(UserStorySerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.UserStory
|
||||||
|
depth = 0
|
||||||
|
read_only_fields = ('created_date', 'modified_date')
|
||||||
|
exclude=("description", "description_html")
|
||||||
|
|
||||||
|
|
||||||
class UserStoryNeighborsSerializer(NeighborsSerializerMixin, UserStorySerializer):
|
class UserStoryNeighborsSerializer(NeighborsSerializerMixin, UserStorySerializer):
|
||||||
def serialize_neighbor(self, neighbor):
|
def serialize_neighbor(self, neighbor):
|
||||||
return NeighborUserStorySerializer(neighbor).data
|
return NeighborUserStorySerializer(neighbor).data
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from taiga.projects.history import services as history_services
|
from taiga.projects.history import services as history_services
|
||||||
from taiga.projects.models import Project
|
from taiga.projects.models import Project
|
||||||
|
@ -79,7 +80,16 @@ def _push_to_timelines(project, user, obj, event_type, created_datetime, extra_d
|
||||||
extra_data=extra_data)
|
extra_data=extra_data)
|
||||||
|
|
||||||
|
|
||||||
|
def _clean_description_fields(values_diff):
|
||||||
|
# Description_diff and description_html if included can be huge, we are
|
||||||
|
# removing the html one and clearing the diff
|
||||||
|
values_diff.pop("description_html", None)
|
||||||
|
if "description_diff" in values_diff:
|
||||||
|
values_diff["description_diff"] = _("Check the history API for the exact diff")
|
||||||
|
|
||||||
|
|
||||||
def on_new_history_entry(sender, instance, created, **kwargs):
|
def on_new_history_entry(sender, instance, created, **kwargs):
|
||||||
|
|
||||||
if instance._importing:
|
if instance._importing:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -99,9 +109,11 @@ def on_new_history_entry(sender, instance, created, **kwargs):
|
||||||
event_type = "delete"
|
event_type = "delete"
|
||||||
|
|
||||||
user = User.objects.get(id=instance.user["pk"])
|
user = User.objects.get(id=instance.user["pk"])
|
||||||
|
values_diff = instance.values_diff
|
||||||
|
_clean_description_fields(values_diff)
|
||||||
|
|
||||||
extra_data = {
|
extra_data = {
|
||||||
"values_diff": instance.values_diff,
|
"values_diff": values_diff,
|
||||||
"user": extract_user_info(user),
|
"user": extract_user_info(user),
|
||||||
"comment": instance.comment,
|
"comment": instance.comment,
|
||||||
"comment_html": instance.comment_html,
|
"comment_html": instance.comment_html,
|
||||||
|
|
Loading…
Reference in New Issue