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 an event dashboard #505

Open
wants to merge 18 commits into
base: development
Choose a base branch
from

Conversation

HungNgien
Copy link
Contributor

@HungNgien HungNgien commented Jan 10, 2025

image
Event dashboard

image
Fix css conflict of info box

This PR resolves #455

Summary by Sourcery

New Features:

  • Add an event dashboard that provides an overview of the event components (tickets, talks, videos).

Copy link

sourcery-ai bot commented Jan 10, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new event dashboard feature in the Eventyay Common platform. It provides an overview of event information, including ticket sales, talks, and video configuration. The dashboard UI is implemented with a new template and leverages existing components for tickets, talks, and videos. Routing is updated to include the new dashboard view.

Class diagram for Event Dashboard Views

classDiagram
    class EventIndexView {
        +template_name: str
        +get_context_data()
        -_get_user_permissions()
        -_collect_dashboard_widgets()
        -_filter_log_entries()
        -_check_event_statuses()
        +rearrange(widgets)
    }

    class Event {
        +talk_schedule_url
        +talk_session_url
        +talk_speaker_url
        +talk_dashboard_url
        +talk_settings_url
    }

    class EventMixin {
        +has_paid_things()
    }

    Event --|> EventMixin
    EventIndexView ..> Event: uses
Loading

File-Level Changes

Change Details Files
Add an event dashboard
  • Created new view and template for the event dashboard.
  • Added links to the tickets, talks, and video dashboards.
  • Updated CSS for better responsiveness and styling of the dashboard.
  • Added utility functions for retrieving subevent information.
  • Updated event model with properties for talk URLs.
  • Updated event creation flow to redirect to the new dashboard.
  • Updated navigation to include the new dashboard link.
  • Updated context processor to include relevant information for the dashboard.
  • Updated component link template to point to the new dashboard.
  • Updated info box and timeline fragments to improve styling.
  • Updated event list template to link to the new dashboard.
  • Added new URL patterns for the dashboard.
  • Created new navigation functions for the dashboard.
  • Created new template for the event dashboard.
  • Created new fragment for the event dashboard.
  • Updated component link template for the event dashboard.
src/pretix/eventyay_common/views/dashboards.py
src/pretix/eventyay_common/context.py
src/pretix/eventyay_common/templates/eventyay_common/base.html
src/pretix/static/eventyay-common/scss/custom.scss
src/pretix/base/models/event.py
src/pretix/eventyay_common/utils.py
src/pretix/eventyay_common/views/event.py
src/pretix/control/templates/pretixcontrol/event/component_link.html
src/pretix/control/templates/pretixcontrol/event/fragment_info_box.html
src/pretix/control/templates/pretixcontrol/event/fragment_timeline.html
src/pretix/eventyay_common/templates/eventyay_common/events/index.html
src/pretix/eventyay_common/urls.py
src/pretix/eventyay_common/navigation.py
src/pretix/eventyay_common/templates/eventyay_common/event/index.html
src/pretix/eventyay_common/templates/eventyay_common/event/fragment_dashboard.html
src/pretix/eventyay_common/templates/eventyay_common/event/component_link.html

Assessment against linked issues

Issue Objective Addressed Explanation
#455 Create an event dashboard on eventyay-common with a left sidebar containing event name and settings link
#455 Include content on the main area with links to tickets, talk, and video dashboards
#455 Create 3 component boxes with specific headings, descriptions, and links
#455 After creating an event, automatically direct to the dashboard instead of settings

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

@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 and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 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.

widgets.extend(result)
return self.rearrange(widgets)

def _filter_log_entries(
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Consider caching ContentType lookups as class attributes to avoid repeated database queries

Move the ContentType.objects.get_for_model() calls outside the method and store them as class attributes. This will prevent executing the same queries multiple times.

Suggested implementation:

            return []

    # Cache ContentType lookups at class level
    order_content_type = ContentType.objects.get_for_model(Order)
    invoice_content_type = ContentType.objects.get_for_model(Invoice)
    checkin_content_type = ContentType.objects.get_for_model(Checkin)
    item_content_type = ContentType.objects.get_for_model(Item)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        request = self.request

You'll also need to:

  1. Add imports for ContentType and the models (Order, Invoice, Checkin, Item) at the top of the file if not already present
  2. Update any places in the code where ContentType.objects.get_for_model() is called to use these class attributes instead
  3. Make sure these models are the correct ones being used in the log entries - adjust the model list according to what's actually being filtered in the log entries

Comment on lines +87 to 89
@media (min-width: $screen-xs-min) and (max-width: $screen-xs-max) {
.dashboard .widget-container.widget-small.no-padding.column {
margin-right: 0px;
Copy link

Choose a reason for hiding this comment

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

suggestion: Add media query for screens smaller than xs breakpoint

Consider adding a media query for screens smaller than $screen-xs-min to ensure proper layout on very small devices.

Suggested change
@media (min-width: $screen-xs-min) and (max-width: $screen-xs-max) {
.dashboard .widget-container.widget-small.no-padding.column {
margin-right: 0px;
@media (max-width: $screen-xs-min - 1) {
.dashboard .widget-container.widget-small.no-padding.column {
margin-right: 0px;
}
}
@media (min-width: $screen-xs-min) and (max-width: $screen-xs-max) {
.dashboard .widget-container.widget-small.no-padding.column {
margin-right: 0px;

@mariobehling mariobehling requested a review from hongquan January 10, 2025 05:41
src/pretix/eventyay_common/context.py Outdated Show resolved Hide resolved
return nav


def get_event_navigation(request: HttpRequest) -> List[Dict[str, Any]]:
Copy link
Member

Choose a reason for hiding this comment

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

Define this function to receive event instead of request, so that this function is only called after we make sure request.event exists.
With current implementation, all the use of `request.event' inside the body is unsafe (lack of checking).

ctx["is_talk_event_created"] = True

if organizer := getattr(request, "organizer", None):
ctx["nav_items"] = get_event_navigation(request)
Copy link
Member

Choose a reason for hiding this comment

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

The get_event_navigation() depends on request.event but here you only check request.organizer existence.

]

# Merge plugin-provided navigation items
plugin_nav_items = sum(
Copy link
Member

Choose a reason for hiding this comment

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

I remember I saw this code in previous PR and I asked why this sum() usage looks weird. Wonder if it is tested.

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 an event dashboard
2 participants