Example #1
0
def process_transactions(character, transaction_data):
    client_ids = list(set(entry['client_id'] for entry in transaction_data))
    type_ids = list(set(entry['type_id'] for entry in transaction_data))
    location_ids = list(set(entry['location_id']
                            for entry in transaction_data))
    clients = get_id_data(client_ids, sorted=False)
    types = Type.get_multi(type_ids)
    location_dict = get_location_multi(character, list(location_ids))
    for entry in transaction_data:
        entry['redlisted'] = []
        client = clients[entry['client_id']]
        type_id = entry['type_id']
        location = location_dict[entry['location_id']]
        entry['client_name'] = client.name
        if client.is_redlisted:
            entry['redlisted'].append('client_name')
        entry['type_name'] = types[type_id].name
        if types[type_id].is_redlisted:
            entry['redlisted'].append('type_name')
        entry['location_name'] = location.name
        if location.is_redlisted:
            entry['redlisted'].append('location_name')
        entry['total_value'] = entry['quantity'] * entry['unit_price']
        if abs(entry['total_value']) > 1e9:
            entry['redlisted'].append('total_value')
    if len(transaction_data) > 0:
        lowest_id = min(entry['transaction_id'] for entry in transaction_data)
    else:
        lowest_id = None
    return {'info': transaction_data, 'lowest_id': lowest_id}
Example #2
0
def process_contacts(contacts_list):
    contacts_dict = {entry['contact_id']: entry for entry in contacts_list}
    sorted_contact_model_dict = get_id_data(contacts_dict.keys())
    for character_id, character in sorted_contact_model_dict.get(
            'character', {}).items():
        contacts_dict[character_id].update(
            get_contact_dict(character,
                             corporation=character.corporation,
                             alliance=character.corporation.alliance))
    for corporation_id, corporation in sorted_contact_model_dict.get(
            'corporation', {}).items():
        contacts_dict[corporation_id].update(
            get_contact_dict(corporation,
                             corporation=corporation,
                             alliance=corporation.alliance))
    for alliance_id, alliance in sorted_contact_model_dict.get('alliance',
                                                               {}).items():
        contacts_dict[alliance_id].update(
            get_contact_dict(
                alliance,
                corporation=None,
                alliance=alliance,
            ))

    return {'info': contacts_dict}
Example #3
0
def get_character_calendar_event(character_id, event_id, current_user=None):
    character = Character.get(character_id)
    character_application_access_check(current_user, character)
    event_data = character.get_op(
        'get_characters_character_id_calendar_event_id',
        character_id=character_id,
        event_id=event_id,
    )
    event_data['redlisted'] = []
    if event_data['owner_type'] in ('corporation', 'character', 'alliance'):
        owner = get_id_data([event_data['owner_id']],
                            sorted=False)[event_data['owner_id']]
        if owner.is_redlisted:
            event_data['redlisted'].append('owner_name')
    return event_data
Example #4
0
def get_party_data(party_ids):
    data_dict = get_id_data(party_ids)
    party_data = {}
    for corporation in data_dict.get('corporation', {}).values():
        party_data[corporation.id] = {
            'id': corporation.id,
            'name': corporation.name,
            'party_type': 'corporation',
            'corporation_name': corporation.name,
            'corporation_ticker': corporation.ticker,
            'redlisted': [],
        }
        if corporation.is_redlisted:
            party_data[corporation.id]['redlisted'].extend(
                ['name', 'corporation_name', 'corporation_ticker'])
    for character in data_dict.get('character', {}).values():
        party_data[character.id] = {
            'id': character.id,
            'name': character.name,
            'party_type': 'character',
            'corporation_name': character.corporation.name,
            'corporation_ticker': character.corporation.ticker,
            'redlisted': [],
        }
        if character.is_redlisted:
            party_data[character.id]['redlisted'].append('name')
        if character.corporation.is_redlisted:
            party_data[character.id]['redlisted'].extend(
                ['corporation_name', 'corporation_ticker'])
    unresolved_ids = set(party_ids).difference(party_data.keys())
    for id in unresolved_ids:
        party_data[id] = {
            'id': id,
            'name': 'Unresolved party {}'.format(id),
            'party_type': 'unknown',
            'corporation_name': '',
            'corporation_ticker': '',
            'redlisted': ['name'],
        }
    return party_data
Example #5
0
def get_details_for_id(id):
    return list(get_id_data([id], sorted=False).values())[0]