Skip to content

Commit

Permalink
add feature to enable selected content types
Browse files Browse the repository at this point in the history
  • Loading branch information
UlrichB22 committed Sep 4, 2023
1 parent fdf59fb commit e8d8472
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/moin/items/content.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright: 2012 MoinMoin:CheerXiao
# Copyright: 2009 MoinMoin:ThomasWaldmann
# Copyright: 2009-2011 MoinMoin:ReimarBauer
# Copyright: 2009 MoinMoin:ChristopherDenter
# Copyright: 2008,2009 MoinMoin:BastianBlank
# Copyright: 2010 MoinMoin:ValentinJaniaut
# Copyright: 2010 MoinMoin:DiogenesAugusto
# Copyright: 2012 MoinMoin:CheerXiao
# Copyright: 2023 MoinMoin:UlrichB
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -78,6 +79,8 @@

COLS = 80
ROWS_DATA = 20
# ENABLED_CONTENT_TYPES = [] # Allow all content types
ENABLED_CONTENT_TYPES = ['MoinMoin', 'PDF', 'PNG', 'JPEG',] # restrict content types


class RegistryContent(RegistryBase):
Expand Down Expand Up @@ -125,9 +128,11 @@ def register(self, e, group):


def register(cls):
content_registry.register(RegistryContent.Entry(cls._factory, Type(cls.contenttype),
cls.default_contenttype_params, cls.display_name,
cls.ingroup_order, RegistryContent.PRIORITY_MIDDLE), cls.group)
if not cls.display_name or len(ENABLED_CONTENT_TYPES) == 0 or cls.display_name in ENABLED_CONTENT_TYPES:
logging.debug("register contenttype {0} in group {1}".format(cls.display_name, cls.group))
content_registry.register(RegistryContent.Entry(cls._factory, Type(cls.contenttype),
cls.default_contenttype_params, cls.display_name,
cls.ingroup_order, RegistryContent.PRIORITY_MIDDLE), cls.group)
return cls


Expand Down
2 changes: 2 additions & 0 deletions src/moin/templates/modify_select_contenttype.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1>{{ _("Create new item named '%(name)s'", name=item_name) }}</h1>
</p>
<table id="moin-create-table" class="zebra">
{% for group in group_names %}
{% if groups[group]|length > 0 %}
<tr>
<th>{{ group }}</th>
</tr>
Expand All @@ -26,6 +27,7 @@ <h1>{{ _("Create new item named '%(name)s'", name=item_name) }}</h1>
{% endfor %}
</td>
</tr>
{% endif %}
{% endfor %}
</table>

Expand Down

0 comments on commit e8d8472

Please sign in to comment.