コード例 #1
0
ファイル: apiviews.py プロジェクト: 01org/iris-panel
def get_submission(request, project, submission):
    submissions = Submission.objects.filter(
        name=submission,
        submissionbuild__product__name=project
        ).prefetch_related(
            'submissionbuild_set__group__imagebuild_set',
            'owner',
            'gittree',
            )
    if submissions:
        sng = SubmissionGroup(submissions)
        bdg = sng.buildgroup(project)
        detail = {
            'submission': submission,
            'target_project': project,
            'commit': sorted(list(sng.commit)),
            'submitter': sorted([u.email for u in sng.owner]),
            'download_url': bdg.download_url if bdg else '',
            'git_trees': sorted([g.gitpath for g in sng.gittree]),
            'images': sorted([
                (i.name, i.STATUS[i.status])
                for i in bdg.imagebuild_set.all()]) if bdg else [],
        }
        return HttpResponse(
            json.dumps(detail),
            content_type="application/json")
    else:
        return HttpResponseNotFound(
            json.dumps({'reason': 'submission can not be found'}),
            content_type="application/json")
コード例 #2
0
ファイル: apiviews.py プロジェクト: pombreda/iris-panel
def get_submission(request, project, submission):
    submissions = Submission.objects.filter(
        name=submission,
        submissionbuild__product__name=project).prefetch_related(
            'submissionbuild_set__group__imagebuild_set',
            'owner',
            'gittree',
        )
    if submissions:
        sng = SubmissionGroup(submissions)
        bdg = sng.buildgroup(project)
        detail = {
            'submission':
            submission,
            'target_project':
            project,
            'commit':
            sorted(list(sng.commit)),
            'submitter':
            sorted([u.email for u in sng.owner]),
            'download_url':
            bdg.download_url if bdg else '',
            'git_trees':
            sorted([g.gitpath for g in sng.gittree]),
            'images':
            sorted([(i.name, i.STATUS[i.status])
                    for i in bdg.imagebuild_set.all()]) if bdg else [],
        }
        return HttpResponse(json.dumps(detail),
                            content_type="application/json")
    else:
        return HttpResponseNotFound(json.dumps(
            {'reason': 'submission can not be found'}),
                                    content_type="application/json")
コード例 #3
0
ファイル: read.py プロジェクト: 01org/iris-panel
def snapshot(request, pkid):
    snapshot = get_object_or_404(Snapshot, id=pkid)
    groups = SubmissionGroup.group(snapshot.submissions)

    # get snapshots with the same product
    snapshots = list(Snapshot.snapshots_with_same_product(snapshot.product))
    st_len = len(snapshots)
    first_item = False
    last_item = False
    pre_st = None
    next_st = None
    current_index = snapshots.index(snapshot)
    if current_index == 0:
        first_item = True
    else:
        pre_st = snapshots[current_index-1]
    if current_index == (st_len -1):
        last_item = True
    else:
        next_st = snapshots[current_index+1]
    return render(request, 'submissions/read/single/snapshot.html', {
            'snapshot': snapshot,
            'groups': groups,
            'pre_st': pre_st,
            'next_st': next_st,
            'first_item': first_item,
            'last_item': last_item,
            })
コード例 #4
0
ファイル: read.py プロジェクト: 01org/iris-panel
def search(request):
    """Search submissions by keyword """
    querystring = request.GET.get('kw')
    if not querystring:
        return HttpResponseBadRequest('error')
    kw = parse_query_string(querystring)
    st = kw.pop('status', None) if kw else None
    subs = Submission.objects.select_related('owner', 'gittree', 'product')
    if kw:
        query = make_query_conditions(kw)
        subs = subs.filter(query)
    else:
        subs = subs.all()

    show_snapshot = False
    if st:
        if st == DISPLAY_STATUS['OPENED']:
            subs = {sub for sub in subs if sub.opened}
        if st == DISPLAY_STATUS['REJECTED']:
            subs = {sub for sub in subs if sub.rejected}
        if st == DISPLAY_STATUS['ACCEPTED']:
            subs = {sub for sub in subs if sub.accepted}
            show_snapshot = True

    return render(
        request,
        'submissions/summary.html',
        {'title': 'Search result for "%s"' % querystring,
         'results': SubmissionGroup.group(subs, st),
         'keyword': querystring,
         'show_snapshot': show_snapshot
        })
コード例 #5
0
ファイル: read.py プロジェクト: pombreda/iris-panel
def snapshot(request, pkid):
    snapshot = get_object_or_404(Snapshot, id=pkid)
    groups = SubmissionGroup.group(snapshot.submissions)

    # get snapshots with the same product
    snapshots = list(Snapshot.snapshots_with_same_product(snapshot.product))
    st_len = len(snapshots)
    first_item = False
    last_item = False
    pre_st = None
    next_st = None
    current_index = snapshots.index(snapshot)
    if current_index == 0:
        first_item = True
    else:
        pre_st = snapshots[current_index - 1]
    if current_index == (st_len - 1):
        last_item = True
    else:
        next_st = snapshots[current_index + 1]
    return render(
        request, 'submissions/read/single/snapshot.html', {
            'snapshot': snapshot,
            'groups': groups,
            'pre_st': pre_st,
            'next_st': next_st,
            'first_item': first_item,
            'last_item': last_item,
        })
コード例 #6
0
ファイル: read.py プロジェクト: pombreda/iris-panel
def search(request):
    """Search submissions by keyword """
    querystring = request.GET.get('kw')
    if not querystring:
        return HttpResponseBadRequest('error')
    kw = parse_query_string(querystring)
    st = kw.pop('status', None) if kw else None
    subs = Submission.objects.select_related('owner', 'gittree', 'product')
    if kw:
        query = make_query_conditions(kw)
        subs = subs.filter(query)
    else:
        subs = subs.all()

    show_snapshot = False
    if st:
        if st == DISPLAY_STATUS['OPENED']:
            subs = {sub for sub in subs if sub.opened}
        if st == DISPLAY_STATUS['REJECTED']:
            subs = {sub for sub in subs if sub.rejected}
        if st == DISPLAY_STATUS['ACCEPTED']:
            subs = {sub for sub in subs if sub.accepted}
            show_snapshot = True

    return render(
        request, 'submissions/summary.html', {
            'title': 'Search result for "%s"' % querystring,
            'results': SubmissionGroup.group(subs, st),
            'keyword': querystring,
            'show_snapshot': show_snapshot
        })
コード例 #7
0
ファイル: read.py プロジェクト: 01org/iris-panel
def rejected(request):
    """
    All rejected submissions
    """
    subs = [sub for sub in get_submissions() if sub.rejected]
    return render(request, 'submissions/summary.html', {
        'title': 'All rejected submissions',
        'results': SubmissionGroup.group(subs, DISPLAY_STATUS['REJECTED']),
        'keyword': 'status:%s' % DISPLAY_STATUS['REJECTED'],
        })
コード例 #8
0
ファイル: read.py プロジェクト: 01org/iris-panel
def accepted(request):
    """
    All accepted submissions
    """
    subs = [sub for sub in get_submissions() if sub.accepted]
    return render(request, 'submissions/summary.html', {
        'title': 'All accepted submissions',
        'results': SubmissionGroup.group(subs, DISPLAY_STATUS['ACCEPTED']),
        'keyword': 'status:%s' % DISPLAY_STATUS['ACCEPTED'],
        'show_snapshot': True,
        })
コード例 #9
0
ファイル: read.py プロジェクト: pombreda/iris-panel
def rejected(request):
    """
    All rejected submissions
    """
    subs = [sub for sub in get_submissions() if sub.rejected]
    return render(
        request, 'submissions/summary.html', {
            'title': 'All rejected submissions',
            'results': SubmissionGroup.group(subs, DISPLAY_STATUS['REJECTED']),
            'keyword': 'status:%s' % DISPLAY_STATUS['REJECTED'],
        })
コード例 #10
0
ファイル: read.py プロジェクト: 01org/iris-panel
def mine(request):
    """
    All my (the logged-in user) opened submissions
    TODO: add menu as all did, show opened, rejected, accepted
    """
    subs = [sub for sub in get_submissions(owner=request.user) if sub.opened]
    return render(request, 'submissions/summary.html', {
        'title': 'My submissions',
        'results': SubmissionGroup.group(subs, DISPLAY_STATUS['OPENED']),
        'keyword': 'status:%s owner:%s' % (DISPLAY_STATUS['OPENED'],
                                           request.user.email)
        })
コード例 #11
0
ファイル: read.py プロジェクト: pombreda/iris-panel
def accepted(request):
    """
    All accepted submissions
    """
    subs = [sub for sub in get_submissions() if sub.accepted]
    return render(
        request, 'submissions/summary.html', {
            'title': 'All accepted submissions',
            'results': SubmissionGroup.group(subs, DISPLAY_STATUS['ACCEPTED']),
            'keyword': 'status:%s' % DISPLAY_STATUS['ACCEPTED'],
            'show_snapshot': True,
        })
コード例 #12
0
ファイル: read.py プロジェクト: pombreda/iris-panel
def mine(request):
    """
    All my (the logged-in user) opened submissions
    TODO: add menu as all did, show opened, rejected, accepted
    """
    subs = [sub for sub in get_submissions(owner=request.user) if sub.opened]
    return render(
        request, 'submissions/summary.html', {
            'title':
            'My submissions',
            'results':
            SubmissionGroup.group(subs, DISPLAY_STATUS['OPENED']),
            'keyword':
            'status:%s owner:%s' %
            (DISPLAY_STATUS['OPENED'], request.user.email)
        })
コード例 #13
0
ファイル: read.py プロジェクト: pombreda/iris-panel
def detail(request, tag):
    """
    Detail info about a submission group identified by certain tag
    """
    groups = SubmissionGroup.group(
        Submission.objects.filter(name=tag.rstrip('/')))
    if not groups:
        raise Http404

    assert len(groups) == 1  # because it's group by tag
    sgroup = groups[0]
    bgroups = submission_group_to_build_groups(sgroup)

    return render(request, 'submissions/detail.html', {
        'sgroup': sgroup,
        'bgroups': bgroups,
    })
コード例 #14
0
ファイル: read.py プロジェクト: 01org/iris-panel
def detail(request, tag):
    """
    Detail info about a submission group identified by certain tag
    """
    groups = SubmissionGroup.group(
        Submission.objects.filter(name=tag.rstrip('/')))
    if not groups:
        raise Http404

    assert len(groups) == 1  # because it's group by tag
    sgroup = groups[0]
    bgroups = submission_group_to_build_groups(sgroup)

    return render(
        request,
        'submissions/detail.html',
        {'sgroup': sgroup,
         'bgroups': bgroups,
        })
コード例 #15
0
ファイル: read.py プロジェクト: pombreda/iris-panel
def snapshot_by_product(request, product_id, offset=0, limit=10):
    """
        if change limit, please also update the value in template:
        iris/submissions/templates/submissions/read/multiple/snapshots.html
    """

    pro = Product.objects.get(pk=product_id)
    all_snapshots = Snapshot.snapshots_with_same_product(pro)

    offset = int(offset)
    limit = int(limit)
    end = offset + limit
    more_data = True
    if end >= len(all_snapshots):
        more_data = False

    snapshots = all_snapshots[offset:end]
    for snapshot in snapshots:
        groups = SubmissionGroup.group(snapshot.submissions)
        snapshot.groups = sorted(groups,
                                 key=lambda group: group.name,
                                 reverse=True)

    if request.is_ajax():
        response = render(
            request, 'submissions/read/multiple/snapshot_submissions.html', {
                'snapshots': snapshots,
                'product': pro,
            })
        response['X-No-More'] = more_data
        return response
    else:
        return render(request, 'submissions/read/multiple/snapshots.html', {
            'snapshots': snapshots,
            'product': pro,
            'more_data': more_data,
        })
コード例 #16
0
ファイル: read.py プロジェクト: 01org/iris-panel
def snapshot_by_product(request, product_id, offset=0, limit=10):
    """
        if change limit, please also update the value in template:
        iris/submissions/templates/submissions/read/multiple/snapshots.html
    """

    pro = Product.objects.get(pk=product_id)
    all_snapshots = Snapshot.snapshots_with_same_product(pro)

    offset = int(offset)
    limit = int(limit)
    end = offset + limit
    more_data = True
    if end >= len(all_snapshots):
        more_data = False

    snapshots = all_snapshots[offset:end]
    for snapshot in snapshots:
        groups = SubmissionGroup.group(snapshot.submissions)
        snapshot.groups = sorted(groups,
                                key=lambda group: group.name,
                                reverse=True)

    if request.is_ajax():
        response = render(request, 'submissions/read/multiple/snapshot_submissions.html', {
                'snapshots': snapshots,
                'product': pro,
        })
        response['X-No-More'] = more_data
        return response
    else:
        return render(request, 'submissions/read/multiple/snapshots.html', {
                'snapshots': snapshots,
                'product': pro,
                'more_data': more_data,
            })