Fix unsupported version warning on security page
authorJonathan S. Katz <jonathan.katz@excoventures.com>
Wed, 23 Mar 2022 19:09:19 +0000 (15:09 -0400)
committerJonathan S. Katz <jonathan.katz@excoventures.com>
Wed, 23 Mar 2022 19:09:19 +0000 (15:09 -0400)
This has probably not worked since 0cb56d93, but this patch will
allow for the warning to appear.

pgweb/security/views.py

index 86f9ddd4a58eb1f6f8640634292bd4e2627b2b4a..55d22f6a9cfe07d2628aa2f5c066153966d8e90d 100644 (file)
@@ -12,7 +12,7 @@ def GetPatchesList(filt):
     return SecurityPatch.objects.raw("SELECT p.*, array_agg(CASE WHEN v.tree >= 10 THEN v.tree::int ELSE v.tree END ORDER BY v.tree DESC) AS affected, array_agg(CASE WHEN v.tree >= 10 THEN v.tree::int ELSE v.tree END || '.' || fixed_minor ORDER BY v.tree DESC) AS fixed FROM security_securitypatch p INNER JOIN security_securitypatchversion sv ON p.id=sv.patch_id INNER JOIN core_version v ON v.id=sv.version_id WHERE p.public AND {0} GROUP BY p.id ORDER BY cvenumber DESC".format(filt))
 
 
-def _list_patches(request, filt):
+def _list_patches(request, filt, version=None):
     patches = GetPatchesList(filt)
 
     return render_pgweb(request, 'support', 'security/security.html', {
@@ -21,6 +21,7 @@ def _list_patches(request, filt):
         'unsupported': Version.objects.filter(supported=False, tree__gt=0).extra(
             where=["EXISTS (SELECT 1 FROM security_securitypatchversion pv WHERE pv.version_id=core_version.id)"],
         ),
+        'version': version,
     })
 
 
@@ -60,4 +61,4 @@ def version(request, numtree):
     version = get_object_or_404(Version, tree=numtree)
     # It's safe to pass in the value since we get it from the module, not from
     # the actual querystring.
-    return _list_patches(request, "EXISTS (SELECT 1 FROM security_securitypatchversion svv WHERE svv.version_id={0} AND svv.patch_id=p.id)".format(version.id))
+    return _list_patches(request, "EXISTS (SELECT 1 FROM security_securitypatchversion svv WHERE svv.version_id={0} AND svv.patch_id=p.id)".format(version.id), version)