Skip to content

Commit

Permalink
Let event managers see timetable & contribs in draft mode
Browse files Browse the repository at this point in the history
Shows the same draft mode warning in the display mode that
is used in management pages to inform managers that
the contributions are in draft mode.
  • Loading branch information
tomasr8 committed Nov 5, 2021
1 parent 2ac3e63 commit dcdbd6c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion indico/modules/events/contributions/__init__.py
Expand Up @@ -109,7 +109,8 @@ def _visible_my_contributions(event):

def _visible_list_of_contributions(event):
published = contribution_settings.get(event, 'published')
return published and Contribution.query.filter(Contribution.event == event).has_rows()
can_manage = event.can_manage(session.user)
return (published or can_manage) and Contribution.query.filter(Contribution.event == event).has_rows()

yield MenuEntryData(title=_('My Contributions'), name='my_contributions', visible=_visible_my_contributions,
endpoint='contributions.my_contributions', position=2, parent='my_conference')
Expand Down
4 changes: 3 additions & 1 deletion indico/modules/events/contributions/controllers/display.py
Expand Up @@ -78,7 +78,8 @@ class RHDisplayProtectionBase(RHDisplayEventBase):
def _check_access(self):
RHDisplayEventBase._check_access(self)
published = contribution_settings.get(self.event, 'published')
if not published and not has_contributions_with_user_as_submitter(self.event, session.user):
can_manage = self.event.can_manage(session.user)
if not published and not can_manage and not has_contributions_with_user_as_submitter(self.event, session.user):
raise NotFound(_('The contributions of this event have not been published yet.'))

if not is_menu_entry_enabled(self.MENU_ENTRY_NAME, self.event):
Expand Down Expand Up @@ -114,6 +115,7 @@ def _process_args(self):
def _process(self):
return self.view_class.render_template('display/contribution_list.html', self.event,
timezone=self.event.display_tzinfo,
published=contribution_settings.get(self.event, 'published'),
**self.list_generator.get_list_kwargs())


Expand Down
@@ -1,13 +1,17 @@
{% extends 'events/display/conference/base.html' %}

{% from 'events/contributions/display/_contribution_list.html' import render_contribution_list %}
{% from 'events/contributions/management/_draft_mode_warning.html' import render_draft_mode_warning %}
{% from 'events/management/_lists.html' import render_displayed_entries_fragment %}

{% block title %}
{{- page_title -}}
{% endblock %}

{% block content -%}
{% if not published %}
{{ render_draft_mode_warning(event) }}
{% endif %}
{% if total_entries %}
<div class="toolbar f-j-end space-after">
<div id="counter" class="group">
Expand Down
2 changes: 1 addition & 1 deletion indico/modules/events/timetable/__init__.py
Expand Up @@ -26,7 +26,7 @@ def _extend_event_menu(sender, **kwargs):
from indico.modules.events.layout.util import MenuEntryData

def _visible_timetable(event):
return contribution_settings.get(event, 'published')
return contribution_settings.get(event, 'published') or event.can_manage(session.user)

yield MenuEntryData(title=_('Timetable'), name='timetable', endpoint='timetable.timetable', position=3,
visible=_visible_timetable, static_site=True)
Expand Down
5 changes: 3 additions & 2 deletions indico/modules/events/timetable/controllers/display.py
Expand Up @@ -30,7 +30,7 @@ class RHTimetableProtectionBase(RHDisplayEventBase):
def _check_access(self):
RHDisplayEventBase._check_access(self)
published = contribution_settings.get(self.event, 'published')
if not published:
if not published and not self.event.can_manage(session.user):
raise NotFound(_('The contributions of this event have not been published yet'))


Expand All @@ -51,7 +51,8 @@ def _process(self):
timetable_settings = layout_settings.get(self.event, 'timetable_theme_settings')
return self.view_class.render_template('display.html', self.event, event_info=event_info,
timetable_data=timetable_data, timetable_settings=timetable_settings,
timetable_layout=self.timetable_layout)
timetable_layout=self.timetable_layout,
published=contribution_settings.get(self.event, 'published'))
else:
return self.view_class_simple(self, self.event, self.theme, self.theme_override).display()

Expand Down
4 changes: 4 additions & 0 deletions indico/modules/events/timetable/templates/display.html
@@ -1,10 +1,14 @@
{% extends 'events/display/conference/base.html' %}
{% from 'events/contributions/management/_draft_mode_warning.html' import render_draft_mode_warning %}
{% from 'events/timetable/_timetable.html' import render_timetable %}

{% block title %}
{{- page_title -}}
{% endblock %}

{% block content %}
{% if not published %}
{{ render_draft_mode_warning(event) }}
{% endif %}
{{ render_timetable(timetable_data, event_info, timetable_layout) }}
{% endblock %}

0 comments on commit dcdbd6c

Please sign in to comment.