├── requirements.txt ├── ckanext ├── announcements │ ├── i18n │ │ └── .gitignore │ ├── public │ │ └── .gitignore │ ├── tests │ │ ├── __init__.py │ │ ├── fixtures.py │ │ ├── test_ui.py │ │ ├── factories.py │ │ └── test_plugin.py │ ├── __init__.py │ ├── templates │ │ ├── header.html │ │ ├── admin │ │ │ ├── base.html │ │ │ ├── snippets │ │ │ │ ├── delete-announcement.html │ │ │ │ ├── new-announcement.html │ │ │ │ └── edit-announcement.html │ │ │ └── announcements.html │ │ ├── base.html │ │ └── announcements │ │ │ └── announcement.html │ ├── assets │ │ ├── webassets.yml │ │ ├── css │ │ │ └── announcements.css │ │ └── js │ │ │ └── announcements.js │ ├── validators.py │ ├── utils.py │ ├── auth.py │ ├── models.py │ ├── migration │ │ └── announcements │ │ │ ├── versions │ │ │ └── 001_95aed1f25344_add_message_models.py │ │ │ ├── alembic.ini │ │ │ └── env.py │ ├── helpers.py │ ├── plugin.py │ ├── actions.py │ └── blueprints.py └── __init__.py ├── dev-requirements.txt ├── .flake8 ├── .coveragerc ├── docs └── imgs │ └── screen.png ├── conftest.py ├── .pre-commit-config.yaml ├── MANIFEST.in ├── setup.cfg ├── .gitignore ├── test.ini ├── CHANGELOG.md ├── .github └── workflows │ ├── test-ckan-2.10.yml │ └── test-ckan-2.11.yml ├── README.md ├── setup.py └── LICENSE /requirements.txt: -------------------------------------------------------------------------------- 1 | ckantoolkit 2 | -------------------------------------------------------------------------------- /ckanext/announcements/i18n/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | pytest-ckan 2 | -------------------------------------------------------------------------------- /ckanext/announcements/public/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ckanext/announcements/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ckanext/announcements/__init__.py: -------------------------------------------------------------------------------- 1 | __VERSION__ = "0.1.6" 2 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | max-complexity = 15 4 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [report] 2 | omit = 3 | */site-packages/* 4 | */python?.?/* 5 | ckan/* 6 | -------------------------------------------------------------------------------- /docs/imgs/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okfn/ckanext-announcements/main/docs/imgs/screen.png -------------------------------------------------------------------------------- /conftest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | pytest_plugins = [ 4 | "ckanext.announcements.tests.fixtures", 5 | ] 6 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/PyCQA/flake8 3 | rev: 7.0.0 4 | hooks: 5 | - id: flake8 6 | files: ckanext 7 | args: [--max-line-length=130] 8 | -------------------------------------------------------------------------------- /ckanext/announcements/templates/header.html: -------------------------------------------------------------------------------- 1 | {% ckan_extends %} 2 | 3 | {% block header_account %} 4 | 5 | {{ super() }} 6 | {% snippet 'announcements/announcement.html' %} 7 | 8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /ckanext/announcements/templates/admin/base.html: -------------------------------------------------------------------------------- 1 | {% ckan_extends %} 2 | 3 | {% block content_primary_nav %} 4 | {{ super() }} 5 | {{ h.build_nav_icon('announcements.index', _('Announcements'), icon='bell') }} 6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /ckanext/announcements/templates/base.html: -------------------------------------------------------------------------------- 1 | {% ckan_extends %} 2 | 3 | {% block styles %} 4 | {{ super() }} 5 | {% asset "announcements/announcements-css" %} 6 | {% asset "announcements/announcements-js" %} 7 | {% endblock %} 8 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | include README.md 3 | include LICENSE 4 | include requirements.txt 5 | recursive-include ckanext/announcements *.html *.json *.js *.less *.css *.mo *.yml 6 | recursive-include ckanext/announcements/migration *.ini *.py *.mako 7 | -------------------------------------------------------------------------------- /ckanext/__init__.py: -------------------------------------------------------------------------------- 1 | # this is a namespace package 2 | try: 3 | import pkg_resources 4 | 5 | pkg_resources.declare_namespace(__name__) 6 | except ImportError: 7 | import pkgutil 8 | 9 | __path__ = pkgutil.extend_path(__path__, __name__) 10 | -------------------------------------------------------------------------------- /ckanext/announcements/assets/webassets.yml: -------------------------------------------------------------------------------- 1 | announcements-css: 2 | filter: cssrewrite 3 | output: ckanext-announcements/%(version)s-announcements.css 4 | contents: 5 | - css/announcements.css 6 | 7 | announcements-js: 8 | filter: rjsmin 9 | output: ckanext-announcements/%(version)s-announcements.js 10 | contents: 11 | - js/announcements.js 12 | extra: 13 | preload: 14 | - base/main 15 | -------------------------------------------------------------------------------- /ckanext/announcements/validators.py: -------------------------------------------------------------------------------- 1 | from ckan.plugins import toolkit 2 | 3 | 4 | def validate_announcement(data_dict): 5 | errors = {} 6 | if not data_dict.get("from_date"): 7 | errors["from_date"] = ["'From date' is required"] 8 | if not data_dict.get("to_date"): 9 | errors["to_date"] = ["'To date' is required"] 10 | if not data_dict.get("message"): 11 | errors["message"] = ["A 'Message' is required"] 12 | if errors: 13 | raise toolkit.ValidationError(errors) 14 | -------------------------------------------------------------------------------- /ckanext/announcements/templates/announcements/announcement.html: -------------------------------------------------------------------------------- 1 |
| Message | 24 |From | 25 |To | 26 |Actions | 27 |
|---|---|---|---|
| {{ h.render_markdown(message.message) }} | 33 |{{ h.render_datetime(message.from_date, with_hours=True) }} ({{ display_timezone }}) | 34 |{{ h.render_datetime(message.to_date, with_hours=True) }} ({{ display_timezone }}) | 35 |36 | 37 | 38 | 39 | 40 | 41 | 42 | | 43 |