Skip to content

Commit

Permalink
Merge pull request #1601 from ResearchHub/author/structure
Browse files Browse the repository at this point in the history
Setting up structure for authorship
  • Loading branch information
yattias committed May 17, 2024
2 parents 0e30ce3 + 076e394 commit 170cd4a
Show file tree
Hide file tree
Showing 8 changed files with 284 additions and 5 deletions.
68 changes: 68 additions & 0 deletions src/paper/migrations/0124_workauthorship.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 4.1 on 2024-05-17 01:59

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("user", "0104_author_country_code_author_i10_index"),
("institution", "0004_institution_openalex_created_date_and_more"),
("paper", "0123_paper_is_retracted_paper_language_paper_mag_id_and_more"),
]

operations = [
migrations.CreateModel(
name="WorkAuthorship",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_date", models.DateTimeField(auto_now_add=True)),
("updated_date", models.DateTimeField(auto_now=True)),
(
"author_position",
models.CharField(
choices=[
("first", "First"),
("middle", "Middle"),
("last", "Last"),
],
max_length=10,
),
),
("is_corresponding", models.BooleanField(default=False)),
(
"raw_author_name",
models.CharField(blank=True, max_length=255, null=True),
),
(
"author",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="authorships",
to="user.author",
),
),
(
"institutions",
models.ManyToManyField(
blank=True,
null=True,
related_name="authors",
to="institution.institution",
),
),
],
options={
"abstract": False,
},
),
]
32 changes: 32 additions & 0 deletions src/paper/migrations/0125_workauthorship_work_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.1 on 2024-05-17 11:35

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("institution", "0004_institution_openalex_created_date_and_more"),
("paper", "0124_workauthorship"),
]

operations = [
migrations.AddField(
model_name="workauthorship",
name="work",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="authorships",
to="paper.paper",
),
),
migrations.AlterField(
model_name="workauthorship",
name="institutions",
field=models.ManyToManyField(
related_name="authors", to="institution.institution"
),
),
]
77 changes: 77 additions & 0 deletions src/paper/migrations/0126_authorship_delete_workauthorship.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Generated by Django 4.1 on 2024-05-17 20:03

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("user", "0105_remove_author_academic_verification_and_more"),
("institution", "0004_institution_openalex_created_date_and_more"),
("paper", "0125_workauthorship_work_and_more"),
]

operations = [
migrations.CreateModel(
name="Authorship",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_date", models.DateTimeField(auto_now_add=True)),
("updated_date", models.DateTimeField(auto_now=True)),
(
"author_position",
models.CharField(
choices=[
("first", "First"),
("middle", "Middle"),
("last", "Last"),
],
max_length=10,
),
),
("is_corresponding", models.BooleanField(default=False)),
(
"raw_author_name",
models.CharField(blank=True, max_length=255, null=True),
),
(
"author",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="authorships",
to="user.author",
),
),
(
"institutions",
models.ManyToManyField(
related_name="authors", to="institution.institution"
),
),
(
"paper",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="authorships",
to="paper.paper",
),
),
],
options={
"abstract": False,
},
),
migrations.DeleteModel(
name="WorkAuthorship",
),
]
51 changes: 51 additions & 0 deletions src/paper/related_models/authorship_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from django.db import models

from utils.models import DefaultModel


class Authorship(DefaultModel):
FIRST_AUTHOR_POSITION = "first"
MIDDLE_AUTHOR_POSITION = "middle"
LAST_AUTHOR_POSITION = "last"

POSITION_CHOICES = [
(FIRST_AUTHOR_POSITION, "First"),
(MIDDLE_AUTHOR_POSITION, "Middle"),
(LAST_AUTHOR_POSITION, "Last"),
]

institutions = models.ManyToManyField(
"institution.Institution",
related_name="authors",
)

paper = models.ForeignKey(
"paper.paper",
on_delete=models.CASCADE,
related_name="authorships",
blank=False,
null=True,
)

author = models.ForeignKey(
"user.Author",
on_delete=models.CASCADE,
related_name="authorships",
)

author_position = models.CharField(
max_length=10,
choices=POSITION_CHOICES,
null=False,
blank=False,
)

is_corresponding = models.BooleanField(
default=False,
)

raw_author_name = models.CharField(
max_length=255,
null=True,
blank=True,
)
2 changes: 2 additions & 0 deletions src/paper/related_models/paper_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
from utils.aws import lambda_compress_and_linearize_pdf
from utils.http import check_url_contains_pdf, scraper_get_url

from .authorship_model import Authorship

DOI_IDENTIFIER = "10."
ARXIV_IDENTIFIER = "arXiv:"
HOT_SCORE_WEIGHT = 5
Expand Down
23 changes: 23 additions & 0 deletions src/user/migrations/0104_author_country_code_author_i10_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.1 on 2024-05-17 01:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("user", "0103_remove_author_linkedin_data"),
]

operations = [
migrations.AddField(
model_name="author",
name="country_code",
field=models.CharField(blank=True, max_length=20, null=True),
),
migrations.AddField(
model_name="author",
name="i10_index",
field=models.IntegerField(default=0),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.1 on 2024-05-17 02:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("user", "0104_author_country_code_author_i10_index"),
]

operations = [
migrations.RemoveField(
model_name="author",
name="academic_verification",
),
migrations.RemoveField(
model_name="author",
name="merged_with",
),
migrations.RemoveField(
model_name="author",
name="orcid_account",
),
]
11 changes: 6 additions & 5 deletions src/user/related_models/author_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Author(models.Model):
updated_date = models.DateTimeField(auto_now=True)
description = models.TextField(null=True, blank=True)
h_index = models.IntegerField(default=0)
i10_index = models.IntegerField(default=0)
profile_image = models.FileField(
upload_to="uploads/author_profile_images/%Y/%m/%d",
max_length=1024,
Expand All @@ -45,9 +46,6 @@ class Author(models.Model):
orcid_id = models.CharField(
max_length=1024, default=None, null=True, blank=True, unique=True
)
orcid_account = models.ForeignKey(
SocialAccount, on_delete=models.SET_NULL, null=True, blank=True
)
openalex_ids = ArrayField(
models.CharField(
max_length=64, default=None, null=True, blank=True, unique=True
Expand All @@ -65,10 +63,13 @@ class Author(models.Model):
google_scholar = models.URLField(
max_length=255, default=None, null=True, blank=True
)
academic_verification = models.BooleanField(default=None, null=True, blank=True)
claimed = models.BooleanField(default=True, null=True, blank=True)
is_verified = models.BooleanField(default=False)
merged_with = models.ForeignKey("self", on_delete=SET_NULL, null=True, blank=True)
country_code = models.CharField(
blank=True,
null=True,
max_length=20,
)

def __str__(self):
university = self.university
Expand Down

0 comments on commit 170cd4a

Please sign in to comment.