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

Allow adding/editing 'mail_template' for a release. #2494

Merged
merged 3 commits into from Aug 17, 2018
Merged

Allow adding/editing 'mail_template' for a release. #2494

merged 3 commits into from Aug 17, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jul 24, 2018

fixes #2475

Signed-off-by: Vismay Golwala [email protected]

@ghost ghost self-requested a review as a code owner July 24, 2018 15:11
@ghost
Copy link
Author

ghost commented Jul 24, 2018

jenkies test

@fedora-infra fedora-infra deleted a comment from centos-ci Jul 24, 2018
@fedora-infra fedora-infra deleted a comment from centos-ci Jul 24, 2018
@bowlofeggs
Copy link
Contributor

The CI failure is due to https://bugzilla.redhat.com/show_bug.cgi?id=1607916, and the fix for that might take a day or so to propagate to the mirrors.

@@ -229,6 +231,7 @@ def test_new_release_invalid_tags(self):
"candidate_tag": "epel42-candidate",
"override_tag": "epel42-override",
"csrf_token": self.get_csrf_token(),
"mail_template": "fedora_errata_template"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add mail_template to all these existing tests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current logic requires mail_template while creating new release. Should we add default template fedora_errata_template when it is not provided?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that's a sane default. Most new releases are going to be Fedora, and the Fedora template is probably fine for other releases anyway.

@@ -291,7 +294,8 @@ def test_query_releases_html_two_releases_same_state(self):
"pending_signing_tag": "f42-updates-testing-signing",
"pending_testing_tag": "f42-updates-testing-pending",
"override_tag": "f42-override",
"csrf_token": self.get_csrf_token()}
"csrf_token": self.get_csrf_token(),
"mail_template": "fedora_errata_template"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test that shows that mail template can be changed via the API and that it alters the db.

result = runner.invoke(
client.edit_release,
['--name', 'F27', '--mail-template', 'edited_fedora_errata_template', '--url',
'http://localhost:6543', '--username', 'bowlofeggs', '--password', 's3kr3t'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the url, username, or password arguments here and the test will be cleaner without them.

@@ -132,6 +132,7 @@ def _warn_if_url_and_staging_set(ctx, param, value):
click.option('--state', type=click.Choice(['disabled', 'pending', 'current',
'archived']),
help='The state of the release'),
click.option('--mail-template', help='Name of the email template for this release'),
staging_option,
url_option]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI should also display the mail template to the user when a release is printed to the terminal.

mail_template = colander.SchemaNode(
colander.String(),
missing="fedora_errata_template",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should validate that the referenced template exists, otherwise users could make a typo and cause the server to fail during mashing:

[vagrant@bodhi-dev bodhi]$ bodhi releases edit --name F28 --mail-template does_not_exist                                                                   
Saved release:
  Name:                F28
  Long Name:           Fedora 28
  Version:             28
  Branch:              f28
  ID Prefix:           FEDORA
  Dist Tag:            f28
  Stable Tag:          f28-updates
  Testing Tag:         f28-updates-testing
  Candidate Tag:       f28-updates-candidate
  Pending Signing Tag: f28-signing-pending
  Pending Testing Tag: f28-updates-testing-pending
  Pending Stable Tag:  f28-updates-pending
  Override Tag:        f28-override
  State:               current
  Email Template:      does_not_exist

Copy link
Contributor

@bowlofeggs bowlofeggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question. Looks good otherwise!

location = config.get('mail.templates_basepath')
directory = get_absolute_path(location)
template_list = [os.path.splitext(file)[0] for file in os.listdir(directory)]
template_vals = ", ".join(template_list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test need the four lines above? It seems like they are not used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to keep it compatible with Python 2 and 3. Because both versions of python add elements to list in different order and hence we cannot directly compare string versions of those.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't noticed it was in fact used on line 308 below, so nevermind!

@mergify mergify bot merged commit dbbb2c0 into fedora-infra:develop Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to the cli to edit the release email template name
1 participant