parent
3493b2b81d
commit
662fdcaa2b
40
main.py
40
main.py
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
14
templates/person/split.html
Normal file
14
templates/person/split.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Split speaker – 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 %}
|
Loading…
Reference in a new issue