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
91b6c315
Commit
91b6c315
authored
Feb 03, 2020
by
Gladys Forte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{dev bugfix} delete media file on master attachment when error occurs
parent
c0703d79
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
app/applicationlayer/cms/form/header/views.py
app/applicationlayer/cms/form/header/views.py
+1
-0
app/applicationlayer/cms/template/header/views.py
app/applicationlayer/cms/template/header/views.py
+12
-1
app/applicationlayer/cms/utils_cr.py
app/applicationlayer/cms/utils_cr.py
+10
-1
No files found.
app/applicationlayer/cms/form/header/views.py
View file @
91b6c315
...
...
@@ -1365,6 +1365,7 @@ class ChangeRequestFormPost(APIView):
except
ValidationError
as
e
:
transaction
.
savepoint_rollback
(
sp1
)
message
=
{
'code'
:
400
,
'status'
:
'failed'
,
...
...
app/applicationlayer/cms/template/header/views.py
View file @
91b6c315
...
...
@@ -14,7 +14,8 @@ from app.applicationlayer.utils import (CustomPagination,
status_message_response
)
from
app.applicationlayer.cms.utils_cr
import
(
entity_log_bulk
entity_log_bulk
,
delete_master_attachment_file
)
from
app.applicationlayer.utils
import
model_to_dict
from
app.entities
import
enums
,
models
...
...
@@ -443,6 +444,11 @@ class ChangeRequestTemplatePost(APIView):
except
ValidationError
as
e
:
transaction
.
savepoint_rollback
(
sp1
)
if
template_header
[
'tmp_attachments'
]:
delete_master_attachment_file
(
template_header
[
'tmp_attachments'
])
message
=
{
'code'
:
400
,
'status'
:
'failed'
,
...
...
@@ -452,6 +458,11 @@ class ChangeRequestTemplatePost(APIView):
except
Exception
as
e
:
transaction
.
savepoint_rollback
(
sp1
)
if
template_header
[
'tmp_attachments'
]:
delete_master_attachment_file
(
template_header
[
'tmp_attachments'
])
message
=
{
'code'
:
500
,
'status'
:
'failed'
,
...
...
app/applicationlayer/cms/utils_cr.py
View file @
91b6c315
...
...
@@ -822,4 +822,13 @@ def cancelled_user_trigger(form_code,
# create notification
notification_create
(
form_code
,
message
,
receiver_code
,
sender_code
,
'cms'
)
\ No newline at end of file
sender_code
,
'cms'
)
def
delete_master_attachment_file
(
attachments
):
# delete master attachment data and media file attachments
for
attachment
in
attachments
:
attach
=
models
.
MasterAttachment
.
objects
.
filter
(
id
=
attachment
[
'file_upload'
])
if
attach
:
attach
.
first
()
.
delete
()
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