Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ch39212] Transfer History #3827

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

smihalache06
Copy link
Contributor

No description provided.


try:
history = transfer.add_transfer_history(
origin_transfer_pk=transfer_origin_pk, transfer_pk=transfer.pk, original_transfer_pk=original_transfer_pk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only pass pk hehe

history = transfer.add_transfer_history(
origin_transfer_pk=transfer_origin_pk, transfer_pk=transfer.pk, original_transfer_pk=original_transfer_pk
)
transfer.set_transfer_history(history, save=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just have 1 method add_transfer_history and then an explicit .save()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could think adding a .save_history() method to Transfer that only saves the transfer_history field

Copy link
Collaborator

@fpbonet fpbonet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. Approved not to block.

Comment on lines 108 to 133
from_partner = models.ForeignKey(
PartnerOrganization,
on_delete=models.SET_NULL,
null=True, blank=True,
related_name='transfer_history_from_partner'
)
destination_partner = models.ForeignKey(
PartnerOrganization,
on_delete=models.SET_NULL,
null=True, blank=True,
related_name='transfer_history_destination_partner'
)
origin_point = models.ForeignKey(
PointOfInterest,
on_delete=models.SET_NULL,
null=True, blank=True,
related_name='transfer_history_origin_point'
)
destination_point = models.ForeignKey(
PointOfInterest,
on_delete=models.SET_NULL,
null=True, blank=True,
related_name='transfer_history_destination_point'
)

comment = models.TextField(null=True, blank=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion, let's please remove, as they are redundant. The transfer already knows origin, destination, points, etc.

logger.warning(f"Item has no transfer : {instance}")
return # No transfer available, exit early

transfer_origin_pk = getattr(transfer.origin_transfer, "pk", None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's simplify by just using the item.original_transfer

@@ -93,6 +93,50 @@ def save(self, **kwargs):
super().save(**kwargs)


class TransferHistoryManager(models.Manager):
def get_or_build_by_origin_id(self, *origin_id_candidates):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed together, let's simplify for only 2 parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants