Skip to content

Commit 2d37e0c

Browse files
committed
accept multiple addresses per calendar account
1 parent df8259d commit 2d37e0c

File tree

10 files changed

+28
-26
lines changed

10 files changed

+28
-26
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ not released yet
2727
tentative)
2828
* NEW event format option `partstat-symbol` which represents the participation
2929
status of an event with a symbol (e.g. `` for accepted, `` for declined,
30-
`?` for tentative); partication status is shown for the email address
30+
`?` for tentative); partication status is shown for the email addresses
3131
configured for the event's calendar
3232

3333
0.11.2

khal/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def build_collection(conf, selection):
175175
'color': cal['color'],
176176
'priority': cal['priority'],
177177
'ctype': cal['type'],
178-
'address': cal['address'],
178+
'addresses': cal['addresses'],
179179
}
180180
collection = khalendar.CalendarCollection(
181181
calendars=props,

khal/custom_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CalendarConfiguration(TypedDict):
1212
color: str
1313
priority: int
1414
ctype: str
15-
address: str
15+
addresses: str
1616

1717

1818
class LocaleConfiguration(TypedDict):

khal/khalendar/event.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self,
6868
color: Optional[str] = None,
6969
start: Optional[dt.datetime] = None,
7070
end: Optional[dt.datetime] = None,
71-
address: str = '',
71+
addresses: Optional[List[str]] =None,
7272
):
7373
"""
7474
:param start: start datetime of this event instance
@@ -88,7 +88,7 @@ def __init__(self,
8888
self.color = color
8989
self._start: dt.datetime
9090
self._end: dt.datetime
91-
self.address = address
91+
self.addresses = addresses if addresses else []
9292

9393
if start is None:
9494
self._start = self._vevents[self.ref]['DTSTART'].dt
@@ -808,9 +808,10 @@ def status(self) -> str:
808808
@property
809809
def partstat(self) -> Optional[str]:
810810
for attendee in self._vevents[self.ref].get('ATTENDEE', []):
811-
print(attendee)
812-
if attendee == 'mailto:' + self.address:
813-
return attendee.params.get('PARTSTAT', '')
811+
for address in self.addresses:
812+
if attendee == 'mailto:' + address:
813+
return attendee.params.get('PARTSTAT', '')
814+
return None
814815

815816

816817
class DatetimeEvent(Event):

khal/khalendar/khalendar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def _construct_event(self,
284284
ref=ref,
285285
color=self._calendars[calendar]['color'],
286286
readonly=self._calendars[calendar]['readonly'],
287-
address=self._calendars[calendar]['address'],
287+
addresses=self._calendars[calendar]['addresses'],
288288
)
289289
return event
290290

khal/settings/khal.spec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ readonly = boolean(default=False)
7171
# *calendars* subsection will be used.
7272
type = option('calendar', 'birthdays', 'discover', default='calendar')
7373

74-
# The email address associated with this account. For now it is only used to
75-
# check what participation status ("PARTSTAT") belongs to the user.
76-
address = string(default='')
74+
# All email addresses associated with this account, separated by commas.
75+
# For now it is only used to check what participation status ("PARTSTAT")
76+
# belongs to the user.
77+
addresses = force_list(default='')
7778

7879
[sqlite]
7980
# khal stores its internal caching database here, by default this will be in the *$XDG_DATA_HOME/khal/khal.db* (this will most likely be *~/.local/share/khal/khal.db*).

tests/configs/small.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
[[work]]
99
path = ~/.calendars/work/
1010
readonly = True
11-
11+
addresses = [email protected]

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def coll_vdirs(tmpdir) -> CollVdirType:
5656
color='dark blue',
5757
priority=10,
5858
ctype='calendar',
59-
address='[email protected]',
59+
addresses='[email protected]',
6060
)
6161
vdirs[name] = Vdir(path, '.ics')
6262
coll = CalendarCollection(calendars=calendars, dbpath=':memory:', locale=LOCALE_BERLIN)
@@ -73,7 +73,7 @@ def coll_vdirs_birthday(tmpdir):
7373
readonly = True if name == 'a_calendar' else False
7474
calendars[name] = {'name': name, 'path': path, 'color': 'dark blue',
7575
'readonly': readonly, 'unicode_symbols': True, 'ctype': 'birthdays',
76-
'address': '[email protected]'}
76+
'addresses': '[email protected]'}
7777
vdirs[name] = Vdir(path, '.vcf')
7878
coll = CalendarCollection(calendars=calendars, dbpath=':memory:', locale=LOCALE_BERLIN)
7979
coll.default_calendar_name = cal1

tests/event_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ def test_status_confirmed():
332332
FORMAT_CALENDAR = ('{calendar-color}{status-symbol}{start-end-time-style} ({calendar}) '
333333
'{title} [{location}]{repeat-symbol}')
334334

335-
assert event.format(FORMAT_CALENDAR, dt.date(2014, 4, 9)) == \
336-
' ✔09:30-10:30 (foobar) An Event []\x1b[0m'
335+
assert human_formatter(FORMAT_CALENDAR)(event.attributes(dt.date(2014, 4, 9))) == \
336+
'✔09:30-10:30 (foobar) An Event []\x1b[0m'
337337

338338
def test_event_d_long():
339339
event_d_long = _get_text('event_d_long')
@@ -703,29 +703,29 @@ def test_partstat():
703703
)
704704

705705
event = Event.fromString(
706-
_get_text('event_dt_partstat'), address='[email protected]', **EVENT_KWARGS)
706+
_get_text('event_dt_partstat'), addresses=['[email protected]'], **EVENT_KWARGS)
707707
assert event.partstat == 'ACCEPTED'
708708
assert human_formatter(FORMAT_CALENDAR)(event.attributes(dt.date(2014, 4, 9))) == \
709709
'✔09:30-10:30 (foobar) An Event []\x1b[0m'
710710

711711
event = Event.fromString(
712-
_get_text('event_dt_partstat'), address='[email protected]', **EVENT_KWARGS)
712+
_get_text('event_dt_partstat'), addresses=['[email protected]'], **EVENT_KWARGS)
713713
assert event.partstat == 'DECLINED'
714714
assert human_formatter(FORMAT_CALENDAR)(event.attributes(dt.date(2014, 4, 9))) == \
715715
'❌09:30-10:30 (foobar) An Event []\x1b[0m'
716716

717717
event = Event.fromString(
718-
_get_text('event_dt_partstat'), address='[email protected]', **EVENT_KWARGS)
718+
_get_text('event_dt_partstat'), addresses=['[email protected]'], **EVENT_KWARGS)
719719
assert event.partstat == 'ACCEPTED'
720720
assert human_formatter(FORMAT_CALENDAR)(event.attributes(dt.date(2014, 4, 9))) == \
721721
'✔09:30-10:30 (foobar) An Event []\x1b[0m'
722722

723723
@pytest.mark.xfail
724724
def test_partstat_deligated():
725725
event = Event.fromString(
726-
_get_text('event_dt_partstat'), address='[email protected]', **EVENT_KWARGS)
726+
_get_text('event_dt_partstat'), addresses=['[email protected]'], **EVENT_KWARGS)
727727
assert event.partstat == 'ACCEPTED'
728728

729729
event = Event.fromString(
730-
_get_text('event_dt_partstat'), address='[email protected]', **EVENT_KWARGS)
730+
_get_text('event_dt_partstat'), addresses=['[email protected]'], **EVENT_KWARGS)
731731
assert event.partstat == 'ACCEPTED'

tests/settings_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ def test_simple_config(self):
4242
'calendars': {
4343
'home': {
4444
'path': os.path.expanduser('~/.calendars/home/'), 'readonly': False,
45-
'color': None, 'priority': 10, 'type': 'calendar', 'address': '',
45+
'color': None, 'priority': 10, 'type': 'calendar', 'addresses': [''],
4646
},
4747
'work': {
4848
'path': os.path.expanduser('~/.calendars/work/'), 'readonly': False,
49-
'color': None, 'priority': 10, 'type': 'calendar', 'address': '',
49+
'color': None, 'priority': 10, 'type': 'calendar', 'addresses': [''],
5050
},
5151
},
5252
'sqlite': {'path': os.path.expanduser('~/.local/share/khal/khal.db')},
@@ -85,10 +85,10 @@ def test_small(self):
8585
'calendars': {
8686
'home': {'path': os.path.expanduser('~/.calendars/home/'),
8787
'color': 'dark green', 'readonly': False, 'priority': 20,
88-
'type': 'calendar', 'address': ''},
88+
'type': 'calendar', 'addresses': ['']},
8989
'work': {'path': os.path.expanduser('~/.calendars/work/'),
9090
'readonly': True, 'color': None, 'priority': 10,
91-
'type': 'calendar', 'address': '[email protected]'}},
91+
'type': 'calendar', 'addresses': ['[email protected]']}},
9292
'sqlite': {'path': os.path.expanduser('~/.local/share/khal/khal.db')},
9393
'locale': {
9494
'local_timezone': get_localzone(),

0 commit comments

Comments
 (0)