Exemple #1
0
def group_add(request):
    check_permissions(request.user, [PERMISSION_GROUP_CREATE])

    if request.method == "POST":
        form = GroupForm(request.POST)
        if form.is_valid():
            group = form.save()
            messages.success(request, _(u'Group "%s" created successfully.') % group)
            return HttpResponseRedirect(reverse("group_list"))
    else:
        form = GroupForm()

    return render_to_response(
        "generic_form.html", {"title": _(u"create new group"), "form": form}, context_instance=RequestContext(request)
    )
Exemple #2
0
def group_new(request):
    if request.method == 'POST':
        form = GroupForm(data=request.POST)
        if form.is_valid():
            if form.save():
                messages.success(
                    request, 'Group \'' + form.cleaned_data['name'] +
                    '\' successfully created!')
            else:
                messages.error(request, 'Some error occured!')
            return redirect('user-management:group-index')
    else:
        form = GroupForm()
    context = {'form': form}
    return render(request, "user_management/groups/new.html", context)
Exemple #3
0
def group_add(request):
    check_permissions(request.user, [PERMISSION_GROUP_CREATE])

    if request.method == 'POST':
        form = GroupForm(request.POST)
        if form.is_valid():
            group = form.save()
            messages.success(request,
                             _(u'Group "%s" created successfully.') % group)
            return HttpResponseRedirect(reverse('group_list'))
    else:
        form = GroupForm()

    return render_to_response('generic_form.html', {
        'title': _(u'create new group'),
        'form': form,
    },
                              context_instance=RequestContext(request))
Exemple #4
0
def group_edit(request, group_id):
    check_permissions(request.user, [PERMISSION_GROUP_EDIT])
    group = get_object_or_404(Group, pk=group_id)

    if request.method == "POST":
        form = GroupForm(instance=group, data=request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, _(u'Group "%s" updated successfully.') % group)
            return HttpResponseRedirect(reverse("group_list"))
    else:
        form = GroupForm(instance=group)

    return render_to_response(
        "generic_form.html",
        {"title": _(u"edit group: %s") % group, "form": form, "object": group, "object_name": _(u"group")},
        context_instance=RequestContext(request),
    )
Exemple #5
0
def group_edit(request, group_id):
    group = get_object_or_404(Group, id=group_id)
    old_name = group.name
    if request.method == 'POST':
        form = GroupForm(request.POST, instance=group)
        if form.is_valid():
            if form.save():
                messages.success(
                    request, 'Group name successfully changed form \'' +
                    old_name + '\' to \'' + group.name + '\'.')
            else:
                messages.error(request, 'Some error occured!')
            return redirect('user-management:group-show', group_id)
    else:
        form = GroupForm(instance=group)

    context = {'change_name_form': form, 'group_id': group.id}
    return render(request, 'user_management/groups/edit.html', context)
Exemple #6
0
def group_edit(request, group_id):
    check_permissions(request.user, [PERMISSION_GROUP_EDIT])
    group = get_object_or_404(Group, pk=group_id)

    if request.method == 'POST':
        form = GroupForm(instance=group, data=request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, _(u'Group "%s" updated successfully.') % group)
            return HttpResponseRedirect(reverse('group_list'))
    else:
        form = GroupForm(instance=group)

    return render_to_response('generic_form.html', {
        'title': _(u'edit group: %s') % group,
        'form': form,
        'object': group,
        'object_name': _(u'group'),
    },
    context_instance=RequestContext(request))
Exemple #7
0
def group_edit(request, group_id):
    check_permissions(request.user, [PERMISSION_GROUP_EDIT])
    group = get_object_or_404(Group, pk=group_id)

    if request.method == 'POST':
        form = GroupForm(instance=group, data=request.POST)
        if form.is_valid():
            form.save()
            messages.success(request,
                             _(u'Group "%s" updated successfully.') % group)
            return HttpResponseRedirect(reverse('group_list'))
    else:
        form = GroupForm(instance=group)

    return render_to_response('generic_form.html', {
        'title': _(u'edit group: %s') % group,
        'form': form,
        'object': group,
        'object_name': _(u'group'),
    },
                              context_instance=RequestContext(request))