From 7fde7395e1a1c523fa6dbae1c92f2fe00ef174fa Mon Sep 17 00:00:00 2001 From: Vikash Kumar Date: Mon, 22 Jul 2024 19:40:26 +0530 Subject: [PATCH] Added email changes,version fixes --- .env_example | 7 +++++ Pipfile | 30 +++++++++---------- Pipfile.lock | 23 ++++++++++++++ azure-pipeline-dev.yml | 12 ++++---- config/settings/base.py | 4 +-- config/settings/prod.py | 2 +- proco/connection_statistics/api.py | 1 + .../populate_school_registration_data.py | 2 +- 8 files changed, 56 insertions(+), 25 deletions(-) diff --git a/.env_example b/.env_example index f0e3be9..5a2e327 100644 --- a/.env_example +++ b/.env_example @@ -59,3 +59,10 @@ INVALIDATE_CACHE_HARD=true CACHE_CONTROL_MAX_AGE_FOR_FE=14400 API_KEY_ADMIN_DASHBOARD_URL=http://localhost:9500/admin/api-keys + + +EMAIL_URL= +SERVER_EMAIL_SIGNATURE=Gigamaps +SERVER_EMAIL=gigamaps@mail.unicef.org +CONTACT_EMAIL=vikash.kumar05@nagarro.com +MAILING_USE_CELERY=false diff --git a/Pipfile b/Pipfile index 4fd4291..732dd18 100644 --- a/Pipfile +++ b/Pipfile @@ -6,24 +6,24 @@ name = "pypi" [dev-packages] django-debug-toolbar = "*" isort = "*" -flake8 = "*" +flake8 = "==6.1.0" dlint = "*" -flake8-bandit = "*" -flake8-blind-except = "*" -flake8-broken-line = "*" -flake8-bugbear = "*" -flake8-comprehensions = "*" -flake8-eradicate = "*" -flake8-string-format = "*" -flake8-commas = "*" -flake8-quotes = "*" -flake8-logging-format = "*" +flake8-bandit = "==4.1.1" +flake8-blind-except = "==0.2.1" +flake8-broken-line = "==1.0.0" +flake8-bugbear = "==23.12.2" +flake8-comprehensions = "==3.14.0" +flake8-eradicate = "==1.5.0" +flake8-string-format = "==0.3.0" +flake8-commas = "==2.1.0" +flake8-quotes = "==3.3.2" +flake8-logging-format = "==0.9.0" mccabe = "*" pep8-naming = "*" pycodestyle = "*" -flake8-rst-docstrings = "*" -flake8-pep3101 = "*" -flake8-mutable = "*" +flake8-rst-docstrings = "==0.3.0" +flake8-pep3101 = "==2.1.0" +flake8-mutable = "==1.2.0" coverage = "==7.3.0" django-anymail = "==7.2" delta-sharing = "==1.0.3" @@ -34,7 +34,7 @@ psycopg2 = "==2.8.6" celery = "<6.0" ipython = "*" django-templated-email = "*" -sentry-sdk = "*" +sentry-sdk = "==1.39.1" newrelic = "*" djangorestframework = ">=3.10" drf-secure-token = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 8d19a97..176140e 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -154,6 +154,13 @@ "index": "pypi", "version": "==5.3.6" }, + "celery-redbeat": { + "hashes": [ + "sha256:71104729380d4eaefd91a9b7d270ba7851bfff9ad55a43ac8365acbb0c608b77" + ], + "index": "pypi", + "version": "==2.2.0" + }, "certifi": { "hashes": [ "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1", @@ -1327,6 +1334,14 @@ ], "version": "==0.6.3" }, + "tenacity": { + "hashes": [ + "sha256:9e6f7cf7da729125c7437222f8a522279751cdfbe6b67bfe64f75d3a348661b2", + "sha256:cd80a53a79336edba8489e767f729e4f391c896956b57140b5d7511a64bbd3ef" + ], + "markers": "python_version >= '3.8'", + "version": "==8.4.2" + }, "text-unidecode": { "hashes": [ "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8", @@ -2328,6 +2343,14 @@ "markers": "python_full_version >= '3.7.0'", "version": "==13.7.0" }, + "setuptools": { + "hashes": [ + "sha256:b8b8060bb426838fbe942479c90296ce976249451118ef566a5a0b7d8b78fb05", + "sha256:bd63e505105011b25c3c11f753f7e3b8465ea739efddaccef8f0efac2137bac1" + ], + "markers": "python_version >= '3.8'", + "version": "==70.2.0" + }, "six": { "hashes": [ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", diff --git a/azure-pipeline-dev.yml b/azure-pipeline-dev.yml index 9334fd3..257f6bd 100644 --- a/azure-pipeline-dev.yml +++ b/azure-pipeline-dev.yml @@ -12,10 +12,10 @@ name: $(SourceBranchName).$(Build.BuildId).$(Date:yyyyMMdd).$(Rev:r) pool: vmImage: 'ubuntu-22.04' -variables: - dockerRegistryServiceConnection: 'UNICEF_DATA_CONNECT_WEB_ACR' +variables: + dockerRegistryServiceConnection: $(DOCKER_SERVICE_CONNECTION) dockerfilePath: './Dockerfile' - app: 'project-connect-backend-v2' + app: $(DOCKER_REPOSITORY) imageRepositoryDev: 'dev/$(app)' imageRepositoryStg: 'stg/$(app)' imageRepositoryProd: 'prod/$(app)' @@ -25,7 +25,7 @@ variables: steps: # Use a specific Python version - task: UsePythonVersion@0 - displayName: Building Razor with $(pythonVersion) + displayName: Building Razor with $(pythonVersion) inputs: versionSpec: $(pythonVersion) addToPath: true @@ -70,9 +70,9 @@ steps: -Dsonar.sources=proco \ -Dsonar.host.url=$(SONAR_HOST) \ -Dsonar.python.coverage.reportPaths=coverage.xml \ - -Dsonar.coverage.exclusions=**/migrations/**,**/proco_data_migrations/**,**/tests/**,**/proco/**/admin.py,**/dailycheckapp_contact/**,**/realtime_dailycheckapp/**,**/realtime_unicef/**,**/management/commands/** + -Dsonar.exclusions=**/migrations/**,**/proco_data_migrations/**,**/tests/**,**/proco/**/admin.py,**/dailycheckapp_contact/**,**/realtime_dailycheckapp/**,**/realtime_unicef/**,**/management/commands/** -# Docker build and push +# Docker build and push - task: Docker@2 displayName: Dev - Build and Push image inputs: diff --git a/config/settings/base.py b/config/settings/base.py index 157c3ec..d2ea53a 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -251,7 +251,7 @@ if CELERY_ENABLED: TEMPLATED_EMAIL_BACKEND = 'proco.mailing.backends.AsyncTemplateBackend' - MAILING_USE_CELERY = True + MAILING_USE_CELERY = env.bool('MAILING_USE_CELERY', default=False) TEMPLATED_EMAIL_TEMPLATE_DIR = 'email' TEMPLATED_EMAIL_FILE_EXTENSION = 'html' @@ -360,7 +360,7 @@ }], } CONSTANCE_CONFIG = { - 'CONTACT_EMAIL': ('', 'Email to receive contact messages', 'email_input'), + 'CONTACT_EMAIL': (env('CONTACT_EMAIL', default=''), 'Email to receive contact messages', 'email_input'), 'DAILYCHECKAPP_CONTACT_EMAIL': ('', 'Email to receive dailycheckapp_contact messages', 'email_input'), } diff --git a/config/settings/prod.py b/config/settings/prod.py index 5a35961..03efcd0 100644 --- a/config/settings/prod.py +++ b/config/settings/prod.py @@ -88,7 +88,7 @@ # Email settings # -------------------------------------------------------------------------- -EMAIL_CONFIG = env.email() +EMAIL_CONFIG = env.email(backend=EMAIL_BACKEND) vars().update(EMAIL_CONFIG) SERVER_EMAIL_SIGNATURE = env('SERVER_EMAIL_SIGNATURE', default='proco'.capitalize()) diff --git a/proco/connection_statistics/api.py b/proco/connection_statistics/api.py index c0c411c..556d16b 100644 --- a/proco/connection_statistics/api.py +++ b/proco/connection_statistics/api.py @@ -900,6 +900,7 @@ def calculate_country_download_data(self, start_date, end_date, week_number, yea ).filter( realtime_registration_status__rt_registered=True, realtime_registration_status__rt_registration_date__date__lte=end_date, + realtime_registration_status__deleted__isnull=True, ).annotate( dummy_group_by=Value(1)).values('dummy_group_by').annotate( good=Count(Case(When(t__connectivity_speed__gt=speed_benchmark, then='id')), distinct=True), diff --git a/proco/core/management/commands/populate_school_registration_data.py b/proco/core/management/commands/populate_school_registration_data.py index 9635a6d..29561ef 100644 --- a/proco/core/management/commands/populate_school_registration_data.py +++ b/proco/core/management/commands/populate_school_registration_data.py @@ -57,7 +57,7 @@ def populate_school_registration_data(country_id, school_id): query = """ SELECT DISTINCT dailystat.school_id as school_id, true rt_registered, - FIRST_VALUE(dailystat.created) OVER (PARTITION BY dailystat.school_id ORDER BY dailystat.created) + FIRST_VALUE(dailystat.date) OVER (PARTITION BY dailystat.school_id ORDER BY dailystat.date) rt_registration_date, NULL rt_source FROM connection_statistics_schooldailystatus dailystat