def twc_authorize(request): if 'AccountSid' in request.params: profile = request.user.get_profile(request) profile.twilio_sid = request.params['AccountSid'] DBSession.merge(profile) DBSession.flush() return HTTPFound(location=request.route_url('index'))
def update_mailbox_password(shelter_phone, mailbox_number, password): mailbox = DBSession.query(MailboxGreeting) \ .filter(MailboxGreeting.shelter_phone==shelter_phone) \ .filter(MailboxGreeting.mailbox==mailbox_number).first() mailbox.password = password DBSession.merge(mailbox) DBSession.commit() DBSession.flush()
def profile(request): record = DBSession.query(Shelter).filter(Shelter.auth_id==request.user.id).first() if record is None: record = Shelter(auth_id=request.user.id) form = ProfileForm(request.POST, obj=record) if request.method == 'POST' and form.validate(): record = merge_session_with_post(record, request.POST.items()) record.auth_id = request.user.id if record.id: DBSession.merge(record) else: DBSession.add(record) DBSession.flush() #raise HTTPFound(location=request.route_url('index')) raise HTTPFound(location=request.route_url('profile')) return {'form': form}