Ejemplo n.º 1
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}
Ejemplo n.º 2
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()
Ejemplo n.º 3
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()
Ejemplo 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}
Ejemplo n.º 5
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}
Ejemplo n.º 6
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() 
Ejemplo n.º 7
0
def index(request):
    shelters = DBSession.query(Shelter).all()
    return {'shelters': shelters}