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

#36: Update index and events to use class based views #39

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

joeriddles
Copy link
Contributor

@joeriddles joeriddles commented Feb 23, 2024

Pull Request

Description:

  • Update Event related views to use class based views, using some Handy Helper base classes as needed
  • Update index to use Handy Helper index base class

Related Issues:

Checklist:

  • All tests pass.
  • Code follows the project's coding standards.
  • Documentation has been updated.

Screenshots

Index
image

Event detail
image

Events list
image

@joeriddles joeriddles self-assigned this Feb 23, 2024
@@ -42,4 +67,7 @@ class GetTechGroups(GenericHtmxView):
class GetEvents(GenericHtmxView):
"""Get a list of upcoming Events and render a partial to use on the sidebar navigation"""
template_name = "web/partials/sidebar_items.htm"
queryset = Event.objects.filter(date_time__gte=timezone.now())

def __init__(self, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

super-ing should not be necessary here; looks like I borked the GenericHtmxView; there should be an init there. I'll fix that and update this after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added the super as a best-practice, though it might not be necessary for this base class.

I moved the queryset into __init__ because otherwise timezone.now() is only calculated once when the class is first parsed, since it was a class-level variable, not an instance variable.

@joeriddles joeriddles merged commit 568ad95 into main Feb 23, 2024
2 checks passed
@joeriddles joeriddles deleted the refactor-views-to-cbv branch February 23, 2024 06:52
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.

2 participants