コード例 #1
0
def remove_term():
    p_id    = request.forms.remove_id
    if p_id:
        db.init()
        db.pw.DeleteQuery(db.Alert).where(id=p_id).execute()
        return dict(alert='Alert removed.', type='success')
    return dict(alert='Oops, something did not work.', type='error')
コード例 #2
0
def alert_terms(database='alerts'):
    ret = {}
    db.init(database)
    terms = db.Alert.select()
    for term in terms:
        ret.update(term.term_dict())
    return ret
コード例 #3
0
def add_term():
    p_term    = request.forms.term
    p_email   = request.forms.email
    p_wait    = request.forms.wait #todo: not implemented

    if p_term and p_email and p_wait:
        db.init()
        new_alert = db.Alert(email=p_email, term=p_term, wait=p_wait)
        new_alert.save()
        return dict(alert='Worked! Added an alert for "' + p_term + '"', type='success')
    return dict(alert='Missed something', type='error')
コード例 #4
0
def select_by_email(r_email, database='alerts'):
    ret = {}
    db.init(database)
    alerts = db.Alert.select().where(email=r_email)
    for alert in alerts:
        ret.update({
                str(alert.term):
                    {'email': str(alert.email),
                    'wait': str(alert.wait),
                    'id': str(alert.id),}
            })
    return ret