Skip to content

add upcoming assignments to home page#113

Closed
madelynnblue wants to merge 1 commit intodavidmreed:mainfrom
madelynnblue:upcoming-assignments
Closed

add upcoming assignments to home page#113
madelynnblue wants to merge 1 commit intodavidmreed:mainfrom
madelynnblue:upcoming-assignments

Conversation

@madelynnblue
Copy link
Copy Markdown
Contributor

Add an upcoming assignments block to the home page. This is super useful as a staffed user to see what are the next games I have to show up for.

@madelynnblue
Copy link
Copy Markdown
Contributor Author

image

Comment thread stave/views.py
for rgca in rgcas:
# TODO: Surely there's a better way to do this instead of an N+1.
if (
not models.User.objects.staffed(rgca.game.event)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This filter seems to be needed to prevent showing assignments that are in progress and maybe haven't yet been finalized. I didn't quite see how to integrate this into the main query.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Let me poke at that a bit!

Comment thread stave/views.py
# Upcoming crew assignments.
rgcas = models.RoleGroupCrewAssignment.for_user(
self.request.user,
[models.EventStatus.OPEN, models.EventStatus.IN_PROGRESS],
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This line is giving a python type that I don't know how to resolve.

Argument of type "list[tuple[Literal[4], Unknown]]" cannot be assigned to parameter "event_status_in" of type "list[EventStatus]" in function "for_user"
"tuple[Literal[4], Unknown]" is not assignable to "EventStatus"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

That looks like a Pylance error - no? Pylance is notably terrible at Django typing. Mypy is somewhat better but I haven't finished converting over to Mypy yet. Don't worry about it. The code is correct.

Comment thread stave/models.py
return list(self.effective_crew_by_role_id().values())

@classmethod
def for_user(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think I'd like to promote this to a method on a custom manager (a pattern I'm using elsewhere). Happy to make that change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could you? django/python is not my thing, and it wasn't clear to me where to stuff this. I tried a few places and this seemed the least bad. I'd like to see what the good pattern is.

Comment thread stave/views.py
Comment on lines +185 to +189
models.GameHistory(
game=rgca.game,
user=self.request.user,
role=role,
secondary_role=secondary_role,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is nice; I like the reuse.

@davidmreed
Copy link
Copy Markdown
Owner

Implemented (finally!) in #252. Thank you for suggestions and guidance!

@davidmreed davidmreed closed this Apr 20, 2026
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