Exemple #1
0
def sense(request, sense_id):
    results = Sense.objects.filter(xml_id=sense_id)
    published = Entry.objects.filter(publish=True).values_list('slug', flat=True)
    if results:
        sense_object = results[0]
        data = {'senses': [build_sense(sense_object, published)]}
        return Response(data)
    else:
        return Response({})
Exemple #2
0
def entry(request, headword_slug):
    if '#' in headword_slug:
        slug = headword_slug.split('#')[0]
    else:
        slug = headword_slug
    template = loader.get_template('dictionary/entry.html')

    entry = get_object_or_404(Entry, slug=slug, publish=True)
    published = Entry.objects.filter(publish=True).values_list('slug', flat=True)
    include_form = request.user.is_authenticated()
    include_all_senses = False
    senses = [build_sense(sense, published, include_all_senses, include_form) for sense in entry.get_senses_ordered_by_example_count()]
    context = {
        'headword': entry.headword,
        'slug': slug,
        'title': entry.headword[0].upper() + entry.headword[1:],
        'image': senses[0]['image'],
        'pub_date': entry.pub_date,
        'last_updated': entry.last_updated,
        'senses': senses,
        'published_entries': published
    }
    return HttpResponse(template.render(context, request))