def __call__(self): uid = self.context.UID if callable(uid): uid = uid() feed_path = "@@watcher-feed?uid=%s" % uid requester = getUtility(IBridgeRequest) try: response = requester("dashboard", "@@add-watcher-portlet", data={"path": feed_path}, silent=True) except MaintenanceError: IStatusMessage(self.request).addStatusMessage(MAINTENANCE_ERROR_MESSAGE, type="error") else: if response is None or response.code != 200: IStatusMessage(self.request).addStatusMessage( _(u"error_portlet_creation_failed", default=u"The dashboard portlet could not be created."), type="error", ) else: IStatusMessage(self.request).addStatusMessage( _(u"info_msg_portlet_created", default=u"A dashboard portlet was created."), type="info" ) referer = self.request.environ.get("HTTP_REFERER") if referer: self.request.RESPONSE.redirect(referer) else: state = getMultiAdapter((self.context, self.request), name="plone_context_state") self.request.RESPONSE.redirect(state.view_url())
def _create_favorite(self, title, url): data = {'title': title, 'url': url} requester = getUtility(IBridgeRequest) try: response = requester('dashboard', '@@add-favorite', data=data, silent=True) except MaintenanceError: IStatusMessage(self.request).addStatusMessage( MAINTENANCE_ERROR_MESSAGE, type='error') return False if response is None or response.code != 200: IStatusMessage(self.request).addStatusMessage( _(u'favorite_creation_failed', default=u'The favorite could not be created.'), type='error') return False else: IStatusMessage(self.request).addStatusMessage( _(u'info_favorite_created', default=u'${title} was added to your favorites.', mapping={'title': title.decode('utf-8')}), type='info') return True
def _create_favorite(self, title, url): data = {'title': title, 'url': url} requester = getUtility(IBridgeRequest) try: response = requester('dashboard', '@@add-favorite', data=data, silent=True) except MaintenanceError: IStatusMessage(self.request).addStatusMessage( MAINTENANCE_ERROR_MESSAGE, type='error') return False if response is None or response.code != 200: IStatusMessage(self.request).addStatusMessage(_( u'favorite_creation_failed', default=u'The favorite could not be created.'), type='error') return False else: IStatusMessage(self.request).addStatusMessage(_( u'info_favorite_created', default=u'${title} was added to your favorites.', mapping={'title': title.decode('utf-8')}), type='info') return True
class AddForm(base.AddForm): form_fields = form.Fields(IWatcherPortlet) label = _(u'title_watcher_portlet', default='Recently modified') def create(self, data): return Assignment(**data)
def __call__(self): uid = self.context.UID if callable(uid): uid = uid() feed_path = '@@watcher-feed?uid=%s' % uid requester = getUtility(IBridgeRequest) try: response = requester('dashboard', '@@add-watcher-portlet', data={'path': feed_path}, silent=True) except MaintenanceError: IStatusMessage(self.request).addStatusMessage( MAINTENANCE_ERROR_MESSAGE, type='error') else: if response is None or response.code != 200: IStatusMessage(self.request).addStatusMessage( _(u'error_portlet_creation_failed', default=u'The dashboard portlet could not be created.'), type='error') else: IStatusMessage(self.request).addStatusMessage( _(u'info_msg_portlet_created', default=u'A dashboard portlet was created.'), type='info') referer = self.request.environ.get('HTTP_REFERER') if referer: self.request.RESPONSE.redirect(referer) else: state = getMultiAdapter((self.context, self.request), name='plone_context_state') self.request.RESPONSE.redirect(state.view_url())
def title(self): return _(u'title_watcher_portlet', default='Recently modified')
# pylint: disable=E0211, E0213 # E0211: Method has no argument # E0213: Method should have "self" as first argument from ftw.bridge.client import _ from zope.interface import Interface PORTAL_URL_PLACEHOLDER = '***portal_url***' MAINTENANCE_ERROR_MESSAGE = _( u'error_msg_maintenance', default=u'The target service is currently in maintenace. Try again later.') class IBridgeConfig(Interface): """Utility providing bridge configuration infos. Configurable using environment variables: ``bridge_url`` -- Full url to the bridge /proxy view. ``bridge_ips`` -- A comma seperated string of allowed bridge IPs. ``bridge_client_id`` -- The id (string) of this client. """ def get_url(): """Returns the URL to the proxy view of the bridge, ending with a slash (/). """ def get_bridge_ips():