Example #1
0
    def update(self):
        super(AcknowledgementsCatalogView, self).update()

        request, context = self.request, self.context

        records = getUtility(IAcknowledgements).records.items()

        if 'form.button.export_csv' in request:
            banned = getUtility(IBanPrincipalConfiglet).banned
            try:
                self.result = self.generate_report(banned, records)
                IStatusMessage(request).add(
                    _(u'The report was successfully generated.'))
            except:
                IStatusMessage(request).add(
                    _(u'The report was not generated.'), 'error')

        self.batch = Batch(records, size=20, context=context, request=request)
Example #2
0
    def __call__(self):
        request = self.request
        excel = self.prepare()

        if excel:
            request.response.setHeader('Content-Type', 'text/csv')
            request.response.setHeader(
                'Content-Disposition',
                'attachment; filename=%s' % self.filename)
            return excel

        IStatusMessage(request).add(_("No results"))
        request.response.redirect(absoluteURL(self.context, request))
        return
Example #3
0
 def __call__(self):
     if not IUnauthenticatedPrincipal.providedBy(self.request.principal):
         self._redirectToRoot()
         return u''
     configlet = component.getUtility(IConfiglet, name="product.zojax-authentication-twitter")
     consumerKey = configlet.consumerKey
     consumerSecret = configlet.consumerSecret
     if not consumerKey or not consumerSecret:
         self._redirectToRoot()
         return u''
     twitter = oauthtwitter.OAuthApi(consumerKey, consumerSecret)
     try:
         requestToken = twitter.getRequestToken()
         session = ISession(self.request)[SESSION_KEY]
         session[REQUEST_TOKEN_KEY] = requestToken
         url = twitter.getSigninURL(requestToken)
     except (BadStatusLine, URLError):
         message = IStatusMessage(self.request)
         message.add(_(u"Can't connect to Twitter server. Try again later."), "error")
         self._redirectToRoot()
         return u''
     self.request.response.redirect(url)
     return u''
Example #4
0
    def update(self, *args, **kw):
        request = self.request
        context = self.context

        service = IStatusMessage(request)

        if request.has_key('install'):
            products = request.get('availproducts', ())
            if not products:
                service.add(_('Select one or more products to install.'), 'warning')
            else:
                try:
                    for product_id in products:
                        product = context.get(product_id)
                        product.install()

                    service.add(_('Selected products has been installed.'))
                except ProductWarningError, e:
                    abort()
                    service.add(unicode(e), 'warning')
                except Exception, e:
                    abort()
                    log_exc(str(e))
                    service.add(e, 'error')
    def applyChanges(self, action):
        service = IStatusMessage(self.request)

        data, errors = self.extractData()

        if errors:
            service.add(self.formErrorsMessage, 'error')
        elif data['password']:
            self.context.changePassword(data['password'])
            service.add(_('Password has been changed for ${title}.',
                          mapping = {'title': self.principal_title}))

            if not self.isManagement:
                if not updateCredentials(
                    self.request, self.principal_login, data['password']):
                    service.add(
                        _("Sorry, system can't update your creadential data. "\
                          "You should logout and login with new password."))