diff --git a/.forgejo/workflows/deployment-pull-request.yaml b/.forgejo/workflows/deployment-pull-request.yaml deleted file mode 100644 index bef68b9..0000000 --- a/.forgejo/workflows/deployment-pull-request.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: deployment-on-pull-request -on: - pull_request: - pull_request_target: - types: - - opened - - reopened - - synchronize - -jobs: - deployment: - runs-on: docker - container: - image: node:bookworm - steps: - - uses: actions/checkout@v4 - - name: Build inventory - uses: https://codeberg.org/umglurf/kaniko-action@main - with: - cache: false - push: 'false' - context: /workspace/snoopy/in-c4/ diff --git a/.forgejo/workflows/deployment.yaml b/.forgejo/workflows/deployment.yaml deleted file mode 100644 index 391e59c..0000000 --- a/.forgejo/workflows/deployment.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: deployment -on: - push: - branches: - - 'main' - -jobs: - deployment: - runs-on: docker - container: - image: node:bookworm - steps: - - uses: actions/checkout@v4 - - name: Build inventory - uses: https://codeberg.org/umglurf/kaniko-action@main - with: - cache: true - cache_repo: git.koeln.ccc.de/${{ github.repository }}/cache - push: 'true' - context: /workspace/snoopy/in-c4/ - credentials: | - git.koeln.ccc.de=snoopy:${{ secrets.REGISTRY_WRITE }} - destinations: | - git.koeln.ccc.de/${{ github.repository }}/in-c4:latest diff --git a/.gitignore b/.gitignore index 03899e1..53c9ebf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/data/* +/inventory.sqlite3 *.pyc diff --git a/contrib/bulk_location_update.py b/contrib/bulk_location_update.py new file mode 100755 index 0000000..fd2752c --- /dev/null +++ b/contrib/bulk_location_update.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 + +from datetime import date + +import requests + +BASE = "https://in.ccc.ac" + + +session = requests.Session() +# session.auth = (":)", ":)") + +res = session.get(f"{BASE}/api/items") +res.raise_for_status() +items = res.json() + +is_in = input("is in (eg. R7): ") +print(items[is_in]) + + +def format_last_updated(item) -> str: + last_updated = item["last_updated"] + if last_updated is None: + return "" + return date.fromtimestamp(item["last_updated"]).isoformat()[:-3] + + +print(f"Items that should be in {is_in}:") +print( + "\n".join( + ( + f"{item['id']:<5} last_updated={format_last_updated(item)}" + for item in items.values() + if item["is_in"] == is_in + ) + ) +) + +while True: + try: + item_id = input(f"item that is in {is_in}: ") + except KeyboardInterrupt: + break + if item_id == "": + break + + if item_id not in items: + item_id = "K" + str(int(item_id)) + if item_id not in items: + print(f"{item_id} and K{item_id} do not exist.") + continue + item = items[item_id] + + print(f'location of {item_id}: {item["is_in"]} ->', end="") + item["is_in"] = is_in + print(f' {item["is_in"]}') + + res = session.put(f"{BASE}/api/items/{item_id}", json=item) + res.raise_for_status() diff --git a/database.py b/database.py index 7759e10..44a3006 100644 --- a/database.py +++ b/database.py @@ -2,7 +2,7 @@ from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker -SQLALCHEMY_DATABASE_URL = "sqlite:///./data/inventory.sqlite3" +SQLALCHEMY_DATABASE_URL = "sqlite:///./inventory.sqlite3" engine = create_engine( SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}, echo=True diff --git a/static/80x80.svg b/static/80x80.svg new file mode 100644 index 0000000..d0124e9 --- /dev/null +++ b/static/80x80.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/c4.css b/static/c4.css deleted file mode 100644 index abeae82..0000000 --- a/static/c4.css +++ /dev/null @@ -1,122 +0,0 @@ -body { - color: #f0f0f0; - background-color: #333; -} - -h1, h1 a { - color: #dfaa37; /* C4 Yellow */ -} - -#search.failed { - color: #200; - background-color: #ec6d5f; -} - -#map { - border: 1px solid #202020; - background-color: #4d4d4d; - max-width: 1440px; - max-height: 50vh; - aspect-ratio: 2 / 1; - box-shadow: 0px 6px 12px #000c; -} - -#mapnote { - background-color: #ccc; - color: #333; - border-color: #202020; - padding: 0.25em 0.5em; - position: relative; - top: -1px; - box-shadow: 0px 6px 12px #000c; -} - -#mapnote:empty { - display: none; -} - -#itemcount { - display: inline-block; - margin-right: 1ch; -} - -.result { - background-color: #202020; - border-color: #4d4d4d; -} - -.result:focus { - background-color: #202020; - border-color: #dfaa37; - outline-color: #dfaa37; -} - -.result a { - color: #dfaa37; -} - -.note { - background-color: #333; - font-size: smaller; -} - -#knowntypes button { - color: #220; - background-color: #dfaa37; - border: 1px solid #220; - border-radius: 4px; - padding: 0.2em 0.4em; - margin: 0.2em; - font-weight: bolder; - cursor: pointer; -} - -#knowntypes button:hover, #knowntypes button:focus { - background-color: #f5c251; -} - -.btn { - box-shadow: 0 3px 6px -1px rgba(0,0,0,0.3); -} - -.btn.primary { - color: #220; - background-color: #dfaa37; -} - -.btn.primary:hover,.btn.primary:focus { - background-color: #f5c251; -} - -.btn.grn { - color: #020; - background-color: #9f6; -} - -.btn.grn:hover ,.btn.grn:focus { - background-color: #3f0; -} - -.btn.red { - color: #200; - background-color: #ec6d5f; -} - -.btn.red:hover, .btn.red:focus { - background-color: #ff7667; -} - -@keyframes blinker { - 0% { opacity: 1; } - 40% { opacity: 1; } - 90% { opacity: 0; } - 100% { opacity: 1; } -} - -#mapgrid { - outline: 2px solid #333; - background-color: #dfaa37; - border-radius: min(4px, 25%); - animation: blinker 1s infinite; -} - diff --git a/static/form.html b/static/form.html index 44d5c16..d894279 100644 --- a/static/form.html +++ b/static/form.html @@ -3,7 +3,6 @@