Example #1
0
def settings_ssh(request):
    post_data = post_or_none(request)
    form = PublicKeyForm(request.user, post_data, prefix='public-key')
    if post_data and form.is_valid():
        form.save(user=request.user)
        return redirect('account:settings:ssh')
    template = 'settings/ssh.html'
    context = {'form': form, 'keys': request.user.public_keys.all()}
    return render(request, template, context)
Example #2
0
def settings_profile(request):
    user = request.user
    post_data = post_or_none(request)
    form = ProfileForm(post_data, instance=user.profile, prefix='profile')
    if post_data and form.is_valid():
        form.save()
        return redirect('account:settings:profile')
    template = 'settings/profile.html'
    context = {'form': form}
    return render(request, template, context)
Example #3
0
def account_join(request):
    post_data = post_or_none(request)
    form = UserForm(post_data, prefix='user')
    if post_data and form.is_valid():
        form.save()
        username = form.cleaned_data['username']
        password = form.cleaned_data['password1']
        user = authenticate(username=username, password=password)
        login(request, user)
        return redirect('project:index')
    template = 'account/join.html'
    context = {'form': form}
    return render(request, template, context)
Example #4
0
def project_new(request, owner=None, project=None):
    post_data = post_or_none(request)

    # We might be forking a new project, so check based on the URL requested
    fork = None
    if owner or project:
        fork = get_object_or_404(Project, owner=owner, project=project)

    # Attempt to validate the form and save against the fork specified
    project_form = ProjectForm(post_data)
    if post_data and project_form.is_valid():
        project = project_form.save(owner=request.user, fork=fork)
        return redirect(project)

    # The view will render notes about the fork if applicable
    context = {'form': project_form, 'fork': fork, 'owner': request.user}
    return render(request, 'project/new.html', context)
Example #5
0
def organization_roles(request, organization):
    """Manages the roles of an organization.

    An organization can have multiple users with different roles. A role just
    defines a user's permission on the site. llab uses bitwise enumerations
    to define multiple roles.

    """
    organization = get_object_or_404(Organization, name=organization)
    post_data = post_or_none(request)
    form = RoleForm(organization, post_data, prefix='role')
    if post_data and form.is_valid():
        form.save()
        return reverse(organization.get_role_management_absolute_url())
    template = 'organization/roles.html'
    context = {'form': form, 'organization': organization}
    return render(request, template, context)
Example #6
0
def organization_new(request):
    """Create a new organization.

    A user can create any organization, however they must be unique to the
    site. The organization names, much like the user names, are slug-based
    names.

    """
    post_data = post_or_none(request)
    form = OrganizationForm(post_data, prefix='organization')
    if post_data and form.is_valid():
        organization = form.save(owner=request.user)
        Group.create_builtins(organization)
        return redirect(organization.get_role_management_absolute_url())
    template = 'organization/new.html'
    context = {'form': form}
    return render(request, template, context)