From 88680f0b3868aaf7f8485e0c0f7f420f7fe2b01d Mon Sep 17 00:00:00 2001 From: Lars Rustand Date: Sun, 28 Jul 2019 21:13:14 +0200 Subject: [PATCH 1/3] Flag lib32 out of date when non lib32 marked out of date Signed-off-by: Lars Rustand --- packages/views/flag.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/views/flag.py b/packages/views/flag.py index 91995ee7..b4aa9105 100644 --- a/packages/views/flag.py +++ b/packages/views/flag.py @@ -9,6 +9,8 @@ from django.template import loader from django.utils.timezone import now from django.views.decorators.cache import cache_page, never_cache +from django.db.models import Q +from django.http import Http404 from ..models import FlagRequest from main.models import Package @@ -54,13 +56,32 @@ def flag(request, name, repo, arch): if pkg.flag_date is not None: # already flagged. do nothing. return render(request, 'packages/flagged.html', {'pkg': pkg}) - # find all packages from (hopefully) the same PKGBUILD - pkgs = Package.objects.normal().filter( - pkgbase=pkg.pkgbase, flag_date__isnull=True, + + # Find packages based on the same packagebase + pkg_filter = Q(pkgbase=pkg.pkgbase, flag_date__isnull=True, repo__testing=pkg.repo.testing, - repo__staging=pkg.repo.staging).order_by( - 'pkgname', 'repo__name', 'arch__name') + repo__staging=pkg.repo.staging) + + if "lib32-" in name: + # Find normal version of lib32 packages + non_lib32_pkg = get_object_or_404(Package.objects.normal(), + pkgname=name.replace("lib32-","")) + pkg_filter = pkg_filter | Q(pkgbase=non_lib32_pkg.pkgbase, + flag_date__isnull=True) + else: + # Find lib32 version of normal packages + try: + lib32_pkg = get_object_or_404(Package.objects.normal(), + pkgname="lib32-"+pkg.pkgbase) + pkg_filter = pkg_filter | Q(pkgbase=lib32_pkg.pkgbase, + flag_date__isnull=True) + except Http404: + pass # Do not raise an error when there is no lib32 version + + + pkgs = Package.objects.normal().filter(pkg_filter).order_by( + 'pkgname', 'repo__name', 'arch__name') authenticated = request.user.is_authenticated if request.POST: From 566227f207057aa0a3661960285ca20faa69ac0f Mon Sep 17 00:00:00 2001 From: Lars Rustand Date: Thu, 8 Aug 2019 21:39:32 +0200 Subject: [PATCH 2/3] Fix confirmation for all flagged packages Signed-off-by: Lars Rustand --- packages/views/flag.py | 46 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/packages/views/flag.py b/packages/views/flag.py index b4aa9105..035e7f15 100644 --- a/packages/views/flag.py +++ b/packages/views/flag.py @@ -15,7 +15,6 @@ from ..models import FlagRequest from main.models import Package - class FlagForm(forms.Form): email = forms.EmailField(label='E-mail Address') message = forms.CharField(label='Message To Developer', @@ -48,40 +47,46 @@ def clean_message(self): def flaghelp(request): return render(request, 'packages/flaghelp.html') - -@never_cache -def flag(request, name, repo, arch): - pkg = get_object_or_404(Package.objects.normal(), - pkgname=name, repo__name__iexact=repo, arch__name=arch) - if pkg.flag_date is not None: - # already flagged. do nothing. - return render(request, 'packages/flagged.html', {'pkg': pkg}) - +def find_same_pkgbase(pkg): # Find packages based on the same packagebase - pkg_filter = Q(pkgbase=pkg.pkgbase, flag_date__isnull=True, + pkg_filter = Q(pkgbase=pkg.pkgbase, repo__testing=pkg.repo.testing, repo__staging=pkg.repo.staging) - if "lib32-" in name: + if "lib32-" in pkg.pkgname: # Find normal version of lib32 packages non_lib32_pkg = get_object_or_404(Package.objects.normal(), - pkgname=name.replace("lib32-","")) + pkgname=pkg.pkgname.replace("lib32-","")) pkg_filter = pkg_filter | Q(pkgbase=non_lib32_pkg.pkgbase, - flag_date__isnull=True) + repo__testing=pkg.repo.testing, + repo__staging=pkg.repo.staging) else: # Find lib32 version of normal packages try: lib32_pkg = get_object_or_404(Package.objects.normal(), pkgname="lib32-"+pkg.pkgbase) pkg_filter = pkg_filter | Q(pkgbase=lib32_pkg.pkgbase, - flag_date__isnull=True) + repo__testing=pkg.repo.testing, + repo__staging=pkg.repo.staging) except Http404: pass # Do not raise an error when there is no lib32 version - - pkgs = Package.objects.normal().filter(pkg_filter).order_by( 'pkgname', 'repo__name', 'arch__name') + + return pkgs + +@never_cache +def flag(request, name, repo, arch): + pkg = get_object_or_404(Package.objects.normal(), + pkgname=name, repo__name__iexact=repo, arch__name=arch) + if pkg.flag_date is not None: + # already flagged. do nothing. + return render(request, 'packages/flagged.html', {'pkg': pkg}) + + pkgs = find_same_pkgbase(pkg).filter( + flag_date__isnull=True) + authenticated = request.user.is_authenticated if request.POST: @@ -166,11 +171,8 @@ def perform_updates(): def flag_confirmed(request, name, repo, arch): pkg = get_object_or_404(Package, pkgname=name, repo__name__iexact=repo, arch__name=arch) - pkgs = Package.objects.normal().filter( - pkgbase=pkg.pkgbase, flag_date=pkg.flag_date, - repo__testing=pkg.repo.testing, - repo__staging=pkg.repo.staging).order_by( - 'pkgname', 'repo__name', 'arch__name') + pkgs = find_same_pkgbase(pkg).filter( + flag_date=pkg.flag_date) context = {'package': pkg, 'packages': pkgs} From 75182def1c6d2def76614bc450f6c873a751c5ee Mon Sep 17 00:00:00 2001 From: Lars Rustand Date: Thu, 8 Aug 2019 21:41:31 +0200 Subject: [PATCH 3/3] Only flag pacakges with same or lower pkgver Signed-off-by: Lars Rustand --- packages/views/flag.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/views/flag.py b/packages/views/flag.py index 035e7f15..f3aadcdb 100644 --- a/packages/views/flag.py +++ b/packages/views/flag.py @@ -53,10 +53,10 @@ def find_same_pkgbase(pkg): repo__testing=pkg.repo.testing, repo__staging=pkg.repo.staging) - if "lib32-" in pkg.pkgname: + if 'lib32-' in pkg.pkgname: # Find normal version of lib32 packages non_lib32_pkg = get_object_or_404(Package.objects.normal(), - pkgname=pkg.pkgname.replace("lib32-","")) + pkgname=pkg.pkgname.replace('lib32-','')) pkg_filter = pkg_filter | Q(pkgbase=non_lib32_pkg.pkgbase, repo__testing=pkg.repo.testing, repo__staging=pkg.repo.staging) @@ -64,7 +64,7 @@ def find_same_pkgbase(pkg): # Find lib32 version of normal packages try: lib32_pkg = get_object_or_404(Package.objects.normal(), - pkgname="lib32-"+pkg.pkgbase) + pkgname='lib32-'+pkg.pkgbase) pkg_filter = pkg_filter | Q(pkgbase=lib32_pkg.pkgbase, repo__testing=pkg.repo.testing, repo__staging=pkg.repo.staging) @@ -85,7 +85,8 @@ def flag(request, name, repo, arch): return render(request, 'packages/flagged.html', {'pkg': pkg}) pkgs = find_same_pkgbase(pkg).filter( - flag_date__isnull=True) + flag_date__isnull=True, + pkgver__lte=pkg.pkgver) authenticated = request.user.is_authenticated