Speaker split page

Resolves: #13
This commit is contained in:
Edward Betts 2023-09-25 15:45:53 +01:00
parent 3493b2b81d
commit 662fdcaa2b
3 changed files with 57 additions and 1 deletions

40
main.py
View file

@ -78,6 +78,46 @@ def person(person_id: int) -> str | Response:
)
@app.route("/person/<int:person_id>/split", methods=["GET", "POST"])
def split_person(person_id: int) -> str | Response:
"""Split person."""
item = model.Person.query.get(person_id)
assert not item.wikidata_qid
if flask.request.method == "GET":
return flask.render_template(
"person/split.html",
item=item,
)
names = flask.request.form["names"].strip().splitlines()
print(names)
assert len(names) > 1
item.name = names[0]
for cp in item.conferences_association:
cp.named_as = names[0]
for num, name in enumerate(names[1:], start=2):
person = model.Person(name=name)
database.session.add(person)
for cp0 in item.conferences_association:
cp = model.ConferencePerson(
person=person, named_as=name, conference_id=cp0.conference_id
)
database.session.add(cp)
for event0 in item.events_association:
ep = model.EventPerson(
person=person, event_id=event0.event_id, position=num
)
database.session.add(ep)
database.session.commit()
return flask.redirect(flask.url_for("person", person_id=person_id))
@app.route("/event/<int:event_id>")
def event_page(event_id: int) -> str:
item = model.Event.query.get(event_id)

View file

@ -62,9 +62,11 @@
</form>
<form method="POST" action="{{ url_for("delete_person", person_id=item.id) }}">
<button type="submit" class="btn btn-primary">delete</button>
<button type="submit" class="btn btn-primary">delete</button>
</form>
<div><a href="{{ url_for("split_person", person_id=item.id) }}">split person</a></div>
{% if show_wikidata_matches %}
{% if wikidata_hits %}
<p>Possible Wikidata matches</p>

View file

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %}Split speaker &ndash; Conference archive{% endblock %}
{% block content %}
<h1>{{ item.name }}</h1>
<form method="POST">
<div><textarea name="names" rows="5" cols="60">{{ item.name }}</textarea></div>
<button>split</button>
</form>
{% endblock %}