Skip to content
Snippets Groups Projects
Commit e5128915 authored by Patricio Kumagae's avatar Patricio Kumagae
Browse files

Merge branch 'desarrollo'

parents 8d89a4d1 30fba8fa
No related branches found
No related tags found
No related merge requests found
...@@ -6,5 +6,6 @@ from django.urls import include ...@@ -6,5 +6,6 @@ from django.urls import include
urlpatterns = [ urlpatterns = [
url(r'api/tsa/', include('app.urls')), url(r'api/tsa/', include('app.urls')),
url(r'^api-token-auth/', obtain_jwt_token), # Habilitar para permitir la autenticación
#url(r'^api-token-auth/', obtain_jwt_token, name='jwt'),
] ]
...@@ -2,6 +2,7 @@ import base64 ...@@ -2,6 +2,7 @@ import base64
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from rest_framework import status from rest_framework import status
from rest_framework.schemas import AutoSchema
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.response import Response from rest_framework.response import Response
from web3.exceptions import CannotHandleRequest from web3.exceptions import CannotHandleRequest
...@@ -14,36 +15,22 @@ from app.utils import Utils ...@@ -14,36 +15,22 @@ from app.utils import Utils
from TsaApi.local_settings import TEMPORARY_OTS_PREFIX, PERMANENT_OTS_PREFIX, CONTRACTS from TsaApi.local_settings import TEMPORARY_OTS_PREFIX, PERMANENT_OTS_PREFIX, CONTRACTS
class Stamp(APIView): class Stamp(APIView):
"""
[POST]
Permite realizar un stamp de un archivo
Parámetros recibidos:
[Content-Type:application/json]
- file_hash: El hash del archivo encodeado en sha256
Devuelve un OTS para poder verificar en el futuro que el archivo fue incluido a la Blockchain
Ejemplo:
{
"file_hash": "1957db7fe23e4be1740ddeb941ddda7ae0a6b782e536a9e00b5aa82db1e84547"
}
"""
schema = ManualSchema(fields=[
coreapi.Field(
name='file_hash',
required=True,
location='form',
schema=coreschema.String(),
description='El hash del archivo encodeado en sha256',
schema = ManualSchema(description='Permite realizar el stamp de un archivo sha256',
), fields=[
coreapi.Field(
'json',
required=True,
location='body',
schema=coreschema.String(
title='json',
description='Parámetros:<br><ul><li>file_hash: El hash del archivo encodeado en sha256</li></ul><br> Ejemplo: <pre>{"file_hash": "1957db7fe23e4be1740ddeb941ddda7ae0a6b782e536a9e00b5aa82db1e84547"}', default='{"file_hash": "1957db7fe23e4be1740ddeb941ddda7ae0a6b782e536a9e00b5aa82db1e84547"}</pre>'),
),
]) ])
def post(self, request): def post(self, request):
try: try:
if not request.data.get('file_hash'): if not request.data.get('file_hash'):
raise ValidationError('file_hash') raise ValidationError('file_hash')
...@@ -87,20 +74,14 @@ class Verify(APIView): ...@@ -87,20 +74,14 @@ class Verify(APIView):
} }
""" """
schema = ManualSchema(fields=[ schema = ManualSchema(description='Permite verificar que un archivo fue subido a la Blockchain',
coreapi.Field( fields=[
name='file_hash', coreapi.Field(
required=True, name='json',
location='form', required=True,
schema=coreschema.String(), location='body',
description='El hash del archivo encodeado en sha256', schema=coreschema.String(description='Parámetros:<br><ul><li>file_hash: El hash del archivo encodeado en sha256</li><li>ots: OTS (Temporal o definitivo) recibido como prueba al momento de realizar el stamp o el verify</li></ul><br>Ejemplo:<br> <pre>{"file_hash": "1957db7fe23e4be1740ddeb941ddda7ae0a6b782e536a9e00b5aa82db1e84547","ots": "MHgtZWViNzJhMzYxZmU3NWMyNDA4Y2VmYjU1NDZkNTRkMDYzNWJmOTA5MmNkNmFkNTYxMjQ4YzFlZjNjZTJkMzQ4NDAxLTB4OTAyMDdiZTI5OTExMGJmZGFhYTliZDI1Zjg5ZTdiYTNhMmFmM2U0YTIzNmYzYTEzMWVmZWRjYjE4Y2E2YTE2Zg=="}</pre>'),
), coreapi.Field( ),
name='ots',
required=True,
location='form',
schema=coreschema.String(),
description='El OTS recibido al hacer el stamp del archivo encodeado en sha256',
)
]) ])
def post(self, request): def post(self, request):
...@@ -177,7 +158,3 @@ class Verify(APIView): ...@@ -177,7 +158,3 @@ class Verify(APIView):
except Exception as e: except Exception as e:
client.captureException() client.captureException()
return Response({_('status'): _('failure'), _('messages'): _('operation_failed')}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response({_('status'): _('failure'), _('messages'): _('operation_failed')}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
No preview for this file type
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-30 15:08-0300\n" "POT-Creation-Date: 2018-09-03 12:22-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -17,17 +17,17 @@ msgstr "" ...@@ -17,17 +17,17 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: TsaApi/settings.py:121 #: TsaApi/settings.py:120
msgid "Spanish" msgid "Spanish"
msgstr "" msgstr ""
#: app/views.py:60 app/views.py:63 app/views.py:65 app/views.py:68 #: app/views.py:60 app/views.py:63 app/views.py:65 app/views.py:68
#: app/views.py:144 app/views.py:150 app/views.py:171 app/views.py:176 #: app/views.py:139 app/views.py:145 app/views.py:162 app/views.py:167
#: app/views.py:180 app/views.py:185 app/views.py:187 app/views.py:190 #: app/views.py:171 app/views.py:174 app/views.py:176 app/views.py:179
msgid "status" msgid "status"
msgstr "" msgstr ""
#: app/views.py:60 app/views.py:144 app/views.py:171 #: app/views.py:60 app/views.py:139 app/views.py:162
msgid "success" msgid "success"
msgstr "" msgstr ""
...@@ -35,45 +35,45 @@ msgstr "" ...@@ -35,45 +35,45 @@ msgstr ""
msgid "temporary_ots" msgid "temporary_ots"
msgstr "" msgstr ""
#: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:150 #: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:145
#: app/views.py:180 app/views.py:185 app/views.py:187 app/views.py:190 #: app/views.py:171 app/views.py:174 app/views.py:176 app/views.py:179
msgid "failure" msgid "failure"
msgstr "" msgstr ""
#: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:146 #: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:141
#: app/views.py:150 app/views.py:171 app/views.py:176 app/views.py:180 #: app/views.py:145 app/views.py:162 app/views.py:167 app/views.py:171
#: app/views.py:185 app/views.py:187 app/views.py:190 #: app/views.py:174 app/views.py:176 app/views.py:179
msgid "messages" msgid "messages"
msgstr "" msgstr ""
#: app/views.py:63 app/views.py:185 #: app/views.py:63 app/views.py:174
msgid "parameter_missing" msgid "parameter_missing"
msgstr "" msgstr ""
#: app/views.py:65 app/views.py:187 #: app/views.py:65 app/views.py:176
msgid "could_not_connect" msgid "could_not_connect"
msgstr "" msgstr ""
#: app/views.py:68 app/views.py:190 #: app/views.py:68 app/views.py:179
msgid "operation_failed" msgid "operation_failed"
msgstr "" msgstr ""
#: app/views.py:145 app/views.py:171 #: app/views.py:140 app/views.py:162
msgid "permanent_ots" msgid "permanent_ots"
msgstr "" msgstr ""
#: app/views.py:146 app/views.py:171 #: app/views.py:141 app/views.py:162
msgid "file_uploaded" msgid "file_uploaded"
msgstr "" msgstr ""
#: app/views.py:150 app/views.py:180 #: app/views.py:145 app/views.py:171
msgid "file_not_found" msgid "file_not_found"
msgstr "" msgstr ""
#: app/views.py:176 #: app/views.py:167
msgid "pending" msgid "pending"
msgstr "" msgstr ""
#: app/views.py:176 #: app/views.py:167
msgid "transaction_pending" msgid "transaction_pending"
msgstr "" msgstr ""
No preview for this file type
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-30 15:08-0300\n" "POT-Creation-Date: 2018-09-03 12:22-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -18,17 +18,17 @@ msgstr "" ...@@ -18,17 +18,17 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: TsaApi/settings.py:121 #: TsaApi/settings.py:120
msgid "Spanish" msgid "Spanish"
msgstr "" msgstr ""
#: app/views.py:60 app/views.py:63 app/views.py:65 app/views.py:68 #: app/views.py:60 app/views.py:63 app/views.py:65 app/views.py:68
#: app/views.py:144 app/views.py:150 app/views.py:171 app/views.py:176 #: app/views.py:139 app/views.py:145 app/views.py:162 app/views.py:167
#: app/views.py:180 app/views.py:185 app/views.py:187 app/views.py:190 #: app/views.py:171 app/views.py:174 app/views.py:176 app/views.py:179
msgid "status" msgid "status"
msgstr "status" msgstr "status"
#: app/views.py:60 app/views.py:144 app/views.py:171 #: app/views.py:60 app/views.py:139 app/views.py:162
msgid "success" msgid "success"
msgstr "success" msgstr "success"
...@@ -36,46 +36,46 @@ msgstr "success" ...@@ -36,46 +36,46 @@ msgstr "success"
msgid "temporary_ots" msgid "temporary_ots"
msgstr "temporay_ots" msgstr "temporay_ots"
#: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:150 #: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:145
#: app/views.py:180 app/views.py:185 app/views.py:187 app/views.py:190 #: app/views.py:171 app/views.py:174 app/views.py:176 app/views.py:179
msgid "failure" msgid "failure"
msgstr "failure" msgstr "failure"
#: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:146 #: app/views.py:63 app/views.py:65 app/views.py:68 app/views.py:141
#: app/views.py:150 app/views.py:171 app/views.py:176 app/views.py:180 #: app/views.py:145 app/views.py:162 app/views.py:167 app/views.py:171
#: app/views.py:185 app/views.py:187 app/views.py:190 #: app/views.py:174 app/views.py:176 app/views.py:179
msgid "messages" msgid "messages"
msgstr "messages" msgstr "messages"
#: app/views.py:63 app/views.py:185 #: app/views.py:63 app/views.py:174
msgid "parameter_missing" msgid "parameter_missing"
msgstr "Parámetro faltante: %s" msgstr "Parámetro faltante: %s"
#: app/views.py:65 app/views.py:187 #: app/views.py:65 app/views.py:176
msgid "could_not_connect" msgid "could_not_connect"
msgstr "No se pudo conectar a la Blockchain" msgstr "No se pudo conectar a la Blockchain"
#: app/views.py:68 app/views.py:190 #: app/views.py:68 app/views.py:179
msgid "operation_failed" msgid "operation_failed"
msgstr "No se pudo realizar la operación" msgstr "No se pudo realizar la operación"
#: app/views.py:145 app/views.py:171 #: app/views.py:140 app/views.py:162
msgid "permanent_ots" msgid "permanent_ots"
msgstr "permanent_ots" msgstr "permanent_ots"
#: app/views.py:146 app/views.py:171 #: app/views.py:141 app/views.py:162
msgid "file_uploaded" msgid "file_uploaded"
msgstr "El archivo %s fue ingresado en el bloque %s el %s" msgstr "El archivo %s fue ingresado en el bloque %s el %s"
#: app/views.py:150 app/views.py:180 #: app/views.py:145 app/views.py:171
msgid "file_not_found" msgid "file_not_found"
msgstr "No se encontró el archivo" msgstr "No se encontró el archivo"
#: app/views.py:176 #: app/views.py:167
msgid "pending" msgid "pending"
msgstr "pending" msgstr "pending"
#: app/views.py:176 #: app/views.py:167
msgid "transaction_pending" msgid "transaction_pending"
msgstr "La transacción se encuentra pendiente de subida a la Blockchain" msgstr "La transacción se encuentra pendiente de subida a la Blockchain"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment