From 64b3828ef440ddcb00dfde968dc44e0541c4f500 Mon Sep 17 00:00:00 2001
From: Harsh Donga <41797494+harshdonga@users.noreply.github.com>
Date: Sat, 13 Jul 2019 16:01:52 +0530
Subject: [PATCH 1/4] Create README.md
---
README.md | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 README.md
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1cae71c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,19 @@
+To run CLI application,
+
+1. install docker, python3.
+
+2. configure hyperledger sawtooth
+
+
+
+3. From a directory above:
+
+ ./dock
+
+ ./normal (for devMode consensus)
+
+ ./poet (for PoET consensus)
+
+
+
+4. Log in to client containers to explore (try following commands: med, transfer)
From 498a2033748828b67ad74a4b1ba0f2abe1dbc9d7 Mon Sep 17 00:00:00 2001
From: HarshDonga -P6Od6yJQU<9|e1!)wi4#WK4=|^p5#;-<=|?4+o*COW
ulNk@9a}ArOMln4 !kC*i+i|R?KgR7l3d$$X^l&DW0&?PHL_IAQI=zwsxkl8g|+1u
DUP(5c
literal 0
HcmV?d00001
diff --git a/app/logistics/__pycache__/__init__.cpython-37.pyc b/app/logistics/__pycache__/__init__.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..1c77ae19eb16267e7d9d78914e416e2806550226
GIT binary patch
literal 113
zcmZ?b<>g`kg4SfqSP=afM8E(ekl_Ht#VkM~g&~+hlhJP_LlH =qklc{O2D;2p;B!?C+;~(4jEu&5A@z>uxdiC^W|JC!SlDnSV
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/home/tests.py b/app/home/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/app/home/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/app/home/urls.py b/app/home/urls.py
new file mode 100644
index 0000000..29a1e4f
--- /dev/null
+++ b/app/home/urls.py
@@ -0,0 +1,8 @@
+from django.contrib import admin
+from django.urls import path , include
+from . import views
+urlpatterns = [
+ path('', views.home , name = 'home'),
+ path('manufacturers/', include('manufacturers.urls')),
+ path('logistics/', include('logistics.urls')),
+]
\ No newline at end of file
diff --git a/app/home/views.py b/app/home/views.py
new file mode 100644
index 0000000..6b0c678
--- /dev/null
+++ b/app/home/views.py
@@ -0,0 +1,4 @@
+from django.shortcuts import render
+
+def home(request):
+ return render(request, 'home/home.html')
\ No newline at end of file
diff --git a/app/logistics/__init__.py b/app/logistics/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/app/logistics/__pycache__/__init__.cpython-35.pyc b/app/logistics/__pycache__/__init__.cpython-35.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5dc9aa19c76eb6b2ffaf09aadea5fae204b6ea6a
GIT binary patch
literal 128
zcmWgR<>hKkwv1%}g2x~N1{i@12OutH0TL+;48fX=ek&P@K*9*(m#%(Ber~FMMq*KM
zhJHa&epYI7iGE^1fqqVYdS-D+W^%E9e0*kJW=VX!UP0w84x8Nkl+v73JCHHOK+FID
D*u)(x
literal 0
HcmV?d00001
diff --git a/app/logistics/__pycache__/admin.cpython-35.pyc b/app/logistics/__pycache__/admin.cpython-35.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..15b27e64fe2e0f58cb7baeac9fd30d01009c84bd
GIT binary patch
literal 173
zcmWgR<>hKkwv4rBU|@I*#Bjg_WH|tFu?Ubz0U}0*90rD5MusRx2F4U7hG0$Rmp~Z?
zO~zZSi7C06d48HqQG6*`iFxVyddc~DB}JJ@MIb{~G88cbDKPO%OFtt&H&s6)v8Xsh
xzn~~TD>b=9Ke3=dKPNvuv$!NPxmX`;m|j8UEe@O9{FKt1R69nX_F^Dr001#lD0u(?
literal 0
HcmV?d00001
diff --git a/app/logistics/__pycache__/models.cpython-35.pyc b/app/logistics/__pycache__/models.cpython-35.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..d7556f515bc830476ecfa2c224c7b47505d6b96f
GIT binary patch
literal 170
zcmWgR<>hKkwv4r8U|@I*#Bjg_WH|tFu?Ubz0U}0*90rD5MusRx2F4U7hG0$Rmp~Z?
zO~zYnx%nxnImLdOOt&~wvJ&&s^Yv1aia-XeWGG?*Qefhjwthx_ZmNDpVo`C1enC-w
sR%&vIequp^eolURW^qYoaLOGS
')
diff --git a/app/manage.py b/app/manage.py
new file mode 100755
index 0000000..a3f0719
--- /dev/null
+++ b/app/manage.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError as exc:
+ raise ImportError(
+ "Couldn't import Django. Are you sure it's installed and "
+ "available on your PYTHONPATH environment variable? Did you "
+ "forget to activate a virtual environment?"
+ ) from exc
+ execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/app/manufacturers/__init__.py b/app/manufacturers/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/app/manufacturers/__pycache__/__init__.cpython-35.pyc b/app/manufacturers/__pycache__/__init__.cpython-35.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..12bcd8a2936892ea12fb7b218624db536582c94c
GIT binary patch
literal 132
zcmWgR<>lf_w2Wl{g2x~N1{i@12OutH0TL+;48fX=ek&P@K*9*(m!W<}er~FMMq*KM
zhJHa&epYI7iGE^1fqrgcUTIola!F}XYEiL%e0*kJW=VX!UP0w84x8Nkl+v73JCISu
HK+FIDCdVFS
literal 0
HcmV?d00001
diff --git a/app/manufacturers/__pycache__/admin.cpython-35.pyc b/app/manufacturers/__pycache__/admin.cpython-35.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..be21de8ff24375aa4a318dc5f6d686467af669e5
GIT binary patch
literal 177
zcmWgR<>lf_w2ZZ9U|@I*#Bjg_WH|tFu?Ubz0U}0*90rD5MusRx2F4U7hG0$Rmp~Z?
zO~zZSi7C06d48HqQG6*`iFxVyddc~DB}JJ@MIb{~G88cbDKPO%Pd_6+H&s6)v8Xsh
zzn~~TD>b=9Ke3=dKQ}S2G%Yc?q_ilts8}Ctpk6`cEe@O9{FKt1R69nX5ye2v005S~
BDYF0o
literal 0
HcmV?d00001
diff --git a/app/manufacturers/__pycache__/models.cpython-35.pyc b/app/manufacturers/__pycache__/models.cpython-35.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..fdb0bcdccb58477465ca0ca15d71c1faf9056d5f
GIT binary patch
literal 174
zcmWgR<>lf_w2ZZ6U|@I*#Bjg_WH|tFu?Ubz0U}0*90rD5MusRx2F4U7hG0$Rmp~Z?
zO~zYnx%nxnImLdOOt&~wvJ&&s^Yv1aia-XeWGG?*QefhjzJ5l2ZmNDpVo`C1enC-w
wR%&vIequp^er{r3X881l9?N6b>2i6nF;j(E{@Y<_paKV6nhrfkl9O^e%yya9dYL3;{Lq3FB(e
zb>!*9T<^0%cXH<9i0PO1(;%L$2TwIq!Y6~~;>ASELECT
+
+
+
\ No newline at end of file
diff --git a/app/manufacturers/templates/med.html b/app/manufacturers/templates/med.html
new file mode 100644
index 0000000..6ef5d5d
--- /dev/null
+++ b/app/manufacturers/templates/med.html
@@ -0,0 +1,38 @@
+
+
+
+
+
diff --git a/app/manufacturers/templates/transfer.html b/app/manufacturers/templates/transfer.html
new file mode 100644
index 0000000..e69de29
diff --git a/app/manufacturers/tests.py b/app/manufacturers/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/app/manufacturers/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/app/manufacturers/urls.py b/app/manufacturers/urls.py
new file mode 100644
index 0000000..6b54903
--- /dev/null
+++ b/app/manufacturers/urls.py
@@ -0,0 +1,9 @@
+from django.contrib import admin
+from django.urls import path, include
+from . import views
+
+urlpatterns = [
+ path('', views.index , name = 'index'),
+ path('task', views.task , name = 'task'),
+ path('medtransact', views.medtransact, name = 'medtransact')
+]
\ No newline at end of file
diff --git a/app/manufacturers/views.py b/app/manufacturers/views.py
new file mode 100644
index 0000000..a7d2b61
--- /dev/null
+++ b/app/manufacturers/views.py
@@ -0,0 +1,19 @@
+from django.shortcuts import render
+from django.http import HttpResponse
+
+def index(request):
+ return render(request, 'index.html')
+
+def task(request):
+ options = request.POST['options']
+ if options == 'med':
+ return render(request, 'med.html')
+ else:
+ return render(request, 'transfer.html')
+
+def medtransact(request):
+ medicineName = request.POST['medicineName']
+ medicineName = request.POST['medicineId']
+ medicineName = request.POST['medicineKeyContent']
+ medicineName = request.POST['medicineAllContents']
+ medicineName = request.POST['ExpiryMonths']
diff --git a/djangodocker b/djangodocker
new file mode 100644
index 0000000..571232e
--- /dev/null
+++ b/djangodocker
@@ -0,0 +1,8 @@
+FROM python:3.7-alpine
+
+COPY ./requirements.txt /requirements.txt
+RUN pip install -r /requirements.txt
+
+RUN mkdir /app
+WORKDIR /app
+COPY ./app /app
diff --git a/dock b/dock
index 52277ac..31153eb 100755
--- a/dock
+++ b/dock
@@ -8,6 +8,10 @@ docker volume rm project_keyshare
docker volume rm project_blocks
-docker build -f transfer_python/Dockerfile -t harsh/transfer:v1 .
+docker volume rm project_node
+
+# docker build -f transfer_python/Dockerfile -t harsh/transfer:v1 .
+
+docker build -f djangodocker -t harsh/djangoapp:v1 .
echo "Done Shit!"
diff --git a/docker-compose-NORMAL.yaml b/docker-compose-NORMAL.yaml
index 0c4d925..cc4920c 100644
--- a/docker-compose-NORMAL.yaml
+++ b/docker-compose-NORMAL.yaml
@@ -8,6 +8,7 @@ services:
volumes:
- keyshare:/root
- blocks:/var/lib/sawtooth
+ - node:/project
depends_on:
- validator
command: |
@@ -22,6 +23,7 @@ services:
volumes:
- keyshare:/root
- blocks:/var/lib/sawtooth
+ - node:/project
depends_on:
- validator
command: |
@@ -36,6 +38,7 @@ services:
volumes:
- keyshare:/root
- blocks:/var/lib/sawtooth
+ - node:/project
depends_on:
- validator
command: |
@@ -51,6 +54,7 @@ services:
volumes:
- keyshare:/root
- blocks:/var/lib/sawtooth
+ - node:/project
depends_on:
- validator
command: |
@@ -66,6 +70,7 @@ services:
container_name: sawtooth-validator
volumes:
- blocks:/var/lib/sawtooth
+ - node:/project
expose:
- 4004
- 8800
@@ -100,6 +105,7 @@ services:
volumes:
- keyshare:/root
- blocks:/var/lib/sawtooth
+ - node:/project
ports:
- "8008:8008"
depends_on:
@@ -117,6 +123,7 @@ services:
volumes:
- keyshare:/root
- blocks:/var/lib/sawtooth
+ - node:/project
depends_on:
- validator
command: |
@@ -124,7 +131,26 @@ services:
devmode-engine-rust -v --connect tcp://validator:5050
"
stop_signal: SIGKILL
+
+
+ # web:
+ # image: harsh/nodeapp:v1
+ # ports:
+ # - "3000:3000"
+ # volumes:
+ # - keyshare:/root
+ # - blocks:/var/lib/sawtooth
+
+ app:
+ image: harsh/djangoapp:v1
+ ports:
+ - "8000:8000"
+ volumes:
+ - ./app:/app
+ command: >
+ sh -c "python3 manage.py runserver 0.0.0.0:8000"
volumes:
keyshare:
blocks:
+ node:
diff --git a/med_python/sawtooth_med/processor/handler.py b/med_python/sawtooth_med/processor/handler.py
index 9ce0a44..d622657 100644
--- a/med_python/sawtooth_med/processor/handler.py
+++ b/med_python/sawtooth_med/processor/handler.py
@@ -114,10 +114,13 @@ def apply(self, transaction , context):
if medicine is None:
raise InvalidTransaction('Invalid action: Medicine DOES NOT exists: {}'.format(med_payload.medicineName))
- medicine.stock = med_payload.stock
- med_state.set_medicine(med_payload.medicineName , medicine)
+ if medicine.medicineID == med_payload.medicineID:
+ medicine.stock = med_payload.stock
+ med_state.set_medicine(med_payload.medicineName , medicine)
- _display('Medicine Info updated successfully by: {}'.format(signer[:6]))
+ _display('Medicine Info updated successfully by: {}'.format(signer[:6]))
+ else:
+ raise InvalidTransaction('Unhandled action: {}'.format(med_payload.action))
else:
raise InvalidTransaction('Unhandled action: {}'.format(med_payload.action))
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..d3677ab
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+Django
+djangorestframework
diff --git a/transfer_python/sawtooth_transfer/processor/handler.py b/transfer_python/sawtooth_transfer/processor/handler.py
index 9b221d5..da57e97 100644
--- a/transfer_python/sawtooth_transfer/processor/handler.py
+++ b/transfer_python/sawtooth_transfer/processor/handler.py
@@ -95,7 +95,7 @@ def apply(self, transaction, context):
if transfer_state.get_shipment(transfer_payload.shipmentID) is not None:
raise InvalidTransaction('Invalid action: Shipment already exists')
-
+
shipment = Shipment(
shipmentID = transfer_payload.shipmentID,
logisticsID = transfer_payload.logisticsID,
@@ -116,6 +116,11 @@ def apply(self, transaction, context):
if shipment is None:
raise InvalidTransaction('Invalid action : Shipment does not exists: {}'.format(transfer_payload.shipmentID))
+ if(transfer_payload.shipmentStatus == 'DELIVERED'):
+ transfer_state.delete_shipment(transfer_payload.shipmentID)
+ _display('Shipment Deleted successfully deleted successfully by: {}'.format(signer[:6]))
+
+
shipment.shipmentStatus = transfer_payload.shipmentStatus
transfer_state.set_shipment(transfer_payload.shipmentID , shipment)
_display('Logistics Company : {} updated Shipment'.format(signer[:6]))
diff --git a/transfer_python/sawtooth_transfer/transfer_cli.py b/transfer_python/sawtooth_transfer/transfer_cli.py
index 19ab0a1..6b60d6f 100644
--- a/transfer_python/sawtooth_transfer/transfer_cli.py
+++ b/transfer_python/sawtooth_transfer/transfer_cli.py
@@ -698,7 +698,11 @@ def do_list(args):
]
if asset_list is not None:
- print(asset_list)
+ print('-'*50)
+ for x in asset_list:
+ print(x)
+ print('x'*10)
+ print('-'*50)
else:
raise TransferException("Could not retireve List")
@@ -715,9 +719,13 @@ def do_show(args):
data = client.show(ID, auth_user=auth_user, auth_password=auth_password)
if data is not None:
- print(data)
+ print('-'*50)
+ for x in data:
+ print(x)
+ print('x'*10)
+ print('-'*50)
else:
- raise TransferException("Asset not found: {}".format(shipmentID))
+ raise TransferException("Assets not found!")
def main(prog_name = os.path.basename(sys.argv[0]), args = None):
diff --git a/transfer_python/sawtooth_transfer/transfer_client.py b/transfer_python/sawtooth_transfer/transfer_client.py
index 4581271..2451733 100644
--- a/transfer_python/sawtooth_transfer/transfer_client.py
+++ b/transfer_python/sawtooth_transfer/transfer_client.py
@@ -286,8 +286,8 @@ def _send_transfer_txn(self,
signer_public_key=self._signer.get_public_key().as_hex(),
family_name="transfer",
family_version="1.0",
- inputs=[addresss, addressb, address, med_address],
- outputs=[addresss, addressb, address, med_address],
+ inputs=[addresss, addressb, address, med_address, '6d0f36e8b34cbf061ca4c58e89b40e797beefdb663b681a96e2d1ccd8f03f9b52eb4e0'],
+ outputs=[addresss, addressb, address, med_address, '6d0f36e8b34cbf061ca4c58e89b40e797beefdb663b681a96e2d1ccd8f03f9b52eb4e0'],
dependencies=[],
payload_sha512=_sha512(payload),
batcher_public_key=self._signer.get_public_key().as_hex(),
From 288a74a49a2fb8b0948465d57fefe001b235aee6 Mon Sep 17 00:00:00 2001
From: HarshDonga 20O&a?LI3~&
literal 878
zcma)4&5qMB5KhvxyJUBPN0?h0sl?D56(C^6ij@!&f0s%q>&9;DDz+or0hTL|!4vRG
zxpLZ9;KbN%r3wjYE!i3;pJ%@Bn|XP5mPNRJzI*)nCW)fo{<2>K44&h*5Ak5pJYq3R
znph_DB=+&38OU^=#t~0h%9G7-Gy0LN;`tF9eu#<@Z7?BiTln<;4V-JW6syiqC$!44
zk82KBooQO?95>2dK_jdKqdUi~e_+9B_#*gMTf&7lAhqEj)KVK6Qb5~qYB^ZWXBpsH
zJJ;G7Axzh{WE-khx;1*kYgg7<60XR!oD!#7QCs4{1j}2Jz4}Ha=CZTwqEoeJw=Elz
zJ}Th_V?Y%M*=plv0867K$m_}r+kQO2Pj~nr83i0D#HT2BJ x<`c)?yhow0Ybu
z896g0_K;URZS6SZLB((xesOri@yjh-A?MGqcCbm0#o%$0I!6>H7Kv3xl3q4b7HczX
z6o&<5E-K})Y
3^2)MhH<
z%m_$Lw$CAh{6ioWNCgx}Dv?SkiFQI&P~EYnKA=BqcuY0e-Ze>-lb)Yq-n(vCz#MR}
zzxGRSUPELt?H!mmJRqI6Cdyfd=U7_
+
+
+
+
diff --git a/app/manufacturers/templates/test.html b/app/manufacturers/templates/test.html new file mode 100644 index 0000000..9630053 --- /dev/null +++ b/app/manufacturers/templates/test.html @@ -0,0 +1,8 @@ + +
+
+ +
+