Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag lib32 out of date when non lib32 marked out of date #230

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions packages/views/flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
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


class FlagForm(forms.Form):
email = forms.EmailField(label='E-mail Address')
message = forms.CharField(label='Message To Developer',
Expand Down Expand Up @@ -46,6 +47,34 @@ def clean_message(self):
def flaghelp(request):
return render(request, 'packages/flaghelp.html')

def find_same_pkgbase(pkg):
# Find packages based on the same packagebase
pkg_filter = Q(pkgbase=pkg.pkgbase,
repo__testing=pkg.repo.testing,
repo__staging=pkg.repo.staging)

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-',''))
pkg_filter = pkg_filter | Q(pkgbase=non_lib32_pkg.pkgbase,
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,
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):
Expand All @@ -54,12 +83,10 @@ 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,
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__isnull=True,
pkgver__lte=pkg.pkgver)

authenticated = request.user.is_authenticated

Expand Down Expand Up @@ -145,11 +172,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}

Expand Down