Code Documentation¶
Common¶
Common abstract mixins for database modules that provide name field, notes, and year date handling.
Models¶
-
class
derrida.common.models.
DateRange
(*args, **kwargs)[source]¶ Abstract model with optional start and end years, and a custom dates property to display the date range nicely. Includes validation that requires end year falls after start year.
-
clean_fields
(exclude=None)[source]¶ Override to clean fields to make sure start/end year are sensical
-
property
dates
¶ Date or date range as a string for display
-
end_year
¶ end year (optional)
-
start_year
¶ start year (optional)
-
Solr Backend¶
Haystack does not yet support range facets on Solr. This module provides subclasses of SolrSearchQuery and SolrSearchBackend to patch in range facet functionalty.
-
class
derrida.common.solr_backend.
RangeSolrSearchQuery
(*args, **kwargs)[source]¶
Places¶
Module for tracking places associated with Derrida’s library. This module primarily focuses on places associated with publishers or owning institutions of Derrida’s personal library.
Models¶
Views¶
Books¶
Module provides tracking for Derrida’s library, its works, and associated instances of those works.
It also services as a hub for links between physical copies and their digital representations in the Django admin.
Models¶
-
class
derrida.books.models.
CreatorType
(*args, **kwargs)[source]¶ Type of creator role a person can have to a book - author, editor, translator, etc.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
DerridaWork
(*args, **kwargs)[source]¶ This models the reference copy used to identify all citations, not part of Derrida’s library
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
full_citation
¶ full citation
-
is_primary
¶ boolean indicator for primary work
-
short_title
¶ short title
-
slug
¶ slug for use in URLs
-
zotero_id
¶ zotero collection ID for use in populating library
-
exception
-
class
derrida.books.models.
DerridaWorkSection
(*args, **kwargs)[source]¶ Sections of a
DerridaWork
(e.g. chapters). Used to look atReference
by sections of the work.-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
Instance
(*args, **kwargs)[source]¶ A single instance of a
Work
- i.e., a specific copy or edition or translation. Can also include books that appear as sections of a collected works.-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
classmethod
allow_canvas_detail
(canvas)[source]¶ Check if canvas detail view is allowed. Allows insertion images, overview images, and pages with documented interventions.
-
allow_canvas_large_image
(canvas)[source]¶ Check if canvas large image view is allowed. Always allows insertion images and overview images; other pages with documented interventions are allowed as long as they are not suppressed, either via
suppress_all_images
or specificsuppressed_images
.
-
alternate_title
¶ alternate title (optional)
-
annotated_pages
()[source]¶ Annotated pages for this book. Filtered based on the presence of a documented
Intervention
in the database.
-
as_zotero_item
(library)[source]¶ Serialize the instance as an item suitable for export to a Zotero library. Requires a
pyzotero.zotero.Zotero
instance for API calls to retrieve item type templates and creator types.
Display Work author names; convenience access for display in admin
-
catalogue_call_numbers
()[source]¶ Convenience access to catalogue call numbers, for display in admin
-
cited_in
¶ DerridaWork
this item is cited in
-
clean
()[source]¶ Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
-
copy
¶ optional label to distinguish multiple copies of the same work
-
copyright_year
¶ copyright year
-
digital_edition
¶ digital edition via IIIF as instance of
djiffy.models.Manifest
-
dimensions
¶ description of item dimensions (optional)
-
end_page
¶ end page for book section or journal article
-
footnotes
¶ generic relation to :class:~`derrida.footnotes.models.Footnote`
-
generate_base_slug
()[source]¶ Generate a slug based on first author, work title, and year. Not guaranteed to be unique if there are multiple copies of the same instance/edition of a work.
- Rtype str
String in the format
lastname-title-of-work-year
-
generate_safe_slug
()[source]¶ Generate a unique slug. Checks for duplicates and calculates an appropriate copy letter if needed.
- Rtype str
String in the format lastname-title-of-work-year-copy
-
images
()[source]¶ Queryset containing all
djiffy.models.Canvas
objects associated with the digital edition for this item.
-
insertion_images
()[source]¶ Insertion images for this book. Filtered based on canvas label naming conventions.
-
is_annotated
¶ item is annotated
-
is_extant
¶ item is extant
-
is_translation
¶ item is translated
-
property
item_type
¶ item type: book, book section, or journal article
-
property
location
¶ Location in Derrida’s library (currently only available for digitized books).
-
overview_images
()[source]¶ Overview images for this book - cover, spine, etc. Filtered based on canvas label naming conventions.
-
overview_labels
= ['cover', 'spine', 'back', 'edge', 'view']¶ terms in an image label that indicate a canvas should be considered an overview image (e.g., cover & outside views)
-
owning_institutions
¶ OwningInstitution
; connected throughInstanceCatalogue
-
primary_language
()[source]¶ Primary
Language
for this work instance. Use only language or primary language for the instance if available; falls back to only or primary language for the associated work.
-
print_date
¶ print date
-
print_date_day_known
¶ print date day is known
-
print_date_month_known
¶ print date month is known
-
print_date_year_known
¶ print date year is known
-
print_year
()[source]¶ Year from
print_date
if year is known
Find related works; for now, this means works by the same author. For a work that collects item, include work by any book section authors.
-
save
(*args, **kwargs)[source]¶ Saves the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
-
start_page
¶ start page for book section or journal article
-
suppress_all_images
¶ flag to suppress content page images, to comply with copyright owner take-down request
-
suppressed_images
¶ specific page images to be suppressed, to comply with copyright owner take-down request
-
uri
¶ finding aid URL
-
property
year
¶ year for indexing and display;
print_date
if known, otherwisecopyright_year
-
zotero_id
¶ Zotero identifier
-
exception
-
class
derrida.books.models.
InstanceCatalogue
(*args, **kwargs)[source]¶ Location of a work instance in the real world, associating it with an owning instutition.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
InstanceCount
(*args, **kwargs)[source]¶ Mix-in for models related to books; adds book count property and link to associated books
-
instance_count
()[source]¶ Return a count of associated
derrida.books.models.Instance
for object as an HTML snippet for the Django admin.
-
-
class
derrida.books.models.
InstanceCreator
(id, notes, creator_type, person, instance)[source]¶ -
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
InstanceLanguage
(*args, **kwargs)[source]¶ Through-model for instance-language relationship, to allow designating one language as primary or adding notes.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
is_primary
¶ boolean flag indicating if this language is primary for this instance
-
exception
-
class
derrida.books.models.
InstanceQuerySet
(model=None, query=None, using=None, hints=None)[source]¶ Custom
QuerySet
forInstance
to make it easy to find all instances that have a digital edition-
with_digital_eds
()[source]¶ Return
derrida.books.models.Instance
queryset filtered by having a digital edition.
-
-
class
derrida.books.models.
Journal
(*args, **kwargs)[source]¶ List of associated journals for items published as journal articles
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
Language
(*args, **kwargs)[source]¶ Language that a book is written in or a language included in a book
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
uri
¶ optional uri
-
exception
-
class
derrida.books.models.
OwningInstitution
(*args, **kwargs)[source]¶ Institution that owns the extant copy of a book
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
contact_info
¶ contact information
-
short_name
¶ short name (optioal)
-
exception
-
class
derrida.books.models.
PersonBook
(*args, **kwargs)[source]¶ Interactions or connections between books and people other than annotation.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
PersonBookRelationshipType
(*args, **kwargs)[source]¶ Type of non-annotation relationship assocating a person with a book.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
Publisher
(*args, **kwargs)[source]¶ Publisher of a book
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
Reference
(*args, **kwargs)[source]¶ Reference to a book from a work by Derrida. Can be a citation, quotation, or other kind of reference.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
anchor_text
¶ anchor text
-
property
book
¶ The “book” this reference is associated with; for a book section, this is the work instance the section is collected in; for all other cases, it is the work instance associated with this reference.
-
book_page
¶ page in the referenced item
-
canvases
¶ ManyToManyField to
djiffy.models.Canvas
-
derridawork
¶ DerridaWork
that references the item
-
derridawork_pageloc
¶ location/identifier on the page
-
static
instance_ids_with_digital_editions
()[source]¶ Used as a convenience method to provide a readonly field in the admin change form for
Reference
with a list of JSON formatted primary keys. This is used by jQuery in theReference
change_form and reference inlines on theInstance`change_form to disable the autocomplete fields when there is or is not a digital edition. See ``sitemedia/js/reference-instance-canvas-toggle.js`
for this logic.- Return type
JSON formatted string of
Instance
primary keys
-
property
instance_slug
¶ Slug for the work instance used to display this reference. For a reference to a book section, returns the slug for the book that collects it.
-
property
instance_url
¶ absolute url for the work instance where this reference is displayed; uses
instance_slug
-
interventions
¶ ManyToManyField to
derrida.interventions.Intervention
-
reference_type
¶
-
exception
-
class
derrida.books.models.
ReferenceQuerySet
(model=None, query=None, using=None, hints=None)[source]¶ Custom
QuerySet
forReference
.Order by author of cited work
-
summary_values
(include_author=False)[source]¶ Return a values list of summary information for display or visualization. Currently used for histogram visualization. Author of cited work is aliased to author.
- Parameters
include_author – optionally include author information; off by default, since this creates repeated records for references to multi-author works
-
class
derrida.books.models.
ReferenceType
(*args, **kwargs)[source]¶ Type of reference, i.e. citation, quotation, footnotes, epigraph, etc.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
-
class
derrida.books.models.
Subject
(*args, **kwargs)[source]¶ Subject categorization for books
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
uri
¶ optional uri
-
exception
-
class
derrida.books.models.
Work
(*args, **kwargs)[source]¶ A platonic work. Stores common information about multiple instances, copies, or editions of the same work. Aggregates one or more
Instance
objects.-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
Display author names; convenience access for display in admin
relation to
Person
authors
-
instance_count
()[source]¶ Return count of
derrida.book.models.Instance
associated withWork
formatted as an HTML snippet for the Django admin.
-
languages
¶ Language
related throughWorkLanguage
-
primary_title
¶ primary title
-
short_title
¶ short title
-
subjects
¶ Subject
related throughWorkSubject
-
uri
¶ optional URI
-
year
¶ original publication date
-
exception
-
class
derrida.books.models.
WorkCount
(*args, **kwargs)[source]¶ Mix-in for models related to works; adds work count property and link to associated works
-
class
derrida.books.models.
WorkLanguage
(*args, **kwargs)[source]¶ Through-model for work-language relationship, to allow designating one language as primary or adding notes.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
is_primary
¶ boolean flag indicating if this language is primary for this work
-
exception
-
class
derrida.books.models.
WorkSubject
(*args, **kwargs)[source]¶ Through-model for work-subject relationship, to allow designating a particular subject as primary or adding notes.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
is_primary
¶ boolean flag indicating if this subject is primary for this work
-
exception
Views¶
-
class
derrida.books.views.
CanvasDetail
(**kwargs)[source]¶ -
get_context_data
(*args, **kwargs)[source]¶ Set extra context for
CanvasDetail
view.
-
get_object
(queryset=None)[source]¶ Limit canvas detail view to those with
derrida.interventions.models.Intervention
objects associated.
-
model
¶ alias of
djiffy.models.Canvas
-
-
class
derrida.books.views.
CanvasImage
(**kwargs)[source]¶ Local view for canvas images. This proxies the configured IIIF image viewer in order to avoid exposing IIIF image urls for copyright content and to allow controlled access to restrict public viewable material to annotated pages, overview images, and insertions.
-
class
derrida.books.views.
CanvasImageByPageNumber
(**kwargs)[source]¶ Get a canvas image from an
Instance
by page number. Searches by page label, if no match is found returns the thumbnail for the Item if there is one. 404 if not found or the Instance has no digital edition associated.
-
class
derrida.books.views.
CanvasSuppress
(**kwargs)[source]¶ Form view to process an admin request to suppress a single canvas image or all annotated pages from a volume. Requires user to have change_instance permission.
-
form_class
¶ alias of
derrida.books.forms.SuppressImageForm
-
-
class
derrida.books.views.
InstanceDetailView
(**kwargs)[source]¶ DetailView
forInstance
. Returns only Instances that have digital editions set.-
get_queryset
()[source]¶ Return the QuerySet that will be used to look up the object.
Note that this method is called by the default implementation of get_object and may not be called if get_object is overridden.
-
model
¶ alias of
derrida.books.models.Instance
-
-
class
derrida.books.views.
InstanceListView
(**kwargs)[source]¶ -
form_class
¶ alias of
derrida.books.forms.InstanceSearchForm
-
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
derrida.books.models.Instance
-
-
class
derrida.books.views.
InstanceURIView
(**kwargs)[source]¶ Generic view for Instance by URI identifier. Redirects to the best view for that item.
-
model
¶ alias of
derrida.books.models.Instance
-
-
class
derrida.books.views.
LanguageAutocomplete
(**kwargs)[source]¶ Autocomplete lookup for
derrida.books.models.Language
, for use with django-autocomplete-light. Restricted to staff only.
-
class
derrida.books.views.
ProxyView
(**kwargs)[source]¶
-
class
derrida.books.views.
PublisherAutocomplete
(**kwargs)[source]¶ Basic publisher autocomplete lookup, for use with django-autocomplete-light. Restricted to staff only.
-
class
derrida.books.views.
ReferenceDetailView
(**kwargs)[source]¶ -
get_object
(queryset=None)[source]¶ Returns the object the view is displaying.
By default this requires self.queryset and a pk or slug argument in the URLconf, but subclasses can override this to return any object.
-
get_template_names
()[source]¶ Return a list of template names to be used for the request. May not be called if render_to_response is overridden. Returns the following list:
the value of
template_name
on the view (if provided)the contents of the
template_name_field
field on the object instance that the view is operating upon (if available)<app_label>/<model_name><template_name_suffix>.html
-
model
¶ alias of
derrida.books.models.Reference
-
-
class
derrida.books.views.
ReferenceHistogramView
(**kwargs)[source]¶ -
-
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
derrida.books.models.Reference
-
-
class
derrida.books.views.
ReferenceListView
(**kwargs)[source]¶ -
form_class
¶ alias of
derrida.books.forms.ReferenceSearchForm
-
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
derrida.books.models.Reference
-
-
class
derrida.books.views.
SearchView
(**kwargs)[source]¶ -
form_class
¶ alias of
derrida.books.forms.SearchForm
-
get
(*args, **kwargs)[source]¶ Process form for
SearchView
.
-
get_context_data
(**kwargs)[source]¶ Retrieve Solr queries for
SearchView
context.
-
Search Indexes¶
-
class
derrida.books.search_indexes.
InstanceIndex
[source]¶ author names in lastname, first for sort/facet;
derrida.books.models.Work.authors
author in firstname last for display;
derrida.books.models.Work.authors
non-multifield for first author to allow sorting by author
-
cited_in
= <haystack.fields.MultiValueField object>¶ gives work of Derrida (DerridaWork) in which this Instance is cited
-
copy
= <haystack.fields.CharField object>¶ copy letter, if any;
derrida.books.models.Instance.copy
-
copyright_year
= <haystack.fields.IntegerField object>¶ copyright year of Instance;
derrida.books.models.Instance.copyright_year
-
digital_edition
= <haystack.fields.FacetBooleanField object>¶ whether the Instance is digitized;
derrida.books.models.Instance.digital_edition
-
display_title
= <haystack.fields.CharField object>¶ display title of book;
derrida.books.models.Instance.display_title
-
display_title_isort
= <haystack.fields.CharField object>¶ sortable field for display title
-
get_model
()[source]¶ Should return the
Model
class (not an instance) that the rest of theSearchIndex
should use.This method is required & you must override it to return the correct class.
-
is_annotated
= <haystack.fields.FacetBooleanField object>¶ whether the Instance has annotations by Derrida;
derrida.books.models.Instance.is_annotated
-
is_extant
= <haystack.fields.FacetBooleanField object>¶ whether the Instance is extant;
derrida.books.models.Instance.is_extant
-
item_type
= <haystack.fields.CharField object>¶ item type;
derrida.books.models.Instance.item_type
-
language
= <haystack.fields.MultiValueField object>¶ languages associated with Instance;
derrida.books.models.Instance.languages
Return first author for author sort field.
-
print_year
= <haystack.fields.IntegerField object>¶ print year of Instance;
derrida.books.models.Instance.print_year
-
pub_place
= <haystack.fields.MultiValueField object>¶ place of publication;
derrida.books.models.Instance.pub_place
-
slug
= <haystack.fields.CharField object>¶ the instance’s url slug;
derrida.books.models.Instance.slug
-
subject
= <haystack.fields.MultiValueField object>¶ subjects associated with Instance;
derrida.books.models.Work.subjects
-
work_language
= <haystack.fields.MultiValueField object>¶ original work languages;
derrida.books.models.Work.languages
-
work_year
= <haystack.fields.IntegerField object>¶ original work year;
derrida.books.models.Work.year
-
year
= <haystack.fields.IntegerField object>¶ sort/display year: print year if known; otherwise, copyright year.
-
class
derrida.books.search_indexes.
ReferenceIndex
[source]¶ Search index instance for
derrida.books.models.Reference
-
anchor_text
= <haystack.fields.CharField object>¶ anchor text
-
book_page
= <haystack.fields.CharField object>¶ Cited page in referenced work;
derrida.books.models.Reference.book_page
-
book_page_sort
= <haystack.fields.IntegerField object>¶ sort field for reference work page to sort page numbers correctly
-
corresponding_intervention
= <haystack.fields.FacetBooleanField object>¶ has corresponding intervention
-
derridawork
= <haystack.fields.CharField object>¶ Short title for search form from
DerridaWork
-
derridawork_page
= <haystack.fields.IntegerField object>¶ Page in derrida work;
derrida.books.models.Reference.derridawork_page
-
derridawork_pageloc
= <haystack.fields.CharField object>¶ Page location in derrida work;
derrida.books.models.Reference.derridawork_pageloc
-
derridawork_slug
= <haystack.fields.CharField object>¶ derrida work slug in derrida work;
derrida.books.models.DerridaWork.slug
-
get_model
()[source]¶ Should return the
Model
class (not an instance) that the rest of theSearchIndex
should use.This method is required & you must override it to return the correct class.
Instance authors for faceted filtering
Instance authors for display
non-multifield for instance first author to allow sorting by author
-
instance_collection_title
= <haystack.fields.CharField object>¶ instance collection title, for references to book sections
-
instance_copy
= <haystack.fields.CharField object>¶ instance copy, for distinguishing multiple copies of the same edition
-
instance_copyright_year
= <haystack.fields.IntegerField object>¶ copyright year of associated instance;
derrida.books.models.Instance.copyright_year
-
instance_digital_edition
= <haystack.fields.FacetBooleanField object>¶ boolean indicating if instance has digital edition
-
instance_is_annotated
= <haystack.fields.FacetBooleanField object>¶ is instance annotated?;
derrida.books.models.Instance.is_annotated
-
instance_is_extant
= <haystack.fields.FacetBooleanField object>¶ is instance extant in PU collection?;
derrida.books.models.Instance.is_extant
-
instance_language
= <haystack.fields.MultiValueField object>¶ languages for associated instance;
derrida.book.models.Instance.languages
-
instance_print_year
= <haystack.fields.IntegerField object>¶ print year of associated instance;
derrida.books.models.Instance.r_year
-
instance_slug
= <haystack.fields.CharField object>¶ instance slug, for generating urls and filtering by instance
-
instance_subject
= <haystack.fields.MultiValueField object>¶ subjects for associated instance;
derrida.books.models.Instance.subjects
-
instance_title
= <haystack.fields.CharField object>¶ Title of instance to which citation points;
derrida.books.models.Instance.display_title()
-
instance_work_year
= <haystack.fields.IntegerField object>¶ work year of the associated instance’s work;
derrida.books.models.Work.year
-
interventions
= <haystack.fields.MultiValueField object>¶ ids for corresponding intervention
-
original_language
= <haystack.fields.MultiValueField object>¶ languages for the original work;
derrida.book.models.Work.languages
-
page_canvas_id
= <haystack.fields.CharField object>¶ canvas id for detail page view, if view available for book page
-
prepare_book_page_sort
(reference)[source]¶ Handle integer values and sort in page references, as well as Roman numerals from introductions.
-
prepare_corresponding_intervention
(reference)[source]¶ Return whether
derrida.books.models.Reference
has a correspondingderrida.interventions.models.Intervention
.
Return first author for author sort field.
-
prepare_instance_language
(reference)[source]¶ Return language of
derrida.books.models.Reference
’s associatedderrida.books.models.Instannce
.
-
prepare_page_canvas_id
(reference)[source]¶ Return canvas short_id for first associated
derrida.interventions.models.Intervention
.
-
reference_type
= <haystack.fields.CharField object>¶ Name value for the
ReferenceType
of citation
-
Signals¶
-
class
derrida.books.signals.
RelationSafeRTSP
(connections, connection_router)[source]¶ -
handle_save
(sender, instance, **kwargs)[source]¶ This code is entirely adapted from Haystack source with custom handling of the Instance model to cascade updates. Using super did not clarify code in a useful way.
Searches gets all backends in use, iterates through them, for all models.
Custom handling makes updates to an Instance also trigger an reindex on all of the Reference and Intervention instances associated with it.
-
Manage commands¶
Import digital editions¶
Manage command to import digitized book content via IIIF. It takes both files and URLs, and supports both IIIF Collections and single Manifests. If a collection is specified, all supported manifests in the system will be loaded. If a manifest is already loaded, it will be skipped (updating manifests is not yet supported). For convenience, you use the preset path “PUL” to load the Princeton University Libraries collection of Derrida materials.
Example use:
python manage.py import_digitaleds https://plum.princeton.edu/collections/p4j03fz143/manifest
python manage.py import_digitaleds https://plum.princeton.edu/concern/scanned_resources/pb2775t87z/manifest
python manage.py import_digitaleds manifest1.json manifest2.json
python manage.py import_digitaleds PUL
When a local identifier is present in manifest metadata, it will be used
to link the cached manifest in the django database with the appropriate
derrida.books.models.Instance`
.
-
class
derrida.books.management.commands.import_digitaleds.
Command
(stdout=None, stderr=None, no_color=False)[source]¶ Import digital editions and associate with Derrida work instances
-
class
derrida.books.management.commands.import_digitaleds.
DerridaManifestImporter
(stdout=None, stderr=None, style=None, update=False)[source]¶ Extends
djiffy.importer.ManifestImporter
to add additional logic for associating the importeddjiffy.models.Manifest
with an existingwinthrop.books.models.Book
-
canvas_short_id
(canvas)[source]¶ Override default short id logic, because that would result in a uuid for PUL figgy content; instead, generate a slug based on the image label. Canvas model requires short id + manifest unique together, but that won’t be a problem with project image label naming conventions.
-
Export Reference data¶
Manage command to export reference data for use by others.
Generates a CSV and JSON file for each Derrida Work in the database (currently only Of Grammatology), with details for each reference documented in the database.
Takes an optional argument to specify the output directory. Otherwise, files are created in the current directory.
-
class
derrida.books.management.commands.reference_data.
Command
(stdout=None, stderr=None, no_color=False)[source]¶ Export reference data for each Derrida Work as CSV and JSON
-
csv_fields
= ['id', 'page', 'page location', 'type', 'book title', 'book id', 'book page', 'book type', 'anchor text', 'interventions']¶ fields for CSV output
-
flatten_dict
(data)[source]¶ Flatten a dictionary with nested dictionaries or lists into a key value pairs that can be output as CSV. Nested dictionaries will be flattened and keys combined; lists will be converted into semi-colon delimited strings.
-
Export to Zotero¶
Manage command to export references cited in all Derrida works to a group Zotero library. Each work is assumed to correspond to a collection in the Zotero library.
Command assumes that the target Zotero library ID and a Zotero API key are populated in local_settings.py.
-
class
derrida.books.management.commands.export_zotero.
Command
(stdout=None, stderr=None, no_color=False)[source]¶ Export all references in all Derrida works to a Zotero library.
-
chunk_size
= 50¶ number of items to send to Zotero API per request; Zotero only allows 50
-
create_collections
(works: django.db.models.query.QuerySet)[source]¶ create zotero collections for the provided derrida works and store the generated zotero collection id on the work
-
create_items
(instances: django.db.models.query.QuerySet)[source]¶ ensure all instances cited in derrida works are represented as items: create new items where no zotero id exists and update those that already have an id
-
handle
(*args, **kwargs)[source]¶ The actual logic of the command. Subclasses must implement this method.
-
v_normal
= 1¶ normal verbosity level
-
verbosity
= 1¶ output verbosity
-
People¶
People module for the Derrida project. It provides basic personography, VIAF lookup, and admin functionality to edit people associated with Derrida’s library.
Models¶
-
class
derrida.people.models.
AliasIntegerField
(verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=<class 'django.db.models.fields.NOT_PROVIDED'>, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=(), error_messages=None)[source]¶ Alias field adapted from https://djangosnippets.org/snippets/10440/ to allow accessing an existing db field by a different name, both for user display and in model and queryset use.
-
class
derrida.people.models.
Person
(*args, **kwargs)[source]¶ -
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
property
firstname
¶ First name, as extracted from authorized name
-
property
firstname_last
¶ Authorized name in ‘firstname lastname’ format for display
-
property
lastname
¶ Last name, as extracted from authorized name
-
save
(*args, **kwargs)[source]¶ Adds birth and death dates from VIAF if they aren’t set and there’s a viaf id for the record
-
property
viaf
¶ viapy.api.ViafEntity
for this record ifviaf_id
is set.
-
exception
-
class
derrida.people.models.
Relationship
(*args, **kwargs)[source]¶ A specific relationship between two people.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
Footnotes¶
Module provides generic footnote functionality for any module that is added to the admin.
Models¶
-
class
derrida.footnotes.models.
Bibliography
(id, notes, bibliographic_note, source_type)[source]¶ -
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
Interventions¶
Django app for managing interventions in Derrida’s Margins. Interventions currently include annotations and insertions.
Models¶
-
derrida.interventions.models.
INTERVENTION_TYPES
= {'ANNOTATION': 'A', 'BOTH': 'AI', 'INSERTION': 'I'}¶ intervention type codes to distinguish annotations and insertions
-
class
derrida.interventions.models.
Intervention
(id, created, updated, text, quote, uri, user, extra_data, intervention_type, canvas, text_language, text_translation, quote_language, author)[source]¶ -
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
property
annotation_type
¶ List of annotation types. Generated from tags, excluding ink and pencil tags, uncertain and illegible tags, and with the addition of verbal or nonverbal annotation.
Associated author, instance of
Person
-
canvas
¶ associated IIIF
djiffy.models.Canvas
for interventions related to an image
-
property
digital_edition
¶ digital edition this annotation is associated, via
djiffy.models.Canvas
-
handle_extra_data
(data, request)[source]¶ Handle “extra” data that is not part of the stock annotation data model. Used to support custom fields that are specific to
Intervention
. Data is as provided from json request data, as sent by annotator.js.
-
iiif_image_selection
()[source]¶ Generate a IIIF image selection for a
Intervention
if it image selection information is present and a canvas is associated.
-
info
()[source]¶ Return a dictionary of fields and values for display in the JSON object representation of the annotation.
-
property
ink
¶ pen ink color or pencil, from tags
-
is_annotation
()[source]¶ Return whether
Intervention
object is an annotation.
-
is_insertion
()[source]¶ Return whether
Intervention
object is an insersetion.
-
is_verbal
()[source]¶ Return whether a
Intervention
has a verbal component.
-
quote_language
¶ language of the quoted text or anchor text (i.e.
quote
)
-
save
(*args, **kwargs)[source]¶ Saves the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
Tags to describe the intervention and its characteristics; many-to-many relationship to
Tag
-
text_language
¶ language of the intervention text (i.e.
text
)
-
text_translation
¶ translation language of the intervention text (i.e.
text
)
-
property
work_instance
¶ Annotated library work
derrida.books.models.Instance
, via associateddigital_edition
.
-
exception
-
class
derrida.interventions.models.
InterventionQuerySet
(model=None, query=None, using=None, hints=None)[source]¶ -
sorted_by_page_loc
()[source]¶ Return a list of
Intervention
objects sorted by their y value on the page.
-
-
class
derrida.interventions.models.
Tag
(id, name, notes, applies_to)[source]¶ -
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
Views¶
-
class
derrida.interventions.views.
CanvasAutocomplete
(**kwargs)[source]¶ Override the default
get_queryset()
in order to allow forms that specify anInstance
object to filter based on annotations associated only with that instance.This lets instances of
ModelForm
that have aCanvas
autocomplete pass a set instance value to restrict autocomplete results only to the Instance currently being edited.dal.autocomplete.Select2QuerySetView
allows aforward
parameter that passes JSON object as a string after as a query string namedforward
.dal.autocomplete.Select2QuerySetView.forwarded.get()
can access those variables easily.The autocomplete looks for an instance primary key passed with the key
instance
in the JSON object.
-
class
derrida.interventions.views.
InterventionAutocomplete
(**kwargs)[source]¶ Provides autocomplete to search on several fields of
Intervention
and filter by an instance primary key provided by a form.This lets instances of
ModelForm
that have aIntervention
autocomplete pass a set instance value to restrict autocomplete results only to the Instance currently being edited.dal.autocomplete.Select2QuerySetView
allows aforward
parameter that passes JSON object as a string after as a querystring namedforward
.dal.autocomplete.Select2QuerySetView.forwarded.get()
can access those variables easily.The autocomplete looks for an instance primary key passed with the key
instance
.
-
class
derrida.interventions.views.
InterventionListView
(**kwargs)[source]¶ -
form_class
¶ alias of
derrida.interventions.forms.InterventionSearchForm
-
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
¶
-
-
class
derrida.interventions.views.
InterventionView
(**kwargs)[source]¶ View for a single intervention, so we can provide a URI for identifiers in datasets that resolve to something meaningful. Currently redirects to the public canvas view with the annotation highlighted if possible, or an intervention search for that item if the intervention is not associated with a canvas.
-
class
derrida.interventions.views.
LoginPermissionRequired
[source]¶ Customization of
django.contrib.auth.mixins.PermissionRequiredMixin
that redirects to the configured login url if the user is not authenticated, and raises a 403 Forbidden if they already are authenticated.
Search Indexes¶
-
class
derrida.interventions.search_indexes.
InterventionIndex
[source]¶ -
anchor_text
= <haystack.fields.CharField object>¶ annotation anchor text;
derrida.interventions.models.Intervention.quote
-
anchor_text_lang
= <haystack.fields.CharField object>¶ language code for anchor text language
annotation author
-
annotation_language
= <haystack.fields.CharField object>¶ annotation text’s language;
derrida.interventions.models.Intervention.text_language
-
annotation_text
= <haystack.fields.CharField object>¶ annotation text;
derrida.interventions.models.Intervention.text
-
annotation_text_lang
= <haystack.fields.CharField object>¶ language code for annotation text language
-
annotation_type
= <haystack.fields.MultiValueField object>¶ annotation type;
derrida.interventions.models.Intervention.annotation_type
-
get_model
()[source]¶ Should return the
Model
class (not an instance) that the rest of theSearchIndex
should use.This method is required & you must override it to return the correct class.
-
index_queryset
(using=None)[source]¶ Get the default QuerySet to index when doing a full update.
Subclasses can override this method to avoid indexing certain objects.
-
ink
= <haystack.fields.MultiValueField object>¶ color ink or pencil of annotation;
derrida.interventions.Intervention.ink
-
intervention_type
= <haystack.fields.CharField object>¶ annotation or insertion (all annotation for now); display value for
derrida.interventions.models.Intervention.intervention_type
author in firstname last for display
first author to allow sorting by author
-
item_copy
= <haystack.fields.CharField object>¶ copy of edition;
derrida.books.models.Instance.copy
-
item_copyright_year
= <haystack.fields.IntegerField object>¶ work copyright year;
derrida.books.models.Instance.copyright_year
-
item_language
= <haystack.fields.MultiValueField object>¶ language of publication;
derrida.books.models.Instance.languages
-
item_print_year
= <haystack.fields.IntegerField object>¶ edition year;
derrida.books.models.Instance.print_year
-
item_pub_place
= <haystack.fields.MultiValueField object>¶ publication place;
derrida.books.models.Instance.pub_place
-
item_slug
= <haystack.fields.CharField object>¶ slug for generating url to work;
derrida.books.models.Instance.slug
-
item_subject
= <haystack.fields.MultiValueField object>¶ subject of annotated work;
derrida.books.models.Work.subjects
-
item_title
= <haystack.fields.CharField object>¶ title of item;
derrida.books.Instance.display_title
-
item_title_isort
= <haystack.fields.CharField object>¶ sortable title field
-
item_work_language
= <haystack.fields.MultiValueField object>¶ original language; class:derrida.books.models.Work.languages
-
item_work_year
= <haystack.fields.IntegerField object>¶ work publication year;
derrida.books.models.Work.year
Return firstname, last of annotation author.
-
thumbnail
= <haystack.fields.CharField object>¶ thumbnail of the annotated page;
-
Manage commands¶
Export Intervention data¶
Manage command to export intervention data for use by others.
Generates a CSV and JSON file with details for all interventions documented in the database.
Takes an optional argument to specify the output directory. Otherwise, files are created in the current directory.
-
class
derrida.interventions.management.commands.intervention_data.
Command
(stdout=None, stderr=None, no_color=False)[source]¶ Export intervention data from the database as CSV and JSON
-
base_filename
= 'interventions'¶ base filename, for CSV and JSON output
-
csv_fields
= ['id', 'book id', 'book title', 'book type', 'page', 'tags', 'text content', 'text language', 'text language code', 'text translation', 'quote content', 'quote language', 'quote language code', 'annotator']¶ fields for CSV output
-
Outwork¶
Models¶
-
class
derrida.outwork.models.
Outwork
(id, keywords_string, site, title, slug, _meta_title, description, gen_description, created, updated, status, publish_date, expiry_date, short_url, in_sitemap, _order, content_model, parent, in_menus, titles, login_required, page_ptr, content, author, orig_pubdate)[source]¶ -
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
exception
Views¶
-
class
derrida.outwork.views.
OutworkListView
(**kwargs)[source]¶ -
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
derrida.outwork.models.Outwork
-