Exemplo n.º 1
0
def index(request):
    """The developer dashboard."""
    if request.user.is_authenticated():
        inner_q = PackageRelation.objects.filter(user=request.user)
    else:
        inner_q = PackageRelation.objects.none()
    inner_q = inner_q.values('pkgbase')

    flagged = Package.objects.normal().filter(
            flag_date__isnull=False, pkgbase__in=inner_q).order_by('pkgname')

    todopkgs = TodolistPackage.objects.select_related(
            'todolist', 'pkg', 'arch', 'repo').exclude(
            status=TodolistPackage.COMPLETE).filter(removed__isnull=True)
    todopkgs = todopkgs.filter(pkgbase__in=inner_q).order_by(
            'todolist__name', 'pkgname')

    todolists = get_annotated_todolists(incomplete_only=True)

    signoffs = sorted(get_signoff_groups(user=request.user),
            key=operator.attrgetter('pkgbase'))

    page_dict = {
            'todos': todolists,
            'flagged': flagged,
            'todopkgs': todopkgs,
            'signoffs': signoffs,
            'reports': available_reports(),
    }

    return render(request, 'devel/index.html', page_dict)
Exemplo n.º 2
0
def index(request):
    """The developer dashboard."""
    if request.user.is_authenticated:
        inner_q = PackageRelation.objects.filter(user=request.user)
    else:
        inner_q = PackageRelation.objects.none()
    inner_q = inner_q.values('pkgbase')

    flagged = Package.objects.normal().filter(
        flag_date__isnull=False, pkgbase__in=inner_q).order_by('pkgname')

    todopkgs = TodolistPackage.objects.select_related(
        'todolist', 'pkg', 'arch', 'repo').exclude(
            status=TodolistPackage.COMPLETE).filter(removed__isnull=True)
    todopkgs = todopkgs.filter(pkgbase__in=inner_q).order_by(
        'todolist__name', 'pkgname')

    todolists = get_annotated_todolists(incomplete_only=True)

    signoffs = sorted(get_signoff_groups(user=request.user),
                      key=operator.attrgetter('pkgbase'))

    page_dict = {
        'todos': todolists,
        'flagged': flagged,
        'todopkgs': todopkgs,
        'signoffs': signoffs,
        'reports': available_reports(),
    }

    return render(request, 'devel/index.html', page_dict)
Exemplo n.º 3
0
def index(request):
    '''the developer dashboard'''
    if (request.user.is_authenticated()):
        inner_q = PackageRelation.objects.filter(user=request.user)
    else:
        inner_q = PackageRelation.objects.none()
    inner_q = inner_q.values('pkgbase')

    flagged = Package.objects.normal().filter(
        flag_date__isnull=False, pkgbase__in=inner_q).order_by('pkgname')

    todopkgs = TodolistPkg.objects.select_related(
        'pkg', 'pkg__arch', 'pkg__repo').filter(complete=False)
    todopkgs = todopkgs.filter(pkg__pkgbase__in=inner_q).order_by(
        'list__name', 'pkg__pkgname')

    todolists = get_annotated_todolists(incomplete_only=True)

    signoffs = sorted(get_signoff_groups(user=request.user),
                      key=operator.attrgetter('pkgbase'))

    arches = Arch.objects.all().annotate(
        total_ct=Count('packages'), flagged_ct=Count('packages__flag_date'))
    repos = Repo.objects.all().annotate(
        total_ct=Count('packages'), flagged_ct=Count('packages__flag_date'))

    maintainers = get_annotated_maintainers()

    maintained = PackageRelation.objects.filter(
        type=PackageRelation.MAINTAINER).values('pkgbase')
    total_orphans = Package.objects.exclude(pkgbase__in=maintained).count()
    total_flagged_orphans = Package.objects.filter(
        flag_date__isnull=False).exclude(pkgbase__in=maintained).count()
    total_updated = Package.objects.filter(packager__isnull=True).count()
    orphan = {
        'package_count': total_orphans,
        'flagged_count': total_flagged_orphans,
        'updated_count': total_updated,
    }

    page_dict = {
        'todos': todolists,
        'arches': arches,
        'repos': repos,
        'maintainers': maintainers,
        'orphan': orphan,
        'flagged': flagged,
        'todopkgs': todopkgs,
        'signoffs': signoffs
    }

    return render(request, 'devel/index.html', page_dict)
Exemplo n.º 4
0
def index(request):
    '''the developer dashboard'''
    if(request.user.is_authenticated()):
        inner_q = PackageRelation.objects.filter(user=request.user)
    else:
        inner_q = PackageRelation.objects.none()
    inner_q = inner_q.values('pkgbase')

    flagged = Package.objects.normal().filter(
            flag_date__isnull=False, pkgbase__in=inner_q).order_by('pkgname')

    todopkgs = TodolistPkg.objects.select_related(
            'pkg', 'pkg__arch', 'pkg__repo').filter(complete=False)
    todopkgs = todopkgs.filter(pkg__pkgbase__in=inner_q).order_by(
            'list__name', 'pkg__pkgname')

    todolists = get_annotated_todolists(incomplete_only=True)

    signoffs = sorted(get_signoff_groups(user=request.user),
            key=operator.attrgetter('pkgbase'))

    arches = Arch.objects.all().annotate(
            total_ct=Count('packages'), flagged_ct=Count('packages__flag_date'))
    repos = Repo.objects.all().annotate(
            total_ct=Count('packages'), flagged_ct=Count('packages__flag_date'))

    maintainers = get_annotated_maintainers()

    maintained = PackageRelation.objects.filter(
            type=PackageRelation.MAINTAINER).values('pkgbase')
    total_orphans = Package.objects.exclude(pkgbase__in=maintained).count()
    total_flagged_orphans = Package.objects.filter(
            flag_date__isnull=False).exclude(pkgbase__in=maintained).count()
    total_updated = Package.objects.filter(packager__isnull=True).count()
    orphan = {
            'package_count': total_orphans,
            'flagged_count': total_flagged_orphans,
            'updated_count': total_updated,
    }

    page_dict = {
            'todos': todolists,
            'arches': arches,
            'repos': repos,
            'maintainers': maintainers,
            'orphan': orphan,
            'flagged': flagged,
            'todopkgs': todopkgs,
            'signoffs': signoffs
    }

    return render(request, 'devel/index.html', page_dict)
Exemplo n.º 5
0
def index(request):
    """The developer dashboard."""
    if request.user.is_authenticated():
        inner_q = PackageRelation.objects.filter(user=request.user)
    else:
        inner_q = PackageRelation.objects.none()
    inner_q = inner_q.values("pkgbase")

    flagged = Package.objects.normal().filter(flag_date__isnull=False, pkgbase__in=inner_q).order_by("pkgname")

    todopkgs = (
        TodolistPackage.objects.select_related("todolist", "pkg", "arch", "repo")
        .exclude(status=TodolistPackage.COMPLETE)
        .filter(removed__isnull=True)
    )
    todopkgs = todopkgs.filter(pkgbase__in=inner_q).order_by("todolist__name", "pkgname")

    todolists = get_annotated_todolists(incomplete_only=True)

    signoffs = sorted(get_signoff_groups(user=request.user), key=operator.attrgetter("pkgbase"))

    page_dict = {"todos": todolists, "flagged": flagged, "todopkgs": todopkgs, "signoffs": signoffs}

    return render(request, "devel/index.html", page_dict)
Exemplo n.º 6
0
def generate_report(email, repo_name):
    repo = Repo.objects.get(name__iexact=repo_name)
    # Collect all existing signoffs for these packages
    signoff_groups = sorted(get_signoff_groups([repo]),
            key=attrgetter('target_repo', 'arch', 'pkgbase'))
    disabled = []
    bad = []
    complete = []
    incomplete = []
    new = []
    old = []

    new_hours = 24
    old_days = 14
    current_time = now()
    new_cutoff = current_time - timedelta(hours=new_hours)
    old_cutoff = current_time - timedelta(days=old_days)

    if len(signoff_groups) == 0:
        # no need to send an email at all
        return

    for group in signoff_groups:
        spec = group.specification
        if spec.known_bad:
            bad.append(group)
        elif not spec.enabled:
            disabled.append(group)
        elif group.approved():
            complete.append(group)
        else:
            incomplete.append(group)

        if group.package.last_update > new_cutoff:
            new.append(group)
        if group.package.last_update < old_cutoff:
            old.append(group)

    old.sort(key=attrgetter('last_update'))

    proto = 'https'
    domain = Site.objects.get_current().domain
    signoffs_url = '%s://%s%s' % (proto, domain, reverse('package-signoffs'))

    # and the fun bit
    Leader = namedtuple('Leader', ['user', 'count'])
    leaders = Signoff.objects.filter(created__gt=new_cutoff,
            revoked__isnull=True).values_list('user').annotate(
                    signoff_count=Count('pk')).order_by('-signoff_count')[:5]
    users = User.objects.in_bulk([l[0] for l in leaders])
    leaders = (Leader(users[l[0]], l[1]) for l in leaders)

    subject = 'Signoff report for [%s]' % repo.name.lower()
    t = loader.get_template('packages/signoff_report.txt')
    c = Context({
        'repo': repo,
        'signoffs_url': signoffs_url,
        'disabled': disabled,
        'bad': bad,
        'all': signoff_groups,
        'incomplete': incomplete,
        'complete': complete,
        'new': new,
        'new_hours': new_hours,
        'old': old,
        'old_days': old_days,
        'leaders': leaders,
    })
    from_addr = 'Arch Website Notification <*****@*****.**>'
    send_mail(subject, t.render(c), from_addr, [email])