예제 #1
0
 def publish(self, publishers=[], accounts={}):
     obj = self.context
     selected_publishers = self.request.get('publishers', publishers)
     if not selected_publishers:
         msg = _(u"Select at list one publisher!")
         self.update_message(msg, type="error")
         return
     published = {}
     self._update_settings(publishers=publishers, accounts=accounts)
     content = self.get_content()
     manager = IPublishStorageManager(obj)
     if manager.get_text() and not self.request.get('one_shot_text'):
         content = manager.get_text()
     published['content'] = content
     selected_accounts = self.request.get('accounts', accounts)
     for pub in selected_publishers:
         account_id = selected_accounts.get(pub)
         self._publish(content, pub, account_id)
         published[pub] = account_id
     msg = _(u'content_published',
             default=u"Content published on ${published_on}",
             mapping={'published_on': ', '.join(selected_publishers)})
     translated = self.context.translate(msg)
     self.update_message(translated)
     return published
 def publish(self, publishers=[], accounts={}):
     obj = self.context
     selected_publishers = self.request.get('publishers', publishers)
     if not selected_publishers:
         msg = _(u"Select at list one publisher!")
         self.update_message(msg, type="error")
         return
     published = {}
     self._update_settings(publishers=publishers, accounts=accounts)
     content = self.get_content()
     manager = IPublishStorageManager(obj)
     if manager.get_text() and not self.request.get('one_shot_text'):
         content = manager.get_text()
     published['content'] = content
     selected_accounts = self.request.get('accounts', accounts)
     for pub in selected_publishers:
         account_id = selected_accounts.get(pub)
         self._publish(content, pub, account_id)
         published[pub] = account_id
     msg = _(u'content_published',
             default=u"Content published on ${published_on}",
             mapping={'published_on': ', '.join(selected_publishers)})
     translated = self.context.translate(msg)
     self.update_message(translated)
     return published
예제 #3
0
class ControlPanelForm(RegistryEditForm):
    schema = IGlobalSettings
    label = _("Social publisher global settings")

    def applyChanges(self, data):
        super(ControlPanelForm, self).applyChanges(data)
        pass
예제 #4
0
 def handle_autopublish(self):
     form = self.request.form
     obj = self.context
     changed = False
     if form.get('enable'):
         if not IAutoPublishable.providedBy(obj):
             alsoProvides(obj, IAutoPublishable)
             msg = _('Auto-publish enabled')
             changed = True
     else:
         if IAutoPublishable.providedBy(obj):
             noLongerProvides(obj, IAutoPublishable)
             msg = _('Auto-publish disabled')
             changed = True
     if changed:
         obj.reindexObject(idxs=['object_provides'])
         self.update_message(msg)
 def handle_autopublish(self):
     form = self.request.form
     obj = self.context
     changed = False
     if form.get('enable'):
         if not IAutoPublishable.providedBy(obj):
             alsoProvides(obj, IAutoPublishable)
             msg = _('Auto-publish enabled')
             changed = True
     else:
         if IAutoPublishable.providedBy(obj):
             noLongerProvides(obj, IAutoPublishable)
             msg = _('Auto-publish disabled')
             changed = True
     if changed:
         obj.reindexObject(idxs=['object_provides'])
         self.update_message(msg)
예제 #6
0
class IGlobalSettings(interface.Interface):
    """ global settings
    """

    autopublish_enabled = schema.Bool(
        title=_("Auto-publish enabled"),
        description=_(u"If disabled the cron will not publish anything."),
        default=False)


# XXX: this should be used to mark content type klasses on the fly
# but I can't find a clean way to do that since it seems there's no safe way
# to get the klass of the content type.

# enabled_content_types = schema.List(
#        title = _(u'Publishable content types'),
#        required = False,
#        default = [],
#        description = _(u"A list of types can be pusblished"),
#        value_type = schema.Choice(
#          title=_(u"Content types"),
#            source="plone.app.vocabularies.ReallyUserFriendlyTypes"
#            )
#        )
예제 #7
0
 def update_settings(self, publishers=[], accounts={}):
     self._update_settings(publishers=publishers, accounts=accounts)
     msg = _(u"Settings updated")
     self.update_message(msg)
 def update_settings(self, publishers=[], accounts={}):
     self._update_settings(publishers=publishers, accounts=accounts)
     msg = _(u"Settings updated")
     self.update_message(msg)