def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"), "info") self.request.response.redirect( "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
def __init__(self, context, request): self.context = context self.request = request self.forms = [] self.status = IStatusMessage(self.request)
class RegisterForm(form.EditForm): ''' Implementation of the registration form ''' fields = field.Fields(IRegisterFormSchema) id = 'RegisterForm' label = _(u'heading_register_form', default=u'Sign up') description = _(u'description_register_form', default=u'Join the club.') ignoreContext = True prefix = '' def updateWidgets(self): super(RegisterForm, self).updateWidgets(prefix='') portal_props = getToolByName(self.context, 'portal_properties') props = portal_props.site_properties use_email_as_login = props.getProperty('use_email_as_login') self.widgets['email'].tabindex = 1 self.widgets['email'].autocapitalize = 'off' self.widgets['email'].placeholder = _(u'placeholder_email', default=u'Email address') append_klasses(self.widgets['email'], 'stretch') if not use_email_as_login: self.widgets['email'].tabindex += 1 self.widgets['username'].tabindex = 1 self.widgets['username'].autocapitalize = _(u'off') self.widgets['username'].placeholder = _(u'placeholder_username', default=u'Username') append_klasses(self.widgets['username'], 'stretch') self.widgets['password'].tabindex = 3 self.widgets['password'].placeholder = _( u'placeholder_password', default=u'Super secure password') append_klasses(self.widgets['password'], 'stretch') self.widgets['password_confirm'].tabindex = 4 self.widgets['password_confirm'].placeholder = _( u'placeholder_password_confirm', default=u'Confirm password') append_klasses(self.widgets['password_confirm'], 'stretch') def updateFields(self): super(RegisterForm, self).updateFields() fields = field.Fields(IRegisterForm) portal_props = getToolByName(self.context, 'portal_properties') props = portal_props.site_properties use_email_as_login = props.getProperty('use_email_as_login') if use_email_as_login: fields.remove('username') @button.buttonAndHandler(_(u'button_register', default=u'Register'), name='register') def handleRegister(self, action): authenticator = getMultiAdapter((self.context, self.request), name=u'authenticator') if not authenticator.verify(): raise Unauthorized data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return password = str(data.get('password')) username = str(data.get('username')) email = data.get('email') portal_props = getToolByName(self.context, 'portal_properties') props = portal_props.site_properties use_email_as_login = props.getProperty('use_email_as_login') if use_email_as_login: username = email = str(data.get('email')) registration = getToolByName(self.context, 'portal_registration') try: registration.addMember(username, password) except (AttributeError, ValueError), err: IStatusMessage(self.request).addStatusMessage(err, type='error') return authenticated = self.context.acl_users.authenticate( username, password, self.request) if authenticated: self.context.acl_users.updateCredentials(self.request, self.request.response, username, password) membership_tool = getToolByName(self.context, 'portal_membership') member = membership_tool.getMemberById(username) # XXX: Improve this for further fields member.setMemberProperties({'email': email}) login_time = member.getProperty('login_time', '2000/01/01') if not isinstance(login_time, DateTime): login_time = DateTime(login_time) initial_login = login_time == DateTime('2000/01/01') if initial_login: # TODO: Redirect if this is initial login pass IStatusMessage(self.request).addStatusMessage( _(u'statusmessage_your_now_logged_in', default=u'You are now ' u'logged in.'), 'info') # TODO: Add way to configure the redirect self.request.response.redirect(self.context.absolute_url())
def __call__(self): request = self.context.REQUEST message = _(self.element.message) message_type = self.element.message_type IStatusMessage(request).addStatusMessage(message, type=message_type) return True
def register_subscriber(self): """ """ props = getToolByName(self, "portal_properties").site_properties charset = props.getProperty("default_charset") subscriber = self.request.get("subscriber") fullname = self.request.get("fullname", "") salutation = self.request.get("salutation", "") organization = self.request.get("organization", "") path_to_easynewsletter = self.request.get("newsletter") # remove leading slash from paths like: /mynewsletter path_to_easynewsletter = path_to_easynewsletter.strip('/') newsletter_container = self.portal.restrictedTraverse( path_to_easynewsletter) messages = IStatusMessage(self.request) if not subscriber: messages.addStatusMessage(_("Please enter a valid email address."), "error") return self.request.response.redirect( newsletter_container.absolute_url()) from Products.validation.validators.BaseValidators import EMAIL_RE EMAIL_RE = "^" + EMAIL_RE mo = re.search(EMAIL_RE, subscriber) if not mo: messages.addStatusMessage(_("Please enter a valid email address."), "error") return self.request.response.redirect( newsletter_container.absolute_url()) norm = queryUtility(IIDNormalizer) normalized_subscriber = norm.normalize(subscriber) if normalized_subscriber in newsletter_container.objectIds(): messages.addStatusMessage( _("Your email address is already registered."), "error") return self.request.response.redirect( newsletter_container.absolute_url()) subscriber_data = {} subscriber_data["subscriber"] = subscriber subscriber_data["fullname"] = fullname subscriber_data["salutation"] = salutation subscriber_data["organization"] = organization subscriber_data["path_to_easynewsletter"] = path_to_easynewsletter # use password reset tool to create a hash pwr_data = self._requestReset(subscriber) hashkey = pwr_data['randomstring'] enl_registration_tool = queryUtility(IENLRegistrationTool, 'enl_registration_tool') if hashkey not in enl_registration_tool.objectIds(): enl_registration_tool[hashkey] = RegistrationData( hashkey, **subscriber_data) msg_subject = newsletter_container.getRawSubscriber_confirmation_mail_subject( ).replace("${portal_url}", self.portal_url.strip('http://')) confirmation_url = self.portal_url + '/confirm-subscriber?hkey=' + str( hashkey) msg_text = newsletter_container.getRawSubscriber_confirmation_mail_text( ).replace("${newsletter_title}", newsletter_container.Title()) msg_text = msg_text.replace("${subscriber_email}", subscriber) msg_text = msg_text.replace("${confirmation_url}", confirmation_url) msg_sender = self.portal.getProperty('email_from_address') msg_receiver = subscriber msg = MIMEText(msg_text, "plain", charset) msg['To'] = msg_receiver msg['From'] = msg_sender msg['Subject'] = msg_subject #msg.epilogue = '' self.portal.MailHost.send(msg.as_string()) messages.addStatusMessage( _("Your email has been registered. \ A confirmation email was sent to your address. Please check \ your inbox and click on the link in the email in order to \ confirm your subscription."), "info") self.request.response.redirect(newsletter_container.absolute_url())
def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage(_(u"Changes canceled."), "info") self.request.response.redirect("@@overview-controlpanel")
def nextURL(self): IStatusMessage(self.request).addStatusMessage(self.status, type='info') return "%s/%s" % (self.getContent().absolute_url(), '@@token_manage')
def processSave(self): form = self.request.form # Form data enabled = form.get('enabled', False) contentTypesMap = form.get('contenttypes', {}) templatesMap = form.get('templates', {}) operations = form.get('operations', {}) purgingEnabled = form.get('purgingEnabled', False) cachingProxies = tuple(form.get('cachingProxies', ())) purgedContentTypes = tuple(form.get('purgedContentTypes', ())) virtualHosting = form.get('virtualHosting', False) domains = tuple(form.get('domains', ())) ramCacheMaxEntries = form.get('ramCacheMaxEntries', None) ramCacheMaxAge = form.get('ramCacheMaxAge', None) ramCacheCleanupInterval = form.get('ramCacheCleanupInterval', None) # Settings operationMapping = {} contentTypeRulesetMapping = {} templateRulesetMapping = {} # Process mappings and validate for ruleset, operation in operations.items(): if not ruleset or not operation: continue if isinstance(ruleset, six.text_type): # should be ASCII ruleset = ruleset.encode('utf-8') if isinstance(operation, six.text_type): # should be ASCII operation = operation.encode('utf-8') ruleset = ruleset.replace('-', '.') operationMapping[ruleset] = operation for ruleset, contentTypes in contentTypesMap.items(): if not ruleset: continue if isinstance(ruleset, six.text_type): # should be ASCII ruleset = ruleset.encode('utf-8') ruleset = ruleset.replace('-', '.') for contentType in contentTypes: if not contentType: continue if isinstance(contentType, six.text_type): # should be ASCII contentType = contentType.encode('utf-8') if contentType in contentTypeRulesetMapping: self.errors.setdefault( 'contenttypes', {}, )[ruleset] = _( u'Content type ${contentType} is already mapped to ' u'the rule ${ruleset}.', mapping={ 'contentType': self.contentTypesLookup.get( contentType, {}, ).get( 'title', contentType, ), 'ruleset': contentTypeRulesetMapping[contentType], }, ) else: contentTypeRulesetMapping[contentType] = ruleset for ruleset, templates in templatesMap.items(): if not ruleset: continue if isinstance(ruleset, six.text_type): # should be ASCII ruleset = ruleset.encode('utf-8') ruleset = ruleset.replace('-', '.') for template in templates: template = template.strip() if not template: continue if isinstance(template, six.text_type): # should be ASCII template = template.encode('utf-8') if template in templateRulesetMapping: self.errors.setdefault( 'templates', {}, )[ruleset] = _( u'Template ${template} is already mapped to the rule ' u'${ruleset}.', mapping={ 'template': template, 'ruleset': templateRulesetMapping[template], }, ) else: templateRulesetMapping[template] = ruleset # Validate purging settings for cachingProxy in cachingProxies: if not _isuri(cachingProxy): self.errors['cachingProxies'] = _(u'Invalid URL: ${url}', mapping={'url': cachingProxy}) # noqa for domain in domains: if not _isuri(domain): self.errors['domain'] = _( u'Invalid URL: ${url}', mapping={'url': domain}, ) # RAM cache settings try: ramCacheMaxEntries = int(ramCacheMaxEntries) except (ValueError, TypeError,): self.errors['ramCacheMaxEntries'] = _(u'An integer is required.') else: if ramCacheMaxEntries < 0: self.errors['ramCacheMaxEntries'] = _( u'A positive number is required.', ) try: ramCacheMaxAge = int(ramCacheMaxAge) except (ValueError, TypeError,): self.errors['ramCacheMaxAge'] = _(u'An integer is required.') else: if ramCacheMaxAge < 0: self.errors['ramCacheMaxAge'] = _( u'A positive number is required.', ) try: ramCacheCleanupInterval = int(ramCacheCleanupInterval) except (ValueError, TypeError,): self.errors['ramCacheCleanupInterval'] = _( u'An integer is required.', ) else: if ramCacheMaxAge < 0: self.errors['ramCacheCleanupInterval'] = _( u'A positive number is required.', ) # Check for errors if self.errors: IStatusMessage(self.request).addStatusMessage( _(u'There were errors.'), 'error') return # Save settings self.settings.enabled = enabled self.settings.operationMapping = operationMapping self.ploneSettings.templateRulesetMapping = templateRulesetMapping self.ploneSettings.contentTypeRulesetMapping = contentTypeRulesetMapping # noqa self.ploneSettings.purgedContentTypes = purgedContentTypes self.purgingSettings.enabled = purgingEnabled self.purgingSettings.cachingProxies = cachingProxies self.purgingSettings.virtualHosting = virtualHosting self.purgingSettings.domains = domains self.ramCache.update( ramCacheMaxEntries, ramCacheMaxAge, ramCacheCleanupInterval, ) IStatusMessage(self.request).addStatusMessage( _(u'Changes saved.'), 'info', )
def processPurge(self): urls = self.request.form.get('urls', []) sync = self.request.form.get('synchronous', True) if not urls: self.errors['urls'] = _(u'No URLs or paths entered.') if self.errors: IStatusMessage(self.request).addStatusMessage( _(u'There were errors.'), 'error') return purger = getUtility(IPurger) serverURL = self.request['SERVER_URL'] def purge(url): if sync: status, xcache, xerror = purger.purgeSync(url) log = url if xcache: log += ' (X-Cache header: ' + xcache + ')' if xerror: log += ' -- ' + xerror if not str(status).startswith('2'): log += ' -- WARNING status ' + str(status) self.purgeLog.append(log) else: purger.purgeAsync(url) self.purgeLog.append(url) portal_url = getToolByName(self.context, 'portal_url') portal = portal_url.getPortalObject() portalPath = portal.getPhysicalPath() proxies = self.purgingSettings.cachingProxies for inputURL in urls: if not inputURL.startswith(serverURL): # not in the site if '://' in inputURL: # Full URL? purge(inputURL) else: # Path? for newURL in getURLsToPurge(inputURL, proxies): purge(newURL) continue physicalPath = relativePath = None try: physicalPath = self.request.physicalPathFromURL(inputURL) except ValueError: purge(inputURL) continue if not physicalPath: purge(inputURL) continue relativePath = physicalPath[len(portalPath):] if not relativePath: purge(inputURL) continue obj = portal.unrestrictedTraverse(relativePath, None) if obj is None: purge(inputURL) continue for path in getPathsToPurge(obj, self.request): for newURL in getURLsToPurge(path, proxies): purge(newURL)
def importData(self): """Import Data from CSV file. In case of error, return a CSV file filled with the lines where errors occured. """ file_upload = self.request.form.get('csv_upload', None) if file_upload is None or not file_upload.filename: return reader = csv.reader(file_upload) # import pdb # pdb.set_trace() header = reader.next() if header != data_VALUES: msg = _('Wrong specification of the CSV file. Please correct it and retry.') type = 'error' IStatusMessage(self.request).addStatusMessage(msg, type=type) return validLines = [] invalidLines = [] for line in reader: # datas = dict(zip(header, line)) validLines.append(line) usersNumber = 0 for line in validLines: # datas = dict(zip(header, line)) datas = dict(zip(data_PROPERTIES, line)) try: # 映射数据到纳税人字段 title = datas['title'] if not isinstance(title, unicode): name = unicode(title, 'utf-8') # id = IUserPreferredFileNameNormalizer(self.request).normalize(filename) id = datas['guanlidaima'] id = self.float2str(id,"E+") if self.IdIsExist(id):continue title = name guanlidaima = id dengjiriqi = datas.pop('dengjiriqi') if ' ' in dengjiriqi: dengjiriqi = dengjiriqi.split(' ')[0] # import pdb # pdb.set_trace() description = datas.pop('description') shuiguanyuan = datas['shuiguanyuan'] danganbianhao = "" # danganbianhao = datas.pop('danganbianhao') # danganbianhao = self.float2str(danganbianhao,"E+") # send a add nashuiren event try: event.notify(CreateNashuirenEvent( id,title,guanlidaima,dengjiriqi,description, shuiguanyuan,danganbianhao)) except (AttributeError, ValueError), err: logging.exception(err) IStatusMessage(self.request).addStatusMessage(err, type="error") return usersNumber += 1 except:
def register_subscriber(self): """ """ messages = IStatusMessage(self.request) path_to_easynewsletter = self.request.get("newsletter") # remove leading slash from paths like: /mynewsletter path_to_easynewsletter = path_to_easynewsletter.strip("/") newsletter_container = self.portal.unrestrictedTraverse( path_to_easynewsletter) subscriber = self.request.get("subscriber") try: valid_subscriber = validate_email(subscriber) except EmailNotValidError as e: messages.addStatusMessage( _("Please enter a valid email address.\n{0}".format(e)), "error") return self._msg_redirect(newsletter_container) lastname = self.request.get("name", "") firstname = self.request.get("firstname", "") name_prefix = self.request.get("name_prefix", "") portal_state = getMultiAdapter((self.context.aq_inner, self.request), name="plone_portal_state") current_language = portal_state.language() nl_language = self.request.get("nl_language", current_language) salutation = self.request.get("salutation", "") organization = self.request.get("organization", "") norm = queryUtility(IIDNormalizer) normalized_subscriber = norm.normalize(valid_subscriber.email) if normalized_subscriber in newsletter_container.objectIds(): messages.addStatusMessage( _("Your email address is already registered."), "error") return self._msg_redirect(newsletter_container) subscriber_data = {} subscriber_data["subscriber"] = valid_subscriber.email subscriber_data["lastname"] = lastname subscriber_data["firstname"] = firstname subscriber_data["name_prefix"] = name_prefix subscriber_data["nl_language"] = nl_language subscriber_data["salutation"] = salutation subscriber_data["organization"] = organization subscriber_data["path_to_easynewsletter"] = path_to_easynewsletter # use password reset tool to create a hash pwr_data = self._requestReset(subscriber_data["subscriber"]) hashkey = pwr_data["randomstring"] enl_registration_tool = queryUtility(IENLRegistrationTool, "enl_registration_tool") if hashkey not in enl_registration_tool.objectIds(): enl_registration_tool[hashkey] = RegistrationData( hashkey, **subscriber_data) msg_subject = (newsletter_container. subscriber_confirmation_mail_subject.replace( "${portal_url}", self.portal_url.strip("http://"))) confirmation_url = (self.portal_url + "/confirm-subscriber?hkey=" + str(hashkey)) confirmation_url = protect.utils.addTokenToUrl(confirmation_url) msg_text = newsletter_container.subscriber_confirmation_mail_text.replace( "${newsletter_title}", newsletter_container.title) msg_text = msg_text.replace("${subscriber_email}", subscriber_data["subscriber"]) msg_text = msg_text.replace("${confirmation_url}", confirmation_url) settings = get_portal_mail_settings() msg_sender = settings.email_from_address msg_receiver = subscriber msg = emails.Message( text=msg_text, subject=msg_subject, mail_from=msg_sender, mail_to=msg_receiver, ) self.portal.MailHost.send(msg.as_string()) messages.addStatusMessage( _("Your email has been registered. \ A confirmation email was sent to your address. Please check \ your inbox and click on the link in the email in order to \ confirm your subscription."), "info", ) return self._msg_redirect(newsletter_container)
return usersNumber += 1 except: invalidLines.append(line) print "Invalid line: %s" % line if invalidLines: datafile = self._createCSV(invalidLines) self.request['csverrors'] = True self.request.form['nashuiren_sheet_errors'] = datafile.getvalue() msg = _('Some errors occured. Please check your CSV syntax and retry.') type = 'error' else: msg, type = _('Data successfully imported.'), 'info' IStatusMessage(self.request).addStatusMessage(msg, type=type) self.request['users_results'] = usersNumber return self.index() def getCSVWithErrors(self): """Return a CSV file that contains lines witch failed.""" users_sheet_errors = self.request.form.get('nashuiren_sheet_errors', None) if users_sheet_errors is None: return # XXX return self._createRequest(users_sheet_errors, "nashuiren_sheet_errors.csv") def exportData(self,**kw): """Export Data within CSV file.""" datafile = self._createCSV(self._getDataInfos(**kw))
def __call__(self): form = self.request.form context = aq_inner(self.context) if not self.memship.checkPermission('Poi: Add Response', context): raise Unauthorized ts = getGlobalTranslationService() response_text = form.get('response', u'') new_response = Response(response_text) new_response.mimetype = self.mimetype new_response.type = self.determine_response_type(new_response) issue_has_changed = False transition = form.get('transition', u'') if transition and transition in self.available_transitions: wftool = getToolByName(context, 'portal_workflow') before = wftool.getInfoFor(context, 'review_state') before = wftool.getTitleForStateOnType(before, 'PoiIssue') wftool.doActionFor(context, transition) after = wftool.getInfoFor(context, 'review_state') after = wftool.getTitleForStateOnType(after, 'PoiIssue') new_response.add_change('review_state', _(u'Issue state'), before, after) issue_has_changed = True options = [ ('severity', _(u'Severity'), 'available_severities'), ('responsibleManager', _(u'Responsible manager'), 'available_managers'), ] # Changes that need to be applied to the issue (apart from # workflow changes that need to be handled separately). changes = {} for option, title, vocab in options: new = form.get(option, u'') if new and new in self.__getattribute__(vocab): current = self.__getattribute__(option) if current != new: changes[option] = new new_response.add_change(option, title, current, new) issue_has_changed = True #('targetRelease', 'Target release', 'available_releases'), new = form.get('targetRelease', u'') if new and new in self.available_releases: current = self.targetRelease if current != new: # from value (uid) to key (id) new_label = self.available_releases.getValue(new) current_label = self.available_releases.getValue(current) changes['targetRelease'] = new new_response.add_change(option, _(u'Target release'), current_label, new_label) issue_has_changed = True attachment = form.get('attachment') if attachment: # File(id, title, file) data = File(attachment.filename, attachment.filename, attachment) new_response.attachment = data issue_has_changed = True if len(response_text) == 0 and not issue_has_changed: status = IStatusMessage(self.request) ts = getGlobalTranslationService() msg = _(u"No response text added and no issue changes made.") msg = ts.translate('Poi', msg, context=context) status.addStatusMessage(msg, type='error') else: # Apply changes to issue context.update(**changes) # Add response self.folder.add(new_response) self.request.response.redirect(context.absolute_url())
def __delitem__(self, name): del self._mapping[name] IStatusMessage(self.request).addStatusMessage(_(u"Panel removed."), type="info")
def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage( _(u"Add New Item operation cancelled"), "info") self.request.response.redirect(self.nextURL())
def actionCancel(self, action, data): status = _(u'canceled') IStatusMessage(self.request).addStatusMessage(status, type='info') self.request.response.redirect(self.next_url)
def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"), "info") self.request.response.redirect(self.context.absolute_url())
def create_subscribers(self, csv_data=None): """Create newsletter subscribers from uploaded CSV file. """ # Do nothing if no submit button was hit if 'form.button.Import' not in self.request.form: return context = aq_inner(self.context) lang = context.Language() # plone_utils = getToolByName(self.context, 'plone_utils') # encoding = plone_utils.getSiteEncoding() existing = [] subscribers = api.content.find(context=self.context, portal_type='ENLSubscriber') for subscriber in subscribers: existing.append(subscriber.email.lower()) # messages = IStatusMessage(self.request) success = [] fail = [] # Show error if no file was specified filename = self.request.form.get('csv_upload', None) if not filename: msg = _('No file specified.') IStatusMessage(self.request).addStatusMessage(msg, type='error') return self.request.response.redirect( context.absolute_url() + '/@@upload_csv') # Show error if no data has been provided in the file reader = UnicodeReader(filename) header = reader.next() if header != [x for x in CSV_HEADER]: logger.info("Got header %s\n Expected:%s" % ( header, CSV_HEADER)) msg = _( 'Wrong specification of the CSV file. ' + 'Please correct it and retry.') IStatusMessage(self.request).addStatusMessage(msg, type='error') return self.request.response.redirect( context.absolute_url() + '/@@upload_csv') for subscriber in reader: # Check the length of the line if len(subscriber) != 7: msg = _('The number of items in the line is not correct. \ It should be 7. Check your CSV file.') fail.append( {'failure': msg}) else: salutation = subscriber[0] name_prefix = subscriber[1] firstname = subscriber[2] lastname = subscriber[3] nl_language = subscriber[4] email = subscriber[5].lower() organization = subscriber[6] id = normalize_id(email) if email in existing: # If subscriber with email exists, update user info sub = api.content.find(context=self.context, email=email) if len(sub) > 1: msg = _('More than one subscriber with this email ' 'address existed, subscriber info was NOT ' 'updated. Check manually!') fail.append( {'salutation': salutation, 'name_prefix': name_prefix, 'firstname': firstname, 'lastname': lastname, 'nl_language': nl_language, 'email': email, 'organization': organization, 'failure': msg}) else: sub = sub[0].getObject() sub.email = email sub.name_prefix = name_prefix sub.firstname = firstname sub.lastname = lastname sub.nl_language = nl_language sub.organization = organization sub.salutation = salutation sub.title = email + " - " + ' '.join([lastname, firstname]) sub.reindexObject() msg = _('Email existed, updated subscriber.') success.append( {'salutation': salutation, 'name_prefix': name_prefix, 'firstname': firstname, 'lastname': lastname, 'nl_language': nl_language, 'email': email, 'organization': organization, 'success': msg}) else: # If it doesn't exist, create subscriber title = email + " - " + ' '.join([lastname, firstname]) try: self.context.invokeFactory( 'ENLSubscriber', id=id, title=title, description="", language=lang) sub = context[id] sub.email = email sub.name_prefix = name_prefix sub.firstname = firstname sub.lastname = lastname sub.nl_language = nl_language sub.organization = organization sub.salutation = salutation sub.reindexObject() # update existing existing.append(email) msg = _('Subscriber created.') success.append({ 'salutation': salutation, 'name_prefix': name_prefix, 'firstname': firstname, 'lastname': lastname, 'nl_language': nl_language, 'email': email, 'organization': organization, 'success': msg}) except Exception, e: fail.append({ 'salutation': salutation, 'name_prefix': name_prefix, 'firstname': firstname, 'lastname': lastname, 'nl_language': nl_language, 'email': email, 'organization': organization, 'failure': ( 'An error occured while creating ' + 'this subscriber: %s') % str(e)})
def redirectMessager(self, message=u"Blank", intype="Info", location=""): IStatusMessage(self.request).addStatusMessage(_(message), type=intype) self.request.response.redirect(location) return ''
def message(self, mensagem): messages = IStatusMessage(self.request) messages.add(mensagem, type='info') return
def handle_continue(self, action): data, errors = self.extractData() if not errors: oguid = ISuccessorTaskController(self.context).get_oguid() # set forwarding flag if self.context.task_type == 'forwarding_task_type': is_forwarding = True else: is_forwarding = False dm = getUtility(IWizardDataStorage) dmkey = 'accept:%s' % oguid dm.set(dmkey, u'is_forwarding', is_forwarding) dm.set(dmkey, u'is_only_assign', False) dm.update(dmkey, data) method = data.get('method') if method == 'participate': accept_task_with_response(self.context, data['text']) IStatusMessage(self.request).addStatusMessage( _(u'The task has been accepted.'), 'info') return self.request.response.redirect( self.context.absolute_url()) elif method == 'forwarding_participate': """only store the forwarding in the inbox and create a successor forwrding""" info = getUtility(IContactInformation) client = info.get_client_by_id(self.context.responsible_client) # push session data to target client dm.push_to_remote_client(dmkey, client.client_id) url = '%s/@@accept_store_in_inbox?oguid=%s' % ( client.public_url, oguid) return self.request.RESPONSE.redirect(url) elif method == 'existing_dossier': info = getUtility(IContactInformation) client = info.get_client_by_id(self.context.responsible_client) # push session data to target client dm.push_to_remote_client(dmkey, client.client_id) url = '%s/@@accept_choose_dossier?oguid=%s' % ( client.public_url, oguid) return self.request.RESPONSE.redirect(url) elif method == 'new_dossier': info = getUtility(IContactInformation) client = info.get_client_by_id(self.context.responsible_client) oguid = ISuccessorTaskController(self.context).get_oguid() # push session data to target client dm.push_to_remote_client(dmkey, client.client_id) url = '/'.join( (client.public_url, '@@accept_select_repositoryfolder?oguid=%s' % oguid)) return self.request.RESPONSE.redirect(url)
def update(self): if not self._show_create(): IStatusMessage(self.request).addStatusMessage( _(u'Cannot initialize zoom.it on unpublished images')) super(ZoomItUpdater, self).update() self.info = IZoomItInfo(self.context)
def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage( _(u"Edit cancelled"), "info" ) self.request.response.redirect(self.nextURL()) notify(EditCancelledEvent(self.context))
def redirect(self, message): IStatusMessage(self.request).add(message) self.request.response.redirect("{0:s}/@@theming-controlpanel".format( self.portalUrl))