Compare commits
10 Commits
733a437ae0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ae657d1b03 | |||
| 362f474e3d | |||
| b8069802f6 | |||
| ff652d6f90 | |||
| fb05b74350 | |||
| 26d62014c9 | |||
| 69ca9bce4d | |||
| 4b15c5f173 | |||
| 8520412867 | |||
| 27b0f62274 |
142
.gitea/workflows/build-on-demand.yml
Normal file
142
.gitea/workflows/build-on-demand.yml
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
name: Build image when workload image tag changes
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ deployment ] # adjust if needed
|
||||||
|
paths:
|
||||||
|
- "arcocd/deployment.yaml"
|
||||||
|
- "Dockerfile" # keep if you also want to rebuild when Dockerfile changes
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-if-image-changed:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
env:
|
||||||
|
DEPLOY_FILE: "arcocd/deployment.yaml"
|
||||||
|
TARGET_REPO: "git.baumann.gr/adebaumann/vui" # repo (no tag)
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Determine base commit
|
||||||
|
id: base
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if git rev-parse --verify -q HEAD~1 >/dev/null; then
|
||||||
|
echo "base=$(git rev-parse HEAD~1)" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "base=$(git hash-object -t tree /dev/null)" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install yq for robust YAML parsing
|
||||||
|
- name: Install yq
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
YQ_VER=v4.44.3
|
||||||
|
curl -sL "https://github.com/mikefarah/yq/releases/download/${YQ_VER}/yq_linux_amd64" -o /usr/local/bin/yq
|
||||||
|
chmod +x /usr/local/bin/yq
|
||||||
|
yq --version
|
||||||
|
|
||||||
|
- name: Read workload image from deployment (old vs new)
|
||||||
|
id: img
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
file="$DEPLOY_FILE"
|
||||||
|
repo="$TARGET_REPO"
|
||||||
|
|
||||||
|
# Function: from a deployment yaml, read .spec.template.spec.containers[].image
|
||||||
|
# and select the one whose image starts with "$repo:"
|
||||||
|
extract() {
|
||||||
|
yq -r '
|
||||||
|
.spec.template.spec.containers // [] # only real containers, not initContainers
|
||||||
|
| map(.image) | .[]? # images as strings
|
||||||
|
| select(startswith(env(repo) + ":")) # match exact repo + ":"
|
||||||
|
' "$1" 2>/dev/null | tail -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Old image from previous commit (if file existed)
|
||||||
|
if git cat-file -e "${{ steps.base.outputs.base }}":"$file" 2>/dev/null; then
|
||||||
|
git show "${{ steps.base.outputs.base }}:$file" > /tmp/old.yaml
|
||||||
|
old_image="$(extract /tmp/old.yaml || true)"
|
||||||
|
else
|
||||||
|
old_image=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# New image from workspace
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
new_image="$(extract "$file" || true)"
|
||||||
|
else
|
||||||
|
new_image=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Old workload image: $old_image"
|
||||||
|
echo "New workload image: $new_image"
|
||||||
|
|
||||||
|
# Helpers to split repo and tag (handles registry with port)
|
||||||
|
parse_tag() {
|
||||||
|
local ref="$1"
|
||||||
|
local after_slash="${ref##*/}"
|
||||||
|
if [[ "$after_slash" == *:* ]]; then echo "${after_slash##*:}"; else echo ""; fi
|
||||||
|
}
|
||||||
|
parse_repo() {
|
||||||
|
local ref="$1"
|
||||||
|
local tag="$(parse_tag "$ref")"
|
||||||
|
if [ -n "$tag" ]; then echo "${ref%:$tag}"; else echo "$ref"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
old_tag="$(parse_tag "$old_image")"
|
||||||
|
new_tag="$(parse_tag "$new_image")"
|
||||||
|
new_repo="$(parse_repo "$new_image")"
|
||||||
|
|
||||||
|
if [ -z "$new_image" ]; then
|
||||||
|
echo "ERROR: Could not find a containers[].image starting with ${repo}: in $file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
registry="$(echo "$new_repo" | awk -F/ '{print $1}')"
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "changed=$([ "$old_tag" != "$new_tag" ] && echo true || echo false)"
|
||||||
|
echo "new_image=$new_image"
|
||||||
|
echo "new_repo=$new_repo"
|
||||||
|
echo "new_tag=$new_tag"
|
||||||
|
echo "registry=$registry"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Skip if tag unchanged
|
||||||
|
if: steps.img.outputs.changed != 'true'
|
||||||
|
run: echo "Workload image tag unchanged in ${{ env.DEPLOY_FILE }}; skipping build."
|
||||||
|
|
||||||
|
- name: Set up Buildx
|
||||||
|
if: steps.img.outputs.changed == 'true'
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
if: steps.img.outputs.changed == 'true'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ steps.img.outputs.registry }}
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push (exact tag from deployment)
|
||||||
|
if: steps.img.outputs.changed == 'true'
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ steps.img.outputs.new_image }}
|
||||||
|
${{ steps.img.outputs.new_repo }}:latest
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.source=${{ gitea.repository }}
|
||||||
|
org.opencontainers.image.revision=${{ gitea.sha }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -8,11 +8,10 @@ include/
|
|||||||
keys/
|
keys/
|
||||||
.venv/
|
.venv/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
*.kate-swp
|
*.kate-swp
|
||||||
|
media/diagram_cache/
|
||||||
|
.env
|
||||||
node_modules/
|
node_modules/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
package.json
|
package.json
|
||||||
# Diagram cache directory
|
data/db.sqlite3
|
||||||
media/diagram_cache/
|
|
||||||
.env
|
|
||||||
|
|||||||
@@ -2,5 +2,8 @@
|
|||||||
|
|
||||||
There are examples for importing text in the "Documentation"-directory. Actual documentation follows.
|
There are examples for importing text in the "Documentation"-directory. Actual documentation follows.
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Documentation on Confluence so far.
|
Documentation on Confluence so far.
|
||||||
This commit should be signed.
|
This commit should be signed.
|
||||||
|
=======
|
||||||
|
>>>>>>> 299c046 (Readme added)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from django.contrib import admin
|
|||||||
#from nested_inline.admin import NestedStackedInline, NestedModelAdmin
|
#from nested_inline.admin import NestedStackedInline, NestedModelAdmin
|
||||||
from nested_admin import NestedStackedInline, NestedModelAdmin, NestedTabularInline
|
from nested_admin import NestedStackedInline, NestedModelAdmin, NestedTabularInline
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.utils.html import format_html
|
||||||
from mptt.forms import TreeNodeMultipleChoiceField
|
from mptt.forms import TreeNodeMultipleChoiceField
|
||||||
from mptt.admin import DraggableMPTTAdmin
|
from mptt.admin import DraggableMPTTAdmin
|
||||||
from adminsortable2.admin import SortableInlineAdminMixin, SortableAdminBase
|
from adminsortable2.admin import SortableInlineAdminMixin, SortableAdminBase
|
||||||
@@ -132,9 +133,57 @@ class StichworterklaerungInline(NestedTabularInline):
|
|||||||
|
|
||||||
@admin.register(Stichwort)
|
@admin.register(Stichwort)
|
||||||
class StichwortAdmin(NestedModelAdmin):
|
class StichwortAdmin(NestedModelAdmin):
|
||||||
|
list_display = ('stichwort', 'vorgaben_count')
|
||||||
search_fields = ('stichwort',)
|
search_fields = ('stichwort',)
|
||||||
ordering=('stichwort',)
|
ordering=('stichwort',)
|
||||||
inlines=[StichworterklaerungInline]
|
inlines=[StichworterklaerungInline]
|
||||||
|
readonly_fields = ('vorgaben_list',)
|
||||||
|
fieldsets = (
|
||||||
|
(None, {
|
||||||
|
'fields': ('stichwort', 'vorgaben_list')
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
def vorgaben_count(self, obj):
|
||||||
|
"""Count the number of Vorgaben that have this Stichwort"""
|
||||||
|
count = obj.vorgabe_set.count()
|
||||||
|
return f"{count} Vorgabe{'n' if count != 1 else ''}"
|
||||||
|
vorgaben_count.short_description = "Anzahl Vorgaben"
|
||||||
|
|
||||||
|
def vorgaben_list(self, obj):
|
||||||
|
"""Display list of Vorgaben that use this Stichwort"""
|
||||||
|
vorgaben = obj.vorgabe_set.select_related('dokument', 'thema').order_by('dokument__nummer', 'nummer')
|
||||||
|
vorgaben_list = list(vorgaben) # Evaluate queryset once
|
||||||
|
count = len(vorgaben_list)
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
return format_html("<em>Keine Vorgaben gefunden</em><p><strong>Gesamt: 0 Vorgaben</strong></p>")
|
||||||
|
|
||||||
|
html = "<div style='max-height: 300px; overflow-y: auto;'>"
|
||||||
|
html += "<table style='width: 100%; border-collapse: collapse;'>"
|
||||||
|
html += "<thead><tr style='background-color: #f5f5f5;'>"
|
||||||
|
html += "<th style='padding: 8px; border: 1px solid #ddd; text-align: left;'>Vorgabe</th>"
|
||||||
|
html += "<th style='padding: 8px; border: 1px solid #ddd; text-align: left;'>Titel</th>"
|
||||||
|
html += "<th style='padding: 8px; border: 1px solid #ddd; text-align: left;'>Dokument</th>"
|
||||||
|
html += "</tr></thead>"
|
||||||
|
html += "<tbody>"
|
||||||
|
|
||||||
|
for vorgabe in vorgaben_list:
|
||||||
|
html += "<tr>"
|
||||||
|
html += f"<td style='padding: 6px; border: 1px solid #ddd;'>{vorgabe.Vorgabennummer()}</td>"
|
||||||
|
html += f"<td style='padding: 6px; border: 1px solid #ddd;'>{vorgabe.titel}</td>"
|
||||||
|
html += f"<td style='padding: 6px; border: 1px solid #ddd;'>{vorgabe.dokument.nummer} – {vorgabe.dokument.name}</td>"
|
||||||
|
html += "</tr>"
|
||||||
|
|
||||||
|
html += "</tbody></table>"
|
||||||
|
html += f"</div><p><strong>Gesamt: {count} Vorgabe{'n' if count != 1 else ''}</strong></p>"
|
||||||
|
|
||||||
|
return format_html(html)
|
||||||
|
vorgaben_list.short_description = "Zugeordnete Vorgaben"
|
||||||
|
|
||||||
|
def get_queryset(self, request):
|
||||||
|
"""Optimize queryset with related data"""
|
||||||
|
return super().get_queryset(request).prefetch_related('vorgabe_set')
|
||||||
|
|
||||||
@admin.register(Person)
|
@admin.register(Person)
|
||||||
class PersonAdmin(admin.ModelAdmin):
|
class PersonAdmin(admin.ModelAdmin):
|
||||||
|
|||||||
@@ -1075,7 +1075,7 @@ class IncompleteVorgabenTest(TestCase):
|
|||||||
|
|
||||||
response = self.client.get(reverse('incomplete_vorgaben'))
|
response = self.client.get(reverse('incomplete_vorgaben'))
|
||||||
# Debug: print response content to see where it appears
|
# Debug: print response content to see where it appears
|
||||||
print("Response content:", response.content.decode())
|
#print("Response content:", response.content.decode())
|
||||||
# Should NOT appear in "no text" list because it has Langtext
|
# Should NOT appear in "no text" list because it has Langtext
|
||||||
self.assertNotContains(response, 'Vorgabe nur mit Langtext')
|
self.assertNotContains(response, 'Vorgabe nur mit Langtext')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user