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

Send out emails: URL hardcoded for join event #406

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

odkhang
Copy link
Collaborator

@odkhang odkhang commented Oct 17, 2024

This PR related to issue #362
Instead of hardcoded video domain, using current video domain, testing other place holder in email settings

Summary by Sourcery

Enhancements:

  • Replace hardcoded video domain with dynamic domain in email settings.

Copy link

sourcery-ai bot commented Oct 17, 2024

Reviewer's Guide by Sourcery

This pull request makes several code style and formatting changes to improve consistency and readability across multiple Python files in the project. The changes primarily involve updating import statements, reformatting code to comply with PEP 8 guidelines, and reorganizing some function definitions. There are no significant functional changes to the codebase.

Class diagram for SendGridEmail class

classDiagram
    class SendGridEmail {
        - api_key: str
        + __init__(api_key)
        + test(from_addr)
        + bytes_to_base64_string(value: bytes) str
        + build_attachment(input)
        + send_messages(emails)
    }
Loading

Class diagram for TemplateBasedMailRenderer class

classDiagram
    class TemplateBasedMailRenderer {
        + template_name()
        + render(plain_body: str, plain_signature: str, subject: str, order, position) str
    }
Loading

Class diagram for ClassicMailRenderer and UnembellishedMailRenderer classes

classDiagram
    TemplateBasedMailRenderer <|-- ClassicMailRenderer
    TemplateBasedMailRenderer <|-- UnembellishedMailRenderer
    class ClassicMailRenderer {
        + verbose_name: str = "Default"
        + identifier: str = "classic"
        + thumbnail_filename: str = "pretixbase/email/thumb.png"
        + template_name: str = "pretixbase/email/plainwrapper.html"
    }
    class UnembellishedMailRenderer {
        + verbose_name: str = "Simple with logo"
        + identifier: str = "simple_logo"
        + thumbnail_filename: str = "pretixbase/email/thumb_simple_logo.png"
        + template_name: str = "pretixbase/email/simple_logo.html"
    }
Loading

File-Level Changes

Change Details Files
Updated import statements and reorganized imports
  • Reordered imports alphabetically
  • Removed unused imports
  • Split long import lines into multiple lines
src/pretix/control/views/event.py
src/pretix/base/email.py
Reformatted code to comply with PEP 8 guidelines
  • Adjusted indentation
  • Added spaces around operators
  • Wrapped long lines
  • Updated string formatting to use f-strings
src/pretix/control/views/event.py
src/pretix/base/email.py
Refactored function definitions and class structures
  • Split long function definitions into multiple lines
  • Reorganized class methods
  • Updated docstrings
src/pretix/control/views/event.py
src/pretix/base/email.py
Updated string literals to use consistent quoting style
  • Changed single quotes to double quotes for string literals
  • Updated multiline strings to use triple double quotes
src/pretix/control/views/event.py
src/pretix/base/email.py
Added type hints and improved function signatures
  • Added type hints to function parameters
  • Updated return type annotations
src/pretix/control/views/event.py
src/pretix/base/email.py
Refactored email placeholder generation
  • Updated placeholder generation logic
  • Added a new function to generate sample video URLs
src/pretix/base/email.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @odkhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • While the code formatting improvements are welcome, please separate formatting changes from functional changes in future pull requests. This makes it easier for reviewers to focus on the important parts. The functional changes (like the new generate_sample_video_url() function) look good, but were hard to spot among the formatting changes.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -127,11 +131,17 @@ def _save_decoupled(self, form):
self.request.event.settings.set(f, self.request.event.settings.get(f))


class EventUpdate(DecoupleMixin, EventSettingsViewMixin, EventPermissionRequiredMixin, MetaDataEditorMixin, UpdateView):
class EventUpdate(
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring the EventUpdate and EventPlugins classes to improve code organization and readability.

The EventUpdate class has grown in complexity, particularly in the get_context_data and form_valid methods. Consider refactoring these methods to improve readability and maintainability:

  1. Extract logic from form_valid into helper methods:
class EventUpdate(DecoupleMixin, EventSettingsViewMixin, EventPermissionRequiredMixin, MetaDataEditorMixin, UpdateView):
    # ... existing code ...

    def form_valid(self, form):
        self._save_form_data(form)
        self._handle_formsets()
        self._log_changes(form)
        self._handle_css_regeneration(form)
        return super().form_valid(form)

    def _save_form_data(self, form):
        self._save_decoupled(self.sform)
        self.sform.save()
        self.save_meta()

    def _handle_formsets(self):
        self.save_item_meta_property_formset(self.object)
        self.save_confirm_texts_formset(self.object)
        self.save_footer_links_formset(self.object)

    def _log_changes(self, form):
        # ... logging logic ...

    def _handle_css_regeneration(self, form):
        # ... CSS regeneration logic ...
  1. In the EventPlugins class, simplify the get_context_data method by extracting the plugin sorting and grouping logic:
class EventPlugins(EventSettingsViewMixin, EventPermissionRequiredMixin, TemplateView, SingleObjectMixin):
    # ... existing code ...

    def get_context_data(self, *args, **kwargs) -> dict:
        context = super().get_context_data(*args, **kwargs)
        context["plugins"] = self._get_sorted_grouped_plugins()
        context["plugins_active"] = self.object.get_plugins()
        context["show_meta"] = settings.PRETIX_PLUGINS_SHOW_META
        return context

    def _get_sorted_grouped_plugins(self):
        plugins = self._get_visible_plugins()
        grouped_plugins = self._group_plugins_by_category(plugins)
        return self._sort_grouped_plugins(grouped_plugins)

    def _get_visible_plugins(self):
        return [p for p in get_all_plugins(self.object) if not p.name.startswith(".") and getattr(p, "visible", True)]

    def _group_plugins_by_category(self, plugins):
        # ... grouping logic ...

    def _sort_grouped_plugins(self, grouped_plugins):
        # ... sorting logic ...

These refactorings will improve code organization and make it easier to understand and maintain the complex logic in these classes.

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.

1 participant