Esempio n. 1
0
def user_detail(request, username):
    
    person = get_object_or_404(Person, user__username=username)

    my_projects = person.project_set.all()
    my_pids = [p.pid for p in my_projects]
    
    not_project_list = Project.active.exclude(pid__in=my_pids)

    #Add to project form
    if request.method == 'POST' and 'project-add' in request.POST:
        # Post means adding this user to a project
        data = request.POST.copy()
        project = Project.objects.get(pk=data['project'])
        no_account_error = ''
        for mc in project.machine_categories.all():
            if not person.has_account(mc):
                no_account_error = "%s has no account on %s. Please create one first" % (person, project.machine_category)
                break
        if not no_account_error:
            add_user_to_project(person, project)
            messages.success(request, "User '%s' was added to %s succesfully" % (person, project))
            log(request.user, project, 2, '%s added to project' % person)

    #change shell form
    shell_form = ShellForm()
    try:
        shell_form.initial = {'shell': person.loginShell()}
    except:
        pass
    
    return render_to_response('people/person_detail.html', locals(), context_instance=RequestContext(request))
Esempio n. 2
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))
Esempio n. 3
0
def shell_field(ua):
    sf = ShellForm()
    sf.initial = {'shell': ua.loginShell()}
    return sf['shell']