Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions khal/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def get_events_between(
def khal_list(
collection,
daterange: Optional[List[str]]=None,
conf: Optional[dict] = None,
conf: dict = None,
agenda_format=None,
day_format: Optional[str]=None,
day_format: str=None,
once=False,
notstarted: bool = False,
width: bool = False,
Expand Down
8 changes: 7 additions & 1 deletion khal/icalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def new_vevent(locale,
location: Optional[str]=None,
categories: Optional[Union[List[str], str]]=None,
repeat: Optional[str]=None,
Class: Optional[str]=None,
until=None,
alarms: Optional[str]=None,
url: Optional[str]=None,
Expand Down Expand Up @@ -125,9 +126,14 @@ def new_vevent(locale,
event.add('categories', categories)
if url:
event.add('url', icalendar.vUri(url))

if repeat and repeat != "none":
rrule = rrulefstr(repeat, until, locale, getattr(dtstart, 'tzinfo', None))
event.add('rrule', rrule)

if Class and Class !="none":
event.add('CLASS',Class)

if alarms:
for alarm in alarms.split(","):
alarm = alarm.strip()
Expand Down Expand Up @@ -493,7 +499,7 @@ def delete_instance(vevent: icalendar.Event, instance: dt.datetime) -> None:
vevent.pop('EXDATE')
vevent.add('EXDATE', exdates)
if 'RDATE' in vevent:
rdates = [one for one in _get_all_properties(vevent, 'RDATE') if one != instance]
rdates = [one for one in _get_allz_properties(vevent, 'RDATE') if one != instance]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here?

vevent.pop('RDATE')
if rdates != []:
vevent.add('RDATE', rdates)
Expand Down
15 changes: 15 additions & 0 deletions khal/khalendar/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,26 @@ def organizer(self) -> str:
else:
return email


@property
def Class(self) -> str:
if 'CLASS' not in self._vevents[self.ref]:
return ''
return self._vevents[self.ref]['CLASS']

def update_Class(self, Class: str) -> None:
if Class:
self._vevents[self.ref]['CLASS'] = Class
else:
self._vevents[self.ref].pop('CLASS')

@property
def url(self) -> str:
if 'URL' not in self._vevents[self.ref]:
return ''
return self._vevents[self.ref]['URL']


def update_url(self, url: str) -> None:
if url:
self._vevents[self.ref]['URL'] = url
Expand Down Expand Up @@ -694,6 +708,7 @@ def format(self, format_string: str, relative_to, env=None, colors: bool=True):
attributes["categories"] = self.categories
attributes['uid'] = self.uid
attributes['url'] = self.url
attributes['CLASS'] = self.Class

if "calendars" in env and self.calendar in env["calendars"]:
cal = env["calendars"][self.calendar]
Expand Down
11 changes: 4 additions & 7 deletions khal/khalendar/khalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,10 @@ def force_update(self, event: Event, collection: Optional[str]=None) -> None:
self._backend.update(event.raw, href, etag, calendar=calendar)
self._backend.set_ctag(self._local_ctag(calendar), calendar=calendar)

def insert(self, event: Event, collection: Optional[str]=None) -> None:
"""Insert a new event to the vdir and the database

The event will get a new href and etag properties. If ``collection`` is
``None``, then ``event.calendar`` must be defined.

:param event: the event to be inserted.
def insert(self, event: Event, collection: Optional[str]=None) -> Event:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not return anything.

I think you started of an old version of main which had typing wrong, but then mis-merged somehow? I do recall this being broken in the past.

"""insert a new event to the vdir and the database
:param event: the event that should be inserted, it will get a new href
and etag properties
"""
# TODO FIXME not all `event`s are actually of type Event, we also uptade
# with vdir.Items. Those don't have an .href or .etag property which we
Expand Down
3 changes: 3 additions & 0 deletions khal/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,9 @@ def __init__(self, conf, event, collection=None):
if event.url != '':
lines.append(urwid.Text('URL: ' + event.url))

if event.Class != '':
lines.append(urwid.Text('CLASS: ' + event.Class))

if event.attendees != '':
lines.append(urwid.Text('Attendees:'))
for attendee in event.attendees.split(', '):
Expand Down
14 changes: 14 additions & 0 deletions khal/ui/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ def __init__(self, pane, event, save_callback=None, always_save=False):
self.attendees = event.attendees
self.categories = event.categories
self.url = event.url

self.Class = event.Class

self.startendeditor = StartEndEditor(
event.start_local, event.end_local, self._conf,
self.start_datechange, self.end_datechange,
Expand Down Expand Up @@ -389,6 +392,11 @@ def decorate_choice(c):
self.url = urwid.AttrMap(ExtendedEdit(
caption=('', 'URL: '), edit_text=self.url), 'edit'
)

self.Class = urwid.AttrMap(ExtendedEdit(
caption=('', 'CLASS [Private or Public]: '), edit_text=self.Class), 'edit'
)

self.alarms = AlarmsEditor(self.event)
self.pile = NListBox(urwid.SimpleFocusListWalker([
self.summary,
Expand All @@ -398,6 +406,7 @@ def decorate_choice(c):
self.categories,
self.description,
self.url,
self.Class,
divider,
self.attendees,
divider,
Expand Down Expand Up @@ -439,6 +448,10 @@ def changed(self):
return True
if get_wrapped_text(self.url) != self.event.url:
return True

if get_wrapped_text(self.Class) != self.event.Class:
return True

if get_wrapped_text(self.attendees) != self.event.attendees:
return True
if self.startendeditor.changed or self.calendar_chooser.changed:
Expand All @@ -456,6 +469,7 @@ def update_vevent(self):
self.event.update_attendees(get_wrapped_text(self.attendees).split(','))
self.event.update_categories(get_wrapped_text(self.categories).split(','))
self.event.update_url(get_wrapped_text(self.url))
self.event.update_Class(get_wrapped_text(self.Class))

if self.startendeditor.changed:
self.event.update_start_end(
Expand Down