Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
DocuSign_test_project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Volkov Gherman
DocuSign_test_project
Commits
229dc5ce
Commit
229dc5ce
authored
May 31, 2023
by
Volkov Gherman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add page with status display
parent
485af427
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
14 deletions
+68
-14
index.html
api/templates/index.html
+13
-9
status.html
api/templates/status.html
+39
-0
views.py
api/views.py
+14
-4
urls.py
core/urls.py
+2
-1
No files found.
api/templates/index.html
View file @
229dc5ce
...
...
@@ -13,8 +13,8 @@
<h1
style=
"text-align: center; margin-top: 10vh"
class=
"display-6"
>
DocuSign Esign
<br>
<small
class=
"text-muted"
>
Подпишите документ с помощью docusign
</small>
</h1>
<main
style=
"background: lightgray; width:
70vh
; margin-inline: auto"
>
<form
style=
"width:
70vh
; margin: 10vh auto; padding: 20px 30px;"
id=
'form'
method=
"POST"
>
<main
style=
"background: lightgray; width:
800px
; margin-inline: auto"
>
<form
style=
"width:
800px
; margin: 10vh auto; padding: 20px 30px;"
id=
'form'
method=
"POST"
>
<div
class=
"form-group"
>
<label
for=
"formGroupExampleInput"
>
Введите свое имя
</label>
<input
name=
"signer_name"
type=
"text"
class=
"form-control"
id=
"formGroupExampleInput"
placeholder=
"Вася"
...
...
@@ -31,8 +31,11 @@
aria-describedby=
"emailHelp"
placeholder=
"vasyaPupkin@.mail.com"
required
>
</div>
<div
class=
"d-flex justify-content-between flex-wrap"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Подтвердить и подписать документ
</button>
<a
style=
"display: none"
href=
"{% url 'view_status' %}"
class=
"btn btn-light"
id=
"link"
>
Показать статус
</a>
</div>
</form>
</main>
...
...
@@ -44,15 +47,16 @@
fetch
(
`
${
window
.
location
.
protocol
+
'//'
+
window
.
location
.
host
}
/api/v1/`
,
{
method
:
'POST'
,
body
:
new
FormData
(
form
)
}).
then
(
form
.
reset
())
})
.
then
(()
=>
{
const
linkBtn
=
document
.
querySelector
(
'#link'
)
linkBtn
.
style
.
display
=
'inline-block'
})
.
catch
(
error
=>
console
.
error
(
'Произошла ошибка: '
,
error
))
.
finally
(
form
.
reset
())
}
const
form
=
document
.
querySelector
(
'#form'
);
try
{
form
.
addEventListener
(
'submit'
,
sendForm
);
}
catch
(
e
)
{
throw
e
}
form
.
addEventListener
(
'submit'
,
sendForm
);
</script>
</html>
\ No newline at end of file
api/templates/status.html
0 → 100644
View file @
229dc5ce
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
DocuSign test page
</title>
<link
rel=
"stylesheet"
href=
"https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css"
integrity=
"sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin=
"anonymous"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js"
integrity=
"sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin=
"anonymous"
></script>
</head>
<body>
<div
style=
"max-width: 800px; margin: 20vh auto;"
class=
"container"
>
<div
class=
"card"
style=
"max-width: 800px;"
>
<div
class=
"card-header text-center"
>
Данные отправителя и статус отправки
</div>
<ul
class=
"list-group list-group-flush"
>
<li
class=
"list-group-item"
>
{{ data.signer.signer_name }}
</li>
<li
class=
"list-group-item"
>
{{ data.signer.signer_surname }}
</li>
<li
class=
"list-group-item"
>
{{ data.signer.signer_email }}
</li>
</ul>
<div
class=
"card text-white
{% if data.status == 'success' %}
bg-success
{% elif data.status == 'fail' %}
bg-danger
{% else %}
bg-primary
{% endif %}
mb-0"
style=
"max-width: 800px;"
>
<div
class=
"card-body"
>
<h5
class=
"card-title"
><strong>
Статус:
</strong>
{{ data.signer.status }}
</h5>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
api/views.py
View file @
229dc5ce
from
http.client
import
HTTPException
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
,
render
from
rest_framework.renderers
import
TemplateHTMLRenderer
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
api.models
import
StatusChoices
from
api.models
import
StatusChoices
,
SignerInfo
from
api.serializers
import
DocumentNDASerializer
from
api.services
import
send_docusign_email
...
...
@@ -19,8 +19,7 @@ class SendDocumentView(APIView):
template_name
=
'index.html'
def
get
(
self
,
request
):
data
=
{
'error'
:
'error'
}
return
Response
(
data
,
template_name
=
self
.
template_name
,
status
=
200
)
return
Response
(
template_name
=
self
.
template_name
,
status
=
200
)
def
post
(
self
,
request
):
serializer
=
DocumentNDASerializer
(
data
=
request
.
data
)
...
...
@@ -36,3 +35,14 @@ class SendDocumentView(APIView):
signer
.
save
()
return
Response
({
'error'
:
e
,
'signer'
:
signer
},
status
=
503
)
return
Response
({
'error'
:
'Bad Request'
,
'description'
:
'Введенные Вами данные не валидны'
},
status
=
400
)
def
view_status
(
request
):
signer
=
SignerInfo
.
objects
.
last
()
if
signer
.
status
==
StatusChoices
.
REJECT
:
data
=
{
'signer'
:
signer
,
'status'
:
'fail'
}
elif
signer
.
status
==
StatusChoices
.
RESOLVE
:
data
=
{
'signer'
:
signer
,
'status'
:
'success'
}
else
:
data
=
{
'signer'
:
signer
,
'status'
:
'default'
}
return
render
(
request
,
'status.html'
,
context
=
{
'data'
:
data
},
status
=
200
)
core/urls.py
View file @
229dc5ce
...
...
@@ -17,11 +17,12 @@ Including another URLconf
from
django.contrib
import
admin
from
django.urls
import
path
from
api.views
import
index_view
,
SendDocumentView
from
api.views
import
index_view
,
SendDocumentView
,
view_status
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
''
,
index_view
,
name
=
'index'
),
path
(
'api/v1/'
,
SendDocumentView
.
as_view
(),
name
=
'send_email'
),
path
(
'api/v1/status/'
,
view_status
,
name
=
'view_status'
),
]
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