From f79e4620519879d4db7b05957cab11f3ff23ad59 Mon Sep 17 00:00:00 2001 From: Roland DENIS Date: Wed, 1 Jun 2022 14:08:37 +0200 Subject: [PATCH 1/2] Revert "Fix #269" This reverts commit ef5e041c3e232d357ef1991d58d9051a51d935da. --- plugins/event_schedule/directives.py | 4 +--- plugins/event_schedule/templates/event.tpl | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/event_schedule/directives.py b/plugins/event_schedule/directives.py index eb372cf5..acb6ef22 100644 --- a/plugins/event_schedule/directives.py +++ b/plugins/event_schedule/directives.py @@ -148,9 +148,7 @@ class Event(Directive): node['begin'] = dateutil.parser.parse(self.options['begin']) node['end'] = dateutil.parser.parse(self.options['end']) node['title'] = self.arguments[0] - # Fix issue #269 - speaker = self.options.get('speaker') - node['speaker'] = speaker if speaker != 'None' else None + node['speaker'] = self.options.get('speaker', None) node['support'] = self.options.get('support', list()) node['content'] = '\n'.join(self.content) content = event_content() diff --git a/plugins/event_schedule/templates/event.tpl b/plugins/event_schedule/templates/event.tpl index 0f774d6c..60ecf404 100644 --- a/plugins/event_schedule/templates/event.tpl +++ b/plugins/event_schedule/templates/event.tpl @@ -49,7 +49,9 @@
{% if node_type == 'speaker' %}

{{ node['title'] }}

-

{{ node['speaker'] if node['speaker'] }}

+ {% if node['speaker'] %} +

{{ node['speaker'] }}

+ {% endif %} {% elif node_type == 'break' %}

{{ node['break'] }}

{% endif %} -- GitLab From 5f0dfb68424b7fd8bb9d30e6d2a931e8380a0116 Mon Sep 17 00:00:00 2001 From: Roland DENIS Date: Wed, 1 Jun 2022 14:09:46 +0200 Subject: [PATCH 2/2] Fixing #269 by using appropriate converter for text `directives.unchanged` converts input to str or empty string if missing, instead of `str` that will convert None type to "None" string. --- plugins/event_schedule/directives.py | 4 ++-- plugins/event_schedule/templates/event.tpl | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/event_schedule/directives.py b/plugins/event_schedule/directives.py index acb6ef22..007c684b 100644 --- a/plugins/event_schedule/directives.py +++ b/plugins/event_schedule/directives.py @@ -133,7 +133,7 @@ class Event(Directive): optional_arguments = 0 final_argument_whitespace = True option_spec = { - 'speaker': str, + 'speaker': directives.unchanged, # To get empty string instead of None in case of missing option's content 'begin': str, 'end': str, 'support': support_converter @@ -148,7 +148,7 @@ class Event(Directive): node['begin'] = dateutil.parser.parse(self.options['begin']) node['end'] = dateutil.parser.parse(self.options['end']) node['title'] = self.arguments[0] - node['speaker'] = self.options.get('speaker', None) + node['speaker'] = self.options.get('speaker', '') node['support'] = self.options.get('support', list()) node['content'] = '\n'.join(self.content) content = event_content() diff --git a/plugins/event_schedule/templates/event.tpl b/plugins/event_schedule/templates/event.tpl index 60ecf404..7827b752 100644 --- a/plugins/event_schedule/templates/event.tpl +++ b/plugins/event_schedule/templates/event.tpl @@ -49,9 +49,7 @@
{% if node_type == 'speaker' %}

{{ node['title'] }}

- {% if node['speaker'] %} -

{{ node['speaker'] }}

- {% endif %} +

{{ node['speaker'] }}

{# always keep a speaker to avoid breaking vertical space #} {% elif node_type == 'break' %}

{{ node['break'] }}

{% endif %} -- GitLab