Skip to content

Commit

Permalink
Add call_schedule_interval as a configurable value to get_frontend_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
iameru committed Nov 29, 2023
1 parent be3c9b4 commit 9ced54e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/dearmep/api/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def get_frontend_setup(
location=l10n_res.location,
frontend_strings=l10n_res.frontend_strings,
office_hours=OfficeHoursResponse(
call_schedule_interval=hours.call_schedule_interval,
timezone=hours.timezone,
weekdays=hours.intervals_by_weekday(),
),
Expand Down
1 change: 1 addition & 0 deletions server/dearmep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class OfficeHoursConfig(BaseModel):
weekdays: Set[WeekdayNumber]
begin: time
end: time
call_schedule_interval: PositiveInt

@validator("begin", "end")
def no_timezone_in_begin_and_end(cls, v: time) -> time:
Expand Down
7 changes: 7 additions & 0 deletions server/dearmep/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ telephony:
# It does not make sense to call representatives' offices in the middle of
# the night. Therefore, you can configure "office hours". Outside of the time
# range defined here, starting new calls will not be possible.
# Keep in mind that changing office hours in a running campaign _might_ lead to
# scheduled calls being outside of it, effectively disabling some.
office_hours:

# A Olson timezone identifier. Will be used both by pytz in the backend as
Expand All @@ -246,6 +248,11 @@ telephony:
begin: "09:00"
end: "20:00"

# The interval of timeslots offered to the User to schedule calls. The
# frontend generates a list of timeslots between 'begin' and 'end' from
# this value. In minutes.
call_schedule_interval: 15 # in minutes

# Calling codes that we allow Users to have. This corresponds to the "country
# code" part of an international phone number. For example, the number
# +491751234567 has a country code of 49. Note that these are not simply
Expand Down
6 changes: 5 additions & 1 deletion server/dearmep/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from canonicaljson import encode_canonical_json
import phonenumbers
from pydantic import BaseModel, ConstrainedFloat, ConstrainedInt, \
ConstrainedStr, Field, validator
ConstrainedStr, Field, PositiveInt, validator
from pydantic.generics import GenericModel


Expand Down Expand Up @@ -557,6 +557,10 @@ def end_after_begin(cls, v: time, values: Dict[str, time]) -> time:


class OfficeHoursResponse(BaseModel):
call_schedule_interval: PositiveInt = Field(
description="The interval between possible schedule times in minutes.",
example=15,
)
timezone: str = Field(
description="The Olson timezone specifier used for the office hours.",
example="Europe/Brussels",
Expand Down
1 change: 1 addition & 0 deletions server/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"weekdays": (1, 2, 3, 4, 5),
"begin": "09:00",
"end": "18:00",
"call_schedule_interval": 15,
})


Expand Down

0 comments on commit 9ced54e

Please sign in to comment.