Skip to content

Commit

Permalink
➕ show timezone for attendee in confirmation email
Browse files Browse the repository at this point in the history
  • Loading branch information
devmount committed Apr 18, 2024
1 parent dddb431 commit d39ed4f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/src/appointment/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class Attendee(Base):
id = Column(Integer, primary_key=True, index=True)
email = Column(StringEncryptedType(String, secret, AesEngine, "pkcs5", length=255), index=True)
name = Column(StringEncryptedType(String, secret, AesEngine, "pkcs5", length=255), index=True)
timezone = Column(String(255), index=True)

slots = relationship("Slot", cascade="all,delete", back_populates="attendee")

Expand Down
1 change: 1 addition & 0 deletions backend/src/appointment/database/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
class AttendeeBase(BaseModel):
email: str
name: str | None = None
timezone: str | None = None


class Attendee(AttendeeBase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""add attendee timezone
Revision ID: 89e1197d980d
Revises: fadd0d1ef438
Create Date: 2024-04-18 08:23:55.660065
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '89e1197d980d'
down_revision = 'fadd0d1ef438'
branch_labels = None
depends_on = None


def upgrade() -> None:
op.add_column('attendees', sa.Column('timezone', sa.String(255), index=True))


def downgrade() -> None:
op.drop_column('attendees', 'timezone')
9 changes: 7 additions & 2 deletions backend/src/appointment/routes/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,12 @@ def request_schedule_availability_slot(
# human readable date in subscribers timezone
# TODO: handle locale date representation
date = slot.start.replace(tzinfo=timezone.utc).astimezone(ZoneInfo(subscriber.timezone)).strftime("%c")
date = f"{date}, {slot.duration} minutes"
date = f"{date}, {slot.duration} minutes ({subscriber.timezone})"

# human readable date in attendee timezone
# TODO: handle locale date representation
attendee_date = slot.start.replace(tzinfo=timezone.utc).astimezone(ZoneInfo(slot.attendee.timezone)).strftime("%c")
attendee_date = f"{attendee_date}, {slot.duration} minutes ({slot.attendee.timezone})"

# Create a pending appointment
attendee_name = slot.attendee.name if slot.attendee.name is not None else slot.attendee.email
Expand All @@ -246,7 +251,7 @@ def request_schedule_availability_slot(
background_tasks.add_task(send_confirmation_email, url=url, attendee=attendee, date=date, to=subscriber.email)

# Sending pending email to attendee
background_tasks.add_task(send_pending_email, owner=subscriber, date=date, to=slot.attendee.email)
background_tasks.add_task(send_pending_email, owner=subscriber, date=attendee_date, to=slot.attendee.email)

# Mini version of slot, so we can grab the newly created slot id for tests
return schemas.SlotOut(
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/components/BookingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@
</template>

<script setup>
import {
inject, computed, reactive, ref, onMounted,
} from 'vue';
import { inject, computed, reactive, ref, onMounted } from 'vue';
import { timeFormat } from '@/utils';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
Expand Down Expand Up @@ -111,15 +109,14 @@ const props = defineProps({
// Store
const bookingModalStore = useBookingModalStore();
const {
open, state, stateData, isLoading, hasErrors, isFinished, isEditable,
} = storeToRefs(bookingModalStore);
const { open, state, stateData, isLoading, hasErrors, isFinished, isEditable } = storeToRefs(bookingModalStore);
// Refs
const attendee = reactive({
name: '',
email: '',
timezone: dj.tz.guess(),
});
const bookingForm = ref();
Expand All @@ -145,6 +142,7 @@ onMounted(() => {
if (user.exists()) {
attendee.name = user.data.name;
attendee.email = user.data.email;
attendee.timezone = user.data.timezone;
}
});
</script>

0 comments on commit d39ed4f

Please sign in to comment.