-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/feature/b-and-i-25-01' into fe…
…ature/allow-for-un-withdrawing-preprint-via-admin # Conflicts: # admin/preprints/urls.py # admin/preprints/views.py
- Loading branch information
Showing
71 changed files
with
8,778 additions
and
6,935 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.urls import re_path | ||
|
||
from admin.draft_registrations import views | ||
|
||
|
||
app_name = 'draft_registrations' | ||
|
||
|
||
urlpatterns = [ | ||
re_path(r'^$', views.UserDraftRegistrationSearchView.as_view(), name='search'), | ||
re_path(r'^(?P<draft_registration_id>\w+)/$', views.DraftRegistrationView.as_view(), name='detail'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from django.urls import NoReverseMatch, reverse | ||
from django.contrib import messages | ||
from django.contrib.auth.mixins import PermissionRequiredMixin | ||
from django.shortcuts import redirect | ||
from django.views.generic import FormView | ||
from django.views.generic import DetailView | ||
|
||
from admin.base.forms import GuidForm | ||
from osf.models.registrations import DraftRegistration | ||
|
||
|
||
class DraftRegistrationMixin(PermissionRequiredMixin): | ||
|
||
def get_object(self): | ||
draft_registration = DraftRegistration.load(self.kwargs['draft_registration_id']) | ||
draft_registration.guid = draft_registration._id | ||
return draft_registration | ||
|
||
def get_success_url(self): | ||
return reverse('draft_registrations:detail', kwargs={ | ||
'draft_registration_id': self.kwargs['draft_registration_id'] | ||
}) | ||
|
||
|
||
class UserDraftRegistrationSearchView(PermissionRequiredMixin, FormView): | ||
""" Allows authorized users to search for user's draft registrations by his guid. | ||
""" | ||
template_name = 'draft_registrations/search.html' | ||
permission_required = 'osf.view_osfuser' | ||
raise_exception = True | ||
form_class = GuidForm | ||
|
||
def form_valid(self, form): | ||
guid = form.cleaned_data['guid'] | ||
if guid: | ||
try: | ||
return redirect(reverse('users:draft-registrations', kwargs={'guid': guid})) | ||
except NoReverseMatch as e: | ||
messages.error(self.request, str(e)) | ||
|
||
return super().form_valid(form) | ||
|
||
|
||
class DraftRegistrationView(DraftRegistrationMixin, DetailView): | ||
""" Allows authorized users to view draft registration | ||
""" | ||
template_name = 'draft_registrations/detail.html' | ||
permission_required = 'osf.view_draftregistration' | ||
|
||
def get_context_data(self, **kwargs): | ||
draft_registration = self.get_object() | ||
return super().get_context_data(**{ | ||
'draft_registration': draft_registration | ||
}, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{% load node_extras %} | ||
|
||
<tr> | ||
<td>Contributors</td> | ||
<td> | ||
<table class="table table-bordered table-hover"> | ||
<thead> | ||
<tr> | ||
<td>Email</td> | ||
<td>Name</td> | ||
<td>Permissions</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for user in draft_registration.contributors %} | ||
<tr> | ||
<td> | ||
<a href="{{ user | reverse_user }}"> | ||
{{ user }} | ||
</a> | ||
</td> | ||
<td>{{ user.fullname }}</td> | ||
<td>{% get_permissions user draft_registration %}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
{% load node_extras %} | ||
{% block title %} | ||
<title>{{ draft_registration.type|cut:'osf.'|title }}: {{draft_registration.guid}} </title> | ||
{% endblock title %} | ||
{% block content %} | ||
<div class="container-fluid"> | ||
<ul class="messages"> | ||
{% for message in messages %} | ||
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> | ||
{% endfor %} | ||
</ul> | ||
<div class="row"> | ||
<h2>Draft Registration: <b>{{ draft_registration.title }}</b> <a href="{{ draft_registration.absolute_url }}"> ({{draft_registration.guid}})</a> </h2> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Field</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>ID</td> | ||
<td>{{ draft_registration.guid }}</td> | ||
</tr> | ||
<tr> | ||
<td>Url</td> | ||
<td><a href="{{ draft_registration.absolute_url }}">{{ draft_registration.absolute_url }}</a></td> | ||
</tr> | ||
<tr> | ||
<td>Title</td> | ||
<td>{{ draft_registration.title }}</td> | ||
</tr> | ||
<tr> | ||
<td>Creator</td> | ||
<td><a href="{{ draft_registration.creator | reverse_user }}">{{ draft_registration.creator }}</a></td> | ||
</tr> | ||
<tr> | ||
<td>Deleted</td> | ||
<td>{{ draft_registration.deleted }}</td> | ||
</tr> | ||
<tr> | ||
<td>Public</td> | ||
<td>{{ draft_registration.is_public }}</td> | ||
</tr> | ||
<tr> | ||
<td>Provider</td> | ||
{% if draft_registration.provider %} | ||
<td><a href="{{ draft_registration | reverse_registration_provider }}">{{ draft_registration.provider.name }}</a></td> | ||
{% else %} | ||
<td>None</td> | ||
{% endif %} | ||
</tr> | ||
{% include "draft_registrations/contributors.html" with draft_registration=draft_registration %} | ||
<tr> | ||
<td>Node storage usage</td> | ||
<td> | ||
<b>Current usage:</b> {{ draft_registration.storage_usage }}<br> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
{#{% load node_extras %}#} | ||
{% block title %} | ||
<title>Draft Registrations Search</title> | ||
{% endblock title %} | ||
{% block content %} | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<form action="{% url 'draft_registrations:search' %}" method="post"> | ||
{% csrf_token %} | ||
{% if form.errors %} | ||
<div class="alert alert-danger">{{ form.errors }}</div> | ||
{% endif %} | ||
<div class="form-group"> | ||
<label for="guid">User GUID:</label> | ||
{{ form.guid }} | ||
</div> | ||
<input type="submit" class="btn btn-primary" value="Submit" /> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% if not preprint.is_published %} | ||
<a data-toggle="modal" data-target="#confirmPublished" class="btn btn-info"> | ||
Make Published | ||
</a> | ||
<div class="modal" id="confirmPublished"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<form class="well" method="post" action="{% url 'preprints:make-published' guid=preprint.guid %}"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal">x</button> | ||
<h3>Are you sure you want to make this preprint published?</h3> | ||
</div> | ||
{% csrf_token %} | ||
<div class="modal-footer"> | ||
<input class="btn btn-danger" type="submit" value="Confirm" /> | ||
<button type="button" class="btn btn-default" data-dismiss="modal"> | ||
Cancel | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% if preprint.article_doi %} | ||
<a data-toggle="modal" data-target="#confirmResyncCrossRef" class="btn btn-info"> | ||
Resync with Crossref | ||
</a> | ||
<div class="modal" id="confirmResyncCrossRef"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<form class="well" method="post" action="{% url 'preprints:resync-crossref' guid=preprint.guid %}"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal">x</button> | ||
<h3>Are you sure you want to resync with CrossRef?</h3> | ||
</div> | ||
{% csrf_token %} | ||
<div class="modal-footer"> | ||
<input class="btn btn-danger" type="submit" value="Confirm" /> | ||
<button type="button" class="btn btn-default" data-dismiss="modal"> | ||
Cancel | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends 'base.html' %} | ||
{% load node_extras %} | ||
{% include "util/pagination.html" with items=page status=status %} | ||
{% block content %} | ||
<table class="table table-striped table-hover table-responsive"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Title</th> | ||
<th>Date created</th> | ||
<th>Public</th> | ||
<th>Contributors</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for draft_registration in draft_registrations %} | ||
<tr> | ||
<td> | ||
<a href="{{ draft_registration | reverse_draft_registration }}" | ||
class="btn btn-primary"> | ||
{{ draft_registration.guid }} | ||
</a> | ||
</td> | ||
<td> | ||
{{draft_registration.title}} | ||
</td> | ||
<td> | ||
{{ draft_registration.created| date }} | ||
</td> | ||
<td> | ||
{{ draft_registration.is_public }} | ||
</td> | ||
<td> | ||
{% for user in draft_registration.contributors %} | ||
<a href="{{ user | reverse_user }}">{{ user.username }}</a>{% if not forloop.last %}, {% endif %} | ||
{% endfor %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.