This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of content listing plugin for Events
New `EventContentListingPlugin` to list events in page content, based on the new `ContentListingPlugin` feature from ICEkit.
- Loading branch information
Showing
10 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = '%s.apps.AppConfig' % __name__ |
22 changes: 22 additions & 0 deletions
22
icekit_events/plugins/event_content_listing/abstract_models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.utils.encoding import python_2_unicode_compatible | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from icekit.plugins.content_listing.abstract_models import \ | ||
AbstractContentListingItem | ||
|
||
|
||
@python_2_unicode_compatible | ||
class AbstractEventContentListingItem(AbstractContentListingItem): | ||
""" | ||
An embedded listing of event content items. | ||
""" | ||
|
||
class Meta: | ||
abstract = True | ||
verbose_name = _('Event Content Listing') | ||
|
||
def __str__(self): | ||
return 'Event Content Listing of %s' % self.content_type | ||
|
||
def get_items(self): | ||
return super(AbstractEventContentListingItem, self).get_items() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AppConfig(AppConfig): | ||
name = '.'.join(__name__.split('.')[:-1]) | ||
label = "ik_event_listing" | ||
verbose_name = "Event Content Listing" |
17 changes: 17 additions & 0 deletions
17
icekit_events/plugins/event_content_listing/content_plugins.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Definition of the plugin. | ||
""" | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from fluent_contents.extensions import ContentPlugin, plugin_pool | ||
|
||
from . import forms, models | ||
|
||
|
||
@plugin_pool.register | ||
class EventContentListingPlugin(ContentPlugin): | ||
model = models.EventContentListingItem | ||
category = _('Assets') | ||
render_template = 'icekit_events/plugins/event_content_listing/default.html' | ||
form = forms.EventContentListingAdminForm | ||
cache_output = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from icekit.plugins.content_listing.forms import ContentListingAdminForm | ||
|
||
from icekit_events.models import EventBase | ||
|
||
from .models import EventContentListingItem | ||
|
||
|
||
class EventContentListingAdminForm(ContentListingAdminForm): | ||
|
||
class Meta: | ||
model = EventContentListingItem | ||
fields = '__all__' | ||
|
||
def filter_content_types(self, content_type_qs): | ||
""" Filter the content types selectable to only event subclasses """ | ||
valid_ct_ids = [] | ||
for ct in content_type_qs: | ||
model = ct.model_class() | ||
if model and issubclass(model, EventBase): | ||
valid_ct_ids.append(ct.id) | ||
return content_type_qs.filter(pk__in=valid_ct_ids) |
29 changes: 29 additions & 0 deletions
29
icekit_events/plugins/event_content_listing/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('fluent_contents', '0001_initial'), | ||
('contenttypes', '0002_remove_content_type_name'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='EventContentListingItem', | ||
fields=[ | ||
('contentitem_ptr', models.OneToOneField(serialize=False, primary_key=True, to='fluent_contents.ContentItem', parent_link=True, auto_created=True)), | ||
('limit', models.IntegerField(null=True, help_text=b'How many items to show? No limit is applied if this field is not set', blank=True)), | ||
('content_type', models.ForeignKey(help_text=b'Content type of items to show in a listing', to='contenttypes.ContentType')), | ||
], | ||
options={ | ||
'db_table': 'contentitem_ik_event_listing_eventcontentlistingitem', | ||
'abstract': False, | ||
'verbose_name': 'Event Content Listing', | ||
}, | ||
bases=('fluent_contents.contentitem',), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from .abstract_models import AbstractEventContentListingItem | ||
|
||
|
||
class EventContentListingItem(AbstractEventContentListingItem): | ||
""" | ||
An embedded listing of event content items. | ||
""" | ||
pass |
4 changes: 4 additions & 0 deletions
4
...s/event_content_listing/templates/icekit_events/plugins/event_content_listing/_event.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<li><a href="{{ event.get_absolute_url }}"> | ||
{{ event.title|safe }} | ||
</a></li> | ||
|
9 changes: 9 additions & 0 deletions
9
.../event_content_listing/templates/icekit_events/plugins/event_content_listing/default.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="content-listing"> | ||
{% for event in instance.get_items %} | ||
{% include "icekit_events/plugins/event_content_listing/_event.html" %} | ||
{% empty %} | ||
<li>There are no items to show on this page</li> | ||
{{ instance.get_default_embed }} | ||
{% endfor %} | ||
</div> | ||
|