def update(self): 'Show account update page' # Render person = Session.query(model.Person).options(orm.eagerload(model.Person.sms_addresses)).get(h.getPersonID()) c.isNew = False c.smsAddresses = person.sms_addresses # Return return formencode.htmlfill.render(render('/people/change.mako'), { 'username': person.username, 'nickname': person.nickname, 'email': person.email, 'key': person.key, })
def update(self): 'Show account update page' # Render person = Session.query(model.Person).options( orm.eagerload(model.Person.sms_addresses)).get(h.getPersonID()) c.isNew = False c.smsAddresses = person.sms_addresses # Return return formencode.htmlfill.render( render('/people/change.mako'), { 'username': person.username, 'nickname': person.nickname, 'email': person.email, 'key': person.key, })
def index(self, responseFormat='html'): 'Get tags with visible features' # Get responseFormat responseFormat = responseFormat.lower() if responseFormat not in ['json', 'html']: abort(400, 'Must specify a valid responseFormat: json, html') # Authenticate via personID or key personID = h.getPersonIDViaKey() # Get tags with visible features c.tags = Session.query(model.Tag).join(model.Tag.features).filter(model.getFeatureFilter(personID)).all() # If the user wants json, if responseFormat == 'json': return '\n'.join(sorted(x.text for x in c.tags)) # If the user wants html, elif responseFormat == 'html': return render('/tags/index.mako')
def index(self, responseFormat='html'): 'Get tags with visible features' # Get responseFormat responseFormat = responseFormat.lower() if responseFormat not in ['json', 'html']: abort(400, 'Must specify a valid responseFormat: json, html') # Authenticate via personID or key personID = h.getPersonIDViaKey() # Get tags with visible features c.tags = Session.query(model.Tag).join(model.Tag.features).filter( model.getFeatureFilter(personID)).all() # If the user wants json, if responseFormat == 'json': return '\n'.join(sorted(x.text for x in c.tags)) # If the user wants html, elif responseFormat == 'html': return render('/tags/index.mako')
def register(self): 'Show account registration page' c.isNew = True return render('/people/change.mako')
def index(self): 'Show information about people registered in the database' c.people = Session.query(model.Person).all() return render('/people/index.mako')
def login(self): 'Show login form' c.url = request.GET.get('url', '/') c.messageCode = request.GET.get('messageCode') c.recaptchaPublicKey = config.get('recaptcha.public', '') return render('/people/login.mako')
except formencode.Invalid, error: return dict(isOk=0, errorByID=error.unpack_errors()) # Prepare candidate candidate = model.PersonCandidate(form['username'], model.hashString(form['password']), form['nickname'], form['email']) candidate.person_id = person.id if person else None candidate.ticket = store.makeRandomUniqueTicket(parameter.TICKET_LENGTH, Session.query(model.PersonCandidate)) candidate.when_expired = datetime.datetime.utcnow() + datetime.timedelta(days=parameter.TICKET_LIFESPAN_IN_DAYS) Session.add(candidate) Session.commit() # Send confirmation toByValue = dict(nickname=form['nickname'], email=form['email']) subject = '[%s] Confirm %s' % (parameter.SITE_NAME, action) c.candidate = candidate c.username = form['username'] c.action = action body = render('/people/confirm.mako') try: smtp.sendMessage(dict(email=config['error_email_from'], smtp=config['smtp_server'], username=config.get('smtp_username', ''), password=config.get('smtp_password', ''), nickname=parameter.SITE_NAME + ' Support'), toByValue, subject, body) except smtp.SMTPError: return dict(isOk=0, errorByID={'status': 'Unable to send confirmation; please try again later.'}) # Return return dict(isOk=1) def confirmPersonCandidate(ticket): 'Move changes from the PersonCandidate table into the Person table' # Load candidate = Session.query(model.PersonCandidate).filter(model.PersonCandidate.ticket==ticket).filter(model.PersonCandidate.when_expired>=datetime.datetime.utcnow()).first() # If the ticket exists, if candidate: # If the person exists, if candidate.person_id:
def polymaps(self): return render('/examples/polymaps.mako')
def openlayers(self): return render('/examples/openlayers.mako')
model.hashString(form['password']), form['nickname'], form['email']) candidate.person_id = person.id if person else None candidate.ticket = store.makeRandomUniqueTicket( parameter.TICKET_LENGTH, Session.query(model.PersonCandidate)) candidate.when_expired = datetime.datetime.utcnow() + datetime.timedelta( days=parameter.TICKET_LIFESPAN_IN_DAYS) Session.add(candidate) Session.commit() # Send confirmation toByValue = dict(nickname=form['nickname'], email=form['email']) subject = '[%s] Confirm %s' % (parameter.SITE_NAME, action) c.candidate = candidate c.username = form['username'] c.action = action body = render('/people/confirm.mako') try: smtp.sendMessage( dict(email=config['error_email_from'], smtp=config['smtp_server'], username=config.get('smtp_username', ''), password=config.get('smtp_password', ''), nickname=parameter.SITE_NAME + ' Support'), toByValue, subject, body) except smtp.SMTPError: return dict(isOk=0, errorByID={ 'status': 'Unable to send confirmation; please try again later.' }) # Return