SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit d4ad751e authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add expected_editors to collections

parent 5b367531
No related branches found
No related tags found
1 merge request!61[Submissions] Add target collection to the submission form
...@@ -36,6 +36,8 @@ class CollectionAdmin(admin.ModelAdmin): ...@@ -36,6 +36,8 @@ class CollectionAdmin(admin.ModelAdmin):
"series", "series",
"submissions", "submissions",
"publications", "publications",
"expected_authors",
"expected_editors",
] ]
......
# Generated by Django 3.2.18 on 2023-09-19 13:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('profiles', '0035_alter_profile_title'),
('colleges', '0039_nomination_add_events'),
('series', '0006_collection_expected_authors'),
]
operations = [
migrations.AddField(
model_name='collection',
name='expected_editors',
field=models.ManyToManyField(blank=True, related_name='collections_editing', to='colleges.Fellowship'),
),
migrations.AlterField(
model_name='collection',
name='expected_authors',
field=models.ManyToManyField(blank=True, related_name='collections_authoring', to='profiles.Profile'),
),
]
...@@ -60,7 +60,12 @@ class Collection(models.Model): ...@@ -60,7 +60,12 @@ class Collection(models.Model):
event_end_date = models.DateField(null=True, blank=True) event_end_date = models.DateField(null=True, blank=True)
image = models.ImageField(upload_to="series/collections/images/", blank=True) image = models.ImageField(upload_to="series/collections/images/", blank=True)
expected_authors = models.ManyToManyField("profiles.Profile", blank=True) expected_authors = models.ManyToManyField(
"profiles.Profile", blank=True, related_name="collections_authoring"
)
expected_editors = models.ManyToManyField(
"colleges.Fellowship", blank=True, related_name="collections_editing"
)
submissions = models.ManyToManyField("submissions.Submission", blank=True) submissions = models.ManyToManyField("submissions.Submission", blank=True)
publications = models.ManyToManyField( publications = models.ManyToManyField(
"journals.Publication", through="series.CollectionPublicationsTable", blank=True "journals.Publication", through="series.CollectionPublicationsTable", blank=True
......
...@@ -5,39 +5,40 @@ ...@@ -5,39 +5,40 @@
{% include 'scipost/messages.html' %} {% include 'scipost/messages.html' %}
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>Profile</th> <th>Profile</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
{% for profile in collection.expected_authors.all %} {% for profile in collection.expected_authors.all %}
<tr> <tr>
<td><a href="{{ profile.get_absolute_url }}">{{ profile }}</a></td> <td>
<td> <a href="{{ profile.get_absolute_url }}">{{ profile }}</a>
<a </td>
class="btn btn-sm btn-outline-danger" <td>
hx-get="{% url 'series:_hx_collection_expected_author_action' slug=collection.slug profile_id=profile.id action='remove' %}" <a class="btn btn-sm btn-outline-danger"
hx-target="#profiles" hx-get="{% url 'series:_hx_collection_expected_author_action' slug=collection.slug profile_id=profile.id action='remove' %}"
hx-confirm="Are you sure you want to remove {{ profile }} from expected authors in this Collection?" hx-target="#author_profiles"
><small>Remove</small></a> hx-confirm="Are you sure you want to remove {{ profile }} from expected authors in this Collection?"><small>Remove</small></a>
</td> </td>
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
<td colspan="4">No expected authors yet</td> <td colspan="4">No expected authors yet</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
<div class="col-md-4 p-4"> <div class="col-md-4 p-4">
<h4>Add an expected author</h4> <h4>Add an expected author</h4>
<form <form hx-post="{% url 'profiles:_hx_profile_dynsel_list' %}"
hx-post="{% url 'profiles:_hx_profile_dynsel_list' %}" hx-trigger="keyup delay:200ms, change"
hx-trigger="keyup delay:200ms, change" hx-target="#author_profile_search_results">
hx-target="#profile_search_results" <div id="author_profile_search_form">{% crispy author_profile_search_form %}</div>
>
<div id="profile_search_form">{% crispy profile_search_form %}</div>
</form> </form>
<div id="profile_search_results" class="border border-light m-2 p-1"></div> <div id="author_profile_search_results"
class="border border-light m-2 p-1"></div>
</div> </div>
</div> </div>
{% load crispy_forms_tags %}
<div class="row">
<div class="col-md-8">
{% include 'scipost/messages.html' %}
<table class="table">
<thead>
<tr>
<th>Fellow</th>
<th>Actions</th>
</tr>
</thead>
{% for editor in collection.expected_editors.all %}
{% with profile=editor.contributor.profile %}
<tr>
<td>
<a href="{{ profile.get_absolute_url }}">{{ profile }}</a>
</td>
<td>
<a class="btn btn-sm btn-outline-danger"
hx-get="{% url 'series:_hx_collection_expected_editor_action' slug=collection.slug fellowship_id=editor.id action='remove' %}"
hx-target="#editor_fellowships"
hx-confirm="Are you sure you want to remove {{ profile }} from expected editors in this Collection?"><small>Remove</small></a>
</td>
</tr>
{% endwith %}
{% empty %}
<tr>
<td colspan="4">No expected editors yet</td>
</tr>
{% endfor %}
</table>
</div>
<div class="col-md-4 p-4">
<h4>Add an expected editor</h4>
<form hx-post="{% url 'colleges:_hx_fellowship_dynsel_list' %}"
hx-trigger="keyup delay:200ms, change"
hx-target="#editor_fellowship_search_results">
<div id="editor_fellowship_search_form">{% crispy editor_fellowship_search_form %}</div>
</form>
<div id="editor_fellowship_search_results"
class="border border-light m-2 p-1"></div>
</div>
</div>
...@@ -12,8 +12,13 @@ ...@@ -12,8 +12,13 @@
<span class="breadcrumb-item">{{ collection.name }}</span> <span class="breadcrumb-item">{{ collection.name }}</span>
{% endblock %} {% endblock %}
{% block meta_description %}{{ block.super }} Collection detail {{ collection.series.name }} {{ collection.name }}{% endblock meta_description %} {% block meta_description %}
{% block pagetitle %}: Collection detail{% endblock pagetitle %} {{ block.super }} Collection detail {{ collection.series.name }} {{ collection.name }}
{% endblock meta_description %}
{% block pagetitle %}
: Collection detail
{% endblock pagetitle %}
{% block content %} {% block content %}
...@@ -22,42 +27,47 @@ ...@@ -22,42 +27,47 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h1 class="highlight"> <h1 class="highlight">
<a href="{{ collection.series.get_absolute_url }}">{{ collection.series.name }}</a> <a href="{{ collection.series.get_absolute_url }}">{{ collection.series.name }}</a>
{% if collection.series.container_journals %}
<br> {% if collection.series.container_journals %}
<small><em> <br />
<ul class="list list-inline mt-2 mb-0"> <small><em>
<li class="list-inline-item mx-0">a series contained in</li> <ul class="list list-inline mt-2 mb-0">
{% for container in collection.series.container_journals.all %} <li class="list-inline-item mx-0">a series contained in</li>
<li class="list-inline-item">
<a href="{{ container.get_absolute_url }}">{{ container }}</a> {% for container in collection.series.container_journals.all %}
</li> <li class="list-inline-item">
{% endfor %} <a href="{{ container.get_absolute_url }}">{{ container }}</a>
</ul> </li>
</em></small> {% endfor %}
{% endif %}
</ul>
</em></small>
{% endif %}
</h1> </h1>
<h2 class="highlight"> <h2 class="highlight">Collection&emsp;{{ collection.name }}</h2>
Collection&emsp;{{ collection.name }}
</h2>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="p-2"> <div class="p-2">{% automarkup collection.description %}</div>
{% automarkup collection.description %}
</div>
{% if collection.event_start_date and collection.event_end_date %} {% if collection.event_start_date and collection.event_end_date %}
<p class="p-2"> <p class="p-2">Dates: from {{ collection.event_start_date }} to {{ collection.event_end_date }}.</p>
Dates: from {{ collection.event_start_date }} to {{ collection.event_end_date }}.
</p>
{% endif %} {% endif %}
{% if collection.image %} {% if collection.image %}
<div class="p-2"> <div class="p-2">
<img class="d-flex me-3 p-2" style="max-height: 350px; max-width: 100%;" alt="image" src="{{ collection.image.url }}"> <img class="d-flex me-3 p-2"
</div> style="max-height: 350px;
max-width: 100%"
alt="image"
src="{{ collection.image.url }}" />
</div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
...@@ -66,77 +76,88 @@ ...@@ -66,77 +76,88 @@
<h3>Editorial Administration</h3> <h3>Editorial Administration</h3>
<div class="card my-4"> <div class="card my-4">
<div class="card-header"> <div class="card-header">Expected authors for this Collection</div>
Expected authors for this Collection <div class="card-body">
</div> <div id="author_profiles"
<div class="card-body"> hx-get="{% url 'series:_hx_collection_expected_authors' slug=collection.slug %}"
<div hx-trigger="load"></div>
id="profiles" </div>
hx-get="{% url 'series:_hx_collection_expected_authors' slug=collection.slug %}" </div>
hx-trigger="load"
> <div class="card my-4">
</div> <div class="card-header">Expected editors for this Collection</div>
</div> <div class="card-body">
<div id="editor_fellowships"
hx-get="{% url 'series:_hx_collection_expected_editors' slug=collection.slug %}"
hx-trigger="load"></div>
</div>
</div> </div>
<div class="card my-4"> <div class="card my-4">
<div class="card-header"> <div class="card-header">Publications</div>
Publications <div class="card-body">
</div> <div id="publications"
<div class="card-body"> hx-get="{% url 'series:_hx_collection_publications' slug=collection.slug %}"
<div hx-trigger="load"></div>
id="publications" </div>
hx-get="{% url 'series:_hx_collection_publications' slug=collection.slug %}"
hx-trigger="load"
>
</div>
</div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% with active_submissions=collection.submissions.under_consideration %} {% with active_submissions=collection.submissions.under_consideration %}
{% if active_submissions|length > 0 %} {% if active_submissions|length > 0 %}
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h3 class="highlight">Submissions to this Collection</h3> <h3 class="highlight">Submissions to this Collection</h3>
<ul> <ul>
{% for submission in active_submissions.accepted %}
<li><strong class="text-success">accepted:</strong>&nbsp; {% for submission in active_submissions.accepted %}
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a> <li>
</li> <strong class="text-success">accepted:</strong>&nbsp;
{% endfor %} <a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
{% for submission in active_submissions.revision_requested %} </li>
<li><strong class="text-primary">awaiting resubmission:</strong>&nbsp; {% endfor %}
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li> {% for submission in active_submissions.revision_requested %}
{% endfor %} <li>
{% for submission in active_submissions.in_refereeing %} <strong class="text-primary">awaiting resubmission:</strong>&nbsp;
<li><strong class="text-warning">under refereeing:</strong>&nbsp; <a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a> </li>
</li> {% endfor %}
{% endfor %}
</ul> {% for submission in active_submissions.in_refereeing %}
</div> <li>
<strong class="text-warning">under refereeing:</strong>&nbsp;
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li>
{% endfor %}
</ul>
</div>
</div> </div>
{% endif %} {% endif %}
{% endwith %} {% endwith %}
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h3 class="highlight">Publications in this Collection</h3> <h3 class="highlight">Publications in this Collection</h3>
<ul> <ul>
{% for publication in collection.publications.all %}
<li><a href="{{ publication.get_absolute_url }}">{{ publication }}</a></li> {% for publication in collection.publications.all %}
{% empty %} <li>
<li>No Publication has yet been associated to this Collection</li> <a href="{{ publication.get_absolute_url }}">{{ publication }}</a>
{% endfor %} </li>
{% empty %}
<li>No Publication has yet been associated to this Collection</li>
{% endfor %}
</ul> </ul>
</div> </div>
</div> </div>
{% endblock content %} {% endblock content %}
{% block footer_script %}
{{ expected_author_form.media }} {% block footer_script %}{{ expected_author_form.media }}{% endblock %}
{% endblock %}
...@@ -24,11 +24,21 @@ urlpatterns = [ ...@@ -24,11 +24,21 @@ urlpatterns = [
views._hx_collection_expected_authors, views._hx_collection_expected_authors,
name="_hx_collection_expected_authors", name="_hx_collection_expected_authors",
), ),
path(
"_hx_collection_expected_editors",
views._hx_collection_expected_editors,
name="_hx_collection_expected_editors",
),
path( path(
"_hx_collection_expected_author_action/<int:profile_id>/<str:action>", "_hx_collection_expected_author_action/<int:profile_id>/<str:action>",
views._hx_collection_expected_author_action, views._hx_collection_expected_author_action,
name="_hx_collection_expected_author_action", name="_hx_collection_expected_author_action",
), ),
path(
"_hx_collection_expected_editor_action/<int:fellowship_id>/<str:action>",
views._hx_collection_expected_editor_action,
name="_hx_collection_expected_editor_action",
),
path( path(
"_hx_collection_publications", "_hx_collection_publications",
views._hx_collection_publications, views._hx_collection_publications,
......
...@@ -13,6 +13,8 @@ from journals.models import Publication ...@@ -13,6 +13,8 @@ from journals.models import Publication
from journals.forms import PublicationDynSelForm from journals.forms import PublicationDynSelForm
from profiles.models import Profile from profiles.models import Profile
from profiles.forms import ProfileSelectForm, ProfileDynSelForm from profiles.forms import ProfileSelectForm, ProfileDynSelForm
from colleges.forms import FellowshipDynSelForm
from colleges.models import Fellowship
from .models import Series, Collection, CollectionPublicationsTable from .models import Series, Collection, CollectionPublicationsTable
...@@ -62,11 +64,11 @@ def _hx_collection_expected_authors(request, slug): ...@@ -62,11 +64,11 @@ def _hx_collection_expected_authors(request, slug):
initial={ initial={
"action_url_name": "series:_hx_collection_expected_author_action", "action_url_name": "series:_hx_collection_expected_author_action",
"action_url_base_kwargs": {"slug": collection.slug, "action": "add"}, "action_url_base_kwargs": {"slug": collection.slug, "action": "add"},
"action_target_element_id": "profiles", "action_target_element_id": "author_profiles",
"action_target_swap": "innerHTML", "action_target_swap": "innerHTML",
} }
) )
context = {"collection": collection, "profile_search_form": form} context = {"collection": collection, "author_profile_search_form": form}
return render(request, "series/_hx_collection_expected_authors.html", context) return render(request, "series/_hx_collection_expected_authors.html", context)
...@@ -91,6 +93,36 @@ def _hx_collection_expected_author_action(request, slug, profile_id, action): ...@@ -91,6 +93,36 @@ def _hx_collection_expected_author_action(request, slug, profile_id, action):
) )
@permission_required("scipost.can_manage_series")
def _hx_collection_expected_editors(request, slug):
collection = get_object_or_404(Collection, slug=slug)
form = FellowshipDynSelForm(
initial={
"action_url_name": "series:_hx_collection_expected_editor_action",
"action_url_base_kwargs": {"slug": collection.slug, "action": "add"},
"action_target_element_id": "editor_fellowships",
"action_target_swap": "innerHTML",
}
)
context = {"collection": collection, "editor_fellowship_search_form": form}
return render(request, "series/_hx_collection_expected_editors.html", context)
@permission_required("scipost.can_manage_series")
def _hx_collection_expected_editor_action(request, slug, fellowship_id, action):
collection = get_object_or_404(Collection, slug=slug)
fellowship = get_object_or_404(Fellowship, pk=fellowship_id)
if action == "add":
collection.expected_editors.add(fellowship)
if action == "remove":
collection.expected_editors.remove(fellowship)
return redirect(
reverse(
"series:_hx_collection_expected_editors", kwargs={"slug": collection.slug}
)
)
@permission_required("scipost.can_manage_series") @permission_required("scipost.can_manage_series")
def _hx_collection_publications(request, slug): def _hx_collection_publications(request, slug):
collection = get_object_or_404(Collection, slug=slug) collection = get_object_or_404(Collection, slug=slug)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment