literature package#

Subpackages#

Submodules#

literature.admin module#

class literature.admin.AuthorAdmin(model, admin_site)[source]#

Bases: ModelAdmin

list_display = ['family', 'given', 'ORCID', 'created', 'modified']#
property media#
class literature.admin.AuthorInline(parent_model, admin_site)[source]#

Bases: TabularInline

property media#
model#

alias of LiteratureAuthor

class literature.admin.CollectionAdmin(model, admin_site)[source]#

Bases: ModelAdmin

property media#
class literature.admin.IdentifierAdmin(model, admin_site)[source]#

Bases: ModelAdmin

list_filter = ['type']#
property media#
search_fields = ['ID', 'literature__title']#
class literature.admin.LiteratureAdmin(*args, **kwargs)[source]#

Bases: DataTableMixin, ModelAdmin

Django Admin setup for the literature.Work model.

change_list_template = 'literature/admin/change_list.html'#
edit(obj)[source]#
endpoint: dict[str, Any] = {'fields': '__all__', 'page_size': 1000, 'permission_classes': [<class 'rest_framework.permissions.IsAdminUser'>, <class 'rest_framework.permissions.DjangoModelPermissions'>]}#
fieldsets = [('Basic', {'fields': ['citation_key', 'pdf', 'type', 'title', 'language', 'created', 'modified']}), ('Recommended', {'fields': ['container_title', 'abstract', 'collections']}), ('Comment', {'fields': ['comment']})]#
get_dt_fields()[source]#
get_urls()[source]#
inlines = [<class 'literature.admin.SupplementaryInline'>, <class 'literature.admin.AuthorInline'>]#
property media#
search_online(request, *args, **kwargs)[source]#

Admin view that handles user-uploaded bibtex files

Returns:

redirects to model admins change_list

Return type:

HttpResponseRedirect

upload(request, *args, **kwargs)[source]#

Admin view that handles user-uploaded bibtex files

Returns:

redirects to model admins change_list

Return type:

HttpResponseRedirect

class literature.admin.SupplementaryInline(parent_model, admin_site)[source]#

Bases: TabularInline

property media#
model#

alias of SupplementaryMaterial

literature.apps module#

class literature.apps.LiteratureConfig(app_name, app_module)[source]#

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'#
name = 'literature'#
verbose_name = 'Literature Manager'#

literature.choices module#

class literature.choices.IdentifierTypes(value)[source]#

Bases: IntegerChoices

An enumeration.

DOI = 0#
ISBN = 2#
ISSN = 1#
PMCID = 3#
PMID = 4#
URL = 5#
class literature.choices.MonthChoices(value)[source]#

Bases: IntegerChoices

An enumeration.

APR = 4#
AUG = 8#
DEC = 12#
FEB = 2#
JAN = 1#
JUL = 7#
JUN = 6#
MAR = 3#
MAY = 5#
NOV = 11#
OCT = 10#
SEP = 9#
class literature.choices.TypeChoices(value)[source]#

Bases: TextChoices

An enumeration.

article = 'article'#
article_journal = 'article-journal'#
article_magazine = 'article-magazine'#
article_newspaper = 'article-newspaper'#
bill = 'bill'#
book = 'book'#
broadcast = 'broadcast'#
chapter = 'chapter'#
dataset = 'dataset'#
entry = 'entry'#
entry_dictionary = 'entry-dictionary'#
entry_encyclopedia = 'entry-encyclopedia'#
figure = 'figure'#
graphic = 'graphic'#
interview = 'interview'#
legal_case = 'legal_case'#
legislation = 'legislation'#
manuscript = 'manuscript'#
map = 'map'#
motion_picture = 'motion_picture'#
musical_score = 'musical_score'#
pamphlet = 'pamphlet'#
paper_conference = 'paper-conference'#
patent = 'patent'#
personal_communication = 'personal_communication'#
post = 'post'#
post_weblog = 'post-weblog'#
report = 'report'#
review = 'review'#
review_book = 'review-book'#
song = 'song'#
speech = 'speech'#
thesis = 'thesis'#
treaty = 'treaty'#
webpage = 'webpage'#

literature.conf module#

Settings for Django Literature.

class literature.conf.LiteratureConf(**kwargs)[source]#

Bases: AppConf

Settings for Django Literature

ADAPTORS = ['literature.adaptors.crossref.Crossref', 'literature.adaptors.datacite.Datacite']#
AUTOLABEL = 'literature.utils.simple_autolabeler'#
DEFAULT_CITATION_STYLE = 'plain_text'#

Default citation style. Must be included in the templates/literautre/citation/ folder.

INACTIVE_AFTER = 5#
class Meta[source]#

Bases: object

Prefix for all Django Literature settings.

prefix = 'LITERATURE'#
PDF_RENAMER = 'literature.utils.simple_file_renamer'#

literature.exceptions module#

exception literature.exceptions.AdaptorError[source]#

Bases: Exception

The requested model field does not exist

exception literature.exceptions.RemoteAdaptorError[source]#

Bases: Exception

The requested model field does not exist

literature.fields module#

class literature.fields.LiteratureFK(*args, **kwargs)[source]#

Bases: ForeignKey

A foreign key field to the literature.Literature model

class literature.fields.LiteratureM2M(*args, **kwargs)[source]#

Bases: ManyToManyField

A many-to-many field to the literature.Literature model

literature.managers module#

class literature.managers.AuthorQuerySet(model=None, query=None, using=None, hints=None)[source]#

Bases: QuerySet

as_lead()[source]#

Convenience filter for retrieving only authors that are listed as the lead author on a publication.

is_active()[source]#
with_last_published()[source]#
with_work_counts()[source]#

Convenience filter for retrieving authors with annotated counts of works published as either lead or supporting author.

These count attributes can be accessed on the queryset as as_lead or as_supporting. Further filtering/manipulation is possible on both fields afterwards.

Example

Get authors that have published at least five works as lead author.

>>> Author.objects.with_work_counts().filter(as_lead__gte=5)

Get authors that have published only once but have been a supporting author on at least three.

>>> Author.objects.with_work_counts().filter(as_lead=1, as_supporting__gte=3)
class literature.managers.LiteratureQuerySet(model=None, query=None, using=None, hints=None)[source]#

Bases: QuerySet

get_or_resolve(doi)[source]#

Loops through all available remote adaptors and attempts to resolve the given DOI until succesful.

Parameters:

doi (_type_) – _description_

resolve_doi(doi, adaptor=None)[source]#

Attempts to fetch a doi from a remote data source. Loops through the available remote adaptors until the doi is succesfully resolved. If the doi registrar (source) is known, you may supply the appropriate adaptor to prevent searching other registries.

Parameters:
  • doi (_type_) – _description_

  • adaptor (_type_, optional) – _description_. Defaults to None.

Returns:

_description_

Return type:

_type_

literature.models module#

class literature.models.Author(id, created, modified, given, family, ORCID)[source]#

Bases: TimeStampedModel

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

ORCID#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

static autocomplete_search_fields()[source]#
created#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

family#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

family_g()[source]#

Returns “Smith, J.”

family_given()[source]#

Returns “Smith, John”

g_family()[source]#

Returns “J. Smith”

get_absolute_url()[source]#
get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
given#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

given_family()[source]#

Returns “John Smith”

id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

literature#

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

modified#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.ManagerFromAuthorQuerySet object>#
position#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class literature.models.Collection(*args, **kwargs)[source]#

Bases: TimeStampedModel

Model representing a collection of publications.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

created#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

literature#

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

modified#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>#
class literature.models.Identifier(created, modified, ID, literature, type)[source]#

Bases: TimeStampedModel

exception DoesNotExist#

Bases: ObjectDoesNotExist

ID#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

created#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
get_type_display(*, field=<django.db.models.fields.IntegerField: type>)#
literature#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

literature_id#
modified#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>#
type#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class literature.models.Literature(*args, **kwargs)[source]#

Bases: TimeStampedModel

Model for storing literature data

CSL#
exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

abstract#
authors#
static autocomplete_search_fields()[source]#
citation_key#
collections#

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

comment#
container_title#
created#
get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
get_type_display(*, field=<django.db.models.fields.CharField: type>)#
id#
identifiers#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

keyword = <taggit.managers._TaggableManager object>#
language#
literatureauthor_set#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

modified#
objects = <django.db.models.manager.ManagerFromLiteratureQuerySet object>#
parse_csl()[source]#
pdf#
published#
refresh_from_db(using=None, fields=None)#

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(*args, **kwargs)[source]#

Overriding the save method in order to make sure that modified field is updated even if it is not given as a parameter to the update field argument.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)#

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

supplementary#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tagged_items#

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example:

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

title#
tracker#
type#
update_identifiers()[source]#
class literature.models.LiteratureAuthor(*args, **kwargs)[source]#

Bases: Model

An intermediate table for the Work-Author m2m relationship. SortedManyToManyField automatically creates this table, however, there is no access via querysets. Defining here instead allows us to have access to the intermediate table in order to query author position.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

author#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

author_id#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

literature#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

literature_id#
objects = <django.db.models.manager.Manager object>#
position#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class literature.models.SupplementaryMaterial(id, created, modified, literature, file)[source]#

Bases: TimeStampedModel

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

created#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

file#

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

literature#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

literature_id#
modified#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>#

literature.utils module#

literature.utils.clean_doi(doi)[source]#

Clean a DOI string to remove any unnecessary characters.

literature.utils.get_current_year()[source]#
literature.utils.pdf_file_renamer(instance, fname=None)[source]#
literature.utils.simple_file_renamer(instance, fname)[source]#

literature.views module#

class literature.views.AuthorDetail(**kwargs)[source]#

Bases: CitationMixin, DetailView

get_context_data(**kwargs)[source]#

Insert the single object into the context dict.

model#

alias of Author

class literature.views.AuthorList(**kwargs)[source]#

Bases: ListView

get_queryset()[source]#

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

model#

alias of Author

class literature.views.CitationMixin[source]#

Bases: object

citation_style = 'bootstrap'#
get_context_data(**kwargs)[source]#
class literature.views.LiteratureDetail(**kwargs)[source]#

Bases: FormCollectionView, CitationMixin

collection_class#

alias of LiteratureFormCollection

extra_context = None#
form_valid(form)[source]#
template_name = 'literature/literature_form.html'#
class literature.views.LiteratureForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]#

Bases: ModelForm

class Meta[source]#

Bases: object

exclude = ['published', 'year']#
model#

alias of Literature

base_fields = {'CSL': <django.forms.fields.JSONField object>, 'abstract': <django.forms.fields.CharField object>, 'authors': <sortedm2m.forms.SortedMultipleChoiceField object>, 'citation_key': <django.forms.fields.CharField object>, 'collections': <django.forms.models.ModelMultipleChoiceField object>, 'comment': <django.forms.fields.CharField object>, 'container_title': <django.forms.fields.CharField object>, 'keyword': <taggit.forms.TagField object>, 'language': <django.forms.fields.CharField object>, 'pdf': <django.forms.fields.FileField object>, 'title': <django.forms.fields.CharField object>, 'type': <django.forms.fields.TypedChoiceField object>}#
declared_fields = {}#
property media#

Return all media required to render the widgets on this form.

class literature.views.LiteratureList(**kwargs)[source]#

Bases: CitationMixin, ListView

get_queryset()[source]#

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

model#

alias of Literature

literature.views.process_csl(request)[source]#

literature.widgets module#

class literature.widgets.DatePartsWidget(attrs=None)[source]#

Bases: MultiWidget

property media#

Media for a multiwidget is the combination of all media of the subwidgets.

class literature.widgets.OnlineSearchWidget(attrs=None)[source]#

Bases: TextInput

property media#
template_name = 'literature/widgets/identifier.html'#
class literature.widgets.PreviewWidget(attrs=None)[source]#

Bases: TextInput

property media#
template_name = 'literature/widgets/preview.html'#

Module contents#