Esempio n. 1
0
def update_mailbox(shelter_phone, mailbox_number, url):
    mailbox = DBSession.query(MailboxGreeting) \
        .filter(MailboxGreeting.shelter_phone==shelter_phone) \
        .filter(MailboxGreeting.mailbox==mailbox_number).first() 
    mailbox.url = url
    DBSession.merge(mailbox)
    DBSession.commit()
Esempio n. 2
0
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'))
Esempio n. 3
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
Esempio n. 4
0
def admin(request):
    message_count = DBSession.query(MailboxContent, func.count(MailboxContent.mailbox)).group_by(MailboxContent.mailbox).all()
    old_messages = DBSession.query(MailboxContent).filter(MailboxContent.timestamp <= '2014-02-06 00:00:00').group_by(MailboxContent.mailbox).all()

    if request.method == 'POST': 
        if 'email' in request.POST:
            send_mail('Admin Report', None, request.POST['email'])
            return HTTPFound(location=request.route_url('admin'))
        else:
            return HTTPFound(location=request.route_url('admin'))

    return {'message_count': message_count, 'old_messages': old_messages}
Esempio n. 5
0
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()
Esempio n. 6
0
def admin(request):
    message_count = (
        DBSession.query(MailboxContent, func.count(MailboxContent.mailbox)).group_by(MailboxContent.mailbox).all()
    )
    old_messages = (
        DBSession.query(MailboxContent)
        .filter(MailboxContent.timestamp <= "2014-02-06 00:00:00")
        .group_by(MailboxContent.mailbox)
        .all()
    )

    if request.method == "POST":
        if "email" in request.POST:
            send_mail("Admin Report", None, request.POST["email"])
            return HTTPFound(location=request.route_url("admin"))
        else:
            return HTTPFound(location=request.route_url("admin"))

    return {"message_count": message_count, "old_messages": old_messages}
Esempio n. 7
0
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}
Esempio n. 8
0
def create_mailbox(shelter_phone, mailbox_number):
    print 'creating mailbox', mailbox_number
    mailbox = MailboxGreeting(shelter_phone=shelter_phone,
        mailbox=mailbox_number)
    DBSession.add(mailbox)
    DBSession.commit()
Esempio n. 9
0
def get_mailbox_url(shelter_phone, mailbox_number):
    return DBSession.query(MailboxGreeting) \
        .filter(MailboxGreeting.shelter_phone==shelter_phone) \
        .filter(MailboxGreeting.mailbox==mailbox_number).first() 
Esempio n. 10
0
def index(request):
    shelters = DBSession.query(Shelter).all()
    return {'shelters': shelters}