Exemple #1
0
def entity_group_edit(request, entity_group_id,
        return_view_name='entities:entity_group_view'):

    entity_group = get_object_or_404(EntityGroup, id=entity_group_id)

    if not can_edit_entity_group(request.user, entity_group):
        raise PermissionDenied

    if request.method == 'POST':
        form = EntityGroupForm(request.POST, instance=entity_group)
        if form.is_valid():
            form.save()
            messages.success(request, _(u'Entity group edited succesfully'))
            return HttpResponseRedirect(
                reverse(return_view_name, args=[form.instance.id])
            )
        else:
            messages.error(request, _('Please correct the errors'
                                      ' indicated below'))

    else:
        form = EntityGroupForm(instance=entity_group)

    return render_to_response('entity/edit_entity_group.html', {
        'entity_group': entity_group,
        'form': form,
    }, context_instance=RequestContext(request))
Exemple #2
0
def entity_group_edit(request,
                      entity_group_id,
                      return_view_name='entities:entity_group_view'):

    entity_group = get_object_or_404(EntityGroup, id=entity_group_id)

    if not can_edit_entity_group(request.user, entity_group):
        raise PermissionDenied

    if request.method == 'POST':
        form = EntityGroupForm(request.POST, instance=entity_group)
        if form.is_valid():
            form.save()
            messages.success(request, _(u'Entity group edited succesfully'))
            return HttpResponseRedirect(
                reverse(return_view_name, args=[form.instance.id]))
        else:
            messages.error(request,
                           _('Please correct the errors'
                             ' indicated below'))

    else:
        form = EntityGroupForm(instance=entity_group)

    return render_to_response('entity/edit_entity_group.html', {
        'entity_group': entity_group,
        'form': form,
    },
                              context_instance=RequestContext(request))
Exemple #3
0
def entity_group_add(request, return_view_name="entity_group_view"):
    if request.method == "POST":
        form = EntityGroupForm(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.owner = request.user
            instance.save()
            messages.success(request, _(u"Entity group created"))
            return HttpResponseRedirect(reverse(return_view_name, args=[instance.id]))
        else:
            messages.error(request, _("Please correct the errors" " indicated below"))

    else:
        form = EntityGroupForm()

    return render_to_response("entity/edit_entity_group.html", {"form": form}, context_instance=RequestContext(request))
Exemple #4
0
def entity_group_add(request, return_view_name='entities:entity_group_view'):
    if request.method == 'POST':
        form = EntityGroupForm(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.owner = request.user
            instance.save()
            messages.success(request, _(u'Entity group created'))
            return HttpResponseRedirect(
                reverse(return_view_name, args=[instance.id])
            )
        else:
            messages.error(request, _('Please correct the errors'
                                      ' indicated below'))

    else:
        form = EntityGroupForm()

    return render_to_response('entity/edit_entity_group.html', {
        'form': form,
    }, context_instance=RequestContext(request))
Exemple #5
0
def entity_group_add(request, return_view_name='entities:entity_group_view'):
    if request.method == 'POST':
        form = EntityGroupForm(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.owner = request.user
            instance.save()
            messages.success(request, _(u'Entity group created'))
            return HttpResponseRedirect(
                reverse(return_view_name, args=[instance.id]))
        else:
            messages.error(request,
                           _('Please correct the errors'
                             ' indicated below'))

    else:
        form = EntityGroupForm()

    return render_to_response('entity/edit_entity_group.html', {
        'form': form,
    },
                              context_instance=RequestContext(request))
Exemple #6
0
def entity_group_edit(request, entity_group_id, return_view_name="entity_group_view"):

    entity_group = get_object_or_404(EntityGroup, id=entity_group_id)

    if not can_edit_entity_group(request.user, entity_group):
        raise PermissionDenied

    if request.method == "POST":
        form = EntityGroupForm(request.POST, instance=entity_group)
        if form.is_valid():
            form.save()
            messages.success(request, _(u"Entity group edited succesfully"))
            return HttpResponseRedirect(reverse(return_view_name, args=[form.instance.id]))
        else:
            messages.error(request, _("Please correct the errors" " indicated below"))

    else:
        form = EntityGroupForm(instance=entity_group)

    return render_to_response(
        "entity/edit_entity_group.html",
        {"entity_group": entity_group, "form": form},
        context_instance=RequestContext(request),
    )