parent
3493b2b81d
commit
662fdcaa2b
3 changed files with 57 additions and 1 deletions
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue