예제 #1
0
def user_add(request, response_format='html'):
    "User add"

    user_limit = getattr(settings, 'HARDTREE_SUBSCRIPTION_USER_LIMIT', 0)
    
    if user_limit > 0:
        user_number = User.objects.filter(disabled=False).count()
        if user_number >= user_limit:
            return HttpResponseRedirect(reverse('core_billing_upgrade'))


    if request.POST:
        if not 'cancel' in request.POST:
            form = UserForm(request.POST)
            if form.is_valid():
                profile = form.save()
                return HttpResponseRedirect(reverse('core_admin_user_view', args=[profile.id]))
        else:
            return HttpResponseRedirect(reverse('core_admin_index_users'))
    else:
        form = UserForm()
    
    return render_to_response('core/administration/user_add',
                              {'form': form},
                              context_instance=RequestContext(request), response_format=response_format)
예제 #2
0
파일: views.py 프로젝트: 5n1p/treeio
def user_edit(request, user_id, response_format='html'):
    "User edit"

    profile = get_object_or_404(User, pk=user_id)
    if request.POST:
        if not 'cancel' in request.POST:
            form = UserForm(request.POST, instance=profile)
            if form.is_valid():
                profile = form.save()
                return HttpResponseRedirect(reverse('core_admin_user_view', args=[profile.id]))
        else:
            return HttpResponseRedirect(reverse('core_admin_user_view', args=[profile.id]))
    else:
        form = UserForm(instance=profile)

    return render_to_response('core/administration/user_edit',
                              {'profile': profile,
                               'form': form},
                              context_instance=RequestContext(request), response_format=response_format)
예제 #3
0
def user_add(request, response_format='html'):
    "User add"

    user_limit = getattr(settings, 'HARDTREE_SUBSCRIPTION_USER_LIMIT', 0)

    if user_limit > 0:
        user_number = User.objects.filter(disabled=False).count()
        if user_number >= user_limit:
            return HttpResponseRedirect(reverse('core_billing_upgrade'))

    if request.POST:
        if not 'cancel' in request.POST:
            form = UserForm(request.POST)
            if form.is_valid():
                profile = form.save()
                return HttpResponseRedirect(
                    reverse('core_admin_user_view', args=[profile.id]))
        else:
            return HttpResponseRedirect(reverse('core_admin_index_users'))
    else:
        form = UserForm()

    return render_to_response('core/administration/user_add', {'form': form},
                              context_instance=RequestContext(request),
                              response_format=response_format)
예제 #4
0
def user_edit(request, user_id, response_format='html'):
    "User edit"

    profile = get_object_or_404(User, pk=user_id)
    if request.POST:
        if not 'cancel' in request.POST:
            form = UserForm(request.POST, instance=profile)
            if form.is_valid():
                profile = form.save()
                return HttpResponseRedirect(
                    reverse('core_admin_user_view', args=[profile.id]))
        else:
            return HttpResponseRedirect(
                reverse('core_admin_user_view', args=[profile.id]))
    else:
        form = UserForm(instance=profile)

    return render_to_response('core/administration/user_edit', {
        'profile': profile,
        'form': form
    },
                              context_instance=RequestContext(request),
                              response_format=response_format)