Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support comma separated author merge url #10114

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,6 @@ SelectionManager.ACTIONS = [
requires_type: ['author'],
multiple_only: true,
name: 'Merge Authors...',
href: olids => `/authors/merge?${olids.map(olid => `key=${olid}`).join('&')}`,
href: olids => `/authors/merge?records=${olids.join(',')}`,
},
];
2 changes: 1 addition & 1 deletion openlibrary/plugins/upstream/edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def create_url(mr_type: int, olids: list[str], primary: str | None = None) -> st
primary_param = f'&primary={primary}' if primary else ''
return f'/works/merge?records={",".join(olids)}{primary_param}'
elif mr_type == CommunityEditsQueue.TYPE['AUTHOR_MERGE']:
return f'/authors/merge?key={"&key=".join(olids)}'
return f'/authors/merge?records={",".join(olids)}'
return ''

@staticmethod
Expand Down
10 changes: 8 additions & 2 deletions openlibrary/plugins/upstream/merge_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,14 @@ def filter_authors(self, keys):
return [k for k in keys if d.get("/authors/" + k) == '/type/author']

def GET(self):
i = web.input(key=[], mrid=None)
keys = uniq(i.key)
i = web.input(key=[], mrid=None, records='')

# key is deprecated in favor of records but we will support both
if deprecated_keys := uniq(i.key):
redir_url = f'/authors/merge/?records={",".join(deprecated_keys)}'
raise web.redirect(redir_url)

keys = uniq(i.records.strip(',').split(','))

# filter bad keys
keys = self.filter_authors(keys)
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/templates/search/authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ <h1>$_("Search Authors")</h1>
$:render_template("search/sort_options.html", selected_sort=sort, search_scheme="authors")
$ user_can_merge = ctx.user and ("merge-authors" in ctx.features or ctx.user.is_admin())
$if results.num_found >= 2 and user_can_merge:
$ keys = '&'.join('key=%s' % doc['key'].split("/")[-1] for doc in results.docs)
<div class="mergeThis">$_('Is the same author listed twice?') <a class="large sansserif" href="/authors/merge?$keys">$_('Merge authors')</a></div>
$ keys = ','.join(doc['key'].split("/")[-1] for doc in results.docs)
<div class="mergeThis">$_('Is the same author listed twice?') <a class="large sansserif" href="/authors/merge?records=$keys">$_('Merge authors')</a></div>
</div>
$else:
<center>
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/templates/search/work_search_facets.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<div class="facet $header">
$ magic_wand_markup = ''
$if header == 'author_key' and len(counts) > 1 and ctx.user and ("merge-authors" in ctx.features or ctx.user.is_admin()):
$ keys = '&'.join('key=%s' % k for k, display, count in counts)
$ magic_wand_markup = ' <span class="merge"><a href="/authors/merge?%s" title="%s">%s</a></span>' % (keys, _('Merge duplicate authors from this search'), _("Merge duplicates"))
$ keys = ','.join(k for k, display, count in counts)
$ magic_wand_markup = ' <span class="merge"><a href="/authors/merge?records=%s" title="%s">%s</a></span>' % (keys, _('Merge duplicate authors from this search'), _("Merge duplicates"))
<h4 class="facetHead">$(label)$:(magic_wand_markup)</h4>
$ num = 0
$for k, display, count in counts:
Expand Down
Loading