Skip to content

Commit

Permalink
Revert "Merge branch 'main' into #352-Compliance-criteria-Funded-by-S…
Browse files Browse the repository at this point in the history
…COAP3"

This reverts commit d568acc, reversing
changes made to 36ffad0.
  • Loading branch information
Lorenzovagliano committed Sep 23, 2024
1 parent 63c55a0 commit c76d34b
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 386 deletions.
4 changes: 0 additions & 4 deletions config/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
ArticleIdentifierViewSet,
ArticleViewSet,
ArticleWorkflowImportView,
RecordViewSet,
)
from scoap3.authors.api.views import AuthorIdentifierViewSet, AuthorViewSet
from scoap3.misc.api.views import (
Expand Down Expand Up @@ -41,9 +40,6 @@
basename="article-workflow-import",
)

# Records
router.register("records", RecordViewSet, basename="records")

# Authors
router.register("author", AuthorViewSet)
router.register("author-identifier", AuthorIdentifierViewSet)
Expand Down
42 changes: 15 additions & 27 deletions scoap3/articles/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class ComplianceReportAdmin(admin.ModelAdmin):
"article_publisher",
"article_journal",
"article_doi",
"compliant",
"check_license",
"check_required_file_formats",
"check_file_formats",
"check_arxiv_category",
"check_article_type",
Expand All @@ -43,11 +41,9 @@ class ComplianceReportAdmin(admin.ModelAdmin):
fields = [
"article",
"report_date",
"compliant",
"get_is_compliant",
"check_license",
"check_license_description",
"check_required_file_formats",
"check_required_file_formats_description",
"check_file_formats",
"check_file_formats_description",
"check_arxiv_category",
Expand All @@ -64,7 +60,7 @@ class ComplianceReportAdmin(admin.ModelAdmin):
readonly_fields = [
"article",
"report_date",
"compliant",
"get_is_compliant",
"check_license",
"check_license_description",
"check_file_formats",
Expand All @@ -88,7 +84,7 @@ class ComplianceReportAdmin(admin.ModelAdmin):
"article_id__publication_info__journal_title",
"article_id__publication_date",
"article_id__report__check_license",
"article_id__report__check_required_file_formats",
"article_id__report__check_file_formats",
"article_id__report__check_arxiv_category",
"article_id__report__check_article_type",
"article_id__report__check_doi_registration_time",
Expand All @@ -102,6 +98,10 @@ class ComplianceReportAdmin(admin.ModelAdmin):
def article_id(self, obj):
return obj.article.id

@admin.display(boolean=True, description="Compliant")
def get_is_compliant(self, obj):
return obj.is_compliant()

@admin.display(description="DOI")
def article_doi(self, obj):
doi_identifier = obj.article.article_identifiers.filter(
Expand All @@ -125,7 +125,7 @@ def export_as_csv(self, request, queryset):
"DOI": "article_doi",
"Journal": "article_journal",
"Check License": "check_license",
"Check File Formats": "check_required_file_formats",
"Check File Formats": "check_file_formats",
"Check Arxiv Category": "check_arxiv_category",
"Check Article Type": "check_article_type",
"Check DOI Registration": "check_doi_registration_time_description",
Expand Down Expand Up @@ -160,8 +160,8 @@ class ArticleComplianceReportInline(admin.StackedInline):
readonly_fields = [
"check_license",
"check_license_description",
"check_required_file_formats",
"check_required_file_formats_description",
"check_file_formats",
"check_file_formats_description",
"check_arxiv_category",
"check_arxiv_category_description",
"check_article_type",
Expand All @@ -183,10 +183,7 @@ class ArticleComplianceReportInline(admin.StackedInline):
{
"fields": [
("check_license", "check_license_description"),
(
"check_required_file_formats",
"check_required_file_formats_description",
),
("check_file_formats", "check_file_formats_description"),
("check_arxiv_category", "check_arxiv_category_description"),
("check_article_type", "check_article_type_description"),
(
Expand Down Expand Up @@ -252,9 +249,8 @@ class ArticleAdmin(admin.ModelAdmin):
"journal_title",
"publisher",
"doi",
"check_compliance",
"check_license",
"check_required_file_formats",
"check_file_formats",
"check_arxiv_category",
"check_article_type",
"check_doi_registration_time",
Expand All @@ -270,13 +266,12 @@ class ArticleAdmin(admin.ModelAdmin):
]
actions = ["make_compliance_check"]
list_filter = [
"report__compliant",
"_updated_at",
"_created_at",
"publication_date",
"publication_info__journal_title",
"report__check_license",
"report__check_required_file_formats",
"report__check_file_formats",
"report__check_arxiv_category",
"report__check_article_type",
"report__check_doi_registration_time",
Expand Down Expand Up @@ -327,13 +322,6 @@ def make_compliance_check(self, request, queryset):
""",
)

@admin.display(boolean=True, description="Compliant")
def check_compliance(self, obj):
report = obj.report.first()
if report:
return report.compliant
return False

@admin.display(boolean=True, description="License")
def check_license(self, obj):
report = obj.report.first()
Expand All @@ -342,10 +330,10 @@ def check_license(self, obj):
return False

@admin.display(description="File formats", boolean=True)
def check_required_file_formats(self, obj):
def check_file_formats(self, obj):
report = obj.report.first()
if report:
return report.check_required_file_formats
return report.check_file_formats
return False

@admin.display(description="ArXiv category", boolean=True)
Expand Down
121 changes: 0 additions & 121 deletions scoap3/articles/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,127 +53,6 @@ def to_representation(self, instance):
return representation


class LegacyArticleSerializer(serializers.ModelSerializer):
metadata = serializers.SerializerMethodField()
updated = serializers.SerializerMethodField()
created = serializers.SerializerMethodField()
id = serializers.SerializerMethodField()

class Meta:
model = Article
fields = ["id", "metadata", "updated", "created"]

def get_id(self, obj):
return obj.id

def get_metadata(self, obj):
return {
"_files": [
{
"filetype": entry.file.type,
"size": entry.file.size,
"key": entry.file.name,
}
for entry in obj.related_files.all()
],
"abstracts": [
{
"source": "".join(
[entry.publisher.name for entry in obj.publication_info.all()]
),
"value": obj.abstract,
}
],
"arxiv_eprints": [
{
"categories": {
entry.category for entry in obj.article_arxiv_category.all()
},
"value": {
entry.identifier_value
for entry in obj.article_identifiers.all()
},
}
],
"authors": [
{
"affiliations": [
{
"country": affiliation.country.name
if affiliation.country
else None,
"organization": affiliation.organization,
"value": affiliation.value,
}
for affiliation in entry.affiliations.all()
],
"email": entry.email,
"full_name": entry.full_name,
"given_names": entry.first_name,
"surname": entry.last_name,
}
for entry in obj.authors.all()
],
"collections": [
{"primary": entry.journal_title} for entry in obj.publication_info.all()
],
"control_number": obj.id,
"copyright": [
{
"statement": entry.statement,
"holder": entry.holder,
"year": entry.year,
}
for entry in obj.copyright.all()
],
"dois": [
{"value": entry.identifier_value}
for entry in obj.article_identifiers.all()
],
"imprints": [
{
"date": entry.journal_issue_date,
"publisher": entry.publisher.name,
}
for entry in obj.publication_info.all()
],
"license": [
{
"license": entry.name,
"url": entry.url,
}
for entry in obj.related_licenses.all()
],
"page_nr": [int(entry.page_end) for entry in obj.publication_info.all()],
"publication_info": [
{
"artid": entry.artid,
"journal_issue": entry.journal_issue,
"journal_title": entry.journal_title,
"journal_volume": entry.journal_volume,
"page_end": entry.page_end,
"page_start": entry.page_start,
"year": entry.volume_year,
}
for entry in obj.publication_info.all()
],
"record_creation_date": obj._created_at,
"titles": [
{
"source": entry.publisher.name,
"title": obj.title,
}
for entry in obj.publication_info.all()
],
}

def get_updated(self, obj):
return obj._updated_at

def get_created(self, obj):
return obj._created_at


class ArticleDocumentSerializer(DocumentSerializer):
class Meta:
document = ArticleDocument
Expand Down
30 changes: 1 addition & 29 deletions scoap3/articles/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
ArticleFileSerializer,
ArticleIdentifierSerializer,
ArticleSerializer,
LegacyArticleSerializer,
SearchCSVSerializer,
)
from scoap3.articles.documents import ArticleDocument
Expand Down Expand Up @@ -67,16 +66,6 @@ def create(self, request, *args, **kwargs):
)


class RecordViewSet(
RetrieveModelMixin,
ListModelMixin,
GenericViewSet,
):
serializer_class = LegacyArticleSerializer
queryset = Article.objects.all()
permission_classes = [IsAuthenticatedOrReadOnly]


class ArticleWorkflowImportView(ViewSet):
permission_classes = [IsAuthenticatedOrReadOnly]

Expand Down Expand Up @@ -120,7 +109,7 @@ def __init__(self, *args, **kwargs):
)

ordering_fields = {"publication_date": "publication_date"}
ordering = ["-publication_date"]
ordering = ["publication_date"]

filter_fields = {
"publication_year": {
Expand Down Expand Up @@ -175,23 +164,6 @@ def __init__(self, *args, **kwargs):
},
}

def get_queryset(self):
get_all = self.request.query_params.get("all", "false").lower() == "true"
search = super().get_queryset()

if get_all and self.request.user.is_staff:
search = search.extra(size=10000)

return search

def list(self, request, *args, **kwargs):
get_all = request.query_params.get("all", "false").lower() == "true"

if get_all and self.request.user.is_staff:
self.pagination_class = None

return super().list(request, *args, **kwargs)

def get_serializer_class(self):
requested_renderer_format = self.request.accepted_media_type
if "text/csv" in requested_renderer_format:
Expand Down
17 changes: 0 additions & 17 deletions scoap3/articles/migrations/0015_compliancereport_compliant.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit c76d34b

Please sign in to comment.