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

Email template create, update, delete views #2467

Merged

Conversation

pbanaszkiewicz
Copy link
Contributor

@pbanaszkiewicz pbanaszkiewicz commented Jul 12, 2023

This fixes #2438.

WIP. TODO:

  • create view
  • update view
  • delete view
  • updates to detail/list view
  • markdown -> html preview
  • tests

@pbanaszkiewicz pbanaszkiewicz added this to the v4.2 milestone Jul 12, 2023
@pbanaszkiewicz pbanaszkiewicz self-assigned this Jul 12, 2023
Copy link
Contributor

@elichad elichad left a comment

Choose a reason for hiding this comment

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

The new views look good on the whole. I have a couple of suggested improvements, and I did run into one bug that I now can't replicate.

I also realized some of the names of the new classes and URLs in this module don't match the conventions that we use elsewhere - most of the comments are about that.

amy/emails/forms.py Show resolved Hide resolved
body = MarkdownxFormField(
label=EmailTemplate._meta.get_field("body").verbose_name,
help_text=EmailTemplate._meta.get_field("body").help_text,
widget=forms.Textarea,
Copy link
Contributor

Choose a reason for hiding this comment

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

When I first tried to create a template, the preview section showed me the AMY login page. When I refreshed, I was logged out fully. After logging in, the view worked as expected. I haven't been able to replicate this, so not sure what happened.
Screenshot of text box with some arbitrary Markdown and a preview section next to it. The preview shows the AMY login screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting! I have never seen this behavior either. This system is used in comments across AMY, so (I hope) it was well tested. Didn't hear from anyone about issues with preview.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. Let's chalk it up to one-off weirdness in my local instance and see if it ever crops up again.

amy/emails/forms.py Show resolved Hide resolved
amy/emails/forms.py Outdated Show resolved Hide resolved
amy/emails/views.py Outdated Show resolved Hide resolved
amy/emails/urls.py Outdated Show resolved Hide resolved
amy/emails/urls.py Outdated Show resolved Hide resolved
amy/emails/urls.py Outdated Show resolved Hide resolved
amy/emails/urls.py Outdated Show resolved Hide resolved
include([
path(
"",
views.EmailTemplateDetailView.as_view(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Another convention point - we don't usually include View in our view class names, and detail views are typically ModelNameDetails (plural)

pbanaszkiewicz and others added 5 commits July 21, 2023 22:23
Co-authored-by: Eli Chadwick <eli.chadwick.256@gmail.com>

Co-authored-by: Eli Chadwick <eli.chadwick.256@gmail.com>
Co-authored-by: Eli Chadwick <eli.chadwick.256@gmail.com>
@pbanaszkiewicz pbanaszkiewicz force-pushed the feature/2438-email-template-create-update-delete branch from 70fd6f2 to a3c038b Compare July 21, 2023 20:58
@pbanaszkiewicz
Copy link
Contributor Author

@elichad Thank you for the review and suggestions. I changed the views as you requested. Please take another look at this PR.

Copy link
Contributor

@elichad elichad left a comment

Choose a reason for hiding this comment

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

LGTM now, approved. Added one additional minor comment.


class ScheduledEmailRescheduleView(
ScheduledEmailLog.objects.create(
details="Scheduled email was changed.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you include the user that made the change here?

This would be useful for reschedule/cancel log entries too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good idea to add author to these log items. I have created a ticket for that: #2484 (it would require changes in multiple places so I didn't want to work on it in this PR).

@pbanaszkiewicz pbanaszkiewicz merged commit bc506f5 into develop Jul 24, 2023
11 checks passed
@pbanaszkiewicz pbanaszkiewicz deleted the feature/2438-email-template-create-update-delete branch July 24, 2023 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Emails] Improve views for email templates
2 participants