translations.load_bundle("woost.extensions.opengraph.publishable") File.default_x_opengraph_enabled = False File.default_x_opengraph_type = None Publishable.members_order += ["x_opengraph_enabled", "x_opengraph_type"] class GroupByOpenGraphCategory(GroupByMember): member = OpenGraphType.category Publishable.add_member( schema.Boolean("x_opengraph_enabled", required=True, default=True, listed_by_default=False, member_group="meta.x_opengraph")) Publishable.add_member( schema.Reference("x_opengraph_type", type=OpenGraphType, required=Publishable["x_opengraph_enabled"], related_end=schema.Collection(block_delete=True), default=schema.DynamicDefault( lambda: OpenGraphType.get_instance(code="article")), indexed=True, listed_by_default=False, member_group="meta.x_opengraph"))
""" @author: Martí Congost @contact: [email protected] @organization: Whads/Accent SL @since: February 2010 """ from decimal import Decimal from cocktail.translations import translations from cocktail import schema from woost.models import Publishable, URI Publishable.add_member(schema.Boolean("sitemap_indexable", required=True, default=True, indexed=True, member_group="sitemap", listed_by_default=False), append=True) URI.default_sitemap_indexable = False Publishable.add_member(schema.String( "sitemap_change_frequency", enumeration=[ "always", "hourly", "daily", "weekly", "monthly", "yearly", "never" ], translate_value=lambda value, language=None, **kwargs: "" if not value else translations( "woost.extensions.sitemap.change_frequency " + value, language, ** kwargs),
@author: Martí Congost @contact: [email protected] @organization: Whads/Accent SL @since: February 2010 """ from decimal import Decimal from cocktail.translations import translations from cocktail import schema from woost.models import Publishable, URI translations.load_bundle("woost.extensions.sitemap.publishable") URI.default_sitemap_indexable = False Publishable.add_member(schema.String("x_sitemap_change_frequency", enumeration=[ "always", "hourly", "daily", "weekly", "monthly", "yearly", "never" ], member_group="meta.robots", text_search=False, listed_by_default=False), append=True) Publishable.add_member(schema.Decimal("x_sitemap_priority", min=0, max=1, listed_by_default=False, member_group="meta.robots"), append=True)
def _load(self): from cocktail.persistence import datastore from cocktail.controllers import UserCollection, get_parameter from cocktail.pkgutils import resolve from woost.models import (Publishable, Role, CreatePermission, get_current_user) from woost.models.changesets import changeset_context from woost.controllers.basecmscontroller import BaseCMSController # Import the extension's models from woost.extensions.comments import strings from woost.extensions.comments.comment import Comment # Captcha #------------------------------------------------------------------------------ try: from woost.extensions.recaptcha import ReCaptchaExtension except ImportError: pass else: from woost.extensions.recaptcha.schemarecaptchas import ReCaptcha if ReCaptchaExtension.instance.enabled: CommentsExtension.add_member( schema.Boolean("captcha_enabled", default=False)) # Extend Publishable model Publishable.add_member( schema.Boolean("allow_comments", required=True, default=False, member_group="administration")) Publishable.add_member( schema.Collection("comments", items=schema.Reference(type=Comment), bidirectional=True, related_key="publishable", integral=True)) @when(BaseCMSController.processed) def _process_comments(event): # Comments variables initialization comments_user_collection = None comments_schema = None comment_errors = None comment_data = {} controller = event.source comment_model = \ resolve(getattr(controller, "comment_model", Comment)) publishable = controller.context["publishable"] user = get_current_user() if publishable is not None and publishable.allow_comments: # Comments collection comments_user_collection = UserCollection(comment_model) comments_user_collection.allow_type_selection = False comments_user_collection.allow_filters = False comments_user_collection.allow_language_selection = False comments_user_collection.allow_member_selection = False comments_user_collection.params.prefix = "comments_" comments_user_collection.base_collection = publishable.comments # Show the last comments page if not specified if "comments_page" not in cherrypy.request.params: div, mod = divmod(len(comments_user_collection.subset), comments_user_collection.page_size) comments_page = div - 1 if not mod and div != 0 else div cherrypy.request.params.update( comments_page=str(comments_page)) # Adapting the comments model comments_schema = CommentsExtension.instance._adapt_comments_schema( comment_model) if user.anonymous \ and getattr(CommentsExtension.instance, "captcha_enabled", False): comments_schema.add_member(ReCaptcha("captcha")) # Insert a new comment if cherrypy.request.method == "POST" \ and "post_comment" in cherrypy.request.params: with changeset_context(user): get_parameter(comments_schema, target=comment_data, errors="ignore") comment_errors = schema.ErrorList( comments_schema.get_errors(comment_data)) if not comment_errors: comment = comment_model() adapter = CommentsExtension.instance._create_comments_adapter( comment_model) adapter.import_object( comment_data, comment, source_schema=comments_schema, target_schema=comment_model) comment.publishable = publishable user.require_permission(CreatePermission, target=comment) comment.insert() datastore.commit() CommentsExtension.instance._after_process_comments( comment) else: comment_errors = schema.ErrorList([]) # Update the output controller.output.update( comments_user_collection=comments_user_collection, comments_schema=comments_schema, comment_errors=comment_errors, comment_data=comment_data) self.install()
""" .. moduleauthor:: Martí Congost <*****@*****.**> """ from cocktail.translations import translations from cocktail import schema from woost.models import Publishable, URI translations.load_bundle("woost.extensions.staticpub.publishable") Publishable.add_member( schema.Boolean( "x_staticpub_exportable", required=True, default=True, indexed=True, affects_cache_invalidation=False, listed_by_default=False, member_group="publication", shadows_attribute=True ) ) URI.default_x_staticpub_exportable = False
from cocktail import schema from cocktail.iteration import first from cocktail.translations import translations from cocktail.html.datadisplay import display_factory from woost.models import Publishable, Document, News, File from woost.extensions.opengraph.opengraphtype import OpenGraphType from woost.extensions.opengraph.utils import export_content File.default_open_graph_enabled = False File.default_open_graph_type = None Publishable.members_order += ["open_graph_enabled", "open_graph_type"] Publishable.add_member( schema.Boolean("open_graph_enabled", required=True, default=True, listed_by_default=False, member_group="meta.open_graph")) Publishable.add_member( schema.Reference("open_graph_type", type=OpenGraphType, required=Publishable["open_graph_enabled"], related_end=schema.Collection(block_delete=True), default=schema.DynamicDefault( lambda: OpenGraphType.get_instance(code="article")), indexed=True, listed_by_default=False, member_group="meta.open_graph", edit_control=display_factory( "cocktail.html.DropdownSelector",
u""" .. moduleauthor:: Martí Congost <*****@*****.**> """ from cocktail.modeling import extend, call_base from cocktail.translations import translations from cocktail import schema from cocktail.html.datadisplay import display_factory from woost.models import Publishable Publishable.add_member( schema.Reference( "access_restriction", type="woost.extensions.restrictedaccess.accessrestriction." "AccessRestriction", bidirectional=True, indexed=True, edit_control=display_factory("cocktail.html.RadioSelector", empty_option_displayed=True), search_control="cocktail.html.DropdownSelector", member_group="publication")) @extend(Publishable.access_restriction) def translate_value(self, value, language=None, **kwargs): if not value: return translations("Publishable.access_restriction=None", language, **kwargs) return call_base(value, language, **kwargs)