Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
red-ci-cd
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
red-group-test
red-ci-cd
Commits
61d8ecf5
Commit
61d8ecf5
authored
Jul 24, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added code to use upload
parent
088c6405
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
+23
-5
api/utils.py
api/utils.py
+23
-5
No files found.
api/utils.py
View file @
61d8ecf5
...
...
@@ -10,6 +10,7 @@ from rest_framework.pagination import PageNumberPagination
from
rest_framework.response
import
Response
import
datetime
from
django.db.models.functions
import
Lower
import
copy
VALIDATE_TOKEN_URL
=
settings
.
VALIDATE_TOKEN_URL
...
...
@@ -46,16 +47,33 @@ class Helper:
req
.
status_code
,
self
.
_headers
)
elif
request
.
method
==
'POST'
:
data
=
request
.
data
json_body
=
json
.
dumps
(
data
)
data
=
copy
.
deepcopy
(
request
.
data
)
filesBody
=
{}
if
not
request
.
FILES
==
{}:
for
fileKey
in
request
.
FILES
.
keys
():
filesBody
[
fileKey
]
=
data
[
fileKey
]
data
.
pop
(
fileKey
,
None
)
# Content type will be set to default
# as MultiPart when files header is
# not empty
headers
.
pop
(
'Content-Type'
,
None
)
json_body
=
data
else
:
json_body
=
json
.
dumps
(
data
)
req
=
requests
.
post
(
final_endpoint
,
data
=
json_body
,
headers
=
headers
headers
=
headers
,
files
=
filesBody
)
return
self
.
_response_data
(
req
.
json
(),
req
.
status_code
,
self
.
_headers
)
req
.
status_code
,
self
.
_headers
)
elif
request
.
method
==
'PUT'
:
data
=
request
.
data
json_body
=
json
.
dumps
(
data
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment