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

Team attendance register #84

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Team attendance register #84

wants to merge 7 commits into from

Conversation

raccube
Copy link
Member

@raccube raccube commented Dec 24, 2024

Resolves #35

@raccube raccube force-pushed the feature/team-attendance branch from a3f5b28 to ea78a25 Compare December 24, 2024 18:56
Comment on lines +7 to +8
type = forms.Select(choices=TeamAttendanceEventType.choices)
comment = forms.CharField(required=False)
Copy link
Member

Choose a reason for hiding this comment

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

Issue: These should be the default types for these fields. You should be able to remove these lines entirely.


def get_initial(self) -> dict[str, Any]:
return {
"team": get_object_or_none(Team, tla=self.kwargs["tla"]),
Copy link
Member

Choose a reason for hiding this comment

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

Issue: Whilst I like the idea, it's probably better to keep the team only in the URL, rather than in the form.

return reverse_lazy("teams:team_list_attendance")

def form_valid(self, form: TeamAttendanceLogForm) -> HttpResponse:
assert self.request.user.is_authenticated
Copy link
Member

Choose a reason for hiding this comment

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

Issue: This assertion shouldn't be necessary

Suggested change
assert self.request.user.is_authenticated

def form_valid(self, form: TeamAttendanceLogForm) -> HttpResponse:
assert self.request.user.is_authenticated
team = form.cleaned_data["team"]
team.team_attendance_events.create(
Copy link
Member

Choose a reason for hiding this comment

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

Issue: You should be able to use form.save() to do this instead.

https://forum.djangoproject.com/t/modify-form-field-before-saving-it/4090/3 is a good example.

Comment on lines +220 to +221
def form_invalid(self, form: TeamAttendanceLogForm) -> HttpResponse:
return HttpResponse("Please fill out the form correctly.")
Copy link
Member

Choose a reason for hiding this comment

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

Issue: This is a bad idea. If you leave this out, the form will show its own errors

{% block title %}Team Attendance{% endblock %}

{% block page_buttons %}
{# <input class="input" type="date">#}
Copy link
Member

Choose a reason for hiding this comment

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

Question: Is this meant to be commented out?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a WIP thing. I wanted to add the option to filter by day. Not sure if I should keep it. We'd also want to make sure that teams which have dropped out ignore the filter.

Comment on lines +64 to +68
ARRIVED = "AR", "Arrived"
LEFT = "LE", "Left"
DELAYED = "DE", "Delayed"
DROPPED_OUT = "DO", "Dropped Out"

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Since these are already small, might as well let the values be human readable

Suggested change
ARRIVED = "AR", "Arrived"
LEFT = "LE", "Left"
DELAYED = "DE", "Delayed"
DROPPED_OUT = "DO", "Dropped Out"
ARRIVED = "ARRIVED", "Arrived"
LEFT = "LEFT", "Left"
DELAYED = "DELAYED", "Delayed"
DROPPED_OUT = "DROPPED_OUT", "Dropped Out"

Comment on lines +30 to +31
lookups = dict(TeamAttendanceEventType.choices)
return lookups.get(value)
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Because this is an enum, I think you can do:

Suggested change
lookups = dict(TeamAttendanceEventType.choices)
return lookups.get(value)
return TeamAttendanceEventType[value].value

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.

Team attendance register
2 participants