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 #484

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

Conversation

HungNgien
Copy link
Contributor

@HungNgien HungNgien commented Dec 23, 2024

Create dashboard the common event
image
Mobile view

image
Alert when component is not enabled

image

This PR resolves #455

Summary by Sourcery

New Features:

  • Add an event dashboard to provide an overview of event information and actions.

Summary by Sourcery

New Features:

  • Introduce an event dashboard that provides a consolidated view of event details and related actions.

Copy link

sourcery-ai bot commented Dec 23, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new event dashboard to Eventyay Common. It provides an overview of event information and actions, including tickets, talks, and videos. The dashboard is accessible from the event page and includes widgets for managing different aspects of the event.

Class diagram for the event dashboard views and navigation

classDiagram
    class EventDashboard {
        +event_index(request, organizer, event)
        +event_index_widgets_lazy(request, organizer, event)
        +rearrange(widgets: list)
    }

    class Navigation {
        +get_event_navigation(request)
        +get_global_navigation(request)
    }

    class Context {
        +_default_context(request)
    }

    EventDashboard --> Navigation: uses
    EventDashboard --> Context: uses

    note for EventDashboard "Main dashboard controller"
    note for Navigation "Handles navigation structure"
    note for Context "Provides context data"
Loading

File-Level Changes

Change Details Files
Created the event dashboard structure and widgets
  • Added a main dashboard view to display event information and widgets.
  • Created widgets for Tickets, Talks and Speakers, and Video.
  • Added navigation links to the respective dashboards or configuration pages.
  • Implemented lazy loading for widgets to improve initial page load time.
src/pretix/eventyay_common/templates/eventyay_common/event/index.html
src/pretix/eventyay_common/templates/eventyay_common/event/fragment_dashboard.html
Implemented the dashboard view and API endpoint
  • Created a view to render the event dashboard.
  • Added an API endpoint to fetch widget data asynchronously.
  • Implemented logic to handle subevents in the dashboard view and API endpoint.
src/pretix/eventyay_common/views/dashboards.py
src/pretix/eventyay_common/urls.py
Updated the event navigation and context
  • Added a new navigation item for the event dashboard.
  • Updated the event context to include dashboard-related data.
  • Added a dropdown menu for context switching between events and organizers.
src/pretix/eventyay_common/context.py
src/pretix/eventyay_common/navigation.py
src/pretix/eventyay_common/templates/eventyay_common/base.html
Updated event creation redirection and styling
  • Redirected event creation to the new event dashboard.
  • Updated the event component link to point to the new dashboard.
  • Updated event list view to link to the new dashboard.
  • Added custom styling for the dashboard layout and widgets.
src/pretix/eventyay_common/views/event.py
src/pretix/control/templates/pretixcontrol/event/component_link.html
src/pretix/eventyay_common/templates/eventyay_common/events/index.html
src/pretix/static/eventyay-common/scss/custom.scss
Added event navigation component
  • Created a reusable component for event navigation links.
  • Included the component in the event dashboard template.
src/pretix/eventyay_common/templates/eventyay_common/event/component_link.html

Assessment against linked issues

Issue Objective Addressed Explanation
#455 Create an event dashboard with left sidebar containing event name and settings
#455 Create main content area with 3 component boxes for Tickets, Talks/Speakers, and Video with specified headings and link text
#455 Automatically direct to dashboard after event creation instead of settings

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

@HungNgien HungNgien marked this pull request as ready for review December 23, 2024 03:31
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: 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.

@HungNgien HungNgien marked this pull request as draft December 23, 2024 04:34
@HungNgien HungNgien marked this pull request as ready for review December 24, 2024 01:43
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: 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.

return JsonResponse({'widgets': widgets})


def event_index(request, organizer, event):
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 extracting permission checks to a dedicated function and simplifying query building by inverting the content type logic to improve readability and testability.

The event_index function's complexity can be reduced by extracting permission checks and simplifying query building:

  1. Extract permissions to a dedicated function:
def get_event_permissions(user, organizer, event, request):
    return {
        'can_view_orders': user.has_event_permission(organizer, event, 'can_view_orders', request=request),
        'can_change_orders': user.has_event_permission(organizer, event, 'can_change_orders', request=request),
        'can_change_settings': user.has_event_permission(organizer, event, 'can_change_event_settings', request=request),
        'can_view_vouchers': user.has_event_permission(organizer, event, 'can_view_vouchers', request=request),
    }
  1. Simplify query building by inverting the content type logic:
def build_log_query(event, permissions):
    qs = event.logentry_set.all().select_related(
        'user', 'content_type', 'api_token', 'oauth_application', 'device'
    ).exclude(action_type__in=OVERVIEW_BANLIST)

    allowed_types = []
    if permissions['can_view_orders']:
        allowed_types.append(ContentType.objects.get_for_model(Order))
    if permissions['can_view_vouchers']:
        allowed_types.append(ContentType.objects.get_for_model(Voucher))
    if permissions['can_change_settings']:
        allowed_types.extend([
            ContentType.objects.get_for_model(model) 
            for model in [Item, ItemCategory, Quota, Question]
        ])

    return qs.filter(content_type__in=allowed_types).order_by('-datetime')

This refactoring maintains all functionality while making the code more maintainable and easier to test.

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.

Please add screenshots with all components enabled and add spacing below the menu in the mobile view.
Screenshot from 2024-12-25 08-13-38

What happens if the a component is not enabled, e.g. talk or video? What happens when you click on the "dashboard" options in that case?

There should probably be a pop up "You need to enable this component first. You can do this here."

Or what is your suggestion?

@HungNgien
Copy link
Contributor Author

HungNgien commented Dec 25, 2024

Please add screenshots with all components enabled and add spacing below the menu in the mobile view. Screenshot from 2024-12-25 08-13-38

What happens if the a component is not enabled, e.g. talk or video? What happens when you click on the "dashboard" options in that case?

There should probably be a pop up "You need to enable this component first. You can do this here."

Or what is your suggestion?

If the component is not enable, the button will not display. I render the event template based on this condition.
I will add a space in mobile view and update the screenshot later.

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