Exemplo n.º 1
0
def autocomplete_category(request):
    if not request.is_ajax():
        return HttpResponseForbidden()
    name = request.GET.get('q',None)
    limit = request.GET.get('limit', 10)
    if not name:
        return HttpResponse('')
    tree = get_api_tree('category', 'search', **{'name':name, 'limit':limit})
    matches = []
    for cat in tree.iter('category'):
        matches.append(cat.find('name').text)

    return HttpResponse('\n'.join(matches))
Exemplo n.º 2
0
     trange = 'week'
     if nl.frequency == 'd':
         frequency = 'daily'
     else:
         frequency = 'weekly'
 else:
     days = 14
     trange = 'two weeks'
     frequency = 'bi-monthly'
 wrange = (today, today + timedelta(days=days))
 kwargs = {
     'category_id': nl.category_id,
     'date_start': wrange[0],
     'date_end': wrange[1],
 }
 tree = get_api_tree('event', 'search', **kwargs)
 kwargs.update({
     'frequency': frequency,
     'range': trange,
     'events' : []
 })
 count = 0
 total_count = 0
 # Get category stuff here
 catid = kwargs['category_id']
 cattree = get_api_tree('category', 'by_id', **{ 'id': catid })
 kwargs['category_name'] = cattree.find('name').text
 kwargs['category_slug'] = cattree.find('slug').text
 for event in tree.iter('event'):
     total_count += 1
     # Only show settings.EVENTS_PER_EMAIL events in the email; we still