Commit 92abcd5a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the processing behind the wizard AffiliationFromPublication.

parent 386c8e3d
......@@ -59,13 +59,35 @@ def affiliation_publication():
publication_id = vars.publication_id
publication_store = vars.publication_store
# find the record for the institute
# find the publication
record = load_record(publication_store, publication_id)
if record is None:
raise HTTP(500, "Record not found!")
# extract the keys defining the affiliation
# find the author
pattern = "^%s, %s$" % (family_name.strip(), first_name.strip())
reg = re.compile(pattern, re.IGNORECASE)
rule = None
if "700" in record and isinstance(record[u"700"], list):
for di in record[u"700"]:
author = di["a"]
if reg.match(author):
rule = dict(u=di["u"])
if "v" in di:
rule["v"] = di["v"]
break
# check that the rules does not exist
if rule is None:
raise HTTP(500, "Author not found!")
# check that the rules does not exist
# load new rules
if get_id(db.affiliation_rules, **rule) is None:
db.affiliation_rules[0] = rule
else:
raise HTTP(500, "Rule already exists!")
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment