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,ModelAdminDjango Admin setup for the literature.Work model.
- change_list_template = 'literature/admin/change_list.html'#
- 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']})]#
- inlines = [<class 'literature.admin.SupplementaryInline'>, <class 'literature.admin.AuthorInline'>]#
- property media#
- class literature.admin.SupplementaryInline(parent_model, admin_site)[source]#
Bases:
TabularInline- property media#
- model#
alias of
SupplementaryMaterial
literature.apps module#
literature.choices module#
- class literature.choices.IdentifierTypes(value)[source]#
Bases:
IntegerChoicesAn enumeration.
- DOI = 0#
- ISBN = 2#
- ISSN = 1#
- PMCID = 3#
- PMID = 4#
- URL = 5#
- class literature.choices.MonthChoices(value)[source]#
Bases:
IntegerChoicesAn 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:
TextChoicesAn 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:
AppConfSettings 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#
- PDF_RENAMER = 'literature.utils.simple_file_renamer'#
literature.exceptions module#
literature.fields module#
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.
- 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.
- 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.
- 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.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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:
TimeStampedModelModel 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.parentis aForwardManyToOneDescriptorinstance.
- 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:
TimeStampedModelModel for storing literature data
- CSL#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- abstract#
- authors#
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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>#
- 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.childrenis aReverseManyToOneDescriptorinstance.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.commentsis a ReverseGenericManyToOneDescriptor instance.
- title#
- tracker#
- type#
- class literature.models.LiteratureAuthor(*args, **kwargs)[source]#
Bases:
ModelAn 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.views module#
- class literature.views.AuthorDetail(**kwargs)[source]#
Bases:
CitationMixin,DetailView
- class literature.views.AuthorList(**kwargs)[source]#
Bases:
ListView
- class literature.views.LiteratureDetail(**kwargs)[source]#
Bases:
FormCollectionView,CitationMixin- collection_class#
alias of
LiteratureFormCollection
- extra_context = None#
- 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.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.