Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschuppi81 committed Jul 16, 2024
2 parents bee51f5 + a4f76d7 commit 5d5c0b2
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 97 deletions.
19 changes: 0 additions & 19 deletions docs/_static/custom.css

This file was deleted.

48 changes: 0 additions & 48 deletions docs/_static/logo.svg

This file was deleted.

25 changes: 5 additions & 20 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,38 +169,23 @@


# -- Options for HTML output ----------------------------------------------
import alabaster

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "default"
html_theme_path = [alabaster.get_path()]
html_theme = "alabaster"
html_sidebars = {
"**": [
"about.html",
"localtoc.html",
"searchbox.html",
]
}
html_theme_options = {
"logo": "logo.svg",
"github_user": "OneGov",
"github_repo": "onegov-cloud",
}
html_style = "custom.css"
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
html_theme_options = {
"display_version": False,
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
# html_title = None
html_title = "Documentation"

# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
Expand Down
7 changes: 1 addition & 6 deletions docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ framework based on Morepath, to find a path out of our reliance on Plone.
Learning Morepath is essential to learn more about OneGov Cloud. Here are
a few good starting points.

First, a general overview over framework patterns, which nicely presents the
case for Morepath:

https://blog.startifact.com/posts/framework-patterns.html

Second, an introductory video (25 mins):
Here's an introductory video (25 mins):

https://www.youtube.com/watch?v=gyDKMAWPyuY

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mypy =
types-vobject
types-webob
docs =
alabaster
sphinx_rtd_theme
docutils
Jinja2
sphinx
Expand Down
8 changes: 7 additions & 1 deletion src/onegov/org/forms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from onegov.gever.encrypt import encrypt_symmetric
from onegov.gis import CoordinatesField
from onegov.org import _
from onegov.org.forms.fields import HtmlField
from onegov.org.forms.fields import (HtmlField,
UploadOrSelectExistingMultipleFilesField)
from onegov.org.forms.user import AVAILABLE_ROLES
from onegov.org.forms.util import TIMESPANS
from onegov.org.theme import user_options
Expand Down Expand Up @@ -1220,6 +1221,11 @@ class EventSettingsForm(Form):
default='tags'
)

event_files = UploadOrSelectExistingMultipleFilesField(
label=_("Documents"),
fieldset=_("General event documents")
)


class DataRetentionPolicyForm(Form):

Expand Down
2 changes: 1 addition & 1 deletion src/onegov/org/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UploadOrLinkExistingFileWidget(UploadWidget):
""")
file_details_icon_template = Markup("""
<a id="button-{file_id}" class="file-edit">
<i class="fas fa-edit" aria-hidden="true"></i>
<i class="fa fa-edit" aria-hidden="true"></i>
</a>
""")

Expand Down
7 changes: 7 additions & 0 deletions src/onegov/org/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,13 @@ def links() -> 'Iterator[Link | LinkGroup]':
)

if self.request.is_manager:
yield Link(
text=_("Edit"),
url=self.request.link(self.request.app.org,
'event-settings'),
attrs={'class': 'edit-link'}
)

yield Link(
text=_("Import"),
url=self.request.link(self.model, 'import'),
Expand Down
6 changes: 6 additions & 0 deletions src/onegov/org/locale/de_CH/LC_MESSAGES/onegov.org.po
Original file line number Diff line number Diff line change
Expand Up @@ -2600,6 +2600,12 @@ msgstr "Als erstes Element des Inhalts"
msgid "As a full width header"
msgstr "Als ein Header-Bild mit voller Breite"

msgid "Documents"
msgstr "Dokumente"

msgid "General event documents"
msgstr "Allgemeine Veranstaltungsdokumente"

msgid "Show file links in sidebar"
msgstr "Dateilinks in der Seitenleiste anzeigen"

Expand Down
6 changes: 6 additions & 0 deletions src/onegov/org/locale/fr_CH/LC_MESSAGES/onegov.org.po
Original file line number Diff line number Diff line change
Expand Up @@ -2604,6 +2604,12 @@ msgstr "Come primo elemento del contenuto"
msgid "As a full width header"
msgstr "Come immagine di intestazione a tutta larghezza"

msgid "Documents"
msgstr "Documents"

msgid "General event documents"
msgstr "Documents généraux de l'événement"

msgid "Show file links in sidebar"
msgstr "Afficher les liens vers les fichiers dans la barre latérale"

Expand Down
6 changes: 6 additions & 0 deletions src/onegov/org/locale/it_CH/LC_MESSAGES/onegov.org.po
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,12 @@ msgstr "En tant que premier élément du contenu"
msgid "As a full width header"
msgstr "En tant qu'image d'en-tête pleine largeur"

msgid "Documents"
msgstr "Documenti"

msgid "General event documents"
msgstr "Documenti generali dell'evento"

msgid "Show file links in sidebar"
msgstr "Mostra i link ai file nella barra laterale"

Expand Down
3 changes: 3 additions & 0 deletions src/onegov/org/models/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
from functools import cached_property, lru_cache
from hashlib import sha256
from onegov.core.orm import Base
from onegov.core.orm.abstract import associated
from onegov.core.orm.mixins import (
dict_markup_property, dict_property, meta_property, TimestampMixin)
from onegov.core.orm.types import JSON, UUID
from onegov.core.utils import linkify, paragraphify
from onegov.file.models.file import File
from onegov.form import flatten_fieldsets, parse_formcode
from onegov.org.theme import user_options
from onegov.org.models.tan import DEFAULT_ACCESS_WINDOW
Expand Down Expand Up @@ -111,6 +113,7 @@ class Organisation(Base, TimestampMixin):
event_filter_definition: dict_property[str | None] = meta_property()
event_filter_configuration: dict_property[dict[str, Any]]
event_filter_configuration = meta_property(default=dict)
event_files = associated(File, 'event_files', 'many-to-many')

# social media
facebook_url: dict_property[str | None] = meta_property()
Expand Down
12 changes: 12 additions & 0 deletions src/onegov/org/templates/occurrences.pt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@
</metal:b>
</div>

<div class="side-panel files-panel occurrence-documents" tal:condition="files">
<h3 i18n:translate>Documents</h3>
<ul class="more-list">
<li tal:repeat="file files">
<a class="list-link" title="${file.name}" href="${request.link(file)}">
<i class="far ${layout.get_fa_file_icon(file.name)}" aria-hidden="true"></i>
<span class="list-title">${file.name.split('.')[0]}</span>
</a>
</li>
</ul>
</div>

<div class="occurrence-exports borderless-side-panel">
<h2 i18n:translate>Exports</h2>
<ul class="calendar-export-list">
Expand Down
3 changes: 3 additions & 0 deletions src/onegov/org/views/occurrence.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def view_occurrences(
) for range, label in range_labels
]

files = list(request.app.org.event_files)

return {
'active_tags': self.tags,
'add_link': request.link(self, name='new'),
Expand All @@ -198,6 +200,7 @@ def view_occurrences(
'start': self.start.isoformat() if self.start else '',
'ranges': ranges,
'tags': tags,
'files': files,
'filters': filters,
'locations': locations,
'title': _('Events'),
Expand Down
12 changes: 12 additions & 0 deletions src/onegov/town6/templates/occurrences.pt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
</div>
</div>

<div class="side-panel files-panel occurrence-documents" tal:condition="files">
<h3 i18n:translate>Documents</h3>
<ul class="more-list">
<li tal:repeat="file files">
<a class="list-link" title="${file.name}" href="${request.link(file)}">
<i class="far ${layout.get_fa_file_icon(file.name)}" aria-hidden="true"></i>
<span class="list-title">${file.name.split('.')[0]}</span>
</a>
</li>
</ul>
</div>

<div class="occurrence-actions side-panel" tal:condition="len(occurrences) > 1 or layout.org.meta.get('submit_events_visible', True)">
<h3 i18n:translate>Actions</h3>
<div class="side-panel-with-bg">
Expand Down
28 changes: 27 additions & 1 deletion tests/onegov/org/test_views_event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from tempfile import TemporaryDirectory

import babel.dates
import os
import pytest
Expand All @@ -8,7 +10,7 @@
import xml.etree.ElementTree as ET

from onegov.event.models import Event
from tests.shared.utils import create_image
from tests.shared.utils import create_image, create_pdf
from tests.shared.utils import get_meta
from unittest.mock import patch
from webtest.forms import Upload
Expand Down Expand Up @@ -241,6 +243,30 @@ def set_filter_on_event(client):
assert 'B Filter' in page


def test_view_occurrences_event_documents(client):
page = client.get('/events')
assert "Dokumente" not in page

with (TemporaryDirectory() as td):
client.login_admin()
settings = client.get('/module-settings')
filename_1 = os.path.join(td, 'zoo-programm-saison-2024.pdf')
pdf_1 = create_pdf(filename_1)
settings.form.fields['event_files'][-1].value = [filename_1]
settings.files = [pdf_1]
settings = settings.form.submit().follow()
assert settings.status_code == 200

settings = client.get('/module-settings')
assert "Verknüpfte Datei" in settings
assert "zoo-programm-saison-2024.pdf" in settings
client.logout()

page = client.get('/events')
assert "Dokumente" in page
assert "zoo-programm-saison-2024.pdf" in page


def test_many_filters(client):
assert client.login_admin()
page = client.get('/event-settings')
Expand Down
29 changes: 29 additions & 0 deletions tests/onegov/town6/test_views_event.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from tempfile import TemporaryDirectory

import babel
import os
import transaction

from datetime import date, timedelta

from onegov.event import Event
from tests.onegov.town6.common import step_class
from unittest.mock import patch

from tests.shared.utils import create_pdf


@patch('onegov.websockets.integration.connect')
@patch('onegov.websockets.integration.authenticate')
Expand Down Expand Up @@ -267,3 +272,27 @@ def test_hide_event_submission_option(client):

events_page = client.get('/events')
assert "Veranstaltung vorschlagen" in events_page


def test_view_occurrences_event_documents(client):
page = client.get('/events')
assert "Dokumente" not in page

with (TemporaryDirectory() as td):
client.login_admin()
settings = client.get('/event-settings')
filename_1 = os.path.join(td, 'zoo-programm-saison-2024.pdf')
pdf_1 = create_pdf(filename_1)
settings.form.fields['event_files'][-1].value = [filename_1]
settings.files = [pdf_1]
settings = settings.form.submit().follow()
assert settings.status_code == 200

settings = client.get('/module-settings')
assert "Verknüpfte Datei" in settings
assert "zoo-programm-saison-2024.pdf" in settings
client.logout()

page = client.get('/events')
assert "Dokumente" in page
assert "zoo-programm-saison-2024.pdf" in page

0 comments on commit 5d5c0b2

Please sign in to comment.