-
Notifications
You must be signed in to change notification settings - Fork 1
feat(frontend): Item Transit and Movement Tracking #61
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
Merged
qiuethan
merged 1 commit into
main
from
feature/Item-Transit-and-Movement-Tracking-frontend
Apr 2, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,80 @@ | ||
| from django.test import TestCase | ||
| import json | ||
|
|
||
| # Create your tests here. | ||
| from django.test import TestCase, Client | ||
| from rest_framework import status | ||
| from rest_framework_simplejwt.tokens import AccessToken | ||
|
|
||
| from users.models import User | ||
| from inventory.models import CollectionItem, Location, ItemHistory | ||
| from movements.models import ItemMovementRequest | ||
|
|
||
|
|
||
| class ItemMovementArrivalAPITest(TestCase): | ||
| def setUp(self): | ||
| self.volunteer = User.objects.create_user( | ||
| email="volunteer-move@example.com", | ||
| name="Volunteer Move", | ||
| password="testpass", | ||
| role="VOLUNTEER", | ||
| ) | ||
| self.admin = User.objects.create_user( | ||
| email="admin-move@example.com", | ||
| name="Admin Move", | ||
| password="testpass", | ||
| role="ADMIN", | ||
| ) | ||
|
|
||
| volunteer_token = AccessToken.for_user(self.volunteer) | ||
| self.client = Client(HTTP_AUTHORIZATION=f"Bearer {volunteer_token}") | ||
|
|
||
| self.from_location = Location.objects.create(name="Storage B", location_type="STORAGE") | ||
| self.to_location = Location.objects.create(name="Event Hall", location_type="EVENT") | ||
|
|
||
| self.item = CollectionItem.objects.create( | ||
| item_code="MOVE001", | ||
| title="Transit Test Item", | ||
| current_location=self.from_location, | ||
| status="AVAILABLE", | ||
| is_on_floor=False, | ||
| ) | ||
|
|
||
| self.move_request = ItemMovementRequest.objects.create( | ||
| item=self.item, | ||
| requested_by=self.volunteer, | ||
| from_location=self.from_location, | ||
| to_location=self.to_location, | ||
| ) | ||
|
|
||
| def test_complete_arrival_updates_item_location_and_status(self): | ||
| self.move_request.approve(admin_user=self.admin, comment="Approved") | ||
|
|
||
| response = self.client.post( | ||
| f"/api/movements/movement-requests/{self.move_request.id}/complete-arrival/", | ||
| data=json.dumps({"comment": "Arrived and checked"}), | ||
| content_type="application/json", | ||
| ) | ||
|
|
||
| assert response.status_code == status.HTTP_200_OK | ||
| self.item.refresh_from_db() | ||
| assert self.item.current_location_id == self.to_location.id | ||
| assert self.item.status == "AVAILABLE" | ||
|
|
||
| assert ItemHistory.objects.filter( | ||
| item=self.item, | ||
| event_type="ARRIVED", | ||
| to_location=self.to_location, | ||
| ).exists() | ||
|
|
||
| def test_complete_arrival_rejects_when_item_not_in_transit(self): | ||
| self.move_request.status = "APPROVED" | ||
| self.move_request.admin = self.admin | ||
| self.move_request.admin_comment = "Approved" | ||
| self.move_request.save(update_fields=["status", "admin", "admin_comment", "updated_at"]) | ||
|
|
||
| response = self.client.post( | ||
| f"/api/movements/movement-requests/{self.move_request.id}/complete-arrival/", | ||
| data=json.dumps({}), | ||
| content_type="application/json", | ||
| ) | ||
|
|
||
| assert response.status_code == status.HTTP_400_BAD_REQUEST |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.