SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 3b80bc3a authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Add app ethics (with CompetingInterest model) to replace conflicts

parent c469f9b1
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,7 @@ INSTALLED_APPS = [
"common",
"conflicts",
"edadmin",
"ethics",
"finances",
"forums",
"funders",
......
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.contrib import admin
from .models import CompetingInterest
class CompetingInterestAdmin(admin.ModelAdmin):
search_fields = (
"profile__last_name",
"related_profile__last_name",
"affected_submissions__title",
"affected_submissions__preprint__identifier_w_vn_nr",
"affected_publications__title",
"affected_publications__doi_label",
)
list_filter = ("nature",)
list_display = (
"nature",
"profile",
"related_profile",
"date_from",
"date_until",
)
autocomplete_fields = (
"profile",
"related_profile",
"affected_submissions",
"affected_publications",
)
admin.site.register(CompetingInterest, CompetingInterestAdmin)
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.apps import AppConfig
class EthicsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'ethics'
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
import datetime
from django.db import models
from django.utils import timezone
class CompetingInterestQuerySet(models.QuerySet):
def valid_on_date(self, date: datetime.date=None):
"""
Filter for validity on given optional date.
"""
if not date:
date = timezone.now().date()
return self.filter(
Q(date_from__lte=date, date_until__isnull=True)
| Q(date_from__isnull=True, date_until__gte=date)
| Q(date_from__lte=date, date_until__gte=date)
| Q(date_from__isnull=True, date_until__isnull=True)
).ordered()
# Generated by Django 3.2.16 on 2023-01-19 07:55
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
('scipost', '0040_auto_20210310_2026'),
('journals', '0124_journal_has_clockss'),
('profiles', '0035_alter_profile_title'),
('submissions', '0136_alter_submissionauthorprofile_profile'),
]
operations = [
migrations.CreateModel(
name='CompetingInterest',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nature', models.CharField(choices=[('coauthor', 'Coauthor'), ('colleague', 'Colleague'), ('PhD_supervisor', 'PhD supervisor'), ('PhD_supervisee', 'PhD supervisee'), ('postdoc_supervisor', 'Postdoc supervisor'), ('postdoc_supervisee', 'Postdoc supervisee'), ('competitor', 'Competitor'), ('disaccord', 'Professional disaccord'), ('shared_funding', 'Involved in shared funding'), ('personal', 'Involved in a personal relationship'), ('family', 'Family ties'), ('financial', 'Financial ties'), ('other', 'Other')], max_length=32)),
('date_from', models.DateField(blank=True, null=True)),
('date_until', models.DateField(blank=True, null=True)),
('declared_on', models.DateTimeField(default=django.utils.timezone.now)),
('comments', models.TextField(blank=True)),
('affected_publications', models.ManyToManyField(blank=True, related_name='competing_interests', to='journals.Publication')),
('affected_submissions', models.ManyToManyField(blank=True, related_name='competing_interests', to='submissions.Submission')),
('declared_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='declared_competing_interests', to='scipost.contributor')),
('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='competing_interests', to='profiles.profile')),
('related_profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='related_competing_interests', to='profiles.profile')),
],
),
]
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.db import models
from django.utils import timezone
from ethics.managers import CompetingInterestQuerySet
class CompetingInterest(models.Model):
COAUTHOR = "coauthor"
COLLEAGUE = "colleague"
PhD_SUPERVISOR = "PhD_supervisor"
PhD_SUPERVISEE = "PhD_supervisee"
POSTDOC_SUPERVISOR = "postdoc_supervisor"
POSTDOC_SUPERVISEE = "postdoc_supervisee"
COMPETITOR = "competitor"
DISACCORD = "disaccord"
SHARED_FUNDING = "shared_funding"
PERSONAL_RELATIONSHIP = "personal"
FAMILY = "family"
FINANCIAL = "financial"
OTHER = "other"
NATURE_CHOICES = (
(COAUTHOR, "Coauthor"),
(COLLEAGUE, "Colleague"),
(PhD_SUPERVISOR, "PhD supervisor"),
(PhD_SUPERVISEE, "PhD supervisee"),
(POSTDOC_SUPERVISOR, "Postdoc supervisor"),
(POSTDOC_SUPERVISEE, "Postdoc supervisee"),
(COMPETITOR, "Competitor"),
(DISACCORD, "Professional disaccord"),
(SHARED_FUNDING, "Involved in shared funding"),
(PERSONAL_RELATIONSHIP, "Involved in a personal relationship"),
(FAMILY, "Family ties"),
(FINANCIAL, "Financial ties"),
(OTHER, "Other"),
)
nature = models.CharField(max_length=32, choices=NATURE_CHOICES)
date_from = models.DateField(blank=True, null=True)
date_until = models.DateField(blank=True, null=True)
profile = models.ForeignKey(
"profiles.Profile",
on_delete=models.CASCADE,
related_name="competing_interests",
)
related_profile = models.ForeignKey(
"profiles.Profile",
on_delete=models.CASCADE,
related_name="related_competing_interests",
)
declared_by = models.ForeignKey(
"scipost.Contributor",
on_delete=models.CASCADE,
related_name="declared_competing_interests",
)
declared_on = models.DateTimeField(default=timezone.now)
affected_submissions = models.ManyToManyField(
"submissions.Submission",
blank=True,
related_name="competing_interests",
)
affected_publications = models.ManyToManyField(
"journals.Publication",
blank=True,
related_name="competing_interests",
)
comments = models.TextField(blank=True)
objects = CompetingInterestQuerySet.as_manager()
def __str__(self):
return f"{self.profile} - {self.related_profile} ({self.get_nature_display()})"
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.test import TestCase
# Create your tests here.
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.shortcuts import render
# Create your views here.
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