""" Zeugnis Seed Data - Initial URLs from Word Document Contains seed URLs for all 16 German federal states (Bundesländer) based on the "Bundesland URL Zeugnisse.docx" document. Training permissions: - Ja: Amtliches Werk (§5 UrhG) - training allowed - Nein: Keine Lizenz angegeben - training NOT allowed - Eingeschränkt: Treated as NOT allowed for safety """ from typing import Dict, List, Any # Seed data structure: bundesland -> list of seed URLs SEED_DATA: Dict[str, Dict[str, Any]] = { "bw": { "name": "Baden-Württemberg", "license": "gov_statute", "training_allowed": True, "base_url": "https://www.landesrecht-bw.de", "urls": [ { "url": "https://www.landesrecht-bw.de/jportal/portal/t/cru/page/bsbawueprod.psml?pid=Dokumentanzeige&showdoccase=1&js_peid=Trefferliste&documentnumber=1&numberofresults=1&fromdoctodoc=yes&doc.id=jlr-SchulGBWpP5&doc.part=X&doc.price=0.0&doc.hl=1", "doc_type": "verordnung", "title": "Schulgesetz BW - Zeugnisse" }, { "url": "https://www.landesrecht-bw.de/jportal/portal/t/cs9/page/bsbawueprod.psml?pid=Dokumentanzeige&showdoccase=1&js_peid=Trefferliste&documentnumber=1&numberofresults=1&fromdoctodoc=yes&doc.id=jlr-NotenBildVBW2016rahmen&doc.part=X&doc.price=0.0", "doc_type": "verordnung", "title": "Notenbildungsverordnung" } ] }, "by": { "name": "Bayern", "license": "gov_statute", "training_allowed": True, "base_url": "https://www.gesetze-bayern.de", "urls": [ { "url": "https://www.gesetze-bayern.de/Content/Document/BaySchO2016", "doc_type": "schulordnung", "title": "Bayerische Schulordnung" }, { "url": "https://www.gesetze-bayern.de/Content/Document/BayGSO", "doc_type": "schulordnung", "title": "Grundschulordnung Bayern" }, { "url": "https://www.gesetze-bayern.de/Content/Document/BayVSO", "doc_type": "schulordnung", "title": "Volksschulordnung Bayern" } ] }, "be": { "name": "Berlin", "license": "unknown", "training_allowed": False, "base_url": "https://gesetze.berlin.de", "urls": [ { "url": "https://gesetze.berlin.de/bsbe/document/jlr-SchulGBEpP58", "doc_type": "verordnung", "title": "Berliner Schulgesetz - Zeugnisse" }, { "url": "https://gesetze.berlin.de/bsbe/document/jlr-SekIVBE2010rahmen", "doc_type": "verordnung", "title": "Sekundarstufe I-Verordnung" } ] }, "bb": { "name": "Brandenburg", "license": "unknown", "training_allowed": False, "base_url": "https://bravors.brandenburg.de", "urls": [ { "url": "https://bravors.brandenburg.de/verordnungen/vvzeugnis", "doc_type": "verordnung", "title": "Verwaltungsvorschriften Zeugnisse" }, { "url": "https://bravors.brandenburg.de/verordnungen/gostv", "doc_type": "verordnung", "title": "GOST-Verordnung Brandenburg" } ] }, "hb": { "name": "Bremen", "license": "unknown", "training_allowed": False, # Eingeschränkt -> False for safety "base_url": "https://www.transparenz.bremen.de", "urls": [ { "url": "https://www.transparenz.bremen.de/metainformationen/bremisches-schulgesetz-bremschg-vom-28-juni-2005-121009", "doc_type": "verordnung", "title": "Bremisches Schulgesetz" }, { "url": "https://www.transparenz.bremen.de/metainformationen/verordnung-ueber-die-sekundarstufe-i-der-oberschule-vom-20-juni-2017-130380", "doc_type": "verordnung", "title": "Sekundarstufe I Verordnung Bremen" } ] }, "hh": { "name": "Hamburg", "license": "unknown", "training_allowed": False, "base_url": "https://www.landesrecht-hamburg.de", "urls": [ { "url": "https://www.landesrecht-hamburg.de/bsha/document/jlr-SchulGHA2009pP44", "doc_type": "verordnung", "title": "Hamburgisches Schulgesetz - Zeugnisse" }, { "url": "https://www.landesrecht-hamburg.de/bsha/document/jlr-AusglLeistVHA2011rahmen", "doc_type": "verordnung", "title": "Ausbildungs- und Prüfungsordnung" } ] }, "he": { "name": "Hessen", "license": "gov_statute", "training_allowed": True, "base_url": "https://www.rv.hessenrecht.hessen.de", "urls": [ { "url": "https://www.rv.hessenrecht.hessen.de/bshe/document/jlr-SchulGHE2017pP73", "doc_type": "verordnung", "title": "Hessisches Schulgesetz - Zeugnisse" }, { "url": "https://www.rv.hessenrecht.hessen.de/bshe/document/jlr-VOBGM11HE2011rahmen", "doc_type": "verordnung", "title": "Verordnung zur Gestaltung des Schulverhältnisses" } ] }, "mv": { "name": "Mecklenburg-Vorpommern", "license": "unknown", "training_allowed": False, # Eingeschränkt -> False for safety "base_url": "https://www.landesrecht-mv.de", "urls": [ { "url": "https://www.landesrecht-mv.de/bsmv/document/jlr-SchulGMV2010pP63", "doc_type": "verordnung", "title": "Schulgesetz MV - Zeugnisse" }, { "url": "https://www.landesrecht-mv.de/bsmv/document/jlr-ZeugnVMVrahmen", "doc_type": "verordnung", "title": "Zeugnisverordnung MV" } ] }, "ni": { "name": "Niedersachsen", "license": "gov_statute", "training_allowed": True, "base_url": "https://www.nds-voris.de", "urls": [ { "url": "https://www.nds-voris.de/jportal/portal/t/1gxi/page/bsvorisprod.psml?pid=Dokumentanzeige&showdoccase=1&js_peid=Trefferliste&documentnumber=1&numberofresults=1&fromdoctodoc=yes&doc.id=jlr-SchulGNDpP59", "doc_type": "verordnung", "title": "Niedersächsisches Schulgesetz - Zeugnisse" }, { "url": "https://www.nds-voris.de/jportal/portal/t/1gxi/page/bsvorisprod.psml?pid=Dokumentanzeige&showdoccase=1&js_peid=Trefferliste&documentnumber=1&numberofresults=1&fromdoctodoc=yes&doc.id=jlr-ErgZeugnErlNDrahmen", "doc_type": "erlass", "title": "Ergänzende Bestimmungen für Zeugnisse" }, { "url": "https://www.mk.niedersachsen.de/startseite/schule/unsere_schulen/allgemein_bildende_schulen/zeugnisse_versetzungen/zeugnisse-und-versetzungen-6351.html", "doc_type": "handreichung", "title": "Handreichung Zeugnisse NI" } ] }, "nw": { "name": "Nordrhein-Westfalen", "license": "gov_statute", "training_allowed": True, "base_url": "https://recht.nrw.de", "urls": [ { "url": "https://recht.nrw.de/lmi/owa/br_text_anzeigen?v_id=10000000000000000521", "doc_type": "verordnung", "title": "Schulgesetz NRW" }, { "url": "https://recht.nrw.de/lmi/owa/br_text_anzeigen?v_id=10000000000000000525", "doc_type": "verordnung", "title": "Ausbildungs- und Prüfungsordnung Sek I" }, { "url": "https://www.schulministerium.nrw/zeugnisse", "doc_type": "handreichung", "title": "Handreichung Zeugnisse NRW" } ] }, "rp": { "name": "Rheinland-Pfalz", "license": "gov_statute", "training_allowed": True, "base_url": "https://landesrecht.rlp.de", "urls": [ { "url": "https://landesrecht.rlp.de/bsrp/document/jlr-SchulGRPpP61", "doc_type": "verordnung", "title": "Schulgesetz RP - Zeugnisse" }, { "url": "https://landesrecht.rlp.de/bsrp/document/jlr-ZeugnVRPrahmen", "doc_type": "verordnung", "title": "Zeugnisverordnung RP" } ] }, "sl": { "name": "Saarland", "license": "unknown", "training_allowed": False, "base_url": "https://recht.saarland.de", "urls": [ { "url": "https://recht.saarland.de/bssl/document/jlr-SchulOGSLrahmen", "doc_type": "schulordnung", "title": "Schulordnungsgesetz Saarland" }, { "url": "https://recht.saarland.de/bssl/document/jlr-ZeugnVSL2014rahmen", "doc_type": "verordnung", "title": "Zeugnisverordnung Saarland" } ] }, "sn": { "name": "Sachsen", "license": "gov_statute", "training_allowed": True, "base_url": "https://www.revosax.sachsen.de", "urls": [ { "url": "https://www.revosax.sachsen.de/vorschrift/4192-Schulgesetz-fuer-den-Freistaat-Sachsen", "doc_type": "verordnung", "title": "Schulgesetz Sachsen" }, { "url": "https://www.revosax.sachsen.de/vorschrift/13500-Schulordnung-Gymnasien-Abiturpruefung", "doc_type": "schulordnung", "title": "Schulordnung Gymnasien Sachsen" } ] }, "st": { "name": "Sachsen-Anhalt", "license": "unknown", "training_allowed": False, # Eingeschränkt -> False for safety "base_url": "https://www.landesrecht.sachsen-anhalt.de", "urls": [ { "url": "https://www.landesrecht.sachsen-anhalt.de/bsst/document/jlr-SchulGSTpP27", "doc_type": "verordnung", "title": "Schulgesetz Sachsen-Anhalt" }, { "url": "https://www.landesrecht.sachsen-anhalt.de/bsst/document/jlr-VersetzVST2017rahmen", "doc_type": "verordnung", "title": "Versetzungsverordnung ST" } ] }, "sh": { "name": "Schleswig-Holstein", "license": "gov_statute", "training_allowed": True, "base_url": "https://www.gesetze-rechtsprechung.sh.juris.de", "urls": [ { "url": "https://www.gesetze-rechtsprechung.sh.juris.de/jportal/portal/t/10wx/page/bsshoprod.psml?pid=Dokumentanzeige&showdoccase=1&js_peid=Trefferliste&documentnumber=1&numberofresults=1&fromdoctodoc=yes&doc.id=jlr-SchulGSHpP22", "doc_type": "verordnung", "title": "Schulgesetz SH - Zeugnisse" }, { "url": "https://www.gesetze-rechtsprechung.sh.juris.de/jportal/portal/t/10wx/page/bsshoprod.psml?pid=Dokumentanzeige&showdoccase=1&js_peid=Trefferliste&documentnumber=1&numberofresults=1&fromdoctodoc=yes&doc.id=jlr-ZeugnVSHrahmen", "doc_type": "verordnung", "title": "Zeugnisverordnung SH" } ] }, "th": { "name": "Thüringen", "license": "gov_statute", "training_allowed": True, "base_url": "https://landesrecht.thueringen.de", "urls": [ { "url": "https://landesrecht.thueringen.de/bsth/document/jlr-SchulGTHpP58", "doc_type": "verordnung", "title": "Thüringer Schulgesetz - Zeugnisse" }, { "url": "https://landesrecht.thueringen.de/bsth/document/jlr-SchulOTH2018rahmen", "doc_type": "schulordnung", "title": "Thüringer Schulordnung" } ] } } async def populate_seed_data(): """Populate database with seed data.""" from metrics_db import get_pool, upsert_zeugnis_source from zeugnis_models import generate_id pool = await get_pool() if not pool: print("Database not available") return False try: async with pool.acquire() as conn: for bundesland, data in SEED_DATA.items(): # Create or update source source_id = generate_id() await upsert_zeugnis_source( id=source_id, bundesland=bundesland, name=data["name"], license_type=data["license"], training_allowed=data["training_allowed"], base_url=data.get("base_url"), ) # Get the actual source ID (might be existing) existing = await conn.fetchrow( "SELECT id FROM zeugnis_sources WHERE bundesland = $1", bundesland ) if existing: source_id = existing["id"] # Add seed URLs for url_data in data.get("urls", []): url_id = generate_id() await conn.execute( """ INSERT INTO zeugnis_seed_urls (id, source_id, url, doc_type, status) VALUES ($1, $2, $3, $4, 'pending') ON CONFLICT DO NOTHING """, url_id, source_id, url_data["url"], url_data["doc_type"] ) print(f"Populated {bundesland}: {len(data.get('urls', []))} URLs") print("Seed data population complete!") return True except Exception as e: print(f"Failed to populate seed data: {e}") return False def get_training_summary() -> Dict[str, List[str]]: """Get summary of training permissions.""" allowed = [] not_allowed = [] for bundesland, data in SEED_DATA.items(): name = data["name"] if data["training_allowed"]: allowed.append(f"{name} ({bundesland})") else: not_allowed.append(f"{name} ({bundesland})") return { "training_allowed": sorted(allowed), "training_not_allowed": sorted(not_allowed), "total_allowed": len(allowed), "total_not_allowed": len(not_allowed), } if __name__ == "__main__": import asyncio print("=" * 60) print("Zeugnis Seed Data Summary") print("=" * 60) summary = get_training_summary() print(f"\nTraining ALLOWED ({summary['total_allowed']} Bundesländer):") for bl in summary["training_allowed"]: print(f" ✓ {bl}") print(f"\nTraining NOT ALLOWED ({summary['total_not_allowed']} Bundesländer):") for bl in summary["training_not_allowed"]: print(f" ✗ {bl}") print("\n" + "=" * 60) print("To populate database, run:") print(" python -c 'import asyncio; from zeugnis_seed_data import populate_seed_data; asyncio.run(populate_seed_data())'")