From a5f80701797e43fcef4a950a3b9bb5751a82fae8 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 25 Sep 2023 17:35:21 +0100 Subject: [PATCH 1/3] Improve speaker merging code. --- main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index f1e5990..82b1262 100755 --- a/main.py +++ b/main.py @@ -186,9 +186,20 @@ def merge() -> str | Response: print(other_ids, "->", merge_to_id) + conference_people = model.ConferencePerson.query.filter( + model.ConferencePerson.person_id.in_(other_ids) + ) + with database.session.begin(): + merge_to = model.Person.query.get(merge_to_id) + existing_conferences = {conf.id for conf in merge_to.conferences} + to_delete = [ + cp for cp in conference_people if cp.conference_id in existing_conferences + ] + for cp in to_delete: + database.session.delete(cp) + if merge_to_id != name_from_person_id: - merge_to = model.Person.query.get(merge_to_id) name_from_person = model.Person.query.get(name_from_person_id) merge_to.name = name_from_person.name From 253096bf59c94c161a1e764d05b3da9918224ae5 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 25 Sep 2023 18:01:12 +0100 Subject: [PATCH 2/3] Reorganise code --- {templates => confarchive/templates}/add_venue.html | 0 {templates => confarchive/templates}/base.html | 0 {templates => confarchive/templates}/conference.html | 0 {templates => confarchive/templates}/country_list.html | 0 {templates => confarchive/templates}/event.html | 0 {templates => confarchive/templates}/github.html | 0 {templates => confarchive/templates}/index.html | 0 {templates => confarchive/templates}/login.html | 0 {templates => confarchive/templates}/merge_people.html | 0 {templates => confarchive/templates}/navbar.html | 0 {templates => confarchive/templates}/person.html | 0 {templates => confarchive/templates}/person/split.html | 0 {templates => confarchive/templates}/reports.html | 0 {templates => confarchive/templates}/search_events.html | 0 {templates => confarchive/templates}/search_everything.html | 0 {templates => confarchive/templates}/search_people.html | 0 {templates => confarchive/templates}/series/list.html | 0 {templates => confarchive/templates}/top_events.html | 0 {templates => confarchive/templates}/top_speakers.html | 0 {templates => confarchive/templates}/wikidata.html | 0 main.py => confarchive/view.py | 0 21 files changed, 0 insertions(+), 0 deletions(-) rename {templates => confarchive/templates}/add_venue.html (100%) rename {templates => confarchive/templates}/base.html (100%) rename {templates => confarchive/templates}/conference.html (100%) rename {templates => confarchive/templates}/country_list.html (100%) rename {templates => confarchive/templates}/event.html (100%) rename {templates => confarchive/templates}/github.html (100%) rename {templates => confarchive/templates}/index.html (100%) rename {templates => confarchive/templates}/login.html (100%) rename {templates => confarchive/templates}/merge_people.html (100%) rename {templates => confarchive/templates}/navbar.html (100%) rename {templates => confarchive/templates}/person.html (100%) rename {templates => confarchive/templates}/person/split.html (100%) rename {templates => confarchive/templates}/reports.html (100%) rename {templates => confarchive/templates}/search_events.html (100%) rename {templates => confarchive/templates}/search_everything.html (100%) rename {templates => confarchive/templates}/search_people.html (100%) rename {templates => confarchive/templates}/series/list.html (100%) rename {templates => confarchive/templates}/top_events.html (100%) rename {templates => confarchive/templates}/top_speakers.html (100%) rename {templates => confarchive/templates}/wikidata.html (100%) rename main.py => confarchive/view.py (100%) diff --git a/templates/add_venue.html b/confarchive/templates/add_venue.html similarity index 100% rename from templates/add_venue.html rename to confarchive/templates/add_venue.html diff --git a/templates/base.html b/confarchive/templates/base.html similarity index 100% rename from templates/base.html rename to confarchive/templates/base.html diff --git a/templates/conference.html b/confarchive/templates/conference.html similarity index 100% rename from templates/conference.html rename to confarchive/templates/conference.html diff --git a/templates/country_list.html b/confarchive/templates/country_list.html similarity index 100% rename from templates/country_list.html rename to confarchive/templates/country_list.html diff --git a/templates/event.html b/confarchive/templates/event.html similarity index 100% rename from templates/event.html rename to confarchive/templates/event.html diff --git a/templates/github.html b/confarchive/templates/github.html similarity index 100% rename from templates/github.html rename to confarchive/templates/github.html diff --git a/templates/index.html b/confarchive/templates/index.html similarity index 100% rename from templates/index.html rename to confarchive/templates/index.html diff --git a/templates/login.html b/confarchive/templates/login.html similarity index 100% rename from templates/login.html rename to confarchive/templates/login.html diff --git a/templates/merge_people.html b/confarchive/templates/merge_people.html similarity index 100% rename from templates/merge_people.html rename to confarchive/templates/merge_people.html diff --git a/templates/navbar.html b/confarchive/templates/navbar.html similarity index 100% rename from templates/navbar.html rename to confarchive/templates/navbar.html diff --git a/templates/person.html b/confarchive/templates/person.html similarity index 100% rename from templates/person.html rename to confarchive/templates/person.html diff --git a/templates/person/split.html b/confarchive/templates/person/split.html similarity index 100% rename from templates/person/split.html rename to confarchive/templates/person/split.html diff --git a/templates/reports.html b/confarchive/templates/reports.html similarity index 100% rename from templates/reports.html rename to confarchive/templates/reports.html diff --git a/templates/search_events.html b/confarchive/templates/search_events.html similarity index 100% rename from templates/search_events.html rename to confarchive/templates/search_events.html diff --git a/templates/search_everything.html b/confarchive/templates/search_everything.html similarity index 100% rename from templates/search_everything.html rename to confarchive/templates/search_everything.html diff --git a/templates/search_people.html b/confarchive/templates/search_people.html similarity index 100% rename from templates/search_people.html rename to confarchive/templates/search_people.html diff --git a/templates/series/list.html b/confarchive/templates/series/list.html similarity index 100% rename from templates/series/list.html rename to confarchive/templates/series/list.html diff --git a/templates/top_events.html b/confarchive/templates/top_events.html similarity index 100% rename from templates/top_events.html rename to confarchive/templates/top_events.html diff --git a/templates/top_speakers.html b/confarchive/templates/top_speakers.html similarity index 100% rename from templates/top_speakers.html rename to confarchive/templates/top_speakers.html diff --git a/templates/wikidata.html b/confarchive/templates/wikidata.html similarity index 100% rename from templates/wikidata.html rename to confarchive/templates/wikidata.html diff --git a/main.py b/confarchive/view.py similarity index 100% rename from main.py rename to confarchive/view.py From 295e8336214993c3126127cea420e847f714dc8b Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 25 Sep 2023 18:02:14 +0100 Subject: [PATCH 3/3] Scripts live in their own dir --- scripts/add_conference_urls.py | 55 ++++++++++++++++++++++++++++ add_place.py => scripts/add_place.py | 3 +- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100755 scripts/add_conference_urls.py rename add_place.py => scripts/add_place.py (99%) diff --git a/scripts/add_conference_urls.py b/scripts/add_conference_urls.py new file mode 100755 index 0000000..49b7feb --- /dev/null +++ b/scripts/add_conference_urls.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 + +import os +import json +from confarchive import database, model +from confarchive.view import app + +app.config.from_object("config.default") +database.init_app(app) + + +def url_from_giggty_menu() -> None: + for conf in model.Conference.query.order_by(model.Conference.short_name): + if conf.url: + continue + + giggity_menu = "giggity/menu/" + + menu_filename = os.path.join(giggity_menu, conf.short_name + ".json") + + if not os.path.exists(menu_filename): + continue + + menu = json.load(open(menu_filename)) + links = {link["title"]: link["url"] for link in menu["metadata"]["links"]} + + if "Website" not in links: + continue + print(json.dumps(links, indent=2)) + + url = links["Website"] + + print(conf.short_name, menu_filename, url) + + conf.url = url + + database.session.commit() + + +def add_more_urls() -> None: + for conf in model.Conference.query.order_by(model.Conference.short_name): + if conf.url: + continue + if conf.short_name.startswith("debconf"): + conf.url = f"https://{conf.short_name}.debconf.org/" + print(conf.short_name, conf.url) + if conf.short_name.startswith("fosdem"): + year = conf.short_name[-4:] + conf.url = f"https://fosdem.org/{year}/" + print(conf.short_name, conf.url) + + database.session.commit() + + +add_more_urls() diff --git a/add_place.py b/scripts/add_place.py similarity index 99% rename from add_place.py rename to scripts/add_place.py index 61d0b92..8bce27a 100755 --- a/add_place.py +++ b/scripts/add_place.py @@ -1,9 +1,8 @@ #!/usr/bin/python3 -from main import app import sys from confarchive import database, model, wikidata - +from confarchive.view import app app.config.from_object("config.default") database.init_app(app)