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

Setup attendee role and Configure video settings for talks #285

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

Conversation

odkhang
Copy link
Collaborator

@odkhang odkhang commented Dec 2, 2024

This pull request resolves fossasia/eventyay-tickets#465.

  • Grant attendees the necessary permissions to access video event resources using the eventyay-video-event-{event_slug} permission.
  • This pull request implements the automatic scheduling setup for Eventyay-Talk in the configuration and synchronizes data between the talk and video projects when the user selects 'is_video_creation' during the event creation process in the ticket project.

Copy link

sourcery-ai bot commented Dec 2, 2024

Reviewer's Guide by Sourcery

The PR implements attendee role functionality by modifying the world creation/update logic to include trait grants, which define role-based permissions. The implementation adds a new attendee role with configurable trait grants alongside existing admin and scheduleuser roles.

Sequence diagram for world creation/update with attendee role

sequenceDiagram
    participant User
    participant API as API Endpoint
    participant World

    User->>API: POST request with world data
    API->>World: Check if world exists
    alt World exists
        World->>World: Update domain, locale, timezone, trait_grants
    else World does not exist
        World->>World: Create new world with domain, locale, timezone, config, trait_grants
    end
    World-->>API: Response with world details
    API-->>User: Return response
Loading

Class diagram for World model with trait grants

classDiagram
    class World {
        String domain
        String locale
        String timezone
        String config
        Map trait_grants
    }
    note for World "The trait_grants attribute is added to manage role-based permissions."
Loading

File-Level Changes

Change Details Files
Added role-based permission system using trait grants
  • Introduced trait_grants dictionary to define permissions for different roles
  • Added support for configurable attendee trait grants with default 'attendee' permission
  • Included trait grants for admin and scheduleuser roles
  • Updated world creation and update logic to include trait_grants field
server/venueless/api/views.py

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

@odkhang odkhang marked this pull request as ready for review December 3, 2024 02:37
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:

  • Consider extracting the trait_grants dictionary into a separate function or constant to avoid duplication between the update and create paths
  • Add validation for attendee_trait_grants input to ensure security of permission assignments
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 1 issue found
  • 🟢 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.

server/venueless/api/views.py Show resolved Hide resolved
server/venueless/api/views.py Outdated Show resolved Hide resolved
server/venueless/api/views.py Outdated Show resolved Hide resolved
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:

  • Consider extracting the trait_grants initialization to avoid duplication in both the update and create paths
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.

@odkhang odkhang force-pushed the setup-attendee-role branch from 1aa1179 to 4278dee Compare December 9, 2024 08:00
@odkhang odkhang changed the title Setup attendee role Setup attendee role and Configure video settings for talks Dec 9, 2024
@odkhang odkhang requested a review from hongquan December 11, 2024 04:35
world.config["pretalx"] = {
"event": event_slug,
"domain": "{}".format(settings.EVENTYAY_TALK_BASE_PATH),
"pushed": datetime.datetime.now().isoformat(),
Copy link
Member

Choose a reason for hiding this comment

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

Please always use timezone-aware datetime. Calling now without tz will create naive datetime.

}
world.save()
except requests.exceptions.ConnectionError as e:
logger.error("Connection error: %s", str(e))
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to wrap e with str. When the log message is to be built, the % formatter will tell logging to "stringify" the passed arguments.
Wrapping str here is even undesired, it makes "stringify" operation run before we need to build the log message.

logger.error("Connection error: %s", str(e))
self.retry(exc=e)
except requests.exceptions.HTTPError as e:
if e.response.status_code in (401, 403, 404):
Copy link
Member

Choose a reason for hiding this comment

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

Use enum from http module, don't use hardcode 401, etc...

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 | Auto config Video component
4 participants