Skip to content

Commit 09220dc

Browse files
Merge pull request #2420 from IFRCGo/feature/s3-storage
Feature/s3 storage
2 parents dde8be0 + b36154c commit 09220dc

File tree

23 files changed

+472
-81
lines changed

23 files changed

+472
-81
lines changed

.github/workflows/build-publish-docker-helm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: 🐳 Helm dependency
4343
working-directory: deploy/helm/ifrcgo-helm
4444
run: |
45-
yq --indent 0 '.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' ./helm/Chart.lock | sh --
45+
yq --indent 0 '.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' ./Chart.lock | sh --
4646
helm dependency build ./
4747
4848
- name: Tag docker image in Helm Chart values.yaml

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,16 @@ jobs:
136136
- name: Install Helm
137137
uses: azure/setup-helm@v4
138138

139+
- name: 🐳 Helm dependency
140+
working-directory: deploy/helm/ifrcgo-helm
141+
run: |
142+
yq --indent 0 '.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' ./Chart.lock | sh --
143+
helm dependency build ./
144+
139145
- name: 🐳 Helm lint
140-
run: helm lint deploy/helm/ifrcgo-helm --values ./deploy/helm/ifrcgo-helm/values-staging.yaml
146+
working-directory: deploy/helm/ifrcgo-helm
147+
run: helm lint ./ --values ./values-staging.yaml
141148

142149
- name: 🐳 Helm template
143-
run: helm template deploy/helm/ifrcgo-helm --values ./deploy/helm/ifrcgo-helm/values-staging.yaml
150+
working-directory: deploy/helm/ifrcgo-helm
151+
run: helm template ./ --values ./values-staging.yaml

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,7 @@ To import GEC codes along with country ids, run `python manage.py import-gec-cod
293293
## SSO setup
294294

295295
For more info checkout [GO-SSO](./docs/go-sso.md)
296+
297+
## Playwright exports
298+
299+
For more info checkout [Playwright exports](./docs/playwright-exports.md)

api/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,5 +1044,5 @@ class ExportTokenAdmin(admin.ModelAdmin):
10441044
admin.site.register(models.CountryOfFieldReportToReview, CountryOfFieldReportToReviewAdmin)
10451045
# admin.site.register(Revision, RevisionAdmin)
10461046

1047-
admin.site.site_url = "https://" + settings.FRONTEND_URL
1047+
admin.site.site_url = settings.GO_WEB_URL
10481048
admin.widgets.RelatedFieldWidgetWrapper.template_name = "related_widget_wrapper.html"

api/management/commands/cron_job_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def handle(self, *args, **options):
3636
project_id = parsed_url.path.strip("/")
3737
api_key = parsed_url.username
3838

39-
SENTRY_INGEST = f"https://{parsed_url.hostname}"
39+
SENTRY_INGEST = f"{parsed_url.scheme}://{parsed_url.hostname}"
4040

4141
for cronjob in SentryMonitor.choices:
4242
job, schedule = cronjob

api/management/commands/index_and_notify.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ def get_admin_uri(self, record, rtype):
264264
RecordType.SURGE_DEPLOYMENT_MESSAGES: "deployments/personneldeployment",
265265
RecordType.SURGE_ALERT: "notifications/surgealert",
266266
}[rtype]
267-
return "https://%s/admin/%s/%s/change" % (
268-
settings.BASE_URL,
267+
return "%s/admin/%s/%s/change" % (
268+
settings.GO_API_URL,
269269
admin_page,
270270
record.id,
271271
)
@@ -960,8 +960,8 @@ def check_ingest_issues(self, having_ingest_issue):
960960
(
961961
"Ingest issue(s) occured, one of them is "
962962
+ ingestor_name
963-
+ ", via CronJob log record id: https://"
964-
+ settings.BASE_URL
963+
+ ", via CronJob log record id: "
964+
+ settings.GO_API_URL
965965
+ "/admin/api/cronjob/"
966966
+ str(ingest_issue_id)
967967
+ ". Please fix it ASAP."

api/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,9 +2436,9 @@ def create(self, validated_data):
24362436
title = "Export"
24372437
user = self.context["request"].user
24382438
if export_type == Export.ExportType.PER:
2439-
validated_data["url"] = f"https://{settings.FRONTEND_URL}/countries/{country_id}/{export_type}/{export_id}/export/"
2439+
validated_data["url"] = f"{settings.GO_WEB_INTERNAL_URL}/countries/{country_id}/{export_type}/{export_id}/export/"
24402440
else:
2441-
validated_data["url"] = f"https://{settings.FRONTEND_URL}/{export_type}/{export_id}/export/"
2441+
validated_data["url"] = f"{settings.GO_WEB_INTERNAL_URL}/{export_type}/{export_id}/export/"
24422442

24432443
# Adding is_pga to the url
24442444
is_pga = validated_data.pop("is_pga")

api/tasks.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
from playwright.sync_api import sync_playwright
1313
from rest_framework.authtoken.models import Token
1414

15+
from main.utils import logger_context
16+
1517
from .logger import logger
1618
from .models import Export
17-
18-
# from .utils import DebugPlaywright
19+
from .utils import DebugPlaywright
1920

2021

2122
def build_storage_state(tmp_dir, user, token):
@@ -25,7 +26,7 @@ def build_storage_state(tmp_dir, user, token):
2526
state = {
2627
"origins": [
2728
{
28-
"origin": "https://" + settings.FRONTEND_URL + "/",
29+
"origin": settings.GO_WEB_INTERNAL_URL + "/",
2930
"localStorage": [
3031
{
3132
"name": "user",
@@ -51,9 +52,10 @@ def build_storage_state(tmp_dir, user, token):
5152

5253
@shared_task
5354
def generate_url(url, export_id, user, title):
54-
export = Export.objects.filter(id=export_id).first()
55-
user = User.objects.filter(id=user).first()
55+
export = Export.objects.get(id=export_id)
56+
user = User.objects.get(id=user)
5657
token = Token.objects.filter(user=user).last()
58+
5759
footer_template = """
5860
<div class="footer" style="width: 100%;font-size: 8px;color: #FEFEFE; bottom: 10px; position: absolute;">
5961
<div style="float: left; margin-top: 10px; margin-left: 40px;">
@@ -80,6 +82,7 @@ def generate_url(url, export_id, user, title):
8082
</div>
8183
</div>
8284
""" # noqa: E501
85+
8386
try:
8487
with tempfile.TemporaryDirectory() as tmp_dir:
8588
with sync_playwright() as p:
@@ -103,7 +106,8 @@ def generate_url(url, export_id, user, title):
103106
)
104107
context = browser.new_context(storage_state=storage_state)
105108
page = context.new_page()
106-
# DebugPlaywright.debug(page)
109+
if settings.DEBUG_PLAYWRIGHT:
110+
DebugPlaywright.debug(page)
107111
timeout = 300000
108112
page.goto(url, timeout=timeout)
109113
time.sleep(5)
@@ -131,7 +135,11 @@ def generate_url(url, export_id, user, title):
131135
"completed_at",
132136
]
133137
)
134-
except Exception as e:
135-
logger.error(e)
138+
except Exception:
139+
logger.error(
140+
f"Failed to export PDF: {export.export_type}",
141+
exc_info=True,
142+
extra=logger_context(dict(export_id=export.pk)),
143+
)
136144
export.status = Export.ExportStatus.ERRORED
137145
export.save(update_fields=["status"])

api/templates/admin/base_site.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<h1 id="site-name">
1010
<a href="{% url 'admin:index' %}">
11-
<img height="40" src="/static/images/logo/go-logo-2020-6cdc2b0c.svg">
11+
<img height="40" src="{% static "images/logo/go-logo-2020-6cdc2b0c.svg" %}" />
1212
</a>
1313
{% if HAVING_INGEST_ISSUE and request.user.is_superuser %}
1414
<span title="Ingest issue – please check erroneous api/CronJob item">

api/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,9 @@ def post(self, request):
958958

959959
# Construct and re-send the email
960960
email_context = {
961-
"confirmation_link": "https://%s/verify_email/?token=%s&user=%s"
961+
"confirmation_link": "%s/verify_email/?token=%s&user=%s"
962962
% (
963-
settings.BASE_URL, # on PROD it should point to goadmin...
963+
settings.GO_API_URL, # on PROD it should point to goadmin...
964964
pending_user.token,
965965
username,
966966
)

0 commit comments

Comments
 (0)