-
Notifications
You must be signed in to change notification settings - Fork 30
#597 simplify attendance updates for members #607
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
Open
Theophile-Madet
wants to merge
16
commits into
master
Choose a base branch
from
597-simplify-attendance-updates-for-members
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5966569
WIP attendance changes.
Theophile-Madet a57aada
Fixed test about accounting being able to see resignations.
Theophile-Madet f7fab1c
Merge branch 'master' into 597-simplify-attendance-updates-for-members
Theophile-Madet f526b07
Services update
Theophile-Madet c40e689
Added tests for CanLookForStandinService
Theophile-Madet e132a5c
First tests for SelfUnregisterService
Theophile-Madet 9a4e39e
WIP more tests for SelfUnregisterService
Theophile-Madet d564493
Update tests
Theophile-Madet 24c127d
Added tests for shifts:attendance_cant_attend
Theophile-Madet d11281f
Fixed main stats page not loading because of unoptimized sql queries.
Theophile-Madet 7a864d8
Merge branch 'master' into 597-simplify-attendance-updates-for-members
Theophile-Madet 978b636
Text updates from Vicky
Theophile-Madet 95727cd
Merge branch 'refs/heads/master' into 597-simplify-attendance-updates…
Theophile-Madet c7ef64f
Restored translations after merging from master.
Theophile-Madet 1607350
Function name fix
Theophile-Madet 2091359
Translation fix
Theophile-Madet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from django.utils import timezone | ||
|
|
||
| from tapir.shifts.models import ShiftSlot | ||
|
|
||
|
|
||
| class CanLookForStandinService: | ||
| @staticmethod | ||
| def can_look_for_a_standin(slot: ShiftSlot): | ||
| return slot.shift.start_time > timezone.now() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| from django.utils import timezone | ||
| from django.utils.translation import gettext_lazy as _ | ||
|
|
||
| from tapir.accounts.models import TapirUser | ||
| from tapir.shifts.models import ( | ||
| ShiftAttendance, | ||
| ShiftAttendanceTemplate, | ||
| Shift, | ||
| ) | ||
|
|
||
|
|
||
| class SelfUnregisterService: | ||
| @classmethod | ||
| def should_show_is_abcd_attendance_reason( | ||
| cls, user: TapirUser, attendance: ShiftAttendance | ||
| ): | ||
| if not attendance.slot.slot_template: | ||
| return False | ||
|
|
||
| return ShiftAttendanceTemplate.objects.filter( | ||
| user=user, slot_template=attendance.slot.slot_template | ||
| ).exists() | ||
|
|
||
| @classmethod | ||
| def should_show_not_enough_days_before_shift_reason( | ||
| cls, attendance: ShiftAttendance, **_ | ||
| ): | ||
| return ( | ||
| attendance.slot.shift.start_time.date() - timezone.now().date() | ||
| ).days <= Shift.NB_DAYS_FOR_SELF_UNREGISTER | ||
|
|
||
| @classmethod | ||
| def build_reasons_why_cant_self_unregister( | ||
| cls, user: TapirUser, attendance: ShiftAttendance | ||
| ): | ||
| return [ | ||
| message | ||
| for check, message in cls.get_check_to_message_map().items() | ||
| if check( | ||
| user=user, | ||
| attendance=attendance, | ||
| ) | ||
| ] | ||
|
|
||
| @classmethod | ||
| def user_can_self_unregister( | ||
| cls, user: TapirUser, attendance: ShiftAttendance | ||
| ) -> bool: | ||
| for check in cls.get_check_to_message_map().keys(): | ||
| if check(user=user, attendance=attendance): | ||
| return False | ||
|
|
||
| return True | ||
|
|
||
| @classmethod | ||
| def get_check_to_message_map(cls): | ||
| return { | ||
| cls.should_show_is_abcd_attendance_reason: _( | ||
| "It is not possible to unregister from a shift that comes from your ABCD shift." | ||
| ), | ||
| cls.should_show_not_enough_days_before_shift_reason: _( | ||
| "It is only possible to unregister from a shift at least 7 days before the shift." | ||
| ), | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| {% extends "core/base.html" %} | ||
| {% load django_bootstrap5 %} | ||
| {% load i18n %} | ||
| {% load static %} | ||
| {% load core %} | ||
| {% block title %} | ||
| {% translate "Can't attend:" %} {{ attendance }} | ||
| {% endblock title %} | ||
| {% block content %} | ||
| <div class="container"> | ||
| <div class="row mb-3"> | ||
| <h3 class="col text-center"> | ||
| {% translate "If you can't attend" %} | ||
| <br /> | ||
| <a href="{{ attendance.slot.shift.get_absolute_url }}">{{ attendance.slot }}</a> | ||
| </h3> | ||
| </div> | ||
| <div class="row"> | ||
| <div class="col-xl mb-2"> | ||
| <div class="card"> | ||
| <h5 class="card-header">{% translate "Option 1: unregister" %}</h5> | ||
| <div class="card-body"> | ||
| <div> | ||
| {% if can_unregister %} | ||
| {% blocktranslate %} | ||
| You can unregister from this shift. | ||
| You will be removed from the attendance list and won't get any negative | ||
| point. | ||
| {% endblocktranslate %} | ||
| {% else %} | ||
| {% blocktranslate %} | ||
| You cannot unregister from this shift. <br /> | ||
| The reasons are: | ||
| {% endblocktranslate %} | ||
| <ul> | ||
| {% for reason in reasons_why_cant_self_unregister %}<li>{{ reason }}</li>{% endfor %} | ||
| </ul> | ||
| {% endif %} | ||
| </div> | ||
| <form role="form" | ||
| method="post" | ||
| action="{% url 'shifts:update_shift_attendance_state' attendance.id attendance.State.CANCELLED %}"> | ||
| {% csrf_token %} | ||
| <div class="d-flex justify-content-end"> | ||
| <button type="submit" | ||
| class="{% tapir_button_action %} {% if not can_unregister %}disabled{% endif %}"> | ||
| <span class="material-icons">event_busy</span> | ||
| {% translate 'Unregister' %} | ||
| </button> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="col-xl"> | ||
| <div class="card"> | ||
| <h5 class="card-header">{% translate "Option 2: Enable looking for a stand-in" %}</h5> | ||
| <div class="card-body"> | ||
| {% blocktranslate %} | ||
| <p> | ||
| If you cannot unregister from the shift, your other option is to look for a replacement ("stand-in"). | ||
| This will notify the team that you can't come, and will allow other members to take over your slot. | ||
| Please enable this as soon as you know you won't be able to come to your shift. | ||
| </p> | ||
| <p> | ||
| This is always possible up to the time of the shift. | ||
| </p> | ||
| <p> | ||
| After enabling this, it is still absolutely necessary that you contact the member office | ||
| (<a href="mailto:{{ email_address_member_office }}">{{ email_address_member_office }}</a>) | ||
| as soon as possible. | ||
| </p> | ||
| <p> | ||
| If you have a valid reason for not coming (see the | ||
| <a href="https://docs.google.com/document/d/19v91mj2MAJTtrPLCw54VMS6qlaiJqBqUAuiC6z_AKpw/edit?tab=t.0#heading=h.vxvgxkgmyf1w">Member Manual</a>), | ||
| the member office will unregister you from the shift and you won't get any negative points. | ||
| </p> | ||
| <p> | ||
| If you don't have a valid reason for not coming, you may still get lucky: | ||
| someone may take over your shift. The shift calendar shows where someone is looking for a stand-in. <br /> | ||
| If that happens, you will be notified by email and will not get any negative points. | ||
| You are still obliged to sign up for an alternative shift in this shift cycle. <br /> | ||
| There is no guarantee that this happens. If your slot is not taken over, you will get negative points. | ||
| </p> | ||
| {% endblocktranslate %} | ||
| <form role="form" | ||
| method="post" | ||
| action="{% url 'shifts:update_shift_attendance_state' attendance.id attendance.State.LOOKING_FOR_STAND_IN %}"> | ||
| {% csrf_token %} | ||
| <div class="d-flex justify-content-end"> | ||
| <button type="submit" class="{% tapir_button_action %}"> | ||
| <span class="material-icons">sync</span> | ||
| {% translate 'Look for a stand-in' %} | ||
| </button> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {% endblock content %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a little few words for this button
{% translate "Cannot attend" %}? Better readable.