コード例 #1
0
def get_client_data_by_page_num(page):
    page = int(page)
    items_per_page = 10
    offset = (page - 1) * items_per_page
    clients = local_client.objects(
        is_active=True).skip(offset).limit(items_per_page).all()

    client_list = []

    i = 0
    try:
        while i < 10:
            client_list.append(clients[i])
            i += 1

    except:
        None

    pag = {
        "data": client_list,
        "total": local_client.objects(is_active=True).count()
    }

    res = result(True, pag, None)
    return res.convert_to_json()
コード例 #2
0
def get_client_data():
    clients = local_client.objects(is_active=True)
    client_list = []
    for i in range(clients.count()):
        client_list.append(clients[i])
    res = result(True, client_list, None)
    return res.convert_to_json()
コード例 #3
0
def delete_client_data(id):
    found_client = local_client.objects(id=ObjectId(id)).first()

    if found_client != None:
        found_client.update(is_active=False)

        res = result(True, "success", None)
        return res.convert_to_json()
    else:
        res = result(False, None, "ID Error or People Not Found")
        return res.convert_to_json(), 400
コード例 #4
0
def update_client_data(id):
    found_client = local_client.objects(id=ObjectId(id)).first()
    if found_client != None:
        form = request.form
        found_client.update(name=form['name'],
                            phone=form['phone'],
                            address=form['address'],
                            email=form['email'])

        res = result(True, "success", None)
        return res.convert_to_json()
    else:
        res = result(False, None, "ID Error or People Not Found")
        return res.convert_to_json(), 400
コード例 #5
0
ファイル: contact.py プロジェクト: dsy401/NewPearlProject
def send_email_to_local_client():
    clients = local_client.objects(is_active=True)
    client_email_list = []
    for i in range(clients.count()):
        if clients[i]['email'] != "" or len(clients[i]['email']) >= 5:
            client_email_list.append(clients[i]['email'])

    form = request.form
    msg = Message(subject=form['subject'],
                  sender="*****@*****.**",
                  recipients=client_email_list,
                  html=render_template(
                      'common/mail_template/mail_to_client_template.html',
                      content=form['content']))

    Mail().send(msg)
    res = result(True, "Your email has been sent.", None)
    return res.convert_to_json()