Skip to content

Conversation

@Aqil-Ahmad
Copy link

@Aqil-Ahmad Aqil-Ahmad commented Nov 16, 2025

fixes : #1315

Description

the Talk panel's sidebar menu items showed darker text/icon colors on hover, while Common and Tickets panels only showed gray background. This created an inconsistent user experience. also the dashboard icon didn't show darken effect in talk panel's sidebar unlike the others.

Summary by Sourcery

Extend User model and authentication flow to better support Wikimedia OAuth users with unique identifiers and adaptive form and email handling, while also refining admin sidebar hover styling for consistency.

New Features:

  • Support Wikimedia OAuth users with a new is_wikimedia_user flag and unique wikimedia_username
  • Add an is_wikimedia_user utility function and include socialauth plugin URLs

Enhancements:

  • Refactor user creation logic to branch on Wikimedia social account and update fields incrementally
  • Make email optional for Wikimedia users in checkout and settings forms and skip sending emails when absent
  • Update admin sidebar CSS to apply consistent hover styles and darken icons/text across panels

Build:

  • Add a migration to introduce is_wikimedia_user and enforce unique wikimedia_username

Tests:

  • Add tests for the is_wikimedia_user identification utility
Recording.2025-11-23.100401.mp4

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 16, 2025

Reviewer's Guide

Implements comprehensive Wikimedia OAuth support by introducing an is_wikimedia_user flag and unique wikimedia_username, refactors user creation logic to guard and branch on social authentication, adjusts model and form behavior around optional emails, adds utilities, tests, and a migration, and unifies sidebar hover styling.

Sequence diagram for user creation via Wikimedia OAuth

sequenceDiagram
    actor User
    participant "Django Request"
    participant "SocialAccount"
    participant "User Model"
    User->>"Django Request": Login via Wikimedia OAuth
    "Django Request"->>"SocialAccount": Get latest Wikimedia account
    "Django Request"->>"User Model": get_or_create(wikimedia_username, is_wikimedia_user)
    "User Model"-->>"Django Request": Return user instance
    "Django Request"-->>User: Login complete
Loading

Sequence diagram for optional email in forms for Wikimedia users

sequenceDiagram
    actor User
    participant "Checkout/UserSettings Form"
    participant "is_wikimedia_user()"
    User->>"Checkout/UserSettings Form": Access form
    "Checkout/UserSettings Form"->>"is_wikimedia_user()": Check user type
    "is_wikimedia_user()"-->>"Checkout/UserSettings Form": True/False
    "Checkout/UserSettings Form"-->>User: Email field required/optional
Loading

Entity relationship diagram for updated User model (Wikimedia support)

erDiagram
    USER {
        string email
        string fullname
        string wikimedia_username "(unique)"
        boolean is_wikimedia_user
        boolean is_active
        boolean is_staff
        datetime date_joined
    }
    USER ||--o{ SOCIALACCOUNT : has
    SOCIALACCOUNT {
        string provider
        string uid
        json extra_data
    }
Loading

Class diagram for updated User model and is_wikimedia_user utility

classDiagram
    class User {
        email: str
        fullname: str
        wikimedia_username: str
        is_wikimedia_user: bool
        is_active: bool
        is_staff: bool
        date_joined: datetime
        get_full_name()
        send_security_notice(messages, email=None)
        send_password_reset(request)
        reset_password(event, user=None, mail_text=None, orga=False)
        change_password(new_password)
    }
    class is_wikimedia_user_user {
        <<function>>
        Returns: bool
    }
    User <|-- is_wikimedia_user_user
Loading

File-Level Changes

Change Details Files
Refactored socialauth user creation to support Wikimedia OAuth
  • Extract and validate email once
  • Fallback to social_account.uid if username is blank
  • Branch get_or_create on wikimedia_username vs email
  • Collect and update only changed fields via save(update_fields)
app/eventyay/plugins/socialauth/views.py
Augmented User model with Wikimedia-specific fields
  • Made wikimedia_username unique
  • Added is_wikimedia_user BooleanField
app/eventyay/base/models/auth.py
Guard email absence in notification and reset methods
  • Early return in send_security_notice when no email
  • Early return in send_password_reset and change_password before sending mails
  • Reordered log_action calls to occur only when appropriate
app/eventyay/base/models/auth.py
Make email optional for Wikimedia users in forms
  • Presale checkout: mark email and email_repeat as not required and skip validation for Wikimedia users
  • UserSettingsForm: set email.required based on is_wikimedia_user util
app/eventyay/presale/forms/checkout.py
app/eventyay/base/forms/user.py
Add is_wikimedia_user utility and corresponding tests
  • Implement is_wikimedia_user in person/utils.py
  • Add unit tests covering authenticated, unauthenticated, and no-email cases
app/eventyay/person/utils.py
tests/person/test_wikimedia_utils.py
Add Django migration for Wikimedia fields
  • Add is_wikimedia_user field defaulting to False
  • Alter wikimedia_username to be unique
app/eventyay/base/migrations/0006_user_is_wikimedia_user.py
Include socialauth URLs in routing
  • Add plugin socialauth URL include under root patterns
app/eventyay/config/urls.py
Unify sidebar hover effects across panels
  • Remove redundant active:hover rules
  • Add &:hover to darken icons/text and maintain background color
app/eventyay/static/orga/css/_layout.css

Assessment against linked issues

Issue Objective Addressed Explanation
#1315 Ensure consistent sidebar hover effects across Talk, Common, and Tickets admin panels.

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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
Contributor

@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 there - I've reviewed your changes - here's some feedback:

  • You have repeated the is_wikimedia_user check in multiple form classes – consider extracting this into a shared mixin or helper to DRY up the code.
  • The get_or_create_user logic splits on email vs. wikimedia_username but doesn’t handle cases where both identifiers map to the same person and could create duplicate accounts – consider adding explicit merge or conflict resolution.
  • The CSS hover selectors for active and non-active nav-links are scattered across rules – consolidating them into a single selector or mixin will help maintain consistency and avoid specificity issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You have repeated the is_wikimedia_user check in multiple form classes – consider extracting this into a shared mixin or helper to DRY up the code.
- The get_or_create_user logic splits on email vs. wikimedia_username but doesn’t handle cases where both identifiers map to the same person and could create duplicate accounts – consider adding explicit merge or conflict resolution.
- The CSS hover selectors for active and non-active nav-links are scattered across rules – consolidating them into a single selector or mixin will help maintain consistency and avoid specificity issues.

## Individual Comments

### Comment 1
<location> `app/eventyay/base/models/auth.py:166` </location>
<code_context>
     )
     fullname = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('Full name'))
-    wikimedia_username = models.CharField(max_length=255, blank=True, null=True, verbose_name=('Wikimedia username'))
+    wikimedia_username = models.CharField(max_length=255, blank=True, null=True, unique=True, verbose_name=_('Wikimedia username'))
+    is_wikimedia_user = models.BooleanField(default=False, verbose_name=_('Is Wikimedia user'))
     is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
</code_context>

<issue_to_address>
**issue (bug_risk):** Adding unique=True to a nullable CharField can cause issues with multiple NULLs.

Consider making the field non-nullable or adding a custom constraint if you require strict uniqueness, as multiple NULLs may bypass the unique constraint.
</issue_to_address>

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.

Copy link
Contributor

@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.

New security issues found

@Aqil-Ahmad
Copy link
Author

Hi @mariobehling! i created the issue and opened this PR for it, but i'm not fully sure if these changes are required. could you please review and advise?

Copy link
Contributor

@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.

New security issues found

Copilot finished reviewing on behalf of mariobehling November 20, 2025 02:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes inconsistent sidebar hover effects across admin panels by standardizing the hover behavior. The Talk panel previously showed darker text/icon colors on hover while Common and Tickets panels only showed gray background. Additionally, the dashboard/search icon (#nav-search) lacked the hover darken effect.

  • Removed inconsistent hover color changes from nav-link elements to match Common and Tickets panels
  • Added hover color change to the dashboard/search icon for consistency
  • Simplified hover state rules by consolidating active and non-active states

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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 provide a short video to show what you changed.

Copy link
Contributor

@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.

New security issues found

@Aqil-Ahmad
Copy link
Author

Please provide a short video to show what you changed.

hi @mariobehling! i've attached the video in the pr description.

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.

Inconsistent sidebar hover effects across Talk, Common, and Tickets panels

2 participants