Skip to content

Commit a188a26

Browse files
Merge pull request #13 from dataiku/bug/dss12-sc-180121-plugin-migration-update-issue-existing-recipes
removing excel_can_ac format key to address migration issue [sc-180121]
2 parents f01530f + 2615b87 commit a188a26

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
## [Version 1.0.1](https://github.com/dataiku/dss-plugin-sendmail/releases/tag/v1.0.1) - Feature release - 2024-04
44

5-
- Recipe configurations saved in version 1.0.0 with "Attachments format" set to "Nothing selected" will no longer send CSV attachments.
6-
If you send CSV attachments in your integrations, please check existing recipes before upgrading to ensure they explicitly use the CSV option.
5+
- Please read if upgrading from version 1.0.0 of the plugin
6+
- For recipe configurations saved in plugin version 1.0.0 if "Attachments format" was set to "Excel", this may instead be set to "do not send attachments" when they are reopened in subsequent versions of the plugin. To ensure such recipes do not cause problems, it is best to open these recipes after plugin upgrade and if needed resave them, ensuring the "Attachments format" is once again set to "Excel".
7+
- Recipe configurations saved in version 1.0.0 with "Attachments format" set to "Nothing selected" will no longer send CSV attachments. If you send CSV attachments in your integrations, please check existing recipes before upgrading to ensure they explicitly use the CSV option.
78

89
- Features added
910
- Generate HTML tables where colors from conditional formatting are applied for inline datasets

custom-recipes/send-mails-from-contacts-dataset/recipe.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -199,25 +199,29 @@
199199
"name": "attachment_type",
200200
"label" : "Attachments format",
201201
"type": "SELECT",
202+
"selectChoices" : [
203+
{"value": "send_no_attachments", "label": "Do not send attachments"},
204+
{"value": "excel", "label": "Excel"},
205+
{"value": "csv", "label": "CSV"}
206+
],
202207
"defaultValue" : "send_no_attachments",
203-
"getChoicesFromPython": true,
204208
"description" : "File format for attachments"
205209
},
206210

207211
{
208212
"name": "sep_cond_format",
209213
"label": "Conditional formatting",
210214
"type": "SEPARATOR",
211-
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel_can_ac')"
215+
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel')"
212216
},
213217

214218
{
215219
"name": "apply_coloring_excel",
216220
"label" : "Apply conditional formatting",
217-
"description" : "Color cells by rules, when applicable in the HTML body. Will also be applied when attachment format is Excel.",
221+
"description" : "Color cells by rules, when applicable in the HTML body and Excel attachments. Full support in DSS 12.6.2 and above.",
218222
"defaultValue" : true,
219223
"type": "BOOLEAN",
220-
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel_can_ac')"
224+
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel')"
221225
}
222226
]
223227
}

python-lib/dku_attachment_handling.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from dku_email_client import AttachmentFile
2-
from dku_support_detection import supports_dataset_to_html
2+
from dku_support_detection import supports_dataset_to_html, supports_messaging_channels_and_conditional_formatting
33
import logging
4+
import dataiku
45

56

67
def attachments_template_dict(attachment_datasets, home_project_key, apply_coloring):
@@ -47,12 +48,15 @@ def build_attachment_files(attachment_datasets, attachment_type, apply_coloring_
4748
return []
4849

4950
logging.info(f"Building attachments, type: {attachment_type}, apply colouring? {apply_coloring_excel}")
51+
52+
# "excel_can_ac" was used to indicate excel in version 1.0.0 of the plugin - but it caused migration problems, so we got rid of it (see SC 80121)
53+
# Still, if the config has "excel_can_ac" and is run from the flow, we want to treat as excel (it means the user saved in v1.0.0 and did not reopen it)
5054
is_excel = attachment_type == "excel" or attachment_type == "excel_can_ac"
5155

5256
format_params = None
5357
if is_excel:
5458
request_fmt = "excel"
55-
if apply_coloring_excel and attachment_type == "excel_can_ac":
59+
if apply_coloring_excel and supports_messaging_channels_and_conditional_formatting(dataiku.api_client()):
5660
format_params = {"applyColoring": True}
5761
else:
5862
request_fmt = "tsv-excel-header"

python-lib/dku_support_detection.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ def supports_dataset_to_html(dataset):
44
# Check for existence to_html() method we added in 12.6.2
55
return hasattr(dataset.__class__, "to_html") and callable(getattr(dataset.__class__, "to_html"))
66

7-
7+
def supports_messaging_channels_and_conditional_formatting(dss_client):
8+
# Check for existence of messaging channel API we added in 12.6
9+
# If this is here we also support conditional formatting, as this was done in the same version
10+
return callable(getattr(dss_client, "list_messaging_channels", None))

resource/dynamic_form.py

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
from dss_selector_choices import DSSSelectorChoices, SENDER_SUFFIX
2+
from dku_support_detection import supports_messaging_channels_and_conditional_formatting
23
import dataiku
34

45

5-
def supports_messaging_channels_and_conditional_formatting(dss_client):
6-
# Check for existence of messaging channel API we added in 12.6
7-
# If this is here we also support conditional formatting, as this was done in the same version
8-
return callable(getattr(dss_client, "list_messaging_channels", None))
9-
10-
116
def do(payload, config, plugin_config, inputs):
127
dss_client = dataiku.api_client()
138
parameter_name = payload.get("parameterName")
@@ -32,15 +27,3 @@ def do(payload, config, plugin_config, inputs):
3227
# If there is no choice, put SMTP there but with a key of None, so it will be the default instead of "Nothing selected"
3328
choices.append("Manually define SMTP", None)
3429
return choices.to_dss()
35-
36-
if parameter_name == "attachment_type":
37-
choices = DSSSelectorChoices()
38-
choices.append("Do not send attachments", "send_no_attachments")
39-
if supports_messaging_channels_and_conditional_formatting(dss_client):
40-
# Added excel and give it the key excel_can_ac to indicate to the UI that we can show the
41-
# apply coloring ("apply conditional formatting") option
42-
choices.append("Excel", "excel_can_ac")
43-
else:
44-
choices.append("Excel", "excel")
45-
choices.append("CSV", "csv")
46-
return choices.to_dss()

0 commit comments

Comments
 (0)