Exemple #1
0
def export(request):
    mode = request.POST.get('mode')
    if mode == 'partial':
        attrs = request.POST.getall('attributes')
    else:
        attrs = _replace_by_composites(_get_contact_attributes())
        attrs = [a['name'] for a in attrs]
    contacts = defaultdict(list)
    full_names = {}
    sort_args = [('last_name', 1), ('first_name', 1)]
    for contact in request.db.contacts.find().sort(sort_args):
        full_names[contact['_id']] = get_full_name(contact)
        initial = get_initial(contact['last_name'])
        contacts[initial.upper()].append(contact)
    links = defaultdict(set)
    for link in request.db.links.find():
        links[link['from']].add(full_names[link['to']])
        links[link['to']].add(full_names[link['from']])
    css_url = request.static_url('mnemos:static/css/export.css')
    return {'css_url': css_url,
            'contacts': contacts,
            'links': links,
            'attributes': attrs,
            'get_full_name': get_full_name,
            'get_birthdate': get_birthdate}
Exemple #2
0
def index(request):
    alphabet = string.ascii_uppercase  # Latin alphabet only!
    contacts = defaultdict(list)
    sort_args = [('last_name', 1), ('first_name', 1)]
    for contact in request.db.contacts.find().sort(sort_args):
        initial = get_initial(contact['last_name'])
        contacts[initial.upper()].append(contact)
    return {'api': TemplateAPI(request),
            'alphabet': alphabet,
            'contacts': contacts,
            'get_full_name': get_full_name}
Exemple #3
0
 def _call_fut(self, name):
     from mnemos.utils import get_initial
     return get_initial(name)