|
@@ -13,25 +13,27 @@
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
|
- "execution_count": 117,
|
|
|
|
|
|
|
+ "execution_count": 31,
|
|
|
"metadata": {},
|
|
"metadata": {},
|
|
|
"outputs": [
|
|
"outputs": [
|
|
|
{
|
|
{
|
|
|
"name": "stdout",
|
|
"name": "stdout",
|
|
|
"output_type": "stream",
|
|
"output_type": "stream",
|
|
|
"text": [
|
|
"text": [
|
|
|
- "comments got removed\n",
|
|
|
|
|
"{'data': {'client': 'some company',\n",
|
|
"{'data': {'client': 'some company',\n",
|
|
|
" 'contractor': 'semmtech',\n",
|
|
" 'contractor': 'semmtech',\n",
|
|
|
" 'discription': 'a sample project',\n",
|
|
" 'discription': 'a sample project',\n",
|
|
|
" 'name': 'project',\n",
|
|
" 'name': 'project',\n",
|
|
|
" 'people': ['astrix', 'obelix']},\n",
|
|
" 'people': ['astrix', 'obelix']},\n",
|
|
|
- " 'date of initiation': '2021-01-07 15:23:49',\n",
|
|
|
|
|
|
|
+ " 'date of initiation': '2021-01-08 11:22:59',\n",
|
|
|
" 'id': 0,\n",
|
|
" 'id': 0,\n",
|
|
|
" 'initiated by': 'astrix',\n",
|
|
" 'initiated by': 'astrix',\n",
|
|
|
- " 'last update': '2021-01-07 15:23:49',\n",
|
|
|
|
|
" 'terms': {'Sign time': 'not yet signed',\n",
|
|
" 'terms': {'Sign time': 'not yet signed',\n",
|
|
|
" 'accepted': False,\n",
|
|
" 'accepted': False,\n",
|
|
|
|
|
+ " 'comments': {0: {'author': 'astrix',\n",
|
|
|
|
|
+ " 'body': 'I like the progress',\n",
|
|
|
|
|
+ " 'contract': 0,\n",
|
|
|
|
|
+ " 'time': '2021-01-08 11:22:59'}},\n",
|
|
|
" 'deadline': '1 month',\n",
|
|
" 'deadline': '1 month',\n",
|
|
|
" 'price': 10000,\n",
|
|
" 'price': 10000,\n",
|
|
|
" 'progress': '0%'},\n",
|
|
" 'progress': '0%'},\n",
|
|
@@ -45,12 +47,12 @@
|
|
|
" 'discription': 'a real project',\n",
|
|
" 'discription': 'a real project',\n",
|
|
|
" 'name': 'r project',\n",
|
|
" 'name': 'r project',\n",
|
|
|
" 'people': ['samson', 'gert']},\n",
|
|
" 'people': ['samson', 'gert']},\n",
|
|
|
- " 'date of initiation': '2021-01-07 15:23:49',\n",
|
|
|
|
|
|
|
+ " 'date of initiation': '2021-01-08 11:22:59',\n",
|
|
|
" 'id': 1,\n",
|
|
" 'id': 1,\n",
|
|
|
" 'initiated by': 'samson',\n",
|
|
" 'initiated by': 'samson',\n",
|
|
|
|
|
+ " 'last update': '2021-01-08 11:22:59',\n",
|
|
|
" 'terms': {'Sign time': 'not yet signed',\n",
|
|
" 'terms': {'Sign time': 'not yet signed',\n",
|
|
|
" 'accepted': False,\n",
|
|
" 'accepted': False,\n",
|
|
|
- " 'comments': {},\n",
|
|
|
|
|
" 'deadline': '31-12-2021',\n",
|
|
" 'deadline': '31-12-2021',\n",
|
|
|
" 'price': 10000,\n",
|
|
" 'price': 10000,\n",
|
|
|
" 'progress': '0%'},\n",
|
|
" 'progress': '0%'},\n",
|
|
@@ -64,15 +66,23 @@
|
|
|
" 'discription': 'to contain 096',\n",
|
|
" 'discription': 'to contain 096',\n",
|
|
|
" 'name': 'containment',\n",
|
|
" 'name': 'containment',\n",
|
|
|
" 'people': ['doctor bright', '05-12']},\n",
|
|
" 'people': ['doctor bright', '05-12']},\n",
|
|
|
- " 'date of initiation': '2021-01-07 15:23:49',\n",
|
|
|
|
|
|
|
+ " 'date of initiation': '2021-01-08 11:22:59',\n",
|
|
|
" 'id': 2,\n",
|
|
" 'id': 2,\n",
|
|
|
" 'initiated by': '05-2',\n",
|
|
" 'initiated by': '05-2',\n",
|
|
|
" 'terms': {'Sign time': 'not yet signed',\n",
|
|
" 'terms': {'Sign time': 'not yet signed',\n",
|
|
|
" 'accepted': False,\n",
|
|
" 'accepted': False,\n",
|
|
|
- " 'comments': {4: {'author': 'doctor bright',\n",
|
|
|
|
|
|
|
+ " 'comments': {0: {'author': 'doctor bright',\n",
|
|
|
|
|
+ " 'body': 'needs to be terminated',\n",
|
|
|
|
|
+ " 'contract': 2,\n",
|
|
|
|
|
+ " 'time': '2021-01-08 11:22:59'},\n",
|
|
|
|
|
+ " 1: {'author': '05-12',\n",
|
|
|
|
|
+ " 'body': 'doctor bright is wrong',\n",
|
|
|
|
|
+ " 'contract': 2,\n",
|
|
|
|
|
+ " 'time': '2021-01-08 11:22:59'},\n",
|
|
|
|
|
+ " 2: {'author': 'doctor bright',\n",
|
|
|
" 'body': 'no im right 05-12 is defo wrong',\n",
|
|
" 'body': 'no im right 05-12 is defo wrong',\n",
|
|
|
" 'contract': 2,\n",
|
|
" 'contract': 2,\n",
|
|
|
- " 'time': '2021-01-07 15:23:49'}},\n",
|
|
|
|
|
|
|
+ " 'time': '2021-01-08 11:22:59'}},\n",
|
|
|
" 'deadline': '31-12-2021',\n",
|
|
" 'deadline': '31-12-2021',\n",
|
|
|
" 'price': 'at all costs',\n",
|
|
" 'price': 'at all costs',\n",
|
|
|
" 'progress': '0%'},\n",
|
|
" 'progress': '0%'},\n",
|
|
@@ -81,12 +91,12 @@
|
|
|
"\n",
|
|
"\n",
|
|
|
"\n",
|
|
"\n",
|
|
|
"\n",
|
|
"\n",
|
|
|
- "[{2: {'author': 'doctor bright', 'body': 'needs to be terminated', 'time': '2021-01-07 15:23:49', 'contract': 2}}, {3: {'author': '05-12', 'body': 'doctor bright is wrong', 'time': '2021-01-07 15:23:49', 'contract': 2}}, {4: {'author': 'doctor bright', 'body': 'no im right 05-12 is defo wrong', 'time': '2021-01-07 15:23:49', 'contract': 2}}]\n",
|
|
|
|
|
|
|
+ "[{0: {'author': 'doctor bright', 'body': 'needs to be terminated', 'time': '2021-01-08 11:22:59', 'contract': 2}}, {1: {'author': '05-12', 'body': 'doctor bright is wrong', 'time': '2021-01-08 11:22:59', 'contract': 2}}, {2: {'author': 'doctor bright', 'body': 'no im right 05-12 is defo wrong', 'time': '2021-01-08 11:22:59', 'contract': 2}}]\n",
|
|
|
"7\n",
|
|
"7\n",
|
|
|
"[{'accepted': True,\n",
|
|
"[{'accepted': True,\n",
|
|
|
" 'change': {'deadline': '1 month'},\n",
|
|
" 'change': {'deadline': '1 month'},\n",
|
|
|
" 'id': 0,\n",
|
|
" 'id': 0,\n",
|
|
|
- " 'last update': '2021-01-07 15:23:49',\n",
|
|
|
|
|
|
|
+ " 'last update': '2021-01-08 11:22:59',\n",
|
|
|
" 'type': 'modify',\n",
|
|
" 'type': 'modify',\n",
|
|
|
" 'update id': 0,\n",
|
|
" 'update id': 0,\n",
|
|
|
" 'updated': 'deadline',\n",
|
|
" 'updated': 'deadline',\n",
|
|
@@ -222,7 +232,7 @@
|
|
|
" if item['type'] == 'init':\n",
|
|
" if item['type'] == 'init':\n",
|
|
|
" self.state = item\n",
|
|
" self.state = item\n",
|
|
|
" continue\n",
|
|
" continue\n",
|
|
|
- " \n",
|
|
|
|
|
|
|
+ "\n",
|
|
|
" # if update is not accept update, save it to updates dict\n",
|
|
" # if update is not accept update, save it to updates dict\n",
|
|
|
" if item['type'] != 'accept':\n",
|
|
" if item['type'] != 'accept':\n",
|
|
|
" \n",
|
|
" \n",
|
|
@@ -240,7 +250,6 @@
|
|
|
" \n",
|
|
" \n",
|
|
|
" # check if the update was removal\n",
|
|
" # check if the update was removal\n",
|
|
|
" if item['type'] == 'remove':\n",
|
|
" if item['type'] == 'remove':\n",
|
|
|
- " print(attr + ' got removed')\n",
|
|
|
|
|
" \n",
|
|
" \n",
|
|
|
" # delete item in the right part of the dict\n",
|
|
" # delete item in the right part of the dict\n",
|
|
|
" try:\n",
|
|
" try:\n",
|
|
@@ -259,9 +268,10 @@
|
|
|
" self.state['data'][attr] = item['change'][attr]\n",
|
|
" self.state['data'][attr] = item['change'][attr]\n",
|
|
|
" \n",
|
|
" \n",
|
|
|
" elif attr in self.state['terms']:\n",
|
|
" elif attr in self.state['terms']:\n",
|
|
|
- " \n",
|
|
|
|
|
|
|
+ " \n",
|
|
|
" # special case for comments\n",
|
|
" # special case for comments\n",
|
|
|
" if attr == 'comments' and item['type'] not in ['remove', 'init']:\n",
|
|
" if attr == 'comments' and item['type'] not in ['remove', 'init']:\n",
|
|
|
|
|
+ " \n",
|
|
|
" k = list(item['change'][attr].keys())[0]\n",
|
|
" k = list(item['change'][attr].keys())[0]\n",
|
|
|
" self.state['terms'][attr][k] = item['change'][attr][k]\n",
|
|
" self.state['terms'][attr][k] = item['change'][attr][k]\n",
|
|
|
" \n",
|
|
" \n",
|
|
@@ -302,7 +312,6 @@
|
|
|
" updates.append(item)\n",
|
|
" updates.append(item)\n",
|
|
|
" # updates for specific contract and specific attr\n",
|
|
" # updates for specific contract and specific attr\n",
|
|
|
" else:\n",
|
|
" else:\n",
|
|
|
- " print(item)\n",
|
|
|
|
|
" if item['type'] != 'init' and item['updated'] == attr and item['id'] == iden:\n",
|
|
" if item['type'] != 'init' and item['updated'] == attr and item['id'] == iden:\n",
|
|
|
" updates.append(item)\n",
|
|
" updates.append(item)\n",
|
|
|
" return updates\n",
|
|
" return updates\n",
|
|
@@ -329,19 +338,20 @@
|
|
|
" for block in self.blockchain + [self.current_block]:\n",
|
|
" for block in self.blockchain + [self.current_block]:\n",
|
|
|
" for item in block.block:\n",
|
|
" for item in block.block:\n",
|
|
|
" if 'updated' in item:\n",
|
|
" if 'updated' in item:\n",
|
|
|
- " if item['updated'] == 'comments':\n",
|
|
|
|
|
|
|
+ " if item['updated'] == 'comments' and item['id'] == iden:\n",
|
|
|
" comment_updates.append(item)\n",
|
|
" comment_updates.append(item)\n",
|
|
|
- " \n",
|
|
|
|
|
|
|
+ " \n",
|
|
|
" # create transaction\n",
|
|
" # create transaction\n",
|
|
|
- " self.current_block.add({'id':iden,\n",
|
|
|
|
|
- " 'updated':'comments',\n",
|
|
|
|
|
- " 'accept':True,\n",
|
|
|
|
|
- " 'type':'update',\n",
|
|
|
|
|
- " 'last update':get_t(),\n",
|
|
|
|
|
- " 'change':{'comments':{len(comment_updates):{'author':author,\n",
|
|
|
|
|
- " 'body': body, \n",
|
|
|
|
|
- " 'time': get_t(),\n",
|
|
|
|
|
- " 'contract':iden}}}})\n",
|
|
|
|
|
|
|
+ " to_add = {'id':iden,\n",
|
|
|
|
|
+ " 'updated':'comments',\n",
|
|
|
|
|
+ " 'accept':True,\n",
|
|
|
|
|
+ " 'type':'modify',\n",
|
|
|
|
|
+ " 'last update':get_t(),\n",
|
|
|
|
|
+ " 'change':{'comments':{len(comment_updates):{'author':author,\n",
|
|
|
|
|
+ " 'body': body, \n",
|
|
|
|
|
+ " 'time': get_t(),\n",
|
|
|
|
|
+ " 'contract':iden}}}}\n",
|
|
|
|
|
+ " self.current_block.add(to_add) \n",
|
|
|
" if self.current_block.size() > 10:\n",
|
|
" if self.current_block.size() > 10:\n",
|
|
|
" self.new_block()\n",
|
|
" self.new_block()\n",
|
|
|
" \n",
|
|
" \n",
|
|
@@ -454,7 +464,7 @@
|
|
|
"chain.update_contract(1, 'Sign time', get_t(), 'gert')\n",
|
|
"chain.update_contract(1, 'Sign time', get_t(), 'gert')\n",
|
|
|
"chain.update_contract(1, 'name', 'actual project', 'samson')\n",
|
|
"chain.update_contract(1, 'name', 'actual project', 'samson')\n",
|
|
|
"chain.update_contract(1, 'price', 16969, 'gert')\n",
|
|
"chain.update_contract(1, 'price', 16969, 'gert')\n",
|
|
|
- "chain.remove_item(0, 'comments')\n",
|
|
|
|
|
|
|
+ "chain.remove_item(1, 'comments')\n",
|
|
|
"\n",
|
|
"\n",
|
|
|
"# updates for contract 2\n",
|
|
"# updates for contract 2\n",
|
|
|
"chain.add_comment(2, 'needs to be terminated', 'doctor bright')\n",
|
|
"chain.add_comment(2, 'needs to be terminated', 'doctor bright')\n",
|
|
@@ -493,7 +503,8 @@
|
|
|
"source": [
|
|
"source": [
|
|
|
"Todo: \n",
|
|
"Todo: \n",
|
|
|
"linking to other contracts \n",
|
|
"linking to other contracts \n",
|
|
|
- "milestones \n"
|
|
|
|
|
|
|
+ "milestones \n",
|
|
|
|
|
+ "fix comments"
|
|
|
]
|
|
]
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -521,7 +532,10 @@
|
|
|
"execution_count": null,
|
|
"execution_count": null,
|
|
|
"metadata": {},
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
"outputs": [],
|
|
|
- "source": []
|
|
|
|
|
|
|
+ "source": [
|
|
|
|
|
+ "[{'id': 2, 'updated': 'comments', 'accept': True, 'type': 'update', 'last update': '2021-01-08 10:31:09', 'change': {'comments': {0: {'author': 'doctor bright', 'body': 'needs to be terminated', 'time': '2021-01-08 10:31:09', 'contract': 2}}}}\n",
|
|
|
|
|
+ " , {'id': 2, 'updated': 'comments', 'accept': True, 'type': 'update', 'last update': '2021-01-08 10:31:09', 'change': {'comments': {1: {'author': '05-12', 'body': 'doctor bright is wrong', 'time': '2021-01-08 10:31:09', 'contract': 2}}}}]"
|
|
|
|
|
+ ]
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
"metadata": {
|
|
"metadata": {
|