Esempio n. 1
0
def outs():
    user_id = int(request.values.get('user_id', 0))
    page = int(request.values.get('p', 1))
    status = int(request.values.get('status', 0))
    start = request.values.get('start', '')
    end = request.values.get('end', '')
    outs = [
        k for k in Out.all() if k.status > 0]

    if start and end:
        start_time = datetime.datetime.strptime(start, "%Y-%m-%d %H:%M")
        end_time = datetime.datetime.strptime(end, "%Y-%m-%d %H:%M")
        outs = [k for k in outs if k.start_time >=
                start_time and k.start_time < end_time]
    if status:
        outs = [k for k in outs if k.status == status]
    if user_id:
        outs = [k for k in outs if k.creator.id == user_id]
    outs = sorted(outs, key=lambda x: x.start_time, reverse=True)
    if request.values.get('action') == 'excel':
        return write_outs_excel(outs)
    paginator = Paginator(outs, 50)
    try:
        outs = paginator.page(page)
    except:
        outs = paginator.page(paginator.num_pages)
    return tpl('/account/out/outs.html', outs=outs, user_id=user_id, start=start,
               title=u'所有外出报备列表', status=status,
               params="&user_id=%s&start=%s&end=%s&status=%s" % (
                   user_id, start, end, status), end=end, page=page,
               under_users=[{'uid': k.id, 'name': k.name} for k in User.all()])
Esempio n. 2
0
def underling():
    user_id = int(request.values.get('user_id', 0))
    page = int(request.values.get('p', 1))
    status = int(request.values.get('status', 0))
    start = request.values.get('start', '')
    end = request.values.get('end', '')

    if g.user.is_super_leader():
        outs = [k for k in Out.all() if k.status in [
            OUT_STATUS_APPLY, OUT_STATUS_PASS, OUT_STATUS_MEETED, OUT_STATUS_MEETED_NOT_PASS]]
        under_users = [{'uid': k.id, 'name': k.name} for k in User.all()]
    else:
        under_users = _get_all_under_users(g.user.id)
        if user_id:
            underling_user_ids = [user_id]
        else:
            underling_user_ids = list(set([k['uid'] for k in under_users]))
        outs = [k for k in Out.all() if k.creator.id in underling_user_ids and k.status in [
            OUT_STATUS_APPLY, OUT_STATUS_PASS, OUT_STATUS_MEETED, OUT_STATUS_MEETED_NOT_PASS]]

    if start and end:
        start_time = datetime.datetime.strptime(start, "%Y-%m-%d %H:%M")
        end_time = datetime.datetime.strptime(end, "%Y-%m-%d %H:%M")
        outs = [k for k in outs if k.start_time >=
                start_time and k.start_time < end_time]
    if status:
        outs = [k for k in outs if k.status == status]
    outs = sorted(outs, key=lambda x: x.start_time, reverse=True)
    paginator = Paginator(outs, 50)
    try:
        outs = paginator.page(page)
    except:
        outs = paginator.page(paginator.num_pages)
    return tpl('/account/out/outs.html', outs=outs, user_id=user_id, start=start,
               title=u'下属的外出报备列表', under_users=under_users, status=status,
               params="&user_id=%s&start=%s&end=%s&status=%s" % (
                   user_id, start, end, status),
               end=end, page=page)
Esempio n. 3
0
# encoding: utf-8
import sys

sys.path.append('/Users/guoyu1/workspace/inad/braavos')
# sys.path.append('/home/inad/apps/braavos/releases/current')

from app import app

from models.user import Out, OutReport

if __name__ == '__main__':
    outs = Out.all()
    for k in outs:
        OutReport.add(start_time=k.start_time,
                      end_time=k.end_time,
                      address=k.address,
                      reason=k.reason,
                      meeting_s=k.meeting_s,
                      persions=k.persions,
                      m_persion=k.m_persion,
                      m_persion_type=k.m_persion_type,
                      creator_type=k.creator_type,
                      create_time=k.create_time,
                      status=k.status,
                      out=k,
                      creator=k.creator)
        for i in k.joiners:
            OutReport.add(start_time=k.start_time,
                          end_time=k.end_time,
                          address=k.address,
                          reason=k.reason,
Esempio n. 4
0
# encoding: utf-8
import sys
sys.path.append('/Users/guoyu1/workspace/inad/braavos')
# sys.path.append('/home/inad/apps/braavos/releases/current')

from app import app

from models.user import Out, OutReport


if __name__ == '__main__':
    outs = Out.all()
    for k in outs:
        OutReport.add(start_time=k.start_time,
                      end_time=k.end_time,
                      address=k.address,
                      reason=k.reason,
                      meeting_s=k.meeting_s,
                      persions=k.persions,
                      m_persion=k.m_persion,
                      m_persion_type=k.m_persion_type,
                      creator_type=k.creator_type,
                      create_time=k.create_time,
                      status=k.status,
                      out=k,
                      creator=k.creator)
        for i in k.joiners:
            OutReport.add(start_time=k.start_time,
                          end_time=k.end_time,
                          address=k.address,
                          reason=k.reason,