Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to production #4021

Merged
merged 23 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
767d8a2
change
OchiengPaul442 Dec 4, 2024
9541602
commit
OchiengPaul442 Dec 5, 2024
e9d4f67
tests
OchiengPaul442 Dec 6, 2024
9a3960d
updates
OchiengPaul442 Dec 6, 2024
8e64869
updates
OchiengPaul442 Dec 6, 2024
5a363c2
updates
OchiengPaul442 Dec 6, 2024
0647fae
worked on board
OchiengPaul442 Dec 6, 2024
d9793f4
update africancities
OchiengPaul442 Dec 6, 2024
9c90166
updated external teams
OchiengPaul442 Dec 6, 2024
be60cc3
Update AirQo exceedance production image tag to prod-db33421c-1733504207
github-actions[bot] Dec 6, 2024
3f6f6d1
Update KCCA exceedance production image tag to prod-db33421c-1733504207
github-actions[bot] Dec 6, 2024
59c5dc9
Update auth service production image tag to prod-db33421c-1733504207
github-actions[bot] Dec 6, 2024
ef52dac
Update workflows prod image tag to prod-db33421c-1733504207
github-actions[bot] Dec 6, 2024
9ebea2c
Update predict production image tag to prod-db33421c-1733504207
github-actions[bot] Dec 6, 2024
13cade2
update hightlights
OchiengPaul442 Dec 6, 2024
964bccc
Update spatial production image tag to prod-db33421c-1733504207
github-actions[bot] Dec 6, 2024
76399be
update partners
OchiengPaul442 Dec 6, 2024
243a689
update press
OchiengPaul442 Dec 6, 2024
0f4b67b
update publications
OchiengPaul442 Dec 6, 2024
6d96cfd
update teams
OchiengPaul442 Dec 6, 2024
5c0162a
update python version in docker file
OchiengPaul442 Dec 6, 2024
9415b2f
updates
OchiengPaul442 Dec 6, 2024
782e9ff
Merge pull request #4020 from airqo-platform/website-backend-fix
Baalmart Dec 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion k8s/auth-service/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-auth-api
tag: prod-16e708ac-1733476956
tag: prod-db33421c-1733504207
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/exceedance/values-prod-airqo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ app:
configmap: env-exceedance-production
image:
repository: eu.gcr.io/airqo-250220/airqo-exceedance-job
tag: prod-16e708ac-1733476956
tag: prod-db33421c-1733504207
nameOverride: ''
fullnameOverride: ''
2 changes: 1 addition & 1 deletion k8s/exceedance/values-prod-kcca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ app:
configmap: env-exceedance-production
image:
repository: eu.gcr.io/airqo-250220/kcca-exceedance-job
tag: prod-16e708ac-1733476956
tag: prod-db33421c-1733504207
nameOverride: ''
fullnameOverride: ''
2 changes: 1 addition & 1 deletion k8s/predict/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ images:
predictJob: eu.gcr.io/airqo-250220/airqo-predict-job
trainJob: eu.gcr.io/airqo-250220/airqo-train-job
predictPlaces: eu.gcr.io/airqo-250220/airqo-predict-places-air-quality
tag: prod-16e708ac-1733476956
tag: prod-db33421c-1733504207
api:
name: airqo-prediction-api
label: prediction-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/spatial/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-spatial-api
tag: prod-16e708ac-1733476956
tag: prod-db33421c-1733504207
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/workflows/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ images:
initContainer: eu.gcr.io/airqo-250220/airqo-workflows-xcom
redisContainer: eu.gcr.io/airqo-250220/airqo-redis
containers: eu.gcr.io/airqo-250220/airqo-workflows
tag: prod-16e708ac-1733476956
tag: prod-db33421c-1733504207
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion src/website/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use Python 3.9-slim as the base image
FROM python:3.9-slim
FROM python:3.11-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
Expand Down
7 changes: 4 additions & 3 deletions src/website/apps/africancities/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def flag_preview(self, obj):
width, height = 60, 40
from django.utils.html import format_html

flag_url = obj.get_country_flag_url()
if flag_url:
return format_html(f'<img src="{flag_url}" width="{width}" height="{height}" />')
if obj.country_flag:
return format_html(f'<img src="{obj.get_country_flag_url()}" width="{width}" height="{height}" />')
return '-'

flag_preview.short_description = "Country Flag"
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.4 on 2024-12-06 16:34

import cloudinary.models
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('africancities', '0010_alter_africancountry_country_flag_alter_image_image'),
]

operations = [
migrations.AlterField(
model_name='africancountry',
name='country_flag',
field=cloudinary.models.CloudinaryField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='image',
name='image',
field=cloudinary.models.CloudinaryField(blank=True, max_length=255, null=True),
),
]
55 changes: 20 additions & 35 deletions src/website/apps/africancities/models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from django.conf import settings
from django.db import models
from utils.fields import ConditionalImageField
from cloudinary.models import CloudinaryField
from utils.models import BaseModel


class AfricanCountry(BaseModel):
country_name = models.CharField(max_length=100)
country_flag = ConditionalImageField(
local_upload_to='countries/flags/',
cloudinary_folder='website/uploads/countries/flags',
country_flag = CloudinaryField(
folder='website/uploads/africancities/flags',
null=True,
blank=True
blank=True,
resource_type='image'
)

order = models.IntegerField(default=1)

class Meta:
Expand All @@ -21,19 +20,12 @@ class Meta:
def __str__(self):
return self.country_name

def get_country_flag_url(self, request=None):
def get_country_flag_url(self):
"""
Return the full URL for the country flag.
- For Cloudinary, return a secure HTTPS URL.
- For local development, return the absolute URL using request.build_absolute_uri.
Return the secure URL for the country flag.
"""
if self.country_flag:
if not settings.DEBUG:
# Cloudinary secure URL
return self.country_flag.url # Already provides secure URL by default
else:
# Local development, ensure full URL
return request.build_absolute_uri(self.country_flag.url) if request else self.country_flag.url
return self.country_flag.url # Cloudinary already provides a secure URL
return None


Expand All @@ -44,7 +36,7 @@ class City(BaseModel):
AfricanCountry,
null=True,
related_name="city",
on_delete=models.deletion.SET_NULL,
on_delete=models.SET_NULL,
)

class Meta:
Expand All @@ -61,7 +53,7 @@ class Content(BaseModel):
City,
null=True,
related_name="content",
on_delete=models.deletion.SET_NULL,
on_delete=models.SET_NULL,
)

class Meta:
Expand All @@ -79,7 +71,7 @@ class Description(BaseModel):
null=True,
blank=True,
related_name="description",
on_delete=models.deletion.SET_NULL,
on_delete=models.SET_NULL,
)

class Meta:
Expand All @@ -90,19 +82,19 @@ def __str__(self):


class Image(BaseModel):
image = ConditionalImageField(
local_upload_to='content/images/',
cloudinary_folder='website/uploads/content/images',
image = CloudinaryField(
folder='website/uploads/africancities/images',
null=True,
blank=True
blank=True,
resource_type='image'
)
order = models.IntegerField(default=1)
content = models.ForeignKey(
'Content',
Content,
null=True,
blank=True,
related_name="image",
on_delete=models.deletion.SET_NULL,
on_delete=models.SET_NULL,
)

class Meta:
Expand All @@ -111,17 +103,10 @@ class Meta:
def __str__(self):
return f"Image-{self.id}"

def get_image_url(self, request=None):
def get_image_url(self):
"""
Return the full URL for the image.
- For Cloudinary, return a secure HTTPS URL.
- For local development, return the absolute URL using request.build_absolute_uri.
Return the secure URL for the image.
"""
if self.image:
if not settings.DEBUG:
# Cloudinary secure URL
return self.image.url # Cloudinary already provides secure URL
else:
# Local development, ensure full URL
return request.build_absolute_uri(self.image.url) if request else self.image.url
return self.image.url # Cloudinary already provides a secure URL
return None
6 changes: 2 additions & 4 deletions src/website/apps/africancities/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class ImageSerializer(serializers.ModelSerializer):
image_url = serializers.SerializerMethodField()

def get_image_url(self, obj):
request = self.context.get('request') # Get the request context for absolute URLs
return obj.get_image_url(request)
return obj.get_image_url() # Cloudinary already provides a secure URL

class Meta:
fields = ('id', 'image_url')
Expand Down Expand Up @@ -42,8 +41,7 @@ class AfricanCitySerializer(serializers.ModelSerializer):
country_flag_url = serializers.SerializerMethodField()

def get_country_flag_url(self, obj):
request = self.context.get('request') # Get the request context for absolute URLs
return obj.get_country_flag_url(request)
return obj.get_country_flag_url()

class Meta:
fields = ('id', 'country_name', 'country_flag_url', 'city')
Expand Down
4 changes: 2 additions & 2 deletions src/website/apps/board/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class BoardMemberAdmin(nested_admin.NestedModelAdmin):
inlines = (BoardMemberBiographyInline,)

def image_tag(self, obj):
width, height = 100, 200
width, height = 150, 200
from django.utils.html import format_html

if obj.picture:
return format_html(f'<img src="{obj.get_picture_url()}" height="{height}" />')
return format_html(f'<img src="{obj.get_picture_url()}" height="{height}" width="{width}" />')
return '-'

image_tag.short_description = "Image Preview"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.1.4 on 2024-12-06 16:24

import cloudinary.models
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('board', '0006_alter_boardmember_picture'),
]

operations = [
migrations.AlterField(
model_name='boardmember',
name='picture',
field=cloudinary.models.CloudinaryField(blank=True, max_length=255, null=True),
),
]
13 changes: 6 additions & 7 deletions src/website/apps/board/models.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from django.db import models
from utils.fields import ConditionalImageField
from cloudinary.models import CloudinaryField
from utils.models import BaseModel


class BoardMember(BaseModel):
name = models.CharField(max_length=100)
title = models.CharField(max_length=100)

picture = ConditionalImageField(
local_upload_to='boardmembers/pictures/',
cloudinary_folder='website/uploads/team/board_members',
picture = CloudinaryField(
folder='website/uploads/team/board_members',
null=True,
blank=True
blank=True,
resource_type='image',
)

twitter = models.URLField(max_length=255, null=True, blank=True)
Expand All @@ -26,8 +26,7 @@ def __str__(self):

def get_picture_url(self):
if self.picture:
# Secure URL is handled internally by Cloudinary or the file system
return self.picture.url
return self.picture.url # Cloudinary provides the actual URL of the uploaded image
return None


Expand Down
4 changes: 3 additions & 1 deletion src/website/apps/board/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ class Meta:
fields = '__all__'

def get_picture_url(self, obj):
return obj.get_picture_url() # Secure or local URL is handled inside the model
if obj.picture:
return obj.picture.url # Cloudinary automatically provides the correct URL
return None
Loading
Loading