Skip to content

Commit 506b7fe

Browse files
authored
[ENG-11171] Add admin tool to update ROR names (#11799)
* simplify ror funder name command code * update migrate to accept a stdout
1 parent 21a161e commit 506b7fe

5 files changed

Lines changed: 1379 additions & 225 deletions

File tree

admin/management/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
re_path(r'^remove_orcid_from_user_social', views.RemoveOrcidFromUserSocial.as_view(),
2424
name='remove_orcid_from_user_social'),
2525
path('migrate_osfmetrics_fix_6to8', views.MigrateOsfmetricsFix6to8.as_view(), name='migrate_osfmetrics_fix_6to8'),
26+
re_path(r'^migrate_funder_names_to_ror', views.MigrateFunderNamesToRor.as_view(),
27+
name='migrate_funder_names_to_ror'),
2628
]

admin/management/views.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,15 @@ def post(self, request):
230230
for _line in _out_io.getvalue().split('\n'):
231231
messages.info(request, _line)
232232
return redirect(reverse('management:commands'))
233+
234+
235+
class MigrateFunderNamesToRor(ManagementCommandPermissionView):
236+
237+
def post(self, request):
238+
_command_kwargs = {}
239+
_out_io = StringIO()
240+
call_command('migrate_funder_names_to_ror', **_command_kwargs, stdout=_out_io)
241+
messages.success(request, 'ROR funder names have been successfully updated and made consistent.')
242+
for _line in _out_io.getvalue().split('\n'):
243+
messages.info(request, _line)
244+
return redirect(reverse('management:commands'))

admin/templates/management/commands.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,22 @@ <h4><u>migrate osf-metrics (fix) 6to8</u></h4>
217217
</nav>
218218
</form>
219219
</section>
220+
<section>
221+
<h4><u>Update ROR funder names to be consistent and proper.</u></h4>
222+
<p>
223+
Take a csv file of <code>ROR ID</code>, <code>ROR
224+
Name</code> (without column headers) and update
225+
all ROR funder entries to use the same name for a
226+
given id.
227+
</p>
228+
<form method="post"
229+
action="{% url 'management:migrate_funder_names_to_ror'%}">
230+
{% csrf_token %}
231+
<nav>
232+
<input class="btn btn-success" type="submit" value="Run" />
233+
</nav>
234+
</form>
235+
</section>
220236
</div>
221237
</section>
222238
{% endblock %}

0 commit comments

Comments
 (0)