Exemplo n.º 1
0
def edit_entry(request, id):
    entry = get_object_or_404(Entry, id=id)
    user = request.user
    user_groups = [t[0] for t in user.groups.values_list('name')]
    if not (user.preplock and entry.preplock) \
            and (not entry.authors.exists() or user.is_superuser
                 or 'editors' in user_groups or 'admins' in user_groups
                 or user in entry.authors.all()):
        pass
    else:
        return redirect(entry.get_absolute_url())

    choices = {
        'author': viewmodels.editAuthors,
        'entry_status': viewmodels.editStatuses,
        'gender': viewmodels.editGenders,
        'onym': viewmodels.editOnyms,
        'part_of_speech': viewmodels._choices(
                            models.PART_OF_SPEECH_CHOICES),
        'participle_type': viewmodels.editParticiples,
        'substantivus_type': viewmodels.editSubstantivusTypes,
        'tantum': viewmodels.editTantum,
    }
    labels = {
        'author': dict(viewmodels.AUTHOR_CHOICES),  # sic! viewmodels
        'entry_status': dict(models.STATUS_CHOICES),
        'gender': dict(models.GENDER_CHOICES),
        'onym': dict(models.ONYM_CHOICES),
        'part_of_speech': dict(models.PART_OF_SPEECH_CHOICES),
        'participle_type': dict(models.PARTICIPLE_CHOICES),
        'substantivus_type': dict(models.SUBSTANTIVUS_TYPE_CHOICES),
        'tantum': dict(models.TANTUM_CHOICES)
    }
    slugs = {
        'onym': models.ONYM_MAP,
        'part_of_speech': models.PART_OF_SPEECH_MAP,
    }
    context = {
        'entry': viewmodels.entry_json(id),
        'choices': viewmodels._json(choices),
        'labels': viewmodels._json(labels),
        'slugs': viewmodels._json(slugs),
        'entryURL': Entry.objects.get(pk=id).get_absolute_url(),
        'PARTS_OF_SPEECH': models.PART_OF_SPEECH_CHOICES,
        'GENDERS': models.GENDER_CHOICES,
        'STATUSES': models.STATUS_CHOICES,
        'GREEK_EQ_STATUSES': models.Example.GREEK_EQ_STATUS,
        'SUBSTANTIVUS_TYPES': models.SUBSTANTIVUS_TYPE_CHOICES,
        'MAX_LENGTHS': models.MAX_LENGTHS,
    }
    return render_to_response('single_entry_edit.html', context,
                              RequestContext(request))
Exemplo n.º 2
0
def edit_entry(request, id):
    choices = {
        'author': viewmodels.editAuthors,
        'entry_status': viewmodels.editStatuses,
        'gender': viewmodels.editGenders,
        'onym': viewmodels.editOnyms,
        'part_of_speech': viewmodels._choices(
                            models.PART_OF_SPEECH_CHOICES),
        'participle_type': viewmodels.editParticiples,
        'substantivus_type': viewmodels.editSubstantivusTypes,
        'tantum': viewmodels.editTantum,
    }
    labels = {
        'author': dict(viewmodels.AUTHOR_CHOICES),  # sic! viewmodels
        'entry_status': dict(models.STATUS_CHOICES),
        'gender': dict(models.GENDER_CHOICES),
        'onym': dict(models.ONYM_CHOICES),
        'part_of_speech': dict(models.PART_OF_SPEECH_CHOICES),
        'participle_type': dict(models.PARTICIPLE_CHOICES),
        'substantivus_type': dict(models.SUBSTANTIVUS_TYPE_CHOICES),
        'tantum': dict(models.TANTUM_CHOICES)
    }
    slugs = {
        'onym': models.ONYM_MAP,
        'part_of_speech': models.PART_OF_SPEECH_MAP,
    }
    context = {
        'entry': viewmodels.entry_json(id),
        'choices': viewmodels._json(choices),
        'labels': viewmodels._json(labels),
        'slugs': viewmodels._json(slugs),
        'entryURL': Entry.objects.get(pk=id).get_absolute_url(),
        'PARTS_OF_SPEECH': models.PART_OF_SPEECH_CHOICES,
        'GENDERS': models.GENDER_CHOICES,
        'STATUSES': models.STATUS_CHOICES,
        'GREEK_EQ_STATUSES': models.Example.GREEK_EQ_STATUS,
        'SUBSTANTIVUS_TYPES': models.SUBSTANTIVUS_TYPE_CHOICES,
        'MAX_LENGTHS': models.MAX_LENGTHS,
    }
    return render_to_response('single_entry_edit.html', context,
                              RequestContext(request))
Exemplo n.º 3
0
def json_entry_get(request, id):
    data = viewmodels.entry_json(id)
    return HttpResponse(data, content_type=IMT_JSON, status=200)
Exemplo n.º 4
0
def json_entry_get(request, id):
    data = viewmodels.entry_json(id).encode('utf-8')
    return HttpResponse(data, content_type=IMT_JSON, status=200)