Skip to content

Commit

Permalink
Merge branch 'development' into 'stage'
Browse files Browse the repository at this point in the history
Development to stage | #4564 and #4707 Deployment and Email PNG images fix

See merge request cometa/cometa!455
  • Loading branch information
anandkushwaha064 committed May 27, 2024
2 parents 2c03491 + 76df510 commit e63c19d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 8 deletions.
Empty file modified backend/.gitignore
100755 → 100644
Empty file.
Empty file modified backend/README.md
100755 → 100644
Empty file.
Empty file modified backend/docker-compose-tests.yml
100755 → 100644
Empty file.
32 changes: 26 additions & 6 deletions backend/src/backend/generatePDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import logging.handlers
import datetime
from email.mime.image import MIMEImage
from PIL import Image


# logger information
logger = getLogger()
Expand Down Expand Up @@ -415,7 +417,10 @@ def BuildEmailSubject(self):
def process_custom_body_for_screenshots(self,email_multi_alternatives) -> dict:
logger.debug("Processing custom body")
# get all the steps in the feature results
step_results_screenshots = Step_result.objects.values_list('screenshot_current').filter(feature_result_id=self.feature_result_id).order_by("step_result_id")
step_results_screenshots = Step_result.objects.values_list('screenshot_current') \
.filter(feature_result_id=self.feature_result_id) \
.exclude(screenshot_current__exact='') \
.order_by("step_result_id")
# Define the regex pattern
pattern = r'\$screenshot\[(\d+)\]'

Expand All @@ -432,26 +437,41 @@ def process_custom_body_for_screenshots(self,email_multi_alternatives) -> dict:
# logger.debug("Found match ")
# logger.debug(f"Match: {match.group(0)}, Number: {match.group(1)}, Start: {match.start()}, End: {match.end()}")
# This is to check if number of screenshot available in the step report are less or equal to screenshot index requested in the email
logger.debug(f'{screen_shot_index} {len(step_results_screenshots)}')
# logger.debug(f'{screen_shot_index} {len(step_results_screenshots)}')
if screen_shot_index>0 and len(step_results_screenshots)>=screen_shot_index:
# Create dictionary with $screenshot[n] = path/to/screenshot
# logger.debug("Attaching screenshots")
logger.debug(step_results_screenshots[screen_shot_index-1])
screen_shot = step_results_screenshots[screen_shot_index-1][0]
# Add image tag to show image in with mail
new_email_body = new_email_body.replace(screenshot_name, f'<img src="cid:{screenshot_name}">')
image_path = os.path.join(settings.SCREENSHOTS_ROOT, screen_shot)
image_name = image_path.split("/")
logger.debug(image_name)
if len(image_name)>0:
image_name = image_name[-1].split(".")[-2]

image_name+='.png'
logger.debug(image_name)
new_email_body = new_email_body.replace(screenshot_name, f'<img src="cid:{screenshot_name}" alt={image_name} >')
# logger.debug(name)
# logger.debug(new_email_body)
# logger.debug(f"Attaching Screenshot {screen_shot}")
image_path = os.path.join(settings.SCREENSHOTS_ROOT, screen_shot)
with open(image_path, 'rb') as img:
mime_image = MIMEImage(img.read(), _subtype="png")
with Image.open(image_path) as img:
with BytesIO() as output:
img.save(output, format='PNG')
png_data = output.getvalue()
mime_image = MIMEImage(png_data, _subtype="png")
mime_image.add_header('Content-ID', f'<{screenshot_name}>')
mime_image.add_header('X-Attachment-Id', f'{screenshot_name}')
mime_image.add_header('Content-Disposition', 'inline', filename=image_name)
email_multi_alternatives.attach(mime_image)
else:
invalid_screenshot_names.append(screenshot_name)
if invalid_screenshot_names:
new_email_body += f"<b>Invalid Screenshot names: <b> {','.join(invalid_screenshot_names)}"

new_email_body = self.replaceFeatureVariables(new_email_body)

return new_email_body, email_multi_alternatives

def BuildEmailBody(self):
Expand Down
Empty file modified docker-compose-dev.yml
100755 → 100644
Empty file.
12 changes: 11 additions & 1 deletion front/src/assets/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.8.345",
"version": "2.8.346",
"language": "en",
"appTitle": "co.meta",
"scenario": "dev",
Expand Down Expand Up @@ -232,6 +232,16 @@
"{Code is Poetry}"
],
"changelog": [
{
"version": "2.8.346",
"date": "2024-05-27",
"features": [
{
"title": "#4707 Changes made in the PDF to support outlook email client when sending image.",
"description": "Outlook was not showing sent image properly, fixed code to support outlook email client."
}
]
},
{
"version": "2.8.345",
"date": "2024-05-24",
Expand Down
15 changes: 14 additions & 1 deletion gitlab-ci-yamls/client03.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#########################################################
# BACKEND
#########################################################
DEPLOY_BACKEND_FOLDER: "/opt/cometa"
DEPLOY_BACKEND_FOLDER: "/opt/IBM/cometa"
COMETA_DOMAIN: "$CLIENT_03_DOMAIN"
COMETA_DEBUG: "False"
COMETA_EMAIL_HOST: '$COMETA_CLIENT01_EMAIL_HOST'
COMETA_EMAIL_USER: '$COMETA_CLIENT01_EMAIL_USER'
COMETA_DJANGO_SECRETKEY: '$COMETA_CLIENT03_DJANGO_SECRETKEY'
COMETA_BEHAVE_SECRETKEY: '$COMETA_CLIENT03_BEHAVE_SECRETKEY'
COMETA_PROXY_ENABLED: 'True'
COMETA_PROXY: '$CLIENT_03_PROXY'
COMETA_NO_PROXY: '$CLIENT_03_NO_PROXY'
Expand All @@ -20,10 +22,21 @@
#########################################################
DOCKER_HTTP_PORT: 58080
DOCKER_OPENIDC_CONFIG_EXT: "client01_int"
before_script:
#########################################################
# FRONTEND
#########################################################
# Remove standard ports for this client, as it conflicts with other running software
- sed -i '/443:443/d; /4200:4200/d' docker-compose.yml
# Client uses port 58080, which is mapped to load balancer, make changes persistent for port 58080
# - sed -i 's#/data/cometa/#./data/cometa/#g' docker-compose.yml
- sed -i_template "s#- /data#- \./data#g" docker-compose.yml

after_script:
#########################################################
# FRONTEND
#########################################################

# make infra folder
- docker exec cometa_front bash -c "mkdir -p /usr/local/apache2/htdocs/infra"
# make a lbtest1.html file with some status info
Expand Down

0 comments on commit e63c19d

Please sign in to comment.