コード例 #1
0
def list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request,
                           project,
                           'patchwork.views.patch.list',
                           view_args={'project_id': project.linkname})
    return render_to_response('patchwork/list.html', context)
コード例 #2
0
ファイル: bundle.py プロジェクト: nwnk/patchwork
def bundle(request, username, bundlename):
    bundle = get_object_or_404(Bundle, owner__username = username,
                                name = bundlename)
    filter_settings = [(DelegateFilter, DelegateFilter.AnyDelegate)]

    is_owner = request.user == bundle.owner

    if not (is_owner or bundle.public):
        return HttpResponseNotFound()

    if is_owner:
        if request.method == 'POST' and request.POST.get('form') == 'bundle':
            action = request.POST.get('action', '').lower()
            if action == 'delete':
                bundle.delete()
                return HttpResponseRedirect(
                        django.core.urlresolvers.reverse(
                            'patchwork.views.user.profile')
                        )
            elif action == 'update':
                form = BundleForm(request.POST, instance = bundle)
                if form.is_valid():
                    form.save()

                # if we've changed the bundle name, redirect to new URL
                bundle = Bundle.objects.get(pk = bundle.pk)
                if bundle.name != bundlename:
                    return HttpResponseRedirect(bundle.get_absolute_url())

            else:
                form = BundleForm(instance = bundle)
        else:
            form = BundleForm(instance = bundle)

        if request.method == 'POST' and \
                           request.POST.get('form') == 'reorderform':
            order = get_object_or_404(BundlePatch, bundle = bundle,
                            patch__id = request.POST.get('order_start')).order

            for patch_id in request.POST.getlist('neworder'):
                bundlepatch = get_object_or_404(BundlePatch,
                            bundle = bundle, patch__id = patch_id)
                bundlepatch.order = order
                bundlepatch.save()
                order += 1
    else:
        form = None

    context = generic_list(request, bundle.project,
            'patchwork.views.bundle.bundle',
            view_args = {'username': bundle.owner.username,
                         'bundlename': bundle.name},
            filter_settings = filter_settings,
            patches = bundle.ordered_patches(),
            editable_order = is_owner)

    context['bundle'] = bundle
    context['bundleform'] = form

    return render_to_response('patchwork/bundle.html', context)
コード例 #3
0
def patches(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request,
                           project,
                           'patch-list',
                           view_args={'project_id': project.linkname})
    return render(request, 'patchwork/list.html', context)
コード例 #4
0
ファイル: bundle.py プロジェクト: alialnu/patchwork
def bundle_detail(request, username, bundlename):
    bundle = get_object_or_404(Bundle, owner__username=username,
                               name=bundlename)
    filter_settings = [(DelegateFilter, DelegateFilter.AnyDelegate)]

    is_owner = request.user == bundle.owner

    if not (is_owner or bundle.public):
        return HttpResponseNotFound()

    if is_owner:
        if request.method == 'POST' and request.POST.get('form') == 'bundle':
            action = request.POST.get('action', '').lower()
            if action == 'delete':
                bundle.delete()
                return HttpResponseRedirect(reverse('user-profile'))
            elif action == 'update':
                form = BundleForm(request.POST, instance=bundle)
                if form.is_valid():
                    form.save()

                # if we've changed the bundle name, redirect to new URL
                bundle = Bundle.objects.get(pk=bundle.pk)
                if bundle.name != bundlename:
                    return HttpResponseRedirect(bundle.get_absolute_url())

            else:
                form = BundleForm(instance=bundle)
        else:
            form = BundleForm(instance=bundle)

        if (request.method == 'POST' and
            request.POST.get('form') == 'reorderform'):
            order = get_object_or_404(
                BundlePatch,
                bundle=bundle,
                patch__id=request.POST.get('order_start')).order

            for patch_id in request.POST.getlist('neworder'):
                bundlepatch = get_object_or_404(BundlePatch,
                                                bundle=bundle,
                                                patch__id=patch_id)
                bundlepatch.order = order
                bundlepatch.save()
                order += 1
    else:
        form = None

    context = generic_list(request, bundle.project,
                           'bundle-detail',
                           view_args={'username': bundle.owner.username,
                                      'bundlename': bundle.name},
                           filter_settings=filter_settings,
                           patches=bundle.ordered_patches(),
                           editable_order=is_owner)

    context['bundle'] = bundle
    context['bundleform'] = form

    return render(request, 'patchwork/bundle.html', context)
コード例 #5
0
ファイル: patch.py プロジェクト: deenseth/patchwork
def list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request, project, 'patchwork.views.patch.list',
            view_args = {'project_id': project.linkname})
    return render_to_response('patchwork/list.html', context)

    context = PatchworkRequestContext(request,
            list_view = 'patchwork.views.patch.list',
            list_view_params = {'project_id': project_id})
    order = get_order(request)
    project = get_object_or_404(Project, linkname=project_id)
    context.project = project

    form = None
    errors = []

    if request.method == 'POST':
        action = request.POST.get('action', None)
        if action:
            action = action.lower()

        # special case: the user may have hit enter in the 'create bundle'
        # text field, so if non-empty, assume the create action:
        if request.POST.get('bundle_name', False):
            action = 'create'

        ps = []
        for patch_id in get_patch_ids(request.POST):
            try:
                patch = Patch.objects.get(id = patch_id)
            except Patch.DoesNotExist:
                pass
            ps.append(patch)

        (errors, form) = set_patches(request.user, project, action, \
                                        request.POST, ps)
        if errors:
            context['errors'] = errors


    elif request.user.is_authenticated() and \
            project in request.user.get_profile().maintainer_projects.all():
        form = MultiplePatchForm(project)

    patches = Patch.objects.filter(project=project).order_by(order)
    patches = context.filters.apply(patches)

    paginator = Paginator(request, patches)

    context.update({
            'page':             paginator.current_page,
            'patchform':        form,
            'project':          project,
            'errors':           errors,
            })

    return render_to_response('patchwork/list.html', context)
コード例 #6
0
ファイル: patch.py プロジェクト: daxtens/patchwork
def patch_list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request, project, 'patch-list',
                           view_args={'project_id': project.linkname})

    if request.user.is_authenticated:
        context['bundles'] = request.user.bundles.all()

    return render(request, 'patchwork/list.html', context)
コード例 #7
0
def patch_list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request, project, 'patch-list',
                           view_args={'project_id': project.linkname})

    if request.user.is_authenticated:
        context['bundles'] = request.user.bundles.all()

    return render(request, 'patchwork/list.html', context)
コード例 #8
0
ファイル: patch.py プロジェクト: alialnu/patchwork
def patch_list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request, project, 'patch-list',
                           view_args={'project_id': project.linkname})

    if is_authenticated(request.user):
        context['bundles'] = Bundle.objects.filter(owner=request.user)

    return render(request, 'patchwork/list.html', context)
コード例 #9
0
def patch_list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request,
                           project,
                           'patch-list',
                           view_args={'project_id': project.linkname})

    if is_authenticated(request.user):
        context['bundles'] = Bundle.objects.filter(owner=request.user)

    return render(request, 'patchwork/list.html', context)
コード例 #10
0
ファイル: bundle.py プロジェクト: deenseth/patchwork
def public(request, username, bundlename):
    user = get_object_or_404(User, username = username)
    bundle = get_object_or_404(Bundle, name = bundlename, public = True)
    filter_settings = [(DelegateFilter, DelegateFilter.AnyDelegate)]
    context = generic_list(request, bundle.project,
            'patchwork.views.bundle.public',
            view_args = {'username': username, 'bundlename': bundlename},
            filter_settings = filter_settings,
            patches = bundle.patches.all())

    context['bundle'] = bundle

    return render_to_response('patchwork/bundle-public.html', context)
コード例 #11
0
def todo_list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    patches = request.user.profile.todo_patches(project=project)
    filter_settings = [(DelegateFilter, {'delegate': request.user})]

    context = generic_list(request,
                           project,
                           'patchwork.views.user.todo_list',
                           view_args={'project_id': project.linkname},
                           filter_settings=filter_settings,
                           patches=patches)

    context['action_required_states'] = \
        State.objects.filter(action_required = True).all()
    return render_to_response('patchwork/todo-list.html', context)
コード例 #12
0
ファイル: user.py プロジェクト: deenseth/patchwork
def todo_list(request, project_id):
    project = get_object_or_404(Project, linkname = project_id)
    patches = request.user.get_profile().todo_patches(project = project)
    filter_settings = [(DelegateFilter,
            {'delegate': request.user})]

    context = generic_list(request, project,
            'patchwork.views.user.todo_list',
            view_args = {'project_id': project.linkname},
            filter_settings = filter_settings,
            patches = patches)

    context['action_required_states'] = \
        State.objects.filter(action_required = True).all()
    return render_to_response('patchwork/todo-list.html', context)
コード例 #13
0
ファイル: user.py プロジェクト: getpatchwork/patchwork
def todo_list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    patches = request.user.profile.todo_patches(project=project)
    filter_settings = [(DelegateFilter,
                        {'delegate': request.user})]

    # TODO(stephenfin): Build the context dict here
    context = generic_list(request, project,
                           'user-todo',
                           view_args={'project_id': project.linkname},
                           filter_settings=filter_settings,
                           patches=patches)

    context['action_required_states'] = \
        State.objects.filter(action_required=True).all()
    return render(request, 'patchwork/todo-list.html', context)
コード例 #14
0
ファイル: user.py プロジェクト: Aleks1966/patchwork
def todo_list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    patches = request.user.profile.todo_patches(project=project)
    filter_settings = [(DelegateFilter, {'delegate': request.user})]

    # TODO(stephenfin): Build the context dict here
    context = generic_list(request,
                           project,
                           'user-todo',
                           view_args={'project_id': project.linkname},
                           filter_settings=filter_settings,
                           patches=patches)

    context['action_required_states'] = \
        State.objects.filter(action_required=True).all()
    return render(request, 'patchwork/todo-list.html', context)
コード例 #15
0
ファイル: bundle.py プロジェクト: tijuca/patchwork
def bundle(request, bundle_id):
    bundle = get_object_or_404(Bundle, id = bundle_id)
    filter_settings = [(DelegateFilter, DelegateFilter.AnyDelegate)]

    if request.method == 'POST' and request.POST.get('form') == 'bundle':
        action = request.POST.get('action', '').lower()
        if action == 'delete':
            bundle.delete()
            return HttpResponseRedirect(
                    django.core.urlresolvers.reverse(
                        'patchwork.views.user.profile')
                    )
        elif action == 'update':
            form = BundleForm(request.POST, instance = bundle)
            if form.is_valid():
                form.save()

        else:
            form = BundleForm(instance = bundle)
    else:
        form = BundleForm(instance = bundle)

    if request.method == 'POST' and request.POST.get('form') == 'reorderform':
        order = get_object_or_404(BundlePatch, bundle = bundle,
                        patch__id = request.POST.get('order_start')).order

        for patch_id in request.POST.getlist('neworder'):
            bundlepatch = get_object_or_404(BundlePatch,
                        bundle = bundle, patch__id = patch_id)
            bundlepatch.order = order
            bundlepatch.save()
            order += 1

    context = generic_list(request, bundle.project,
            'patchwork.views.bundle.bundle',
            view_args = {'bundle_id': bundle_id},
            filter_settings = filter_settings,
            patches = bundle.ordered_patches(),
            editable_order = True)

    context['bundle'] = bundle
    context['bundleform'] = form

    return render_to_response('patchwork/bundle.html', context)
コード例 #16
0
ファイル: patch.py プロジェクト: joselamego/patchwork
def list(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request, project, 'patchwork.views.patch.list',
                           view_args={'project_id': project.linkname})
    return render_to_response('patchwork/list.html', context)
コード例 #17
0
ファイル: patch.py プロジェクト: getpatchwork/patchwork
def patches(request, project_id):
    project = get_object_or_404(Project, linkname=project_id)
    context = generic_list(request, project, 'patch-list',
                           view_args={'project_id': project.linkname})
    return render(request, 'patchwork/list.html', context)