def _import_action(self, us, action, statuses, options): key = make_key_from_model_object(us) typename = get_typename_for_model_class(UserStory) action_data = self._transform_action_data(us, action, statuses, options) if action_data is None: return change_old = action_data['change_old'] change_new = action_data['change_new'] hist_type = action_data['hist_type'] comment = action_data['comment'] user = action_data['user'] diff = make_diff_from_dicts(change_old, change_new) fdiff = FrozenDiff(key, diff, {}) entry = HistoryEntry.objects.create( user=user, project_id=us.project.id, key=key, type=hist_type, snapshot=None, diff=fdiff.diff, values=make_diff_values(typename, fdiff), comment=comment, comment_html=mdrender(us.project, comment), is_hidden=False, is_snapshot=False, ) HistoryEntry.objects.filter(id=entry.id).update( created_at=action['date']) return HistoryEntry.objects.get(id=entry.id)
def _import_activity(self, obj, activity, options): activity_data = self._transform_activity_data(obj, activity, options) if activity_data is None: return change_old = activity_data["change_old"] change_new = activity_data["change_new"] hist_type = activity_data["hist_type"] comment = activity_data["comment"] user = activity_data["user"] key = make_key_from_model_object(activity_data["obj"]) typename = get_typename_for_model_class(type(activity_data["obj"])) diff = make_diff_from_dicts(change_old, change_new) fdiff = FrozenDiff(key, diff, {}) entry = HistoryEntry.objects.create( user=user, project_id=obj.project.id, key=key, type=hist_type, snapshot=None, diff=fdiff.diff, values=make_diff_values(typename, fdiff), comment=comment, comment_html=mdrender(obj.project, comment), is_hidden=False, is_snapshot=False, ) HistoryEntry.objects.filter(id=entry.id).update( created_at=activity["occurred_at"]) return HistoryEntry.objects.get(id=entry.id)
def _import_event(self, obj, event, options, cumulative_data): typename = get_typename_for_model_class(type(obj)) key = make_key_from_model_object(obj) event_data = self._transform_event_data(obj, event, options, cumulative_data) if event_data is None: return change_old = event_data['change_old'] change_new = event_data['change_new'] user = event_data['user'] diff = make_diff_from_dicts(change_old, change_new) fdiff = FrozenDiff(key, diff, {}) values = make_diff_values(typename, fdiff) values.update(event_data['update_values']) entry = HistoryEntry.objects.create( user=user, project_id=obj.project.id, key=key, type=HistoryType.change, snapshot=None, diff=fdiff.diff, values=values, comment="", comment_html="", is_hidden=False, is_snapshot=False, ) HistoryEntry.objects.filter(id=entry.id).update(created_at=event['created_at']) return HistoryEntry.objects.get(id=entry.id)
def _import_history(self, project, obj, history, options): key = make_key_from_model_object(obj) typename = get_typename_for_model_class(obj.__class__) history_data = self._transform_history_data(project, obj, history, options) if history_data is None: return change_old = history_data['change_old'] change_new = history_data['change_new'] hist_type = history_data['hist_type'] comment = history_data['comment'] user = history_data['user'] diff = make_diff_from_dicts(change_old, change_new) fdiff = FrozenDiff(key, diff, {}) values = make_diff_values(typename, fdiff) values.update(history_data['update_values']) entry = HistoryEntry.objects.create( user=user, project_id=obj.project.id, key=key, type=hist_type, snapshot=None, diff=fdiff.diff, values=values, comment=comment, comment_html=mdrender(obj.project, comment), is_hidden=False, is_snapshot=False, ) HistoryEntry.objects.filter(id=entry.id).update(created_at=history['created']) return HistoryEntry.objects.get(id=entry.id)