Пример #1
0
def populate_departments_dbs(departments_dbs, ids):
    ids['state'] = {}
    for db_name in departments_dbs:
        if db_name == 'users':
            continue
        else:
            for state in states:
                ids['state'][state] = StateService.add(departments_dbs[db_name], state)
    for idsender in ids['useraddress']:
        for _ in range(50):
            idreceiver = random.randint(0, len(ids['useraddress']) - 1)
            MailService.add(departments_dbs, 0, idsender, ids['useraddress'][idreceiver])        
Пример #2
0
def get_mail_id(barcode):
    mail = MailService.selectById(app.dbs['LAW'], barcode)
    m = {
        'barcode': mail.barcode,
        'Sender': mail.idsenderuseraddress,
        'Receiver': mail.idreceiveruseraddress,
        'State': mail.idstate
    }
    return m
Пример #3
0
def get_mail_barcode(barcode):
    db = MailService.findDatabaseForBarcode(app.dbs, barcode)
    mail = MailService.selectByBarcode(db, barcode)
    state = mail.statehistory
    ua_sender = UserAddressService.selectById(app.dbs['users'],
                                              mail.idsenderuseraddress)
    ua_receiver = UserAddressService.selectById(app.dbs['users'],
                                                mail.idreceiveruseraddress)
    m = {
        'barcode': mail.barcode,
        'sender': ua_sender.user.name,
        'receiver': ua_receiver.user.name,
        'date': str(state[0].date),
        'history': [
            {'status': s.idstate, 'text': str(s.date)} for s in state
        ]

    }
    for d in mail.statehistory:
        print d.date
    return m
Пример #4
0
def user_mails_sent(id):
    u = UserService.selectByStudentnumber(app.dbs['users'], id)
    dep = u.iddepartment
    addresses = UserAddressService.listByUser(app.dbs['users'], u.iduserthu)
    db = app.dbs[codes.codes['0{}'.format(dep)]]
    j = []
    mails = MailService.selectBySenderUserAdresses(
        db,
        [a.iduseraddress for a in addresses]
    )
    for m in mails:
        j.append(get_mail_barcode(m.barcode))
    response.content_type = 'text/json; charset=utf-8'
    return j
Пример #5
0
              'D1': db_d1 }

codes.codes = { "01": "D1" }
codes.rev_codes = { "D1": "01" }


a1 = AddressService.add(db_users, "A1")
a2 = AddressService.add(db_users, "A2")
d1 = DepartmentService.add(db_users, "D1")
s1 = StateService.add(db_users, "S1")
s2 = StateService.add(db_users, "S2")
s3 = StateService.add(db_users, "S3")
u1 = UserService.add(db_users, 2013400576, "U1", "[email protected]", d1)
ua1 = UserAddressService.add(db_users, a1, u1)
ua2 = UserAddressService.add(db_users, a2, u1)
bc = MailService.add(databases, s1, ua1, ua2)

las = UserAddressService.listByUser(db_users, u1)

selectedMail = MailService.selectByBarcode(databases['D1'], bc)

print las

print a1
print d1
print s1
print u1
print ua1
print bc
print selectedMail