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)

class derrida.common.models.Named(*args, **kwargs)[source]

Abstract model with a ‘name’ field; by default, name is used as the string display.

name

unique name (required)

class derrida.common.models.Notable(*args, **kwargs)[source]

Abstract model with an optional notes text field

has_notes()[source]

boolean flag indicating if notes are present, for display in admin lists

notes

optional notes

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]
add_field_facet(field, **options)[source]

Adds a regular facet on a field.

add_range_facet(field, **options)[source]

Adds a solr range facet on a field. Options must include start, end, and gap.

build_params(*args, **kwargs)[source]

Generates a list of params to use when searching.

post_process_facets(results)[source]

Extend post processing logic to include facet range data in returned facets.

class derrida.common.solr_backend.SolrRangeSearchBackend(connection_alias, **connection_options)[source]
build_schema(fields)[source]

Takes a dictionary of fields and returns schema information.

This method MUST be implemented by each backend, as it will be highly specific to each one.

derrida.common.solr_backend.facet_sort_ignoreaccents(facets, *fields)[source]

Update alpha facet so that sorting ignores accents.

Utils

derrida.common.utils.absolutize_url(local_url, request=None)[source]

Convert a local url to an absolute url, with scheme and server name, based on the current configured Site.

Parameters

local_url – local url to be absolutized, e.g. something generated by reverse()

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

class derrida.places.models.Place(*args, **kwargs)[source]

Simple model for tracking places and associated with people and books.

exception DoesNotExist
exception MultipleObjectsReturned
geonames_id

geonames URI

latitude

latitude

longitude

longitude

Views

class derrida.places.views.GeonamesLookup(**kwargs)[source]

GeoNames ajax lookup for use as autocomplete. Currently restricted to staff only.

get(request, *args, **kwargs)[source]

Return option list json response.

get_label(item)[source]

Display country name as part of label for context.

class derrida.places.views.PlaceAutocomplete(**kwargs)[source]

Basic place ajax autocomplete lookup, based on django-autocomplete-light. Currently restricted to staff only.

get_queryset()[source]

Filter the queryset with GET[‘q’].

GeoNames

class derrida.places.geonames.GeoNamesAPI[source]

Minimal wrapper around GeoNames API. Currently supports simple searching by name and generating a uri from an id. Expects GEONAMES_USERNAME to be configured in django settings.

search(query, max_rows=None)[source]

Search for places and return the list of results

classmethod uri_from_id(geonames_id)[source]

Convert a GeoNames id into a GeoNames URI

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
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

class derrida.books.models.DerridaWorkSection(*args, **kwargs)[source]

Sections of a DerridaWork (e.g. chapters). Used to look at Reference by sections of the work.

exception DoesNotExist
exception MultipleObjectsReturned
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 specific suppressed_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.

author_names()[source]

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.

collected_in

Instance that collects this item, for book section

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)

display_title()[source]

display title - alternate title or work short title

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

get_absolute_url()[source]

URL for this Instance on the website.

get_uri()[source]

public URI for this instance to be used as an identifier

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_digitized()[source]

boolean indicator if there is an associated digital edition

is_extant

item is extant

is_translation

item is translated

property item_type

item type: book, book section, or journal article

journal

related Journal for a 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 through InstanceCatalogue

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

pub_place

publication Place (optional, sorted many to many)

publisher

Publisher (optional)

property related_instances

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

work

Work this instance belongs to

property year

year for indexing and display; print_date if known, otherwise copyright_year

zotero_id

Zotero identifier

zotero_template_by_itemtype = {'Book': 'book', 'Book Section': 'bookSection', 'Journal Article': 'journalArticle'}

map local item_type to equivalent zotero template name

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
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
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
instance

Instance

is_primary

boolean flag indicating if this language is primary for this instance

language

Language

class derrida.books.models.InstanceQuerySet(model=None, query=None, using=None, hints=None)[source]

Custom QuerySet for Instance 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
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

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

place

Place

short_name

short name (optioal)

class derrida.books.models.PersonBook(*args, **kwargs)[source]

Interactions or connections between books and people other than annotation.

exception DoesNotExist
exception MultipleObjectsReturned
class derrida.books.models.PersonBookRelationshipType(*args, **kwargs)[source]

Type of non-annotation relationship assocating a person with a book.

exception DoesNotExist
exception MultipleObjectsReturned
class derrida.books.models.Publisher(*args, **kwargs)[source]

Publisher of a book

exception DoesNotExist
exception MultipleObjectsReturned
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

anchor_text_snippet()[source]

Anchor text snippet, for admin display

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

get_absolute_url()[source]

URL for this reference on the site

get_uri()[source]

public URI for this instance to be used as an identifier

instance

Instance that is referenced

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 the Reference change_form and reference inlines on the Instance`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

ReferenceType

class derrida.books.models.ReferenceQuerySet(model=None, query=None, using=None, hints=None)[source]

Custom QuerySet for Reference.

order_by_author()[source]

Order by author of cited work

order_by_source_page()[source]

Order by page in derrida work (attr:Reference.derridawork_page)

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
class derrida.books.models.Subject(*args, **kwargs)[source]

Subject categorization for books

exception DoesNotExist
exception MultipleObjectsReturned
uri

optional uri

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
author_names()[source]

Display author names; convenience access for display in admin

authors

relation to Person authors

instance_count()[source]

Return count of derrida.book.models.Instance associated with Work formatted as an HTML snippet for the Django admin.

languages

Language related through WorkLanguage

primary_title

primary title

short_title

short title

subjects

Subject related through WorkSubject

uri

optional URI

year

original publication date

class derrida.books.models.WorkCount(*args, **kwargs)[source]

Mix-in for models related to works; adds work count property and link to associated works

work_count()[source]

Return number of associated derrida.books.models.Works for a given object as an HTML snippet for the Django admin.

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

language

Language

work

Work

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

subject

Subject

work

Work

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.

get_proxy_url(*args, **kwargs)[source]

Return a proxy url for client browsers to access IIIF images from.

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.

get(request, *args, **kwargs)[source]

Return a canvas looked up by page number on GET request.

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

form_valid(form)[source]

Custom form validation for canvas surpress form.

get(*args, **kwargs)[source]

Return 303 for suppressed canvas and redirect to detail view for derria.books.models.Instance.

class derrida.books.views.InstanceDetailView(**kwargs)[source]

DetailView for Instance. 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_context_data(**kwargs)[source]

Get the context for this view.

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.InstanceReferenceDetailView(**kwargs)[source]
get_context_data(*args, **kwargs)[source]

Insert the single object into the context dict.

class derrida.books.views.InstanceURIView(**kwargs)[source]

Generic view for Instance by URI identifier. Redirects to the best view for that item.

get_context_data(*args, **kwargs)[source]

Insert the single object into the context dict.

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.

get_queryset()[source]

Filter the queryset with GET[‘q’].

class derrida.books.views.ProxyView(**kwargs)[source]
get(request, *args, **kwargs)[source]

Set headers for image requests to ProxyView. Ensures HTTP cache headers are set.

head(request, *args, **kwargs)[source]

Proxy HTTP headers for image.

class derrida.books.views.PublisherAutocomplete(**kwargs)[source]

Basic publisher autocomplete lookup, for use with django-autocomplete-light. Restricted to staff only.

get_queryset()[source]

Filter the queryset with GET[‘q’].

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_context_data()[source]

Get the context for this view.

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_context_data(**kwargs)[source]

Get the context for this view.

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 = <haystack.fields.MultiValueField object>

author names in lastname, first for sort/facet; derrida.books.models.Work.authors

author_firstname_last = <haystack.fields.MultiValueField object>

author in firstname last for display; derrida.books.models.Work.authors

author_isort = <haystack.fields.CharField object>

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 the SearchIndex 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

prepare_author_isort(instance)[source]

Return first author for author sort field.

prepare_cited_in(instance)[source]

Return Derridaworks in which this instance is cited.

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 the SearchIndex should use.

This method is required & you must override it to return the correct class.

instance_author = <haystack.fields.MultiValueField object>

Instance authors for faceted filtering

instance_author_firstname_last = <haystack.fields.MultiValueField object>

Instance authors for display

instance_author_isort = <haystack.fields.CharField object>

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

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 corresponding derrida.interventions.models.Intervention.

prepare_instance_author_isort(reference)[source]

Return first author for author sort field.

prepare_instance_language(reference)[source]

Return language of derrida.books.models.Reference’s associated derrida.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.

setup()[source]

A hook for setting up anything necessary for handle_save/handle_delete to be executed.

Default behavior is to do nothing (pass).

teardown()[source]

A hook for tearing down anything necessary for handle_save/handle_delete to no longer be executed.

Default behavior is to do nothing (pass).

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

add_arguments(parser)[source]

Entry point for subclassed commands to add custom arguments.

handle(*args, **kwargs)[source]

The actual logic of the command. Subclasses must implement this method.

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 imported djiffy.models.Manifest with an existing winthrop.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.

import_manifest(manifest, path)[source]

Process a single IIIF manifest and create Manifest and Canvas objects.

Parameters
  • manifestIIIFPresentation

  • path – file or url import path

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

add_arguments(parser)[source]

Entry point for subclassed commands to add custom arguments.

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.

handle(*args, **kwargs)[source]

The actual logic of the command. Subclasses must implement this method.

reference_data(reference)[source]

Generate a dictionary of data to export for a single Reference object

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.

contribute_to_class(cls, name, virtual_only=False)[source]

Register the field with the model class it belongs to.

If private_only is True, a separate instance of this field will be created for every subclass of cls, even if cls is not an abstract model.

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

set_birth_death_years()[source]

Set local birth and death dates based on information from VIAF

property viaf

viapy.api.ViafEntity for this record if viaf_id is set.

class derrida.people.models.Relationship(*args, **kwargs)[source]

A specific relationship between two people.

exception DoesNotExist
exception MultipleObjectsReturned
class derrida.people.models.RelationshipType(*args, **kwargs)[source]

Types of relationships between people

exception DoesNotExist
exception MultipleObjectsReturned
class derrida.people.models.Residence(*args, **kwargs)[source]

A residence where a person lived at some point in time

exception DoesNotExist
exception MultipleObjectsReturned

Views

class derrida.people.views.PersonAutocomplete(**kwargs)[source]

Basic person autocomplete lookup, for use with django-autocomplete-light. Restricted to staff only.

get_queryset()[source]

Filter the queryset with GET[‘q’].

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
footnote_count()[source]

number of footnotes this item is referenced in

class derrida.footnotes.models.Footnote(*args, **kwargs)[source]

Footnote that can be associated with any other model via generic relationship. Used to provide supporting documentation for or against information in the system.

exception DoesNotExist
exception MultipleObjectsReturned
class derrida.footnotes.models.SourceType(*args, **kwargs)[source]

Type of source document.

exception DoesNotExist
exception MultipleObjectsReturned
item_count()[source]

number of associated bibliographic items

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
admin_thumbnail()[source]

Provide an admin thumbnail image of associated IIIF image selection.

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.

author

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

get_uri()[source]

Return a public URI for this intervention that can be used as an identifier

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

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 associated digital_edition.

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
class derrida.interventions.models.TagQuerySet(model=None, query=None, using=None, hints=None)[source]

Custom QuerySet for Tag to make it easy to find tags that apply to a particular kind of Intervention.

for_annotations()[source]

Find tags that apply to annotations

for_insertions()[source]

Find tags that apply to insertions

derrida.interventions.models.get_default_intervener()[source]

Function to either return the pk of a Person object representing Jacques Derrida if he exists in the database or None

Views

class derrida.interventions.views.CanvasAutocomplete(**kwargs)[source]

Override the default get_queryset() in order to allow forms that specify an Instance object to filter based on annotations associated only with that instance.

This lets instances of ModelForm that have a Canvas autocomplete pass a set instance value to restrict autocomplete results only to the Instance currently being edited.

dal.autocomplete.Select2QuerySetView allows a forward parameter that passes JSON object as a string after as a query string named forward. 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.

get_queryset()[source]

Filter the queryset with GET[‘q’].

class derrida.interventions.views.CanvasDetail(**kwargs)[source]
get_context_data(**kwargs)[source]

Insert the single object into the context dict.

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 a Intervention autocomplete pass a set instance value to restrict autocomplete results only to the Instance currently being edited.

dal.autocomplete.Select2QuerySetView allows a forward parameter that passes JSON object as a string after as a querystring named forward. dal.autocomplete.Select2QuerySetView.forwarded.get() can access those variables easily.

The autocomplete looks for an instance primary key passed with the key instance.

get_queryset()[source]

Filter the queryset with GET[‘q’].

class derrida.interventions.views.InterventionListView(**kwargs)[source]
form_class

alias of derrida.interventions.forms.InterventionSearchForm

get_context_data(**kwargs)[source]

Get the context for this view.

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.interventions.models.Intervention

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.

get(*args, **kwargs)[source]

Patch the response to set status code to 303 See Other

get_redirect_url(*args, **kwargs)[source]

Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method.

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.

handle_no_permission()[source]

Redirect to login url or raise 403.

class derrida.interventions.views.ManifestDetail(**kwargs)[source]
class derrida.interventions.views.ManifestList(**kwargs)[source]
class derrida.interventions.views.TagAutocomplete(**kwargs)[source]

Autocomplete view for Tag to use in association with Intervention

get_queryset()[source]

Filter the queryset with GET[‘q’].

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 = <haystack.fields.CharField object>

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 the SearchIndex 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

item_author_firstname_last = <haystack.fields.MultiValueField object>

author in firstname last for display

item_author_isort = <haystack.fields.CharField object>

first author to allow sorting by author

item_copy = <haystack.fields.CharField object>

copy of edition; derrida.books.models.Instance.copy

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

prepare_annotation_author(item)[source]

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

add_arguments(parser)[source]

Entry point for subclassed commands to add custom arguments.

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

handle(*args, **kwargs)[source]

The actual logic of the command. Subclasses must implement this method.

intervention_data(intervention)[source]

Generate a dictionary of data to export for a single Reference object

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
get_slug()[source]

customize slug logic to include year and ensure url is under outwork/

is_published()[source]

Return whether the Outwork is published.

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

Search Indexes

class derrida.outwork.search_indexes.OutworkIndex[source]
author = <haystack.fields.CharField object>

author name; firstname lastname for display

get_model()[source]

Should return the Model class (not an instance) that the rest of the SearchIndex should use.

This method is required & you must override it to return the correct class.