Exemple #1
0
def create(request):
    account_form = AccountForm(request.POST or None)
    user_form = UserEmailCreationForm(request.POST or None)
    if account_form.is_valid() and user_form.is_valid():
        messages.success(request, 'AccountForm and UserEmailCreatioForm are valid')
        return HttpResponseRedirect('/welcome/')

    data = {'title': 'Kolabria - Create Account', 'form': account_form,
            'user_form': user_form, }

    return render_to_response('main/create.html', data,
                              context_instance=RequestContext(request))
Exemple #2
0
def create_account(request):
    form = AccountForm(request.POST or None)
    if form.is_valid():
        form.instance.owner = request.user
        account = form.save()

        # Create profile for account owner, link to Account
        profile = Profile.objects.create(user=request.user, account=account)
        profile.admin = profile.account.owner
        profile.save()

        msg = 'Successfully created Account: %s with Owner: %s'
        messages.success(request, msg % (account.company, request.user.username))
        return HttpResponseRedirect('http://%s.kolabria.com:8000/accounts/welcome/' % \
                                                                      account.subdomain)

    data = {'title': 'Kolabria - Create a new company account and administrative user',
            'form': form,}

    return render_to_response('main/create.html', data,
                              context_instance=RequestContext(request))