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

Eventyay Common: Create a dashboard and enhance settings page #498

Merged
merged 19 commits into from
Jan 18, 2025

Conversation

HungNgien
Copy link
Collaborator

@HungNgien HungNgien commented Jan 6, 2025

image
image

Update dashboard of Eventyay Common

image
image

image
Enable feature
image
Enabled
image

Enhance settings page

This PR resolves #443

Summary by Sourcery

New Features:

  • Add an Eventyay Common dashboard that displays upcoming, recent, and series events, along with other features.

Summary by Sourcery

New Features:

  • Add an Eventyay Common dashboard that displays upcoming, recent, and series events, along with other features.

Copy link

sourcery-ai bot commented Jan 6, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new dashboard for Eventyay Common, enhancing the user interface with event overviews and quick actions. It also refines the settings page by integrating video and talk system controls directly into the event settings, improving user experience and feature accessibility.

Sequence diagram for enabling video system in event settings

sequenceDiagram
  actor User
  participant UI as Settings UI
  participant View as EventUpdate View
  participant Task as CreateWorldTask
  participant Plugin as Video Plugin

  User->>UI: Click Enable Video
  UI->>View: POST enable_video_system
  View->>View: Check permissions
  View->>Task: create_world.delay()
  Task->>Task: Setup video world
  Task->>Plugin: Install and configure
  Task-->>View: Success response
  View-->>UI: Redirect to settings
  UI-->>User: Show enabled status
Loading

Class diagram for the new EventWidgetGenerator and task classes

classDiagram
  class EventWidgetGenerator {
    +get_event_query(qs: QuerySet, nmax: int, lazy: bool)
    +format_event_daterange(event: Event, tz: DstTzInfo)
    +format_event_times(event: Event, tz: DstTzInfo, request: HttpRequest)
    +generate_video_button(event: Event)
    +generate_talk_button(event: Event)
    +generate_widget(event: Event, request: HttpRequest, lazy: bool)
  }

  class CreateWorldTask {
    +add_plugin(event: Event, plugin_name: str)
    +attach_plugin_to_event(plugin_name: str, event_slug: str)
    +save_video_settings_information(event_id: str, video_settings: dict)
    +check_installed_plugin(plugin_name: str)
    +extract_jwt_config(world_data: dict)
    +setup_video_plugin(world_data: dict)
    +on_success(retval: Any, task_id: str, args: tuple, kwargs: dict)
  }

  class SendEventTask {
    +on_success(retval: Any, task_id: str, args: tuple, kwargs: dict)
  }

  class Task
  CreateWorldTask --|> Task
  SendEventTask --|> Task
Loading

File-Level Changes

Change Details Files
Implements a dashboard view with event widgets
  • Adds a new view to display a dashboard with upcoming, recent, and series events.
  • Introduces a widget system for displaying event information.
  • Implements lazy loading for event widgets to improve performance.
  • Adds a search input to navigate to events.
  • Adds styling for the dashboard and widgets.
src/pretix/eventyay_common/views/dashboards.py
src/pretix/eventyay_common/templates/eventyay_common/dashboard/dashboard.html
src/pretix/static/eventyay-common/scss/custom.scss
Enhances the event settings page with video and talk system controls
  • Integrates video and talk system controls directly into the event settings page.
  • Adds modals to enable video and talk systems.
  • Removes the video creation checkbox from the settings form.
  • Adds logic to enable talk and video systems via the settings page.
  • Updates the event model to include talk dashboard and settings URLs.
  • Updates the event settings form to remove the video creation checkbox.
  • Adds styling for the settings page.
src/pretix/eventyay_common/templates/eventyay_common/event/settings.html
src/pretix/eventyay_common/views/event.py
src/pretix/eventyay_common/tasks.py
src/pretix/eventyay_common/utils.py
src/pretix/base/models/event.py
src/pretix/control/forms/event.py
src/pretix/static/eventyay-common/css/settings.css
src/pretix/eventyay_common/base_tasks.py
Updates task to create video world
  • Refactors the video world creation task to use a base class.
  • Adds logic to set the event settings to 'create_for' both after the video world is created.
  • Adds logic to retry the video world creation task if it fails.
src/pretix/eventyay_common/tasks.py
src/pretix/eventyay_common/base_tasks.py
Updates the event webhook task
  • Refactors the event webhook task to use a base class.
  • Adds logic to set the event settings to 'create_for' both after the event is created or updated.
src/pretix/eventyay_common/tasks.py
src/pretix/eventyay_common/base_tasks.py

Assessment against linked issues

Issue Objective Addressed Explanation
#443 Link the event name to the settings page
#443 Add links to the dashboards of Tickets, Talk, and Video component
#443 If one component is not enabled show the message 'You need to enable this module first. Go to the settings page to enable it. Ok / Cancel'
#443 Move 'Settings' into the Basics box
#443 Show 'Enabled / Disabled' depending on if the module is enabled or not followed by 'Dashboard' and 'Settings'
#443 Follow the design of other elements in this area

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

@mariobehling
Copy link
Member

Please remove "Setting for" in front of component

Change "Enabled/Disabled" into a button.

@HungNgien
Copy link
Collaborator Author

Please remove "Setting for" in front of component

Change "Enabled/Disabled" into a button.

@mariobehling Could give me more detail with the button "Enabled/Disabled" here?
For example, if the talk component is not created yet, the button "Enabled" will create it, but if it's already created then the button will delete the component?

@mariobehling
Copy link
Member

@mariobehling Could give me more detail with the button "Enabled/Disabled" here? For example, if the talk component is not created yet, the button "Enabled" will create it, but if it's already created then the button will delete the component?

Just keep the feature as is and change the UI into a button. If the feature is disabled and can be enabled show a pop up "Do you want to enable the feature? Yes / Cancel"

If the feature is enabled and the user clicks it show a pop-up "The feature cannot be disabled, but if you do not publish it, it will not show up publicly. Ok".

@HungNgien HungNgien marked this pull request as ready for review January 10, 2025 04:59
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 @HungNgien - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding caching for the widget queries to optimize performance of the lazy loading implementation
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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.

@mariobehling mariobehling requested a review from hongquan January 10, 2025 05:42
Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

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

The link to the talk component does not work. Are you testing this actually? The previous PR had the same issue.

@HungNgien
Copy link
Collaborator Author

The link to the talk component does not work. Are you testing this actually? The previous PR had the same issue.

I tested everything locally, and the talk_hostname in the server's configuration file, which points to the talk component, always ends with "talk"

Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

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

Thanks for sharing. Please make the following changes.

  1. Links to talk component on dashboard and settings page are not working.
    Current link is https://app-test.eventyay.com/orga/event/nvw3u
    Expected is https://app-test.eventyay.com/talk/orga/event/nvw3u
    Also check settings page links, please.

  2. We need to standardize the description. We are using sometimes singular and sometimes plural for tickets and talks. Please change the blue menu items:
    ticket -> tickets
    talk -> talks
    Also check on settings page.

  3. Pop-up "Component not enabled!"

  • Effect: Avoid moving effect from top and moving out effect. Simply display pop-up as fast as possible.
  • Follow the design of other existing pop-ups.
    a) Add the same icon on the left.
    b) Use same white overlay as other pop-ups.
    c) Add a pop-up heading "Component not enabled."
    d) Change "Close" to "Ok"
    Screenshot from 2025-01-10 14-33-38

@HungNgien HungNgien marked this pull request as draft January 15, 2025 09:35
@HungNgien
Copy link
Collaborator Author

image
@mariobehling Please help me to review this popup.

@mariobehling
Copy link
Member

Still not resolved:

Links to talk component on dashboard and settings page are not working.
Current link is https://app-test.eventyay.com/orga/event/nvw3u
Expected is https://app-test.eventyay.com/talk/orga/event/nvw3u
Also check settings page links, please.

@mariobehling
Copy link
Member

Please help me to review this popup.

Thank you. The pop up looks good.

Please increase the spacing to on the edges to match the existing pop up.

Clicking "Yes" on the button does not do anything yet.

@HungNgien
Copy link
Collaborator Author

Still not resolved:

Links to talk component on dashboard and settings page are not working. Current link is https://app-test.eventyay.com/orga/event/nvw3u Expected is https://app-test.eventyay.com/talk/orga/event/nvw3u Also check settings page links, please.

So the reason is the talk_hostname of .cfg file is missing a backslash at the end which make the urljoin failed
I have modified it: https://app-test.eventyay.com/talk -> https://app-test.eventyay.com/talk/

@HungNgien
Copy link
Collaborator Author

Please help me to review this popup.

Thank you. The pop up looks good.

Please increase the spacing to on the edges to match the existing pop up.

Clicking "Yes" on the button does not do anything yet.

image
Is it ok yet? @mariobehling

@mariobehling
Copy link
Member

Yes, thanks.

@mariobehling
Copy link
Member

Please also resolve conflicts.

@HungNgien HungNgien marked this pull request as ready for review January 18, 2025 04:38
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 @HungNgien - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding rate limiting to the API endpoints to prevent potential abuse
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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.

Comment on lines 87 to 91
response = requests.post(
settings.TALK_HOSTNAME + "/webhook/team/", json=payload, headers=headers
urljoin(settings.TALK_HOSTNAME, "webhook/team/"),
json=payload,
headers=headers
)
Copy link

Choose a reason for hiding this comment

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

🚨 suggestion (security): Add timeout parameters to HTTP requests to prevent hanging tasks

Add explicit timeouts to prevent requests from hanging indefinitely:

response = requests.post(
    url,
    json=payload,
    headers=headers,
    timeout=(3.05, 27) # (connect timeout, read timeout)
)
Suggested change
response = requests.post(
settings.TALK_HOSTNAME + "/webhook/team/", json=payload, headers=headers
urljoin(settings.TALK_HOSTNAME, "webhook/team/"),
json=payload,
headers=headers
)
response = requests.post(
urljoin(settings.TALK_HOSTNAME, "webhook/team/"),
json=payload,
headers=headers,
timeout=(3.05, 27) # (connect timeout, read timeout)
)

settings.TALK_HOSTNAME + "/webhook/team/", json=payload, headers=headers
urljoin(settings.TALK_HOSTNAME, "webhook/team/"),
json=payload,
headers=headers
)
response.raise_for_status() # Raise exception for bad status codes
except requests.RequestException as e:
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Enhance error handling to provide more context about failed requests

Include more details in the error log to help with debugging:

except requests.RequestException as e:
    logger.error('Error sending webhook to talk component: %s. URL: %s, Status: %s', 
                 str(e), e.request.url if hasattr(e, 'request') else 'unknown',
                 e.response.status_code if hasattr(e, 'response') else 'unknown')

Suggested implementation:

    except requests.RequestException as e:
        logger.error('Error sending webhook to talk component: %s. URL: %s, Status: %s', 
                    str(e), e.request.url if hasattr(e, 'request') else 'unknown',
                    e.response.status_code if hasattr(e, 'response') else 'unknown')

The logger import should be added at the top of the file with the other imports. If there's already a logger defined elsewhere in the codebase that's being used, you may want to use that instead of creating a new one. In that case, you'd need to import the existing logger instead of adding the logging import.

@mariobehling mariobehling merged commit 876c402 into fossasia:development Jan 18, 2025
3 of 5 checks passed
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.

Eventyay Common: Create a dashboard and enhance settings page
4 participants