Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
c3post
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
hanfi
c3post
Commits
745f2316
Verified
Commit
745f2316
authored
May 5, 2023
by
hanfi
Browse files
Options
Downloads
Patches
Plain Diff
use request object instead app to fix root-path
parent
2622840f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
c3post/main.py
+9
-7
9 additions, 7 deletions
c3post/main.py
with
9 additions
and
7 deletions
c3post/main.py
+
9
−
7
View file @
745f2316
...
...
@@ -105,6 +105,7 @@ def get_item(uuid: str, request: Request, db: Session = Depends(get_db)):
@app.post
(
"
/item/{uuid}
"
,
response_class
=
HTMLResponse
)
def
update_item
(
uuid
:
str
,
request
:
Request
,
addressee
:
Annotated
[
str
,
Form
()]
=
None
,
team
:
Annotated
[
str
,
Form
()]
=
None
,
deployed
:
Annotated
[
str
,
Form
()]
=
None
,
...
...
@@ -132,16 +133,18 @@ def update_item(
db
.
commit
()
if
deployed
is
not
None
:
return
RedirectResponse
(
url
=
app
.
url_path
_for
(
"
get_storage
"
,
storage_name
=
item
.
storage
),
url
=
request
.
url
_for
(
"
get_storage
"
,
storage_name
=
item
.
storage
),
status_code
=
HTTP_303_SEE_OTHER
,
)
return
RedirectResponse
(
url
=
app
.
url_path
_for
(
"
get_item
"
,
uuid
=
uuid
),
status_code
=
HTTP_303_SEE_OTHER
url
=
request
.
url
_for
(
"
get_item
"
,
uuid
=
uuid
),
status_code
=
HTTP_303_SEE_OTHER
)
@app.post
(
"
/items
"
,
response_class
=
RedirectResponse
)
def
update_items
(
items
:
list
[
str
]
=
Form
(),
receiver
:
Annotated
[
str
,
Form
()]
=
None
):
def
update_items
(
request
:
Request
,
items
:
list
[
str
]
=
Form
(),
receiver
:
Annotated
[
str
,
Form
()]
=
None
):
if
receiver
is
None
:
raise
HTTPException
(
status_code
=
422
,
...
...
@@ -154,7 +157,7 @@ def update_items(items: list[str] = Form(), receiver: Annotated[str, Form()] = N
db_item
.
deployed_at
=
datetime
.
now
()
db
.
commit
()
return
RedirectResponse
(
url
=
app
.
url_path
_for
(
"
list_items
"
),
status_code
=
HTTP_303_SEE_OTHER
url
=
request
.
url
_for
(
"
list_items
"
),
status_code
=
HTTP_303_SEE_OTHER
)
...
...
@@ -171,6 +174,7 @@ def get_storage(storage_name: str, request: Request, db: Session = Depends(get_d
@app.post
(
"
/{storage_name}/add
"
,
response_class
=
RedirectResponse
)
def
store_item
(
storage_name
:
str
,
request
:
Request
,
addressee
:
Annotated
[
str
,
Form
()]
=
None
,
team
:
Annotated
[
str
,
Form
()]
=
None
,
image
:
Union
[
UploadFile
,
None
]
=
None
,
...
...
@@ -210,6 +214,4 @@ def store_item(
)
db
.
add
(
item
)
db
.
commit
()
return
RedirectResponse
(
url
=
app
.
url_path_for
(
"
main
"
),
status_code
=
HTTP_303_SEE_OTHER
)
return
RedirectResponse
(
url
=
request
.
url_for
(
"
main
"
),
status_code
=
HTTP_303_SEE_OTHER
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment