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

Feature/simpler cancel #164

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions api/utils/appointment_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from experiments.emails import ConfirmationEmail

from api.auth.models import UserToken
from experiments.models import Experiment, TimeSlot
from participants.models import Participant

Expand All @@ -19,10 +20,6 @@ def get_initial_confirmation_context(experiment: Experiment) -> dict:
'leader_email': experiment.leader.api_user.email,
'leader_phonenumber': experiment.leader.phonenumber,
'all_leaders_name_list': experiment.all_leaders_str,
'cancel_link': parse.urljoin(
settings.FRONTEND_URI,
'participant/cancel/'
),
}

if experiment.location:
Expand All @@ -42,9 +39,20 @@ def send_appointment_mail(
if participant.email is None:
return

# create login token for cancelation link
token = UserToken.objects.create(
participant=participant,
type=UserToken.CANCEL_APPOINTMENTS,
)
cancel_link = parse.urljoin(
settings.FRONTEND_URI,
"participant/appointments/{}/".format(token.token)
)

context = get_initial_confirmation_context(experiment)
context.update({
'name': participant.mail_name,
'cancel_link': cancel_link
})

if experiment.use_timeslots:
Expand All @@ -65,4 +73,3 @@ def send_appointment_mail(
context=context,
)
email.send()

2 changes: 1 addition & 1 deletion api/views/participant_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,4 @@ def _get_participant(self):
raise PermissionDenied

def get_queryset(self):
return Appointment.objects.filter(participant=self._get_participant())
return Appointment.objects.filter(participant=self._get_participant()).order_by('-timeslot__datetime')
Loading