Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2c1ce944
authored
Dec 14, 2023
by
Carpoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group import/export add rerror handling
parent
d7c3c84c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
circle/dashboard/views/group.py
+34
-5
No files found.
circle/dashboard/views/group.py
View file @
2c1ce944
...
@@ -453,7 +453,11 @@ class GroupImportView(LoginRequiredMixin, TemplateView):
...
@@ -453,7 +453,11 @@ class GroupImportView(LoginRequiredMixin, TemplateView):
if
form
.
is_valid
():
if
form
.
is_valid
():
group_path
=
form
.
cleaned_data
[
"group_path"
]
group_path
=
form
.
cleaned_data
[
"group_path"
]
url
=
Store
(
request
.
user
)
.
request_download
(
group_path
)
url
=
Store
(
request
.
user
)
.
request_download
(
group_path
)
json_str
=
requests
.
get
(
url
)
.
content
try
:
response
=
requests
.
get
(
url
,
verify
=
False
)
#response = requests.get(url)
if
response
.
status_code
==
200
:
json_str
=
response
.
content
profile
=
GroupProfile
.
create_from_json
(
request
.
user
,
json_str
)
profile
=
GroupProfile
.
create_from_json
(
request
.
user
,
json_str
)
if
profile
is
None
:
if
profile
is
None
:
raise
SuspiciousOperation
()
raise
SuspiciousOperation
()
...
@@ -472,6 +476,12 @@ class GroupImportView(LoginRequiredMixin, TemplateView):
...
@@ -472,6 +476,12 @@ class GroupImportView(LoginRequiredMixin, TemplateView):
messages
.
success
(
request
,
success_message
)
messages
.
success
(
request
,
success_message
)
return
redirect
(
profile
.
get_absolute_url
())
return
redirect
(
profile
.
get_absolute_url
())
else
:
else
:
messages
.
error
(
request
,
response
.
reason
)
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
except
requests
.
exceptions
.
RequestException
as
e
:
messages
.
error
(
e
)
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
else
:
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
...
@@ -529,22 +539,41 @@ class GroupExportView(LoginRequiredMixin, SingleObjectMixin, TemplateView):
...
@@ -529,22 +539,41 @@ class GroupExportView(LoginRequiredMixin, SingleObjectMixin, TemplateView):
url
=
store
.
request_upload
(
"/"
)
url
=
store
.
request_upload
(
"/"
)
data
=
{
'data'
:
(
name
+
'.group'
,
group_json
)}
data
=
{
'data'
:
(
name
+
'.group'
,
group_json
)}
requests
.
post
(
url
,
files
=
data
)
try
:
response
=
requests
.
post
(
url
,
files
=
data
,
verify
=
False
)
#response = requests.post(url, files=data)
if
response
.
status_code
==
200
:
success_message
=
_
(
"Group successfully exported."
)
success_message
=
_
(
"Group successfully exported."
)
if
request
.
is_ajax
():
if
request
.
is_ajax
():
response
=
{
ajax_
response
=
{
'message'
:
success_message
,
'message'
:
success_message
,
'redirect'
:
group
.
profile
.
get_absolute_url
()
'redirect'
:
group
.
profile
.
get_absolute_url
()
}
}
return
HttpResponse
(
return
HttpResponse
(
json
.
dumps
(
response
),
json
.
dumps
(
ajax_
response
),
content_type
=
"application/json"
content_type
=
"application/json"
)
)
else
:
else
:
messages
.
success
(
request
,
success_message
)
messages
.
success
(
request
,
success_message
)
return
redirect
(
group
.
profile
.
get_absolute_url
())
return
redirect
(
group
.
profile
.
get_absolute_url
())
else
:
else
:
if
request
.
is_ajax
():
ajax_response
=
{
'message'
:
response
.
reason
,
'redirect'
:
group
.
profile
.
get_absolute_url
()
}
return
HttpResponse
(
json
.
dumps
(
ajax_response
),
content_type
=
"application/json"
)
else
:
messages
.
error
(
request
,
response
.
reason
)
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
# This catches all requests Exceptions as this is the base class
except
requests
.
exceptions
.
RequestException
as
e
:
messages
.
error
(
e
)
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
else
:
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
return
self
.
get
(
request
,
form
,
*
args
,
**
kwargs
)
...
...
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