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

Implement talk component to dashboard #307

Open
wants to merge 2 commits into
base: interconnection
Choose a base branch
from

Conversation

AviGawande
Copy link
Contributor

@AviGawande AviGawande commented Aug 23, 2024

This PR fixes #257.
Screenshot (102)

Summary by Sourcery

Implement a new 'Components' page in the dashboard to manage 'eventyay-talk' integration and update the base HTML template with a new navigation structure.

New Features:

  • Introduce a new 'Components' page in the dashboard that checks for the installation of 'eventyay-talk' and provides a link to it if installed.

Enhancements:

  • Redesign the base HTML template to include a new navigation bar and sidebar for improved user interface and navigation.

Copy link

sourcery-ai bot commented Aug 23, 2024

Reviewer's Guide by Sourcery

This pull request implements a new "talk component" feature in the dashboard. It modifies the authentication base template, adds a new component view, updates URL routing, and introduces a new template for the components page. The changes focus on integrating the Eventyay-Talk component into the existing dashboard structure.

File-Level Changes

Change Details Files
Update authentication base template to include new styles and navigation
  • Add new stylesheet links for main.scss and lightbox.scss
  • Implement a new navigation bar with dashboard, components, and documentation links
  • Restructure the page layout with a sidebar and main content area
  • Update the logo and branding elements
src/pretix/control/templates/pretixcontrol/auth/base.html
Add new ComponentsView function to handle the components page
  • Create a new view function to check if Eventyay-Talk is installed
  • Prepare context data for the components template
src/pretix/control/views/auth.py
Update URL routing to include the new components page
  • Add a new URL pattern for the components view
src/pretix/control/urls.py
Create a new template for the components page
  • Implement a new template file for displaying component information
  • Add conditional rendering for Eventyay-Talk installation status
  • Include a button to navigate to Eventyay-Talk if installed
src/pretix/control/templates/pretixcontrol/auth/components.html

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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

Overall Comments:

  • Consider removing the hardcoded path in ComponentsView and use a configuration setting instead. This will improve flexibility and security.
  • The ComponentsView function doesn't follow the class-based view pattern used elsewhere in the codebase. Consider refactoring it for consistency.
  • The extensive changes to the base template might affect other parts of the application. Please ensure these changes don't break existing functionality and are necessary for the new component.
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 to tell me if it was helpful.



def ComponentsView(request):
parent_directory = '/home/abhigawande/Downloads/fossasia'
Copy link

Choose a reason for hiding this comment

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

🚨 suggestion (security): Avoid hardcoding file paths

Hardcoding file paths can lead to issues with portability and maintenance. Consider using a configuration setting for this path instead. Also, be cautious about exposing file system information to the client for security reasons.

from django.conf import settings

def ComponentsView(request):
    parent_directory = settings.FOSSASIA_DIRECTORY
    # Construct the path to the eventyay-talk directory
    eventyay_talk_path = os.path.join(parent_directory, 'eventyay-talk')


{% if is_eventyay_talk_installed %}
<p>
<a href="http://127.0.0.1:8000/eventyay-talk" class="btn btn-primary">
Copy link

Choose a reason for hiding this comment

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

suggestion: Use reverse URL lookup instead of hardcoded URL

Hardcoded URLs can lead to maintenance issues. Consider using Django's reverse URL lookup function to generate this URL dynamically.

                    <a href="{% url 'eventyay-talk' %}" class="btn btn-primary">

@@ -439,3 +440,17 @@

def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)


def ComponentsView(request):
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 refactoring the ComponentsView function to separate concerns.

The new code introduces additional complexity and could benefit from some refactoring. Here are a few suggestions:

  1. Single Responsibility Principle: The ComponentsView function mixes file system operations with rendering logic. Consider separating these concerns to improve maintainability and testability.

  2. Hardcoded Paths: The use of a hardcoded path (/home/abhigawande/Downloads/fossasia) reduces flexibility. Consider using Django settings to define the directory path, making the code more portable and adaptable to different environments.

  3. Lack of Error Handling: The current implementation does not handle potential errors from file system operations, such as permission issues or missing directories. Adding error handling could prevent runtime errors.

  4. Code Organization: The new function is added at the end of the file without integration into the existing class or view structure, which can make the codebase harder to navigate. Consider organizing the code to improve readability.

  5. Naming Conventions: Use snake_case for function names to adhere to Python's PEP 8 style guide.

Refactoring these aspects can enhance the code's maintainability and adaptability.

@AviGawande AviGawande changed the base branch from development to interconnection September 10, 2024 18:25
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.

Add Eventyay-Talk component to User-Dashboard
1 participant