2024-01-06 06:28:38 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
2024-02-01 02:03:02 +01:00
|
|
|
BASE = "https://in.ccc.ac"
|
2024-01-06 06:28:38 +01:00
|
|
|
COUNT = 0
|
|
|
|
START_ID = 1
|
|
|
|
|
|
|
|
|
|
|
|
session = requests.Session()
|
|
|
|
# session.auth = (":)", ":)")
|
|
|
|
|
2024-02-01 02:03:02 +01:00
|
|
|
res = session.get(f"{BASE}/api/items")
|
2024-01-06 06:28:38 +01:00
|
|
|
res.raise_for_status()
|
|
|
|
ids = res.json().keys()
|
|
|
|
kiste_ids = {int(i.lstrip("K")) for i in ids if i.startswith("K") and i != "K"}
|
|
|
|
print("existing ids:", repr(kiste_ids), file=sys.stderr)
|
|
|
|
|
|
|
|
current_id = START_ID
|
|
|
|
new_ids = []
|
|
|
|
while len(new_ids) < COUNT:
|
|
|
|
if current_id not in kiste_ids:
|
|
|
|
new_ids.append(current_id)
|
|
|
|
current_id += 1
|
|
|
|
|
|
|
|
print("created:", file=sys.stderr)
|
|
|
|
if len(new_ids) == 0:
|
|
|
|
print("(none)", file=sys.stderr)
|
|
|
|
|
|
|
|
|
|
|
|
for i in new_ids:
|
|
|
|
j = {
|
|
|
|
"id": f"K{i}",
|
|
|
|
"is_in": None,
|
|
|
|
"coords_bl": None,
|
|
|
|
"coords_tr": None,
|
|
|
|
"type": "Kiste",
|
|
|
|
"name": None,
|
|
|
|
"content": None,
|
|
|
|
"note": "Bitte Name, Ort, Inhalt eintragen",
|
|
|
|
"hidden": False,
|
|
|
|
}
|
2024-02-01 02:03:02 +01:00
|
|
|
res = session.put(f"{BASE}/api/items/{j['id']}", json=j)
|
2024-01-06 06:28:38 +01:00
|
|
|
res.raise_for_status()
|
2024-02-01 02:03:02 +01:00
|
|
|
print(f"{j['id']},{BASE}/form.html?id={j['id']}")
|