Beispiel #1
0
def change_account_shell(request, account_id):
    account = get_object_or_404(Account, pk=account_id)
    if request.method != "POST":
        return HttpResponseRedirect(account.get_absolute_url())

    shell_form = ShellForm(request.POST)
    if shell_form.is_valid():
        shell_form.save(account=account)
        messages.success(request, "Shell changed successfully")
        return HttpResponseRedirect(account.get_absolute_url())
Beispiel #2
0
def change_account_shell(request, account_id):
    person = request.user
    account = get_object_or_404(Account, pk=account_id, person=person)

    if request.method != 'POST':
        return HttpResponseRedirect(reverse('kg_user_profile_accounts'))

    shell_form = ShellForm(request.POST)
    if shell_form.is_valid():
        shell_form.save(account=account)
        messages.success(request, 'Shell changed successfully')
        return HttpResponseRedirect(reverse('kg_user_profile_accounts'))
Beispiel #3
0
def change_shell(request, useraccount_id):

    if not request.user.has_perm('people.change_person'):
        return HttpResponseForbidden('<h1>Access Denied</h1>')
    ua = get_object_or_404(UserAccount, pk=useraccount_id)
    
    if request.method == 'POST':
        shell_form = ShellForm(request.POST)
        if shell_form.is_valid():
            shell_form.save(user_account=ua)
            messages.success(request, 'Shell changed successfully')
            return HttpResponseRedirect(ua.get_absolute_url())
    else:
        
        return HttpResponseRedirect('/')
Beispiel #4
0
def profile_accounts(request):

    person = request.user.get_profile()
    user_account = person.get_user_account(MachineCategory.objects.get_default())

    if request.method == 'POST' and 'shell-form' in request.POST:
        shell_form = ShellForm(request.POST)
        if shell_form.is_valid():
            shell_form.save(user_account)
            messages.success(request, 'Shell changed successfully')
            return HttpResponseRedirect(reverse('kg_user_profile'))

    else:
        shell_form = ShellForm()
        try:
            shell_form.initial = {'shell': person.loginShell}
        except:
            pass

    return render_to_response('people/profile_accounts.html', locals(), context_instance=RequestContext(request))