SciPost Code Repository

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

Move OrganizationLookup from journals app to organizations

parent ec0a545a
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,6 @@ from ajax_select import register, LookupChannel ...@@ -10,7 +10,6 @@ from ajax_select import register, LookupChannel
from ..models import Publication from ..models import Publication
from funders.models import Funder, Grant from funders.models import Funder, Grant
from organizations.models import Organization
@register('publication_lookup') @register('publication_lookup')
...@@ -43,30 +42,6 @@ class PublicationLookup(LookupChannel): ...@@ -43,30 +42,6 @@ class PublicationLookup(LookupChannel):
raise PermissionDenied raise PermissionDenied
@register('organization_lookup')
class OrganizationLookup(LookupChannel):
model = Organization
def get_query(self, q, request):
return (self.model.objects.order_by('name')
.filter(Q(name__icontains=q) |
Q(acronym__icontains=q) |
Q(name_original__icontains=q))[:10])
def format_item_display(self, item):
"""(HTML) format item for displaying item in the selected deck area."""
return u"<span class='auto_lookup_display'>%s</span>" % item.full_name_with_acronym
def format_match(self, item):
"""(HTML) Format item for displaying in the dropdown."""
return item.full_name_with_acronym
def check_auth(self, request):
"""Allow use by logged-in users (e.g. for Affiliations handling)."""
if not request.user.is_authenticated():
raise PermissionDenied
@register('funder_lookup') @register('funder_lookup')
class FunderLookup(LookupChannel): class FunderLookup(LookupChannel):
model = Funder model = Funder
......
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from ajax_select import register, LookupChannel
from ..models import Organization
@register('organization_lookup')
class OrganizationLookup(LookupChannel):
model = Organization
def get_query(self, q, request):
return (self.model.objects.order_by('name')
.filter(Q(name__icontains=q) |
Q(acronym__icontains=q) |
Q(name_original__icontains=q))[:10])
def format_item_display(self, item):
"""(HTML) format item for displaying item in the selected deck area."""
return u"<span class='auto_lookup_display'>%s</span>" % item.full_name_with_acronym
def format_match(self, item):
"""(HTML) Format item for displaying in the dropdown."""
return item.full_name_with_acronym
def check_auth(self, request):
"""Allow use by logged-in users (e.g. for Affiliations handling)."""
if not request.user.is_authenticated():
raise PermissionDenied
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