fix(models.package_source): fix primary key constraints

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-12-21 15:26:25 -08:00
parent 22093c5c38
commit 5142447b7e
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
3 changed files with 12 additions and 5 deletions

View file

@ -10,7 +10,10 @@ class PackageSource(Base):
__table__ = schema.PackageSources
__tablename__ = __table__.name
__mapper_args__ = {
"primary_key": [__table__.c.PackageID]
"primary_key": [
__table__.c.PackageID,
__table__.c.Source
]
}
Package = relationship(
@ -26,3 +29,6 @@ class PackageSource(Base):
statement="Foreign key PackageID cannot be null.",
orig="PackageSources.PackageID",
params=("NULL"))
if not self.Source:
self.Source = "/dev/null"

View file

@ -201,7 +201,8 @@ async def package(request: Request, name: str) -> Response:
context["package"] = pkg
# Package sources.
context["sources"] = pkg.package_sources
context["sources"] = pkg.package_sources.order_by(
models.PackageSource.Source.asc()).all()
# Package dependencies.
dependencies = db.query(models.PackageDependency).join(

View file

@ -45,14 +45,14 @@
</div>
<div id="pkgfiles" class="listing">
<h3>Sources ({{ sources.count() }})</h3>
<h3>Sources ({{ sources | length }})</h3>
</div>
<div>
<ul id="pkgsrcslist">
{% for source in sources.all() %}
{% for src in sources %}
<li>
<a href="{{ source.Source }}">{{ source.Source }}</a>
<a href="{{ src.Source }}">{{ src.Source }}</a>
</li>
{% endfor %}
</ul>