Add an Agenda to your blog that displays upcoming events!
Easy! CheapFree! Not seen on TV!
Install
-
Install the package
python3 -m pip install djangocms-blog-agenda
-
Add it in your
INSTALLED_APPS:"djangocms_blog_agenda", "recurrence",
-
Run the migration:
python3 manage.py migrate djangocms_blog_agenda
-
Update the
djangocms-blogurls by the ones in this module, by using this lovely setting:BLOG_URLCONF = "djangocms_blog_agenda.patched_urls"
-
Create a new blog configuration.
- Instance namespace: put what you want.
- Application title: put what you want.
- Object name: put what you want.
- [...]
- Click on Layout (Show):
- [...]
- Template prefix:
djangocms_blog_agenda.
That's very important since this application will check this value multiple times (to update the queryset, to check the templates, to add the post extension "event date" only to the Agenda app...).
- Save this config.
-
Explanations/Views/Misc
- A new
Event dateDateTime field has been added to blog posts that have the template prefix set todjangocms_blog_agenda. - A new post list view was created for the Agenda view, it includes all the posts where the
event_dateis set to a date in the future. - Another view is available at
_("/past/"), that will display each post where theevent_dateis in the past. - The templates are not in
djangocms_blog/templatesanymore, but indjangocms_blog_agenda/templates. Something's not appearing on your templates? Try to edit the file indjangocms_blog_agenda/templates/! - We removed the mention of comments & liveblog in the admin form, because we're not using this.
- We use some very special bits of code that are using some internal features of djangocms-blog (see
misc.py, andapps.py). Try the module before pushing an update.
Config
Settings
DJANGOCMS_BLOG_AGENDA_HIDE_UPCOMING_EVENTS_AFTER_CHOICES
a tuple of choices describing when AgendaUpcomingEntriesPlugin will hide events.
Default choices are:
(
("start", _("just after event start date")),
("start+1h", _("1 hour after event start date")),
("start+4h", _("4 hours after event start date")),
("start+1d", _("1 day after event start date")),
("start+2d", _("2 days after event start date")),
("start+3d", _("3 days after event start date")),
("start+7d", _("7 days after event start date")),
("end", _("just after event end date")),
)
DJANGOCMS_BLOG_AGENDA_RECURRENCE_IS_ENABLED
wether to enable recurrence for events.
DJANGOCMS_BLOG_AGENDA_RECURRENCE_MAX_DAYS_SEARCH
a number of days (int) to limit the search of recurring events. Defaults to 365.
DJANGOCMS_BLOG_AGENDA_TEMPLATE_PREFIXES
You may need to add multiple agenda blogs with different template prefixes, in order to have different html content or styles for each agenda.
Add this list in your settings so that djangocms-blog-agenda will work (display start_date & end_date in add/update views of the articles):
DJANGOCMS_BLOG_AGENDA_TEMPLATE_PREFIXES = [
"djangocms_blog_upcoming_calendar",
"other_djangocms_blog_template_prefix",
"...",
]
The default template prefix (
djangocms_blog_agenda) will still be recognized even if you had this setting, you don't need to add it in the list.
Multisite
This modules handles multisite just fine; just add BLOG_MULTISITE = True in your settings, and our module will inject the get_site function directly inside the class returned by get_user_model()! (it is done in AppConfig ready() method)
You will then need to create a new "Global Page Permission" entry with your user/group, and to select the site where the user/group will have the right to post new articles/agenda posts.
If you're curious about this function, here it is.
Recurrences
Recurring events are handled with the help of django-recurrence package. Only the first event is saved into database, and following recurring events are added into querysets just before they are displayed. Only events that will occur up to n days after the first event are displayed. You can change this delay with the setting DJANGOCMS_BLOG_AGENDA_RECURRENCE_MAX_DAYS_SEARCH.
You need to update the way you display dates on the templates in order to show the correct date from a recurring event, like this:
{% if post.occurrence %}
{# use post.occurrence here #}
{% else %}
{% with post_event=post.extension.first %}
{# use post_event.event_start_date and post_event.event_end_date here #}
{% endwith %}
{% endif %}
Tests
Run the tests using tox:
tox
Run the tests using pytest:
virtualenv .venv
source .venv/bin/activate
pip install -r requirements-test.txt
pytest
Metadata
Release files for djangocms-blog-agenda 0.13.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| djangocms_blog_agenda-0.13.2.tar.gz | 39.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| djangocms_blog_agenda-0.13.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 89.2 kB
Release files / djangocms_blog_agenda-0.13.2.tar.gz
| Download URL | djangocms_blog_agenda-0.13.2.tar.gz |
|---|---|
| Size | 39.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ba7398b1ad340ab228f3c798449f795be35eec900b68de67c6ed3137b17dcfd
|
|
BLAKE2b-256 checksum How to use checksums |
e26a4080796ea28d8e478dbc135739ca66a99fb15a89a2c5d74785f834ac32e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.10
|
Release files / djangocms_blog_agenda-0.13.2-py3-none-any.whl
| Download URL | djangocms_blog_agenda-0.13.2-py3-none-any.whl |
|---|---|
| Size | 49.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5333283eb5f46c0e79120fdf6462cb2de7ca9521b8ea092a527d990dede81012
|
|
BLAKE2b-256 checksum How to use checksums |
4bb72ad1b3c4cae76682f9f74e6538dfd05f1011fb7e73a5d3853da6eacf1d3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.10
|