-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement item movement request workflow with admin approval #27
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
Open
tharjiha
wants to merge
7
commits into
main
Choose a base branch
from
feature/item-move-endpoints
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fa87f1e
feat: add ItemHistory model to support move request tracking
tharjiha e5ebeca
feat(backend): add ItemMovementRequest and ItemHistory models, serial…
tharjiha 180f100
feat: add item movement request workflow with admin approval
tharjiha 383b7ea
chore: format code with black
tharjiha 926416d
chore: changed formatting and import suggestions
tharjiha 93d032f
chore: format code with black
tharjiha 9837bae
fix(requests): prevent double approve/reject
tharjiha 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Generated by Django 5.2.8 on 2025-11-29 17:55 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("inventory", "0002_initial"), | ||
| ("requests", "0002_initial"), | ||
| migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="ItemHistory", | ||
| fields=[ | ||
| ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
| ( | ||
| "item_type", | ||
| models.CharField( | ||
| choices=[ | ||
| ("MOVE_REQUESTED", "Move Requested"), | ||
| ("MOVE_APPROVED", "Move Approved"), | ||
| ("MOVE_REJECTED", "Move Rejected"), | ||
| ("MOVE_CANCELLED", "Move Cancelled"), | ||
| ], | ||
| max_length=50, | ||
| ), | ||
| ), | ||
| ("notes", models.TextField(blank=True)), | ||
| ("timestamp", models.DateTimeField(auto_now_add=True)), | ||
| ( | ||
| "acted_by", | ||
| models.ForeignKey( | ||
| blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL | ||
| ), | ||
| ), | ||
| ( | ||
| "from_location", | ||
| models.ForeignKey( | ||
| blank=True, | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="+", | ||
| to="inventory.location", | ||
| ), | ||
| ), | ||
| ("item", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="inventory.collectionitem")), | ||
| ( | ||
| "movement_request", | ||
| models.ForeignKey( | ||
| blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="requests.itemmovementrequest" | ||
| ), | ||
| ), | ||
| ( | ||
| "to_location", | ||
| models.ForeignKey( | ||
| blank=True, | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="+", | ||
| to="inventory.location", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "ordering": ["-timestamp"], | ||
| }, | ||
| ), | ||
| ] | ||
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,28 +1,48 @@ | ||
| from django.urls import path, include | ||
| from rest_framework.routers import DefaultRouter | ||
| # from django.urls import path, include | ||
| # from rest_framework.routers import DefaultRouter | ||
| # from .views import ItemMovementRequestViewSet | ||
|
|
||
| # # from .views import RequestViewSet | ||
|
|
||
| # from .views import RequestViewSet | ||
| # # Create your URL patterns here. | ||
|
|
||
| # Create your URL patterns here. | ||
| # # Example: Using DRF Router for ViewSets | ||
| # # Uncomment and modify as needed | ||
| # # | ||
| # # router = DefaultRouter() | ||
| # # router.register(r'requests', RequestViewSet, basename='request') | ||
| # # | ||
| # # urlpatterns = [ | ||
| # # path('', include(router.urls)), | ||
| # # ] | ||
|
|
||
| # Example: Using DRF Router for ViewSets | ||
| # Uncomment and modify as needed | ||
| # | ||
| # # This will create the following endpoints: | ||
| # # GET /api/requests/ - List all requests | ||
| # # POST /api/requests/ - Create a new request | ||
| # # GET /api/requests/{id}/ - Retrieve a specific request | ||
| # # PUT /api/requests/{id}/ - Update a request | ||
| # # PATCH /api/requests/{id}/ - Partial update | ||
| # # DELETE /api/requests/{id}/ - Delete a request | ||
| # # POST /api/requests/{id}/approve/ - Custom action (if defined) | ||
| # # POST /api/requests/{id}/reject/ - Custom action (if defined) | ||
|
|
||
| # # create a router and register viewsets | ||
| # router = DefaultRouter() | ||
| # router.register(r'requests', RequestViewSet, basename='request') | ||
| # | ||
| # router.register(r'movement-requests', ItemMovementRequestViewSet, basename='movement-request') | ||
| # router.register(r'item-history', ItemHistoryViewSet, basename='item-history') | ||
|
|
||
| # # wire the router URLs into urlpatterns | ||
| # urlpatterns = [ | ||
| # path('', include(router.urls)), | ||
| # ] | ||
|
|
||
| # This will create the following endpoints: | ||
| # GET /api/requests/ - List all requests | ||
| # POST /api/requests/ - Create a new request | ||
| # GET /api/requests/{id}/ - Retrieve a specific request | ||
| # PUT /api/requests/{id}/ - Update a request | ||
| # PATCH /api/requests/{id}/ - Partial update | ||
| # DELETE /api/requests/{id}/ - Delete a request | ||
| # POST /api/requests/{id}/approve/ - Custom action (if defined) | ||
| # POST /api/requests/{id}/reject/ - Custom action (if defined) | ||
|
|
||
| urlpatterns = [] | ||
| from django.urls import path, include | ||
| from rest_framework.routers import DefaultRouter | ||
| from .views import ItemMovementRequestViewSet | ||
|
|
||
| router = DefaultRouter() | ||
| router.register(r"movement-requests", ItemMovementRequestViewSet, basename="movement-request") | ||
|
|
||
| urlpatterns = [ | ||
| path("", include(router.urls)), | ||
| ] |
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
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.
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.
This migration creates a duplicate ItemHistory model that conflicts with the existing ItemHistory in the inventory app. The existing model uses 'event_type' as the field name, but this migration creates 'item_type'. This migration should be removed since ItemHistory already exists in inventory.models.