add upcoming assignments to home page#113
add upcoming assignments to home page#113madelynnblue wants to merge 1 commit intodavidmreed:mainfrom
Conversation
| 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) |
There was a problem hiding this comment.
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.
| # Upcoming crew assignments. | ||
| rgcas = models.RoleGroupCrewAssignment.for_user( | ||
| self.request.user, | ||
| [models.EventStatus.OPEN, models.EventStatus.IN_PROGRESS], |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.
e052c35 to
5a7092d
Compare
| return list(self.effective_crew_by_role_id().values()) | ||
|
|
||
| @classmethod | ||
| def for_user( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| models.GameHistory( | ||
| game=rgca.game, | ||
| user=self.request.user, | ||
| role=role, | ||
| secondary_role=secondary_role, |
There was a problem hiding this comment.
This is nice; I like the reuse.
|
Implemented (finally!) in #252. Thank you for suggestions and guidance! |

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.