From: Michael Tremer Date: Tue, 11 Feb 2025 17:08:42 +0000 (+0000) Subject: images: Add modal with all checksums X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3e23eea2b9312b0b8a3fb96eb332ae8e68b3477;p=pbs.git images: Add modal with all checksums Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/images.py b/src/buildservice/images.py index 6833dea0..526c1e11 100644 --- a/src/buildservice/images.py +++ b/src/buildservice/images.py @@ -19,6 +19,7 @@ ############################################################################### import logging +import os.path import sqlalchemy from sqlalchemy import Column, ForeignKey @@ -90,6 +91,12 @@ class Image(database.Base, database.BackendMixin, database.SoftDeleteMixin): path = Column(Text, nullable=False) + # Filename + + @property + def filename(self): + return os.path.basename(self.path) + # Link @property @@ -103,6 +110,25 @@ class Image(database.Base, database.BackendMixin, database.SoftDeleteMixin): size = Column(BigInteger, nullable=False) + # Checksums + + @property + def checksums(self): + """ + A dictionary with all available checksums + """ + checksums = { + "sha3-512" : self.checksum_sha3_512, + "sha3-256" : self.checksum_sha3_256, + "blake2b512" : self.checksum_blake2b512, + "blake2s256" : self.checksum_blake2s256, + "sha2-512" : self.checksum_sha2_512, + "sha2-256" : self.checksum_sha2_256, + } + + # Filter out any empty checksums + return { algo : checksums[algo] for algo in checksums if checksums[algo] } + # Checksum SHA3-512 checksum_sha3_512 = Column(LargeBinary, nullable=False) diff --git a/src/templates/images/macros.html b/src/templates/images/macros.html index 14bfe5c1..27b11a4b 100644 --- a/src/templates/images/macros.html +++ b/src/templates/images/macros.html @@ -47,8 +47,75 @@ + + {# Checksums Link #} + + + {# Modal with the checksums #} + {% endfor %}