Skip to content

Commit 7404916

Browse files
committed
Merge branch 'feature/pbs-25-13' of https://github.com/CenterForOpenScience/osf.io into add-brand-to-collection-provider
* 'feature/pbs-25-13' of https://github.com/CenterForOpenScience/osf.io: (25 commits) [ENG-8224] Fixed force archive template with registration addons (CenterForOpenScience#11210) API: Allow /v2/users/me/preprints list view to filter by title [ENG-8325] Public column does not display the visibility status of child nodes on the Nodes page in the Admin App [ENG-8246] Fixed deletion of maintenance alerts in admin (CenterForOpenScience#11226) add exception handling to /review_actions/ endpoint added a route to download node metadata (CenterForOpenScience#11215) [ENG-7929] Ability to move registrations to draft state (CenterForOpenScience#11153) switch to new UI when user views draft registration file (CenterForOpenScience#11144) [ENG-5862] SPAM - Fix Wiki Spamming (CenterForOpenScience#11171) improved displaying of stashed urls and approval state in admin (CenterForOpenScience#11193) [ENG-7962] Fix User Setting Response Payload async mailchimp perference change issues (CenterForOpenScience#11136) fixed children/parent fields in admin templates (CenterForOpenScience#11156) don't add multiple group perms for preprint provider (CenterForOpenScience#11159) fix content overflow for node page (CenterForOpenScience#11182) [ENG-8096] Admins on projects are unable to reject user access requests (CenterForOpenScience#11163) added retry to avoid race condition (CenterForOpenScience#11179) upgrade django to 4.2.17 (CenterForOpenScience#11173) add additional information to user admin (CenterForOpenScience#11184) [ENG-8192] Ability to force archive registrations when OSFS Folders have changed (CenterForOpenScience#11194) [ENG-8193] Fix issues with Preprint submission via API (CenterForOpenScience#11185) ...
2 parents 914e7b9 + cc51cb3 commit 7404916

54 files changed

Lines changed: 1340 additions & 376 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

admin/maintenance/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from admin.maintenance.forms import MaintenanceForm
77

88
from django.shortcuts import redirect
9+
from django.urls import reverse_lazy
910
from django.forms.models import model_to_dict
1011
from django.views.generic import DeleteView, TemplateView
1112
from django.contrib.auth.mixins import PermissionRequiredMixin
@@ -15,11 +16,13 @@ class DeleteMaintenance(PermissionRequiredMixin, DeleteView):
1516
permission_required = 'osf.delete_maintenancestate'
1617
raise_exception = True
1718
template_name = 'maintenance/delete_maintenance.html'
19+
success_url = reverse_lazy('maintenance:display')
1820

1921
def get_object(self, queryset=None):
2022
return MaintenanceState.objects.first()
2123

22-
def delete(self, request, *args, **kwargs):
24+
def post(self, request, *args, **kwargs):
25+
super().post(request, *args, **kwargs)
2326
maintenance.unset_maintenance()
2427
return redirect('maintenance:display')
2528

admin/nodes/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@
4545
re_path(r'^(?P<guid>[a-z0-9]+)/remove_notifications/$', views.NodeRemoveNotificationView.as_view(), name='node-remove-notifications'),
4646
re_path(r'^(?P<guid>[a-z0-9]+)/update_moderation_state/$', views.NodeUpdateModerationStateView.as_view(), name='node-update-mod-state'),
4747
re_path(r'^(?P<guid>[a-z0-9]+)/resync_datacite/$', views.NodeResyncDataCiteView.as_view(), name='resync-datacite'),
48+
re_path(r'^(?P<guid>[a-z0-9]+)/revert/$', views.NodeRevertToDraft.as_view(), name='revert-to-draft'),
4849
]

admin/nodes/views.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def get_context_data(self, **kwargs):
107107
'SPAM_STATUS': SpamStatus,
108108
'STORAGE_LIMITS': settings.StorageLimits,
109109
'node': node,
110+
'children': node.get_nodes(is_node_link=False),
110111
'duplicates': detailed_duplicates
111112
})
112113

@@ -761,7 +762,7 @@ def post(self, request, *args, **kwargs):
761762

762763
allow_unconfigured = force_archive_params.get('allow_unconfigured', False)
763764

764-
addons = set(force_archive_params.getlist('addons', []))
765+
addons = set(registration.registered_from.get_addon_names())
765766
addons.update(DEFAULT_PERMISSIBLE_ADDONS)
766767

767768
try:
@@ -780,8 +781,8 @@ def post(self, request, *args, **kwargs):
780781
registration,
781782
permissible_addons=addons,
782783
allow_unconfigured=allow_unconfigured,
783-
skip_collision=skip_collision,
784-
delete_collision=delete_collision,
784+
skip_collisions=skip_collision,
785+
delete_collisions=delete_collision,
785786
)
786787
messages.success(request, 'Registration archive process has finished.')
787788
except Exception as exc:
@@ -800,3 +801,12 @@ def post(self, request, *args, **kwargs):
800801
registration = self.get_object()
801802
registration.request_identifier_update('doi', create=True)
802803
return redirect(self.get_success_url())
804+
805+
806+
class NodeRevertToDraft(NodeMixin, View):
807+
permission_required = 'osf.change_node'
808+
809+
def post(self, request, *args, **kwargs):
810+
registration = self.get_object()
811+
registration.to_draft()
812+
return redirect(self.get_success_url())

admin/preprint_providers/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ def __init__(self, *args, provider_groups=None, **kwargs):
116116
super().__init__(*args, **kwargs)
117117

118118
provider_groups = provider_groups or Group.objects.none()
119-
self.fields['group_perms'] = forms.ModelMultipleChoiceField(
119+
self.fields['group_perms'] = forms.ModelChoiceField(
120120
queryset=provider_groups,
121121
required=False,
122-
widget=forms.CheckboxSelectMultiple
122+
widget=forms.RadioSelect
123123
)
124124

125125
user_id = forms.CharField(required=True, max_length=5, min_length=5)

admin/preprint_providers/views.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,14 @@ def form_valid(self, form):
481481
if not osf_user:
482482
raise Http404(f'OSF user with id "{user_id}" not found. Please double check.')
483483

484-
for group in form.cleaned_data.get('group_perms'):
485-
self.target_provider.add_to_group(osf_user, group)
484+
if osf_user.has_groups(self.target_provider.group_names):
485+
messages.error(self.request, f'User with guid: {user_id} is already a moderator or admin')
486+
return super().form_invalid(form)
486487

488+
group = form.cleaned_data.get('group_perms')
489+
self.target_provider.add_to_group(osf_user, group)
487490
osf_user.save()
491+
488492
messages.success(self.request, f'Permissions update successful for OSF User {osf_user.username}!')
489493
return super().form_valid(form)
490494

admin/providers/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def post(self, request, *args, **kwargs):
2929
messages.error(request, f'User for guid: {data["add-moderators-form"][0]} could not be found')
3030
return redirect(f'{self.url_namespace}:add_admin_or_moderator', provider_id=provider.id)
3131

32-
groups = [provider.format_group(name) for name in provider.groups.keys()]
33-
if target_user.has_groups(groups):
32+
if target_user.has_groups(provider.group_names):
3433
messages.error(request, f'User with guid: {data["add-moderators-form"][0]} is already a moderator or admin')
3534
return redirect(f'{self.url_namespace}:add_admin_or_moderator', provider_id=provider.id)
3635

admin/templates/nodes/children.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</a>
2424
</td>
2525
<td>{{ child.title }}</td>
26-
<td>{{ child.public }}</td>
26+
<td>{{ child.is_public }}</td>
2727
<td>{{ child.contributors|length }}</td>
2828
{% if perms.osf.delete_node %}
2929
<td>

admin/templates/nodes/contributors.html

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,60 @@
33
<tr>
44
<td>Contributors</td>
55
<td>
6-
<table class="table table-bordered table-hover">
7-
<thead>
8-
<tr>
9-
<td>Email</td>
10-
<td>Name</td>
11-
<td>Permissions</td>
12-
<td>Actions</td>
13-
{% if perms.osf.change_node %}
14-
<td></td>
15-
{% endif %}
16-
</tr>
17-
</thead>
18-
<tbody>
19-
{% for user in node.contributors %}
6+
<div style="overflow-x: auto; width: 100%;">
7+
<table class="table table-bordered table-hover">
8+
<thead>
209
<tr>
21-
<td>
22-
<a href="{{ user | reverse_user }}">
23-
{{ user }}
24-
</a>
25-
</td>
26-
<td>{{ user.fullname }}</td>
27-
<td>{% get_permissions user node %}</td>
10+
<td>Email</td>
11+
<td>Name</td>
12+
<td>Permissions</td>
13+
<td>Actions</td>
2814
{% if perms.osf.change_node %}
15+
<td></td>
16+
{% endif %}
17+
</tr>
18+
</thead>
19+
<tbody>
20+
{% for user in node.contributors %}
21+
<tr>
2922
<td>
30-
<a data-toggle="modal" data-target="#{{ user.id }}Modal" class="btn btn-danger">Remove</a>
31-
<div class="modal" id="{{ user.id }}Modal">
32-
<div class="modal-dialog">
33-
<div class="modal-content">
34-
<form class="well" method="post" action="{% url 'nodes:remove-user' guid=node.guid user_id=user.id %}">
35-
<div class="modal-header">
36-
<button type="button" class="close" data-dismiss="modal">x</button>
37-
<h3>Removing contributor: {{ user.username }}</h3>
38-
</div>
39-
<div class="modal-body">
40-
User will be removed. Currently only an admin on this node type will be able to add them back.
41-
{% csrf_token %}
42-
</div>
43-
<div class="modal-footer">
44-
<input class="btn btn-danger" type="submit" value="Confirm" />
45-
<button type="button" class="btn btn-default" data-dismiss="modal">
46-
Cancel
47-
</button>
48-
</div>
49-
</form>
23+
<a href="{{ user | reverse_user }}">
24+
{{ user }}
25+
</a>
26+
</td>
27+
<td>{{ user.fullname }}</td>
28+
<td>{% get_permissions user node %}</td>
29+
{% if perms.osf.change_node %}
30+
<td>
31+
<a data-toggle="modal" data-target="#{{ user.id }}Modal" class="btn btn-danger">Remove</a>
32+
<div class="modal" id="{{ user.id }}Modal">
33+
<div class="modal-dialog">
34+
<div class="modal-content">
35+
<form class="well" method="post" action="{% url 'nodes:remove-user' guid=node.guid user_id=user.id %}">
36+
<div class="modal-header">
37+
<button type="button" class="close" data-dismiss="modal">x</button>
38+
<h3>Removing contributor: {{ user.username }}</h3>
39+
</div>
40+
<div class="modal-body">
41+
User will be removed. Currently only an admin on this node type will be able to add them back.
42+
{% csrf_token %}
43+
</div>
44+
<div class="modal-footer">
45+
<input class="btn btn-danger" type="submit" value="Confirm" />
46+
<button type="button" class="btn btn-default" data-dismiss="modal">
47+
Cancel
48+
</button>
49+
</div>
50+
</form>
51+
</div>
5052
</div>
5153
</div>
52-
</div>
53-
</td>
54-
{% endif %}
55-
</tr>
56-
{% endfor %}
57-
</tbody>
58-
</table>
54+
</td>
55+
{% endif %}
56+
</tr>
57+
{% endfor %}
58+
</tbody>
59+
</table>
60+
</div>
5961
</td>
6062
</tr>

admin/templates/nodes/embargo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
</tr>
5252
<tr>
5353
<td>Approval State</td>
54-
<td><p>{{ embargo.approval_state }}</p></td>
54+
<td><pre style="width: 1200px !important;" >{{ embargo.approval_state | pprint }}</pre></td>
5555
</tr>
5656
<tr>
5757
<td>Stashed Urls</td>
58-
<td><p>{{ embargo.stashed_urls }}</p></td>
58+
<td><pre style="width: 1200px !important;">{{ embargo.stashed_urls | pprint }}</pre></td>
5959
</tr>
6060
<tr>
6161
<td>For Existing Registration</td>

admin/templates/nodes/embargo_termination_approval.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
</tr>
4545
<tr>
4646
<td>Approval State</td>
47-
<td><pre style="width: 20%;">{{ embargo_termination_approval.approval_state }}</pre></td>
47+
<td><pre style="width: 1200px !important;">{{ embargo_termination_approval.approval_state | pprint }}</pre></td>
4848
</tr>
4949
<tr>
5050
<td>Stashed Urls</td>
51-
<td><pre style="width: 20%;">{{ embargo_termination_approval.stashed_urls }}</pre></td>
51+
<td><pre style="width: 1200px !important;">{{ embargo_termination_approval.stashed_urls | pprint }}</pre></td>
5252
</tr>
5353
</tbody>
5454
</table>

0 commit comments

Comments
 (0)