Fixing history import and export
parent
5f58042e44
commit
7d30ee5e00
|
@ -241,7 +241,9 @@ class HistoryExportSerializerMixin(serializers.ModelSerializer):
|
|||
history = serializers.SerializerMethodField("get_history")
|
||||
|
||||
def get_history(self, obj):
|
||||
history_qs = history_service.get_history_queryset_by_model_instance(obj)
|
||||
history_qs = history_service.get_history_queryset_by_model_instance(obj,
|
||||
types=(history_models.HistoryType.change, history_models.HistoryType.create,))
|
||||
|
||||
return HistoryExportSerializer(history_qs, many=True).data
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ from django.template.defaultfilters import slugify
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from taiga.projects.history.services import make_key_from_model_object
|
||||
from taiga.projects.history.services import make_key_from_model_object, take_snapshot
|
||||
from taiga.timeline.service import build_project_namespace
|
||||
from taiga.projects.references import sequences as seq
|
||||
from taiga.projects.references import models as refs
|
||||
|
@ -229,9 +229,13 @@ def store_task(project, data):
|
|||
for task_attachment in data.get("attachments", []):
|
||||
store_attachment(project, serialized.object, task_attachment)
|
||||
|
||||
for history in data.get("history", []):
|
||||
history_entries = data.get("history", [])
|
||||
for history in history_entries:
|
||||
store_history(project, serialized.object, history)
|
||||
|
||||
if not history_entries:
|
||||
take_snapshot(serialized.object, user=serialized.object.owner)
|
||||
|
||||
custom_attributes_values = data.get("custom_attributes_values", None)
|
||||
if custom_attributes_values:
|
||||
custom_attributes = serialized.object.project.taskcustomattributes.all().values('id', 'name')
|
||||
|
@ -319,9 +323,13 @@ def store_wiki_page(project, wiki_page):
|
|||
for attachment in wiki_page.get("attachments", []):
|
||||
store_attachment(project, serialized.object, attachment)
|
||||
|
||||
for history in wiki_page.get("history", []):
|
||||
history_entries = wiki_page.get("history", [])
|
||||
for history in history_entries:
|
||||
store_history(project, serialized.object, history)
|
||||
|
||||
if not history_entries:
|
||||
take_snapshot(serialized.object, user=serialized.object.owner)
|
||||
|
||||
return serialized
|
||||
|
||||
add_errors("wiki_pages", serialized.errors)
|
||||
|
@ -381,9 +389,13 @@ def store_user_story(project, data):
|
|||
for role_point in data.get("role_points", []):
|
||||
store_role_point(project, serialized.object, role_point)
|
||||
|
||||
for history in data.get("history", []):
|
||||
history_entries = data.get("history", [])
|
||||
for history in history_entries:
|
||||
store_history(project, serialized.object, history)
|
||||
|
||||
if not history_entries:
|
||||
take_snapshot(serialized.object, user=serialized.object.owner)
|
||||
|
||||
custom_attributes_values = data.get("custom_attributes_values", None)
|
||||
if custom_attributes_values:
|
||||
custom_attributes = serialized.object.project.userstorycustomattributes.all().values('id', 'name')
|
||||
|
@ -434,9 +446,13 @@ def store_issue(project, data):
|
|||
for attachment in data.get("attachments", []):
|
||||
store_attachment(project, serialized.object, attachment)
|
||||
|
||||
for history in data.get("history", []):
|
||||
history_entries = data.get("history", [])
|
||||
for history in history_entries:
|
||||
store_history(project, serialized.object, history)
|
||||
|
||||
if not history_entries:
|
||||
take_snapshot(serialized.object, user=serialized.object.owner)
|
||||
|
||||
custom_attributes_values = data.get("custom_attributes_values", None)
|
||||
if custom_attributes_values:
|
||||
custom_attributes = serialized.object.project.issuecustomattributes.all().values('id', 'name')
|
||||
|
|
Loading…
Reference in New Issue