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):
"series",
"submissions",
"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):
event_end_date = models.DateField(null=True, 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)
publications = models.ManyToManyField(
"journals.Publication", through="series.CollectionPublicationsTable", blank=True
......
......@@ -5,39 +5,40 @@
{% include 'scipost/messages.html' %}
<table class="table">
<thead>
<tr>
<th>Profile</th>
<th>Actions</th>
</tr>
<tr>
<th>Profile</th>
<th>Actions</th>
</tr>
</thead>
{% for profile in collection.expected_authors.all %}
<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_author_action' slug=collection.slug profile_id=profile.id action='remove' %}"
hx-target="#profiles"
hx-confirm="Are you sure you want to remove {{ profile }} from expected authors in this Collection?"
><small>Remove</small></a>
</td>
</tr>
<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_author_action' slug=collection.slug profile_id=profile.id action='remove' %}"
hx-target="#author_profiles"
hx-confirm="Are you sure you want to remove {{ profile }} from expected authors in this Collection?"><small>Remove</small></a>
</td>
</tr>
{% empty %}
<tr>
<td colspan="4">No expected authors yet</td>
</tr>
<tr>
<td colspan="4">No expected authors yet</td>
</tr>
{% endfor %}
</table>
</div>
<div class="col-md-4 p-4">
<h4>Add an expected author</h4>
<form
hx-post="{% url 'profiles:_hx_profile_dynsel_list' %}"
hx-trigger="keyup delay:200ms, change"
hx-target="#profile_search_results"
>
<div id="profile_search_form">{% crispy profile_search_form %}</div>
<form hx-post="{% url 'profiles:_hx_profile_dynsel_list' %}"
hx-trigger="keyup delay:200ms, change"
hx-target="#author_profile_search_results">
<div id="author_profile_search_form">{% crispy author_profile_search_form %}</div>
</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>
{% 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 @@
<span class="breadcrumb-item">{{ collection.name }}</span>
{% endblock %}
{% block meta_description %}{{ block.super }} Collection detail {{ collection.series.name }} {{ collection.name }}{% endblock meta_description %}
{% block pagetitle %}: Collection detail{% endblock pagetitle %}
{% block meta_description %}
{{ block.super }} Collection detail {{ collection.series.name }} {{ collection.name }}
{% endblock meta_description %}
{% block pagetitle %}
: Collection detail
{% endblock pagetitle %}
{% block content %}
......@@ -22,42 +27,47 @@
<div class="row">
<div class="col-12">
<h1 class="highlight">
<a href="{{ collection.series.get_absolute_url }}">{{ collection.series.name }}</a>
{% if collection.series.container_journals %}
<br>
<small><em>
<ul class="list list-inline mt-2 mb-0">
<li class="list-inline-item mx-0">a series contained in</li>
{% for container in collection.series.container_journals.all %}
<li class="list-inline-item">
<a href="{{ container.get_absolute_url }}">{{ container }}</a>
</li>
{% endfor %}
</ul>
</em></small>
{% endif %}
<a href="{{ collection.series.get_absolute_url }}">{{ collection.series.name }}</a>
{% if collection.series.container_journals %}
<br />
<small><em>
<ul class="list list-inline mt-2 mb-0">
<li class="list-inline-item mx-0">a series contained in</li>
{% for container in collection.series.container_journals.all %}
<li class="list-inline-item">
<a href="{{ container.get_absolute_url }}">{{ container }}</a>
</li>
{% endfor %}
</ul>
</em></small>
{% endif %}
</h1>
<h2 class="highlight">
Collection&emsp;{{ collection.name }}
</h2>
<h2 class="highlight">Collection&emsp;{{ collection.name }}</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="p-2">
{% automarkup collection.description %}
</div>
<div class="p-2">{% automarkup collection.description %}</div>
{% if collection.event_start_date and collection.event_end_date %}
<p class="p-2">
Dates: from {{ collection.event_start_date }} to {{ collection.event_end_date }}.
</p>
<p class="p-2">Dates: from {{ collection.event_start_date }} to {{ collection.event_end_date }}.</p>
{% endif %}
{% if collection.image %}
<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 }}">
</div>
<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 }}" />
</div>
{% endif %}
</div>
</div>
......@@ -66,77 +76,88 @@
<h3>Editorial Administration</h3>
<div class="card my-4">
<div class="card-header">
Expected authors for this Collection
</div>
<div class="card-body">
<div
id="profiles"
hx-get="{% url 'series:_hx_collection_expected_authors' slug=collection.slug %}"
hx-trigger="load"
>
</div>
</div>
<div class="card-header">Expected authors for this Collection</div>
<div class="card-body">
<div id="author_profiles"
hx-get="{% url 'series:_hx_collection_expected_authors' slug=collection.slug %}"
hx-trigger="load"></div>
</div>
</div>
<div class="card my-4">
<div class="card-header">Expected editors for this Collection</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 class="card my-4">
<div class="card-header">
Publications
</div>
<div class="card-body">
<div
id="publications"
hx-get="{% url 'series:_hx_collection_publications' slug=collection.slug %}"
hx-trigger="load"
>
</div>
</div>
<div class="card-header">Publications</div>
<div class="card-body">
<div id="publications"
hx-get="{% url 'series:_hx_collection_publications' slug=collection.slug %}"
hx-trigger="load"></div>
</div>
</div>
</div>
{% endif %}
{% with active_submissions=collection.submissions.under_consideration %}
{% if active_submissions|length > 0 %}
<div class="row">
<div class="col-12">
<h3 class="highlight">Submissions to this Collection</h3>
<ul>
{% for submission in active_submissions.accepted %}
<li><strong class="text-success">accepted:</strong>&nbsp;
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li>
{% endfor %}
{% for submission in active_submissions.revision_requested %}
<li><strong class="text-primary">awaiting resubmission:</strong>&nbsp;
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li>
{% endfor %}
{% for submission in active_submissions.in_refereeing %}
<li><strong class="text-warning">under refereeing:</strong>&nbsp;
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li>
{% endfor %}
</ul>
</div>
<div class="col-12">
<h3 class="highlight">Submissions to this Collection</h3>
<ul>
{% for submission in active_submissions.accepted %}
<li>
<strong class="text-success">accepted:</strong>&nbsp;
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li>
{% endfor %}
{% for submission in active_submissions.revision_requested %}
<li>
<strong class="text-primary">awaiting resubmission:</strong>&nbsp;
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li>
{% endfor %}
{% for submission in active_submissions.in_refereeing %}
<li>
<strong class="text-warning">under refereeing:</strong>&nbsp;
<a href="{{ submission.get_absolute_url }}" target="_blank">{{ submission }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% endwith %}
<div class="row">
<div class="col-12">
<h3 class="highlight">Publications in this Collection</h3>
<ul>
{% for publication in collection.publications.all %}
<li><a href="{{ publication.get_absolute_url }}">{{ publication }}</a></li>
{% empty %}
<li>No Publication has yet been associated to this Collection</li>
{% endfor %}
{% for publication in collection.publications.all %}
<li>
<a href="{{ publication.get_absolute_url }}">{{ publication }}</a>
</li>
{% empty %}
<li>No Publication has yet been associated to this Collection</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock content %}
{% block footer_script %}
{{ expected_author_form.media }}
{% endblock %}
{% block footer_script %}{{ expected_author_form.media }}{% endblock %}
......@@ -24,11 +24,21 @@ urlpatterns = [
views._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(
"_hx_collection_expected_author_action/<int:profile_id>/<str:action>",
views._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(
"_hx_collection_publications",
views._hx_collection_publications,
......
......@@ -13,6 +13,8 @@ from journals.models import Publication
from journals.forms import PublicationDynSelForm
from profiles.models import Profile
from profiles.forms import ProfileSelectForm, ProfileDynSelForm
from colleges.forms import FellowshipDynSelForm
from colleges.models import Fellowship
from .models import Series, Collection, CollectionPublicationsTable
......@@ -62,11 +64,11 @@ def _hx_collection_expected_authors(request, slug):
initial={
"action_url_name": "series:_hx_collection_expected_author_action",
"action_url_base_kwargs": {"slug": collection.slug, "action": "add"},
"action_target_element_id": "profiles",
"action_target_element_id": "author_profiles",
"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)
......@@ -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")
def _hx_collection_publications(request, 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