-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: develop
Are you sure you want to change the base?
Conversation
|
||
try: | ||
history = transfer.add_transfer_history( | ||
origin_transfer_pk=transfer_origin_pk, transfer_pk=transfer.pk, original_transfer_pk=original_transfer_pk |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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
There was a problem hiding this 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.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
No description provided.