From 2df16481bba5c17e73d2f57c47bfd229e09cf08e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2019 06:29:18 +0000 Subject: [PATCH 01/15] Bump psycopg2 from 2.8.3 to 2.8.4 Bumps [psycopg2](https://github.com/psycopg/psycopg2) from 2.8.3 to 2.8.4. - [Release notes](https://github.com/psycopg/psycopg2/releases) - [Changelog](https://github.com/psycopg/psycopg2/blob/master/NEWS) - [Commits](https://github.com/psycopg/psycopg2/commits) Signed-off-by: dependabot-preview[bot] --- requirements/project.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/project.txt b/requirements/project.txt index d12d035..53a583b 100644 --- a/requirements/project.txt +++ b/requirements/project.txt @@ -6,7 +6,7 @@ django-cors-headers==3.1.1 django==2.2.6 djangorestframework-jwt==1.11.0 djangorestframework==3.10.3 -psycopg2==2.8.3 +psycopg2==2.8.4 requests==2.22.0 sendgrid==6.1.0 whitenoise==4.1.4 From d104165c7428fbccc08a9aaacaf0ab894237f015 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2019 11:51:54 +0000 Subject: [PATCH 02/15] Bump dataclasses-json from 0.3.4 to 0.3.5 Bumps [dataclasses-json](https://github.com/lidatong/dataclasses-json) from 0.3.4 to 0.3.5. - [Release notes](https://github.com/lidatong/dataclasses-json/releases) - [Commits](https://github.com/lidatong/dataclasses-json/compare/v0.3.4...v0.3.5) Signed-off-by: dependabot-preview[bot] --- requirements/project.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/project.txt b/requirements/project.txt index 53a583b..82e7414 100644 --- a/requirements/project.txt +++ b/requirements/project.txt @@ -1,5 +1,5 @@ boto3==1.9.250 -dataclasses-json==0.3.4 +dataclasses-json==0.3.5 dj-database-url==0.5.0 django-admin-multiple-choice-list-filter==0.1.1 django-cors-headers==3.1.1 From 646084a47e86ebdeb9be151ba0a2a706789efcef Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2019 12:51:21 +0000 Subject: [PATCH 03/15] Bump boto3 from 1.9.250 to 1.9.253 Bumps [boto3](https://github.com/boto/boto3) from 1.9.250 to 1.9.253. - [Release notes](https://github.com/boto/boto3/releases) - [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst) - [Commits](https://github.com/boto/boto3/compare/1.9.250...1.9.253) Signed-off-by: dependabot-preview[bot] --- requirements/project.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/project.txt b/requirements/project.txt index 82e7414..6cac8e6 100644 --- a/requirements/project.txt +++ b/requirements/project.txt @@ -1,4 +1,4 @@ -boto3==1.9.250 +boto3==1.9.253 dataclasses-json==0.3.5 dj-database-url==0.5.0 django-admin-multiple-choice-list-filter==0.1.1 From 567682f44e58f99eed8773b502c1831faaf5f432 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2019 06:14:22 +0000 Subject: [PATCH 04/15] Bump boto3 from 1.9.253 to 1.10.0 Bumps [boto3](https://github.com/boto/boto3) from 1.9.253 to 1.10.0. - [Release notes](https://github.com/boto/boto3/releases) - [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst) - [Commits](https://github.com/boto/boto3/compare/1.9.253...1.10.0) Signed-off-by: dependabot-preview[bot] --- requirements/project.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/project.txt b/requirements/project.txt index 6cac8e6..53a8b2d 100644 --- a/requirements/project.txt +++ b/requirements/project.txt @@ -1,4 +1,4 @@ -boto3==1.9.253 +boto3==1.10.0 dataclasses-json==0.3.5 dj-database-url==0.5.0 django-admin-multiple-choice-list-filter==0.1.1 From 3a2a96a7310b629f975e5915c79b3940e98d48dd Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 24 Oct 2019 06:09:07 +0000 Subject: [PATCH 05/15] Bump pytest-mock from 1.11.1 to 1.11.2 Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 1.11.1 to 1.11.2. - [Release notes](https://github.com/pytest-dev/pytest-mock/releases) - [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-mock/compare/v1.11.1...v1.11.2) Signed-off-by: dependabot-preview[bot] --- requirements/tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/tests.txt b/requirements/tests.txt index f512897..4345c68 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,4 +1,4 @@ coverage==4.5.4 pytest-flask==0.15.0 -pytest-mock==1.11.1 +pytest-mock==1.11.2 pytest==5.2.1 From 372bc94f33ee0ecd8bc79b23aceb7310f23548e1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2019 15:25:11 +0000 Subject: [PATCH 06/15] Bump pytest from 5.2.1 to 5.2.2 Bumps [pytest](https://github.com/pytest-dev/pytest) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/5.2.1...5.2.2) Signed-off-by: dependabot-preview[bot] --- requirements/tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/tests.txt b/requirements/tests.txt index 4345c68..2c51bba 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,4 +1,4 @@ coverage==4.5.4 pytest-flask==0.15.0 pytest-mock==1.11.2 -pytest==5.2.1 +pytest==5.2.2 From e8004541ace23f4f77e03fc5be912f74db574c05 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2019 15:39:43 +0000 Subject: [PATCH 07/15] Bump boto3 from 1.10.0 to 1.10.4 Bumps [boto3](https://github.com/boto/boto3) from 1.10.0 to 1.10.4. - [Release notes](https://github.com/boto/boto3/releases) - [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst) - [Commits](https://github.com/boto/boto3/compare/1.10.0...1.10.4) Signed-off-by: dependabot-preview[bot] --- requirements/project.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/project.txt b/requirements/project.txt index 53a8b2d..8cbbf2f 100644 --- a/requirements/project.txt +++ b/requirements/project.txt @@ -1,4 +1,4 @@ -boto3==1.10.0 +boto3==1.10.4 dataclasses-json==0.3.5 dj-database-url==0.5.0 django-admin-multiple-choice-list-filter==0.1.1 From 5be26c1c920dd145d332bb348b2891c06811b06e Mon Sep 17 00:00:00 2001 From: Anastasiia Bilova Date: Tue, 29 Oct 2019 15:55:36 +0000 Subject: [PATCH 08/15] Send message to Telegram bot if block producer update --- directory/block_producer/views/block_producer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/directory/block_producer/views/block_producer.py b/directory/block_producer/views/block_producer.py index 91b8d21..0b53e8e 100644 --- a/directory/block_producer/views/block_producer.py +++ b/directory/block_producer/views/block_producer.py @@ -94,6 +94,13 @@ def post(self, request, block_producer_id): ) as error: return JsonResponse({'error': error.message}, status=HTTPStatus.NOT_FOUND) + if request.META.get('HTTP_HOST'): # fixme: if tests, no https host, better to mock + admin_host = f"{request.scheme}://{request.META.get('HTTP_HOST')}" + + TelegramBot().notify_block_producer_update( + admin_host=admin_host, block_producer_identifier=block_producer_id, + ) + return JsonResponse({'result': 'Block producer has been updated.'}, status=HTTPStatus.OK) @authentication_classes((JSONWebTokenAuthentication,)) From 1a96dc13836ddf6a81ecbc68a89bfd0397dd837a Mon Sep 17 00:00:00 2001 From: Anastasiia Bilova Date: Tue, 29 Oct 2019 15:56:34 +0000 Subject: [PATCH 09/15] Create function to notify block producer update --- directory/services/telegram.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/directory/services/telegram.py b/directory/services/telegram.py index 76d6770..1bcd8da 100644 --- a/directory/services/telegram.py +++ b/directory/services/telegram.py @@ -56,3 +56,27 @@ def notify_block_producer_creation(self, admin_host, block_producer_identifier): message += f'\nTo moderate use following [link]({link_to_moderate}).' self._send_message_telegram_api(chat_id=subscriber_chat_id, message=message) + + def notify_block_producer_update(self, admin_host, block_producer_identifier): + """ + Notify block producer update. + """ + subscribers = requests.get(f'{self.host}/subscribers/block-producer/creation', headers={ + 'Content-type': 'application/json', + }).json().get('result') + + administrators = requests.get(f'{self.host}/administrators', headers={ + 'Content-type': 'application/json', + }).json().get('result') + + link_to_moderate = f'{admin_host}/admin/block_producer/blockproducer/{block_producer_identifier}/change/' + + for subscriber in subscribers: + message = f'Block producer with identifier {block_producer_identifier} has been updated.' + + subscriber_chat_id = subscriber.get('chat_id') + + if subscriber in administrators: + message += f'\nTo moderate use following [link]({link_to_moderate}).' + + self._send_message_telegram_api(chat_id=subscriber_chat_id, message=message) From d874d57eff99bceecc8c983b1dd014179970d03e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2019 15:58:49 +0000 Subject: [PATCH 10/15] Bump flake8-comprehensions from 2.2.0 to 3.0.1 Bumps [flake8-comprehensions](https://github.com/adamchainz/flake8-comprehensions) from 2.2.0 to 3.0.1. - [Release notes](https://github.com/adamchainz/flake8-comprehensions/releases) - [Changelog](https://github.com/adamchainz/flake8-comprehensions/blob/master/HISTORY.rst) - [Commits](https://github.com/adamchainz/flake8-comprehensions/compare/2.2.0...3.0.1) Signed-off-by: dependabot-preview[bot] --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index d47c023..6a586d3 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,6 +1,6 @@ add-trailing-comma==1.4.1 flake8-commas==2.0.0 -flake8-comprehensions==2.2.0 +flake8-comprehensions==3.0.1 flake8-docstrings==1.5.0 flake8-per-file-ignores==0.8.1 flake8-print==3.1.1 From 221faa1293406a988ddf3f8d959509130d708e4b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2019 16:16:36 +0000 Subject: [PATCH 11/15] Bump flake8 from 3.7.8 to 3.7.9 Bumps [flake8](https://gitlab.com/pycqa/flake8) from 3.7.8 to 3.7.9. - [Release notes](https://gitlab.com/pycqa/flake8/tags) - [Commits](https://gitlab.com/pycqa/flake8/compare/3.7.8...3.7.9) Signed-off-by: dependabot-preview[bot] --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 6a586d3..5761f1c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -4,7 +4,7 @@ flake8-comprehensions==3.0.1 flake8-docstrings==1.5.0 flake8-per-file-ignores==0.8.1 flake8-print==3.1.1 -flake8==3.7.8 +flake8==3.7.9 isort==4.3.21 pep8-naming==0.8.2 pydocstyle==4.0.1 From 863884b2b7f1673427ca6cd42d935333d94c30ab Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2019 12:55:34 +0000 Subject: [PATCH 12/15] Bump boto3 from 1.10.4 to 1.10.5 Bumps [boto3](https://github.com/boto/boto3) from 1.10.4 to 1.10.5. - [Release notes](https://github.com/boto/boto3/releases) - [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst) - [Commits](https://github.com/boto/boto3/compare/1.10.4...1.10.5) Signed-off-by: dependabot-preview[bot] --- requirements/project.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/project.txt b/requirements/project.txt index 8cbbf2f..0b05cd8 100644 --- a/requirements/project.txt +++ b/requirements/project.txt @@ -1,4 +1,4 @@ -boto3==1.10.4 +boto3==1.10.5 dataclasses-json==0.3.5 dj-database-url==0.5.0 django-admin-multiple-choice-list-filter==0.1.1 From 42cade31030766e7aee26a0f1ef14f7da64661c7 Mon Sep 17 00:00:00 2001 From: Anastasiia Bilova Date: Wed, 30 Oct 2019 17:24:23 +0000 Subject: [PATCH 13/15] Add a few arguments for the update function, change the update message that is sent to the telegram bot --- directory/services/telegram.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/directory/services/telegram.py b/directory/services/telegram.py index 1bcd8da..9945a27 100644 --- a/directory/services/telegram.py +++ b/directory/services/telegram.py @@ -57,7 +57,7 @@ def notify_block_producer_creation(self, admin_host, block_producer_identifier): self._send_message_telegram_api(chat_id=subscriber_chat_id, message=message) - def notify_block_producer_update(self, admin_host, block_producer_identifier): + def notify_block_producer_update(self, admin_host, block_producer_id, block_producer_name, username): """ Notify block producer update. """ @@ -69,10 +69,11 @@ def notify_block_producer_update(self, admin_host, block_producer_identifier): 'Content-type': 'application/json', }).json().get('result') - link_to_moderate = f'{admin_host}/admin/block_producer/blockproducer/{block_producer_identifier}/change/' + link_to_moderate = f'{admin_host}/admin/block_producer/blockproducer/{block_producer_id}/change/' for subscriber in subscribers: - message = f'Block producer with identifier {block_producer_identifier} has been updated.' + message = f'User {username} HAS BEEN UPDATED his block producer with ' \ + f'the name {block_producer_name} and identifier {block_producer_id}.' subscriber_chat_id = subscriber.get('chat_id') From 6ea6c7fb0ed427f775bcb364a4a2bb78e7d52514 Mon Sep 17 00:00:00 2001 From: Anastasiia Bilova Date: Wed, 30 Oct 2019 17:26:54 +0000 Subject: [PATCH 14/15] Get the block producer name and user username to pass them to the update function --- directory/block_producer/views/block_producer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/directory/block_producer/views/block_producer.py b/directory/block_producer/views/block_producer.py index 0b53e8e..4844cb6 100644 --- a/directory/block_producer/views/block_producer.py +++ b/directory/block_producer/views/block_producer.py @@ -94,11 +94,19 @@ def post(self, request, block_producer_id): ) as error: return JsonResponse({'error': error.message}, status=HTTPStatus.NOT_FOUND) + block_producer = self.get(request=None, block_producer_id=block_producer_id) + + block_producer_name = json.loads(block_producer.content).get('result').get('name') + username = json.loads(block_producer.content).get('result').get('user').get('username') + if request.META.get('HTTP_HOST'): # fixme: if tests, no https host, better to mock admin_host = f"{request.scheme}://{request.META.get('HTTP_HOST')}" TelegramBot().notify_block_producer_update( - admin_host=admin_host, block_producer_identifier=block_producer_id, + admin_host=admin_host, + block_producer_id=block_producer_id, + block_producer_name=block_producer_name, + username=username, ) return JsonResponse({'result': 'Block producer has been updated.'}, status=HTTPStatus.OK) From b3d4c30218dd3680e2443a647681109591f9ca41 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2019 17:30:56 +0000 Subject: [PATCH 15/15] Bump add-trailing-comma from 1.4.1 to 1.5.0 Bumps [add-trailing-comma](https://github.com/asottile/add-trailing-comma) from 1.4.1 to 1.5.0. - [Release notes](https://github.com/asottile/add-trailing-comma/releases) - [Commits](https://github.com/asottile/add-trailing-comma/compare/v1.4.1...v1.5.0) Signed-off-by: dependabot-preview[bot] --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 5761f1c..eaba31d 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,4 +1,4 @@ -add-trailing-comma==1.4.1 +add-trailing-comma==1.5.0 flake8-commas==2.0.0 flake8-comprehensions==3.0.1 flake8-docstrings==1.5.0