mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: Add "groups" to package details page
Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
765f989b7d
commit
9d5b9c4795
3 changed files with 30 additions and 0 deletions
|
@ -200,6 +200,8 @@ async def package(
|
|||
|
||||
context["licenses"] = pkg.package_licenses
|
||||
|
||||
context["groups"] = pkg.package_groups
|
||||
|
||||
conflicts = pkg.package_relations.filter(
|
||||
models.PackageRelation.RelTypeID == CONFLICTS_ID
|
||||
).order_by(models.PackageRelation.RelName.asc())
|
||||
|
|
|
@ -68,6 +68,12 @@
|
|||
<td>{{ licenses.all() | join(', ', attribute='License.Name') }} </td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if show_package_details and groups and groups.count() %}
|
||||
<tr id="groups">
|
||||
<th>{{ "Groups" | tr }}:</th>
|
||||
<td>{{ groups.all() | join(', ', attribute='Group.Name') }} </td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if show_package_details and conflicts and conflicts.count() %}
|
||||
<tr id="conflicts">
|
||||
<th>{{ "Conflicts" | tr }}:</th>
|
||||
|
|
|
@ -8,8 +8,10 @@ from aurweb import config, db, templates, time
|
|||
from aurweb.filters import as_timezone, number_format, timestamp_to_datetime as to_dt
|
||||
from aurweb.models import Package, PackageBase, User
|
||||
from aurweb.models.account_type import USER_ID
|
||||
from aurweb.models.group import Group
|
||||
from aurweb.models.license import License
|
||||
from aurweb.models.package_base import popularity
|
||||
from aurweb.models.package_group import PackageGroup
|
||||
from aurweb.models.package_license import PackageLicense
|
||||
from aurweb.models.package_relation import PackageRelation
|
||||
from aurweb.models.relation_type import PROVIDES_ID, REPLACES_ID
|
||||
|
@ -88,6 +90,12 @@ def create_license(pkg: Package, license_name: str) -> PackageLicense:
|
|||
return pkglic
|
||||
|
||||
|
||||
def create_group(pkg: Package, group_name: str) -> PackageLicense:
|
||||
grp = db.create(Group, Name=group_name)
|
||||
pkggrp = db.create(PackageGroup, Group=grp, Package=pkg)
|
||||
return pkggrp
|
||||
|
||||
|
||||
def test_register_function_exists_key_error():
|
||||
"""Most instances of register_filter are tested through module
|
||||
imports or template renders, so we only test failures here."""
|
||||
|
@ -219,6 +227,15 @@ def check_package_details(content: str, pkg: Package) -> None:
|
|||
else:
|
||||
assert "Licenses" not in content
|
||||
|
||||
groups = pkg.package_groups.all()
|
||||
if groups:
|
||||
i += 1
|
||||
expected = ", ".join([p.Group.Name for p in groups])
|
||||
group_markup = rows[i].xpath("./td")[0]
|
||||
assert group_markup.text.strip() == expected
|
||||
else:
|
||||
assert "Groups" not in content
|
||||
|
||||
provides = pkg.package_relations.filter(
|
||||
PackageRelation.RelTypeID == PROVIDES_ID
|
||||
).all()
|
||||
|
@ -319,6 +336,10 @@ def test_package_details_filled(user: User, package: Package):
|
|||
create_license(package, "TPL") # Testing Public License
|
||||
create_license(package, "TPL2") # Testing Public License 2
|
||||
|
||||
# Create two groups.
|
||||
create_group(package, "GRP")
|
||||
create_group(package, "GRP2")
|
||||
|
||||
# Add provides.
|
||||
create_pkgrel(package, PROVIDES_ID, "test-provider")
|
||||
|
||||
|
@ -337,6 +358,7 @@ def test_package_details_filled(user: User, package: Package):
|
|||
"package": package,
|
||||
"comaintainers": [],
|
||||
"licenses": package.package_licenses,
|
||||
"groups": package.package_groups,
|
||||
"provides": package.package_relations.filter(
|
||||
PackageRelation.RelTypeID == PROVIDES_ID
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue