Exemplo n.º 1
0
Arquivo: views.py Projeto: rtnpro/faf
def listing(request, *args, **kwargs):
    db = pyfaf.storage.getDatabase()
    params = dict(request.REQUEST)
    params.update(kwargs)
    form = ReportFilterForm(db, params)

    filters = { 'new'       : (lambda q: q.filter(Report.problem_id==None)),
                'processed' : (lambda q: q.filter(Report.problem_id!=None)) }

    states = None
    for s in form.get_status_selection():
        # if 's' isn't in filters exceptions is thrown
        # it is intended behaviour - someone has to take care about it
        subquery = filters[s](db.session.query(
                                Report.id.label('id'),
                                literal(s.upper()).label('status')))
        states = states.union_all(subquery) if states else subquery

    # if list of statuses is empty the states variable is None
    # it means that no reports are to be selected
    # hope that there will never be a Report with id equal to -1
    if not states:
        states = (db.session.query(literal(-1).label('id'),
                                   literal('').label('status')))

    states = states.subquery()

    opsysrelease_id = form.os_release_id
    reports = (db.session.query(Report.id, literal(0).label('rank'),
            states.c.status, Report.first_occurence.label('created'),
            Report.last_occurence.label('last_change'),
            OpSysComponent.name.label('component'), Report.type)
        .join(ReportOpSysRelease)
        .join(OpSysComponent)
        .filter(states.c.id==Report.id)
        .filter((ReportOpSysRelease.opsysrelease_id==opsysrelease_id) |
            (opsysrelease_id==-1))
        .order_by(desc('last_change')))

    component_ids = form.get_component_selection()
    if component_ids:
        reports = reports.filter(Report.component_id.in_(component_ids))

    reports = reports.all()

    i = 1
    for rep in reports:
        rep.rank = i
        i += 1

    reports = paginate(reports, request)
    forward = {'reports' : reports,
               'form'  : form}

    return render_to_response('reports/list.html',
        forward, context_instance=RequestContext(request))
Exemplo n.º 2
0
Arquivo: views.py Projeto: rtnpro/faf
def llvm(request):
    db = getDatabase()
    llvm_builds = db.session.query(LlvmBuild).order_by(desc(LlvmBuild.started)).all()
    llvm_builds = paginate(llvm_builds, request)

    for llvm_build in llvm_builds.object_list:
        llvm_build.add_nvr()
        llvm_build.add_human_readable_duration()
        llvm_build.count_bcfiles()

    return render_to_response("status/llvm.html", {"builds": llvm_builds}, context_instance=RequestContext(request))
Exemplo n.º 3
0
Arquivo: views.py Projeto: rtnpro/faf
def invalid(request):
    if not request.user.is_staff:
        raise Http404

    db = pyfaf.storage.getDatabase()
    reports = (db.session.query(InvalidUReport)
                         .order_by(desc(InvalidUReport.date))
                         .all())

    return render_to_response("reports/invalid.html",
        {"reports": paginate(reports, request)},
        context_instance=RequestContext(request))
Exemplo n.º 4
0
Arquivo: views.py Projeto: rtnpro/faf
def longterm(request, *args, **kwargs):
    db = pyfaf.storage.getDatabase()
    params = dict(request.REQUEST)
    params.update(kwargs)
    form = OsAssociateComponentFilterForm(db, params)

    ids = (r[0] for r in form.get_release_selection())

    problems = query_longterm_problems(db,
        flatten(ids),
        form.get_component_selection())

    problems = paginate(problems, request)
    forward = {'problems' : problems,
               'form' : form}

    return render_to_response('problems/longterm.html',
                              forward,
                              context_instance=RequestContext(request))
Exemplo n.º 5
0
Arquivo: views.py Projeto: rtnpro/faf
def hot(request, *args, **kwargs):
    db = pyfaf.storage.getDatabase()
    params = dict(request.REQUEST)
    params.update(kwargs)
    form = OsAssociateComponentFilterForm(db, params)
    last_date = datetime.date.today() - datetime.timedelta(days=14)

    ids = (r[0] for r in form.get_release_selection())

    problems = query_hot_problems(db,
        flatten(ids),
        form.get_component_selection(),
        last_date)

    problems = paginate(problems, request)
    forward = {'problems' : problems,
               'form' : form}

    return render_to_response('problems/hot.html',
                              forward,
                              context_instance=RequestContext(request))