def view(self): # Get LDAP settings ldap_settings = self.request.db.ldap.find_one() if ldap_settings is None: ldap_settings = dict() # Generate form from phoenix.settings.schema import LdapSchema ldap_form = Form(schema=LdapSchema().bind(request=self.request), buttons=('submit',), formid='deform') if 'submit' in self.request.params: check_csrf_token(self.request) try: # Validate form appstruct = ldap_form.validate(list(self.request.params.items())) except ValidationFailure as e: LOGGER.exception('Validation failed!') return dict(title='LDAP Settings', form=e.render()) else: # Update LDAP settings ldap_settings['server'] = appstruct['server'] ldap_settings['use_tls'] = appstruct['use_tls'] ldap_settings['bind'] = appstruct['bind'] ldap_settings['passwd'] = appstruct['passwd'] ldap_settings['base_dn'] = appstruct['base_dn'] ldap_settings['filter_tmpl'] = appstruct['filter_tmpl'] ldap_settings['scope'] = appstruct['scope'] # Optional: ldap_settings['name'] = appstruct['name'] ldap_settings['email'] = appstruct['email'] self.request.db.ldap.save(ldap_settings) import ldap if ldap_settings['scope'] == 'ONELEVEL': ldap_scope = ldap.SCOPE_ONELEVEL else: ldap_scope = ldap.SCOPE_SUBTREE from pyramid.config import Configurator config = Configurator(registry=self.request.registry) config.ldap_setup( ldap_settings['server'], bind=ldap_settings['bind'], passwd=ldap_settings['passwd'], use_tls=ldap_settings['use_tls']) config.ldap_set_login_query( base_dn=ldap_settings['base_dn'], filter_tmpl=ldap_settings['filter_tmpl'], scope=ldap_scope) config.commit() self.session.flash('Successfully updated LDAP settings!', queue='success') # Display form return dict(title='LDAP Settings', form=ldap_form.render(ldap_settings))
def view(self): # Get LDAP settings ldap_settings = self.request.db.ldap.find_one() if ldap_settings is None: ldap_settings = dict() # Generate form from phoenix.settings.schema import LdapSchema ldap_form = Form(schema=LdapSchema().bind(request=self.request), buttons=('submit',), formid='deform') if 'submit' in self.request.params: check_csrf_token(self.request) try: # Validate form appstruct = ldap_form.validate(list(self.request.params.items())) except ValidationFailure as e: LOGGER.exception('Validation failed!') return dict(title='LDAP Settings', form=e.render()) else: # Update LDAP settings ldap_settings['server'] = appstruct['server'] ldap_settings['use_tls'] = appstruct['use_tls'] ldap_settings['bind'] = appstruct['bind'] ldap_settings['passwd'] = appstruct['passwd'] ldap_settings['base_dn'] = appstruct['base_dn'] ldap_settings['filter_tmpl'] = appstruct['filter_tmpl'] ldap_settings['scope'] = appstruct['scope'] # Optional: ldap_settings['name'] = appstruct['name'] ldap_settings['email'] = appstruct['email'] self.request.db.ldap.save(ldap_settings) import ldap if ldap_settings['scope'] == 'ONELEVEL': ldap_scope = ldap.SCOPE_ONELEVEL else: ldap_scope = ldap.SCOPE_SUBTREE from pyramid.config import Configurator config = Configurator(registry=self.request.registry) config.ldap_setup( ldap_settings['server'], bind=ldap_settings['bind'], passwd=ldap_settings['passwd'], use_tls=ldap_settings['use_tls']) config.ldap_set_login_query( base_dn=ldap_settings['base_dn'], filter_tmpl=ldap_settings['filter_tmpl'], scope=ldap_scope) config.commit() self.session.flash('Successfully updated LDAP settings!', queue='success') # Display form return dict(title='LDAP Settings', form=ldap_form.render(ldap_settings))
def view(self): form = self.generate_form() if 'submit' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) if not has_execute_permission(self.request, self.service_name): msg = """<strong>Warning:</strong> You are not allowed to run this process. Please <a href="{0}" class="alert-link">sign in</a> and wait for account activation.""" msg = msg.format(self.request.route_path('sign_in')) self.session.flash(msg, queue='warning') return dict(process=self.process, url=wps_describe_url(self.wps.url, self.processid), form=form.render(self.appstruct()))
def view(self): form = self.generate_form() if 'update' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(user_name=self.user.get('name', 'Guest'), title=self.panel_title(), buttons=self.generate_buttons(), userid=self.userid, active=self.tab, form=form.render(self.appstruct(), readonly=self.readonly()))
def view(self): form = self.generate_form() if 'update' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(user_name=self.user.get('name', 'Guest'), title=self.panel_title(), buttons=self.generate_buttons(), userid=self.userid, active=self.tab, form=form.render(self.appstruct(), readonly=self.readonly()))
def view(self): if self.request.registry.settings.get("phoenix.local_user_management", "true").lower() != "true": return HTTPNotFound() form = self.generate_form() if 'update' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(user_name=self.user.get('name', 'Guest'), title=self.panel_title(), buttons=self.generate_buttons(), userid=self.userid, active=self.tab, form=form.render(self.appstruct(), readonly=self.readonly()))
def view(self): form = self.generate_form() if 'submit' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) if not self.has_execute_permission(): if self.request.user is not None: msg = """<strong>Warning:</strong> You are not allowed to run this process as you do not have access to the datasets. Please contact the CEDA Helpdesk for more information about applying for access to the required resources. Include a copy of the URL above to indicate which resources you are trying to access.""" else: msg = """<strong>Warning:</strong> You are not allowed to run this process. Please <a href="{0}" class="alert-link">sign in</a> and wait for account activation.""" msg = msg.format(self.request.route_path('sign_in')) self.session.flash(msg, queue='warning') return dict( process=self.process, url=wps_describe_url(self.wps.url, self.processid), form=form.render(self.appstruct()))
def view(self): form = self.generate_form() if 'submit' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) if not has_execute_permission(self.request, self.service_name): msg = """<strong>Warning:</strong> You are not allowed to run this process. Please <a href="{0}" class="alert-link">sign in</a> and wait for account activation.""" msg = msg.format(self.request.route_path('sign_in')) self.session.flash(msg, queue='warning') elif not self.request.cert_ok: msg = """<strong>Warning:</strong> You are not allowed to access ESGF data. Please <a href="{0}" class="alert-link">update</a> your ESGF credentials.""" callback = self.request.current_route_path() self.session.flash(msg.format( self.request.route_path('esgflogon', _query=[('callback', callback)])), queue='warning') return dict(process=self.process, url=wps_describe_url(self.wps.url, self.processid), form=form.render(self.appstruct()))
def view(self): form = self.generate_form() if 'previous' in self.request.POST: check_csrf_token(self.request) return self.process_form(form, 'previous') elif 'next' in self.request.POST: check_csrf_token(self.request) return self.process_form(form, 'next') elif 'cancel' in self.request.POST: check_csrf_token(self.request) return self.cancel() result = dict(title=self.title, form=form.render(self.appstruct())) custom = self.custom_view() return dict(result, **custom)
def login(self): form = self.generate_form() if 'submit' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(form=form.render())
def view(self): form = self.generate_form() if 'register' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(title=self.title, form=form.render())
def view(self): form = self.generate_form() if 'submit' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(title=self.title, form=form.render(self.appstruct()))
def view(self): form = self.generate_form() if 'register' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(title=self.title, form=form.render())
def login(self): form = self.generate_form() if 'submit' in self.request.POST: check_csrf_token(self.request) return self.process_form(form) return dict(form=form.render())