Skip to content

Commit

Permalink
fix(trello_importer): errors importing attachments withowt owner or w…
Browse files Browse the repository at this point in the history
…hen the name ends with /
  • Loading branch information
bameda committed Feb 21, 2024
1 parent 6c254e3 commit 14b9c0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
## 6.7.3 (unreleased)

- GitHub Importer: fix import error with issues associated to a closed milestone.
- Trello Importer: fix import error with attachemts without owner.
- Trello Importer: fix import error when attachemt name ends with '/'.

## 6.7.2 (2024-02-16)

Expand Down
12 changes: 7 additions & 5 deletions taiga/importers/trello/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _import_attachments(self, us, card, options):
data = self._client.download(attachment['url'])

att = Attachment(
owner=users_bindings.get(attachment['idMember'], self._user),
owner=users_bindings.get(attachment['idMember'], self._user) or self._user,
project=us.project,
content_type=ContentType.objects.get_for_model(UserStory),
object_id=us.id,
Expand All @@ -352,7 +352,9 @@ def _import_attachments(self, us, card, options):
created_date=attachment['date'],
is_deprecated=False,
)
att.attached_file.save(attachment['name'], ContentFile(data), save=True)

file_name = attachment['name'][:-1] if attachment['name'].endswith('/') else attachment['name']
att.attached_file.save(file_name, ContentFile(data), save=True)

UserStory.objects.filter(id=us.id, created_date__gt=attachment['date']).update(
created_date=attachment['date']
Expand Down Expand Up @@ -452,19 +454,19 @@ def _transform_action_data(self, us, action, statuses, options):
elif action['type'] == "convertToCardFromCheckItem":
UserStory.objects.filter(id=us.id, created_date__gt=action['date']).update(
created_date=action['date'],
owner=users_bindings.get(action["idMemberCreator"], self._user)
owner=users_bindings.get(action["idMemberCreator"], self._user) or self._user
)
result['hist_type'] = HistoryType.create
elif action['type'] == "copyCommentCard":
UserStory.objects.filter(id=us.id, created_date__gt=action['date']).update(
created_date=action['date'],
owner=users_bindings.get(action["idMemberCreator"], self._user)
owner=users_bindings.get(action["idMemberCreator"], self._user) or self._user
)
result['hist_type'] = HistoryType.create
elif action['type'] == "createCard":
UserStory.objects.filter(id=us.id, created_date__gt=action['date']).update(
created_date=action['date'],
owner=users_bindings.get(action["idMemberCreator"], self._user)
owner=users_bindings.get(action["idMemberCreator"], self._user) or self._user
)
result['hist_type'] = HistoryType.create
elif action['type'] == "updateCard":
Expand Down

0 comments on commit 14b9c0e

Please sign in to comment.