-
Notifications
You must be signed in to change notification settings - Fork 0
Fixed Table component and CRUD operations for the various pages that use the table #28
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
kreydev
wants to merge
38
commits into
master
Choose a base branch
from
table
base: master
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
38 commits
Select commit
Hold shift + click to select a range
b8c3686
Minor style changes
kreydev 7af8256
Merge branch 'james-dev'
kreydev c66246e
Cycle 1 navbar changes
kreydev aa97b8c
Fixed nits from PR:
kreydev b421bbb
fix the bugs that somehow I didn't catch before
kreydev 6e87c3e
Merge NavBar and AuthNavBar :)
kreydev 1e73d89
changes to MyForge table
kreydev d9a8c77
Merge github.com:BreadInvasion/forge-new-website into table
kreydev c0dede8
Various changes to table and avatar icon
kreydev dd57b29
made edit and delete buttons only show when the row is hovered over
kreydev fd2bd9e
Merge branch 'master' into table
kreydev 2d859c4
Merge branch 'master' into table
kreydev d2b46b7
Various changes to MyForge table & sidebar
kreydev 3fc13b8
Fix typos on MachineTypes tab
kreydev 7b9aebd
various usermenu fixes
kreydev 041bea0
cleaned up table code
kreydev 1d3e2d8
Merge remote-tracking branch 'origin/master' into table
kreydev 9ea1c96
Merge remote-tracking branch 'origin/master' into table
kreydev 509982a
resources + resourceslots add menu works
kreydev b41706d
Merge remote-tracking branch 'origin/master' into table
kreydev da965ad
update table to work with new structure
kreydev 3043165
machine type add works
kreydev f4f5a9d
adding machinegroups works. also changed backend a bit because the cr…
kreydev 5770b3b
all add endpoints are set in the frontend wooooo
kreydev a983d12
Merge branch 'master' into table
kreydev e02a9fd
update packages
kreydev 14534c2
make table not go off the page
kreydev 5baa538
add/edit menu works for machines tab
kreydev 2f247b6
add machine type add/edit menus; still need to do backend changes
kreydev c283959
upgrade packages, again
kreydev 75c6844
Merge remote-tracking branch 'origin' into table
kreydev 07ef5cb
got edit menu for machine types working
kreydev f0c06c5
fixed loading the machines on the machine group page
kreydev cd94182
finished edit menu for machine groups; made omniapi throw errors on r…
kreydev b3490ae
Resources CRUD fixed
kreydev fc529d0
ResourceSlots CRUD fixed
kreydev 305c1e8
Merge remote-tracking branch 'origin' into table
kreydev 02628db
fixed the lack of useeffects on machinetypes.tsx
kreydev 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
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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
|
|
||
| from models.audit_log import AuditLog | ||
| from models.resource import Resource | ||
| from models.resource_slot import ResourceSlot, ResourceSlotAssociation | ||
| from schemas.requests import ResourceCreateRequest, ResourceEditRequest | ||
| from schemas.responses import ( | ||
| AuditLogModel, | ||
|
|
@@ -50,7 +51,7 @@ async def create_resource( | |
| ) | ||
|
|
||
| new_resource = Resource( | ||
| name=request.name, brand=request.brand, units=request.units, cost=request.cost | ||
| name=request.name, color=request.color, brand=request.brand, units=request.units, cost=request.cost | ||
| ) | ||
| session.add(new_resource) | ||
| await session.commit() | ||
|
|
@@ -166,12 +167,14 @@ async def edit_resource( | |
| differences = { | ||
| "name": request.name if resource.name != request.name else None, | ||
| "brand": request.brand if resource.brand != request.brand else None, | ||
| "color": request.color if resource.color != request.color else None, | ||
| "units": request.units if resource.units != request.units else None, | ||
| "cost": request.cost if resource.cost != request.cost else None, | ||
| } | ||
|
|
||
| resource.name = request.name | ||
| resource.brand = request.brand | ||
| resource.color = request.color | ||
| resource.units = request.units | ||
| resource.cost = request.cost | ||
|
|
||
|
|
@@ -204,6 +207,14 @@ async def delete_resource( | |
| status_code=status.HTTP_404_NOT_FOUND, | ||
| detail="Resource with provided ID not found", | ||
| ) | ||
|
|
||
| slotAcc: ResourceSlotAssociation = await session.scalar(select(ResourceSlotAssociation).where(ResourceSlotAssociation.resource_id == resource_id)) | ||
| if slotAcc: | ||
| slotWith: ResourceSlot = await session.get(ResourceSlot, slotAcc.resource_slot_id) | ||
| raise HTTPException( | ||
| status_code=status.HTTP_406_NOT_ACCEPTABLE, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See other comment about 406 |
||
| detail=f"One or more resource slots is using this resource: {slotWith.display_name})" | ||
| ) | ||
|
|
||
| await session.delete(resource) | ||
|
|
||
|
|
||
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
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.
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 is an incorrect use of HTTP 406 - 406 is used for mismatch with the http "accept: " header. You're looking for HTTP 409: Conflict.