Skip to content

Commit

Permalink
Disable copy button when only one meeting exists in the working group.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrillkuettel committed Nov 14, 2024
1 parent b719f5d commit 0308637
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/privatim/locale/de/LC_MESSAGES/privatim.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
"POT-Creation-Date: 2024-11-14 22:32+0100\n"
"POT-Creation-Date: 2024-11-14 23:14+0100\n"
"PO-Revision-Date: 2024-05-21 21:20+0200\n"
"Last-Translator: cyrill <[email protected]>\n"
"Language-Team: German <[email protected]>\n"
Expand Down Expand Up @@ -231,6 +231,10 @@ msgstr "Kopieren"
msgid "Copy Agenda Items"
msgstr "Traktanden kopieren"

#: src/privatim/views/meetings.py
msgid "No other meetings to copy from"
msgstr "Keine weiteren Sitzungen zum Kopieren vorhanden"

#: src/privatim/views/meetings.py
msgid "Export"
msgstr "Exportieren"
Expand Down
6 changes: 5 additions & 1 deletion src/privatim/locale/fr/LC_MESSAGES/privatim.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
"POT-Creation-Date: 2024-11-14 22:32+0100\n"
"POT-Creation-Date: 2024-11-14 23:14+0100\n"
"PO-Revision-Date: 2024-04-11 15:53+0200\n"
"Last-Translator: cyrill <[email protected]>\n"
"Language-Team: French <[email protected]>\n"
Expand Down Expand Up @@ -228,6 +228,10 @@ msgstr "Copier"
msgid "Copy Agenda Items"
msgstr "Copier les points de l'ordre du jour"

#: src/privatim/views/meetings.py
msgid "No other meetings to copy from"
msgstr "Aucune autre réunion à copier"

#: src/privatim/views/meetings.py
msgid "Export"
msgstr "Exporter"
Expand Down
6 changes: 5 additions & 1 deletion src/privatim/locale/privatim.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
"POT-Creation-Date: 2024-11-14 22:32+0100\n"
"POT-Creation-Date: 2024-11-14 23:14+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -230,6 +230,10 @@ msgstr ""
msgid "Copy Agenda Items"
msgstr ""

#: ./src/privatim/views/meetings.py
msgid "No other meetings to copy from"
msgstr ""

#: ./src/privatim/views/meetings.py
msgid "Export"
msgstr ""
Expand Down
17 changes: 14 additions & 3 deletions src/privatim/views/meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from markupsafe import Markup
from pyramid.response import Response

from sqlalchemy import func, select
from privatim.models.association_tables import AttendanceStatus
from privatim.reporting.report import (
MeetingReport,
Expand All @@ -27,7 +27,6 @@
from privatim.i18n import translate

from typing import TypeVar, TYPE_CHECKING, Any, Sequence

if TYPE_CHECKING:
from pyramid.interfaces import IRequest
from privatim.models.association_tables import MeetingUserAttendance
Expand All @@ -46,6 +45,13 @@ def meeting_view(
) -> 'RenderData':
""" Displays a single meeting. """
assert isinstance(context, Meeting)

stmt = select(func.count(Meeting.id)).where(
Meeting.working_group_id == context.working_group.id
)
meeting_count = request.dbsession.execute(stmt).scalar_one()
disable_copy_button = meeting_count <= 1

formatted_time = datetime_format(context.time)
request.add_action_menu_entries(
(
Expand All @@ -61,7 +67,12 @@ def meeting_view(
css_class='dropdown-item',
url=request.route_url('copy_agenda_item', id=context.id),
icon='copy',
description=translate(_('Copy Agenda Items')),
description=(
translate(_('Copy Agenda Items'))
if not disable_copy_button
else translate(_('No other meetings to copy from'))
),
disabled=disable_copy_button,
),
Button(
title=_('Export'),
Expand Down

0 comments on commit 0308637

Please sign in to comment.