Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from PGScatalog:master #125

Merged
merged 9 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
# Ignored by the build system
/setup.cfg

# IDE configs
.idea
.vscode

# Virtual env
/venv/

# Other
/rest_api/fixtures/
/static/CACHE/
Expand Down
5 changes: 5 additions & 0 deletions catalog/static/catalog/pgs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,11 @@ td > ul {
font-size: 14px;
padding: 3px 8px;
}
.btn-pgs-2-small {
@extend .btn-pgs-2;
font-size:14px !important;
padding: 3px 8px;
}

.btn-pgs-like {
i {
Expand Down
3 changes: 3 additions & 0 deletions catalog/templates/catalog/pgp.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ <h2>PGS
Publication:
{% endif %}
<span class="pgs_title">{{ publication.id }}</span></h2>
{% if is_pgs_curation_site %}
<a class="btn-pgs-2-small" href="/admin/curation_tracker/curationpublicationannotation/by_pgp_id/{{ publication.id }}"><span class="fas fa-user-pen pgs_color_2 pr-1"></span>Open in Curation Tracker</a>
{% endif %}
<table class="table table-bordered table_pgs_h mt-4">
<tbody>
<tr>
Expand Down
47 changes: 28 additions & 19 deletions curation_tracker/admin.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
from django.contrib import admin
from django.utils.html import format_html
import datetime as dt
import sys
from typing import List

from django import forms
from django.urls import path
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.db import models, transaction
from django.utils import timezone
from django.core.exceptions import ValidationError
from django.contrib import admin, messages
from django.contrib.admin import DateFieldListFilter
# Register your models here.
from .models import *
from catalog.models import Publication
from curation_tracker.litsuggest import litsuggest_fileupload_to_annotation_imports, annotation_to_dict, dict_to_annotation_import, annotation_import_to_dict, CurationPublicationAnnotationImport
from pgs_web import constants
from django.contrib.auth.decorators import login_required, permission_required
from django.core.exceptions import ValidationError
from django.db import transaction
from django.http import HttpResponseRedirect, JsonResponse
from django.shortcuts import render
from django.urls import path
from django.utils.decorators import method_decorator
from django.http import JsonResponse
from django.utils.html import format_html

from typing import List
import re
import datetime as dt
import sys
from catalog.models import Publication
from curation_tracker.litsuggest import litsuggest_fileupload_to_annotation_imports, annotation_to_dict, \
dict_to_annotation_import, annotation_import_to_dict, CurationPublicationAnnotationImport
# Register your models here.
from .models import *

admin.site.site_header = "PGS Catalog - Curation Tracker"
admin.site.site_title = "PGS Catalog - Curation Tracker"
Expand Down Expand Up @@ -493,7 +491,8 @@ def get_urls(self):
path('import-litsuggest/', login_required(self.import_litsuggest, login_url='/admin/login/')),
path('import-litsuggest/confirm_preview', login_required(self.confirm_litsuggest_preview, login_url='/admin/login/')),
path('import-litsuggest/confirm_formset', login_required(self.confirm_litsuggest_formset, login_url='/admin/login/')),
path('<path:object_id>/contact-author/', login_required(self.contact_author, login_url='/admin/login/'))
path('<path:object_id>/contact-author/', login_required(self.contact_author, login_url='/admin/login/')),
path('by_pgp_id/<path:pgp_id>', login_required(self.by_pgp_id, login_url='/admin/login/'))
]
return my_urls + urls

Expand Down Expand Up @@ -748,6 +747,16 @@ def confirm_litsuggest_formset(self,request):
del request.session['triage_info']

return HttpResponseRedirect('/admin/curation_tracker/curationpublicationannotation')

@method_decorator(permission_required('curation_tracker.change_curationpublicationannotation', raise_exception=True))
def by_pgp_id(self, request, pgp_id):
try:
annotation = CurationPublicationAnnotation.objects.get(pgp_id=pgp_id)
num = annotation.num
return HttpResponseRedirect('/admin/curation_tracker/curationpublicationannotation/' + str(num))
except CurationPublicationAnnotation.DoesNotExist:
messages.error(request, "No annotation associated with '{}'".format(pgp_id))
return HttpResponseRedirect('/admin/curation_tracker/curationpublicationannotation')

display_pgp_id.short_description = 'PGP ID'
display_study_name.short_description = 'Study Name'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ function setError(error){
}
}

function goToPGP(new_window){
setError('');
var pgp_id = $('#id_pgp_id').val();
if(pgp_id){
var url = '/publication/'+pgp_id;
if(new_window){
window.open(url);
} else {
window.location = url;
}
} else {
alert('Please provide a PGP ID first');
}
}

function goToPublication(){
setError('');
var doi = $('#id_doi').val();
Expand Down Expand Up @@ -122,6 +137,12 @@ function requestAuthorData(){
}

$(document).ready(function(){
// Adding 'go to PGS Catalog publication' button after the PGP id field
var pgp_id_div = $('div.form-row.field-pgp_id > div');
pgp_id_div.addClass('flex-container');
pgp_id_div.find(">:first-child").addClass('fieldBox');
pgp_id_div.append('<div><a title="Go to the PGS Catalog curation publication page" href="" class="extra-field-button external-link" onclick="goToPGP(false); return false;" onauxclick="goToPGP(true); return false;">Go to PGS Catalog publication</a></div>');

// Adding 'go to publication' and 'Autofill' buttons after the DOI and PMID form fields
$('div.form-row.field-doi.field-PMID > div.flex-container').append('<div><div><a title="Go to the publication page using DOI or the Pubmed page if only the PMID is provided" href="" class="extra-field-button external-link" onclick="goToPublication(); return false;">Go to publication</a></div><div style="display: flex;"><div><a title="Fetch the publication data from EPMC and fill in the form automatically (DOI or PMID required)" href="" class="extra-field-button" onclick="autofillForm(); return false;">Autofill <i class="fa-solid fa-gears"></i></a></div><div id="doi_pmid_error" class="fieldBox errors"><ul class="errorlist"></ul></div></div></div>');

Expand Down
Loading