Code Documentation¶
Pages¶
Pages app for the CDH website. Includes logic related to generic content pages & landing pages.
Models¶
- cdhweb.pages.models.ALT_TEXT_HELP = 'Alternative text for visually impaired users to\nbriefly communicate the intended message of the image in this context.'¶
help text for image alternative text
- class cdhweb.pages.models.AttachmentBlock(*args, **kwargs)[source]¶
Page attachments, including local files and external URLs.
- class cdhweb.pages.models.BasePage(*args, **kwargs)[source]¶
Abstract Page class from which all Wagtail page types are derived.
- attachments¶
relationship to uploaded documents and external links
- body¶
main page text
- class cdhweb.pages.models.BodyContentBlock(*args, **kwargs)[source]¶
Common set of blocks available in StreamFields for body text.
- migrated¶
used to hold content migrated from mezzanine via a “kitchen-sink” approach; enable all supported wagtail features. Should NOT be used when creating new pages.
- class cdhweb.pages.models.CaptionedImageBlock(*args, **kwargs)[source]¶
StructBlock
for an image with alternative text and optional formatted caption, so that both caption and alternative text can be context-specific.
- class cdhweb.pages.models.ContentPage(*args, **kwargs)[source]¶
Basic content page model.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.pages.models.DateRange(*args, **kwargs)[source]¶
Abstract model with start and end dates. Includes validation that requires end date falls after start date (if set), and custom properties to check if dates are current/active and to display years.
- clean_fields(exclude=None)[source]¶
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
- end_date¶
end date (optional)
- property is_current¶
is current: start date before today and end date in the future or not set
- start_date¶
start date
- property years¶
year or year range for display
- class cdhweb.pages.models.DisplayUrlMixin(*args, **kwargs)[source]¶
Mixin that provides a single required URL field and a display method.
- property display_url¶
URL cleaned up for display, with scheme and extra params removed.
- class cdhweb.pages.models.ExternalAttachment(*args, **kwargs)[source]¶
An externally hosted link or file that can be associated with a Page.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- get_usage()¶
Returns a queryset of pages that link to a particular object
- class cdhweb.pages.models.HomePage(*args, **kwargs)[source]¶
A home page that aggregates and displays featured content.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.pages.models.LandingPage(*args, **kwargs)[source]¶
Page type that aggregates and displays multiple ContentPages.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- header_image¶
image that will be used for the header
- tagline¶
short sentence overlaid on the header image
- class cdhweb.pages.models.LinkPage(*args, **kwargs)[source]¶
Link page for controlling appearance in menus of non-Page content.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.pages.models.LocalAttachment(*args, **kwargs)[source]¶
A locally hosted file that can be associated with a Page.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- cdhweb.pages.models.PARAGRAPH_FEATURES = ['h3', 'h4', 'bold', 'italic', 'link', 'ol', 'ul', 'hr', 'blockquote', 'document', 'superscript', 'subscript', 'strikethrough', 'code']¶
common features for paragraph text
- class cdhweb.pages.models.PageIntro(*args, **kwargs)[source]¶
Snippet for optional page intro text on for pages generated from django views not managed by wagtail
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- get_usage()¶
Returns a queryset of pages that link to a particular object
- paragraph¶
intro text
- class cdhweb.pages.models.PagePreviewDescriptionMixin(*args, **kwargs)[source]¶
Page mixin with logic for page preview content. Adds an optional richtext description field, and methods to get description and plain-text description, for use in previews on the site and plain-text metadata previews.
- allowed_tags = ['em', 'acronym', 'ol', 'code', 'b', 'ul', 'abbr', 'strong', 'li', 'i']¶
allowed tags for bleach html stripping in description
- description¶
brief description for preview display
- get_description()[source]¶
Get formatted description for preview. Uses description field if there is content, otherwise uses beginning of the body content.
- get_plaintext_description()[source]¶
Get plain-text description for use in metadata. Uses search_description field if set; otherwise uses the result of
get_description()
with tags stripped.
- max_length = 225¶
maximum length for description to be displayed
- class cdhweb.pages.models.RelatedLink(*args, **kwargs)[source]¶
Abstract typed relationship between a URL and a model. Used for personal URLs like Twitter, project links like Github, etc.
- class cdhweb.pages.models.RelatedLinkType(*args, **kwargs)[source]¶
Link types for RelatedLinks, with sort order determined by type.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.pages.models.SVGImageBlock(*args, **kwargs)[source]¶
StructBlock
for an SVG image with alternative text and optional formatted caption. Separate fromCaptionedImageBlock
because Wagtail image handling does not work with SVG.
Views¶
- class cdhweb.pages.views.LastModifiedListMixin(**kwargs)[source]¶
Mixin that adds last-modified timestamps to response for list views.
Uses Django’s get_conditional_response to return a 304 if none of the objects in the list have been modified since time specified in the HTTP if-modified-since header.
- class cdhweb.pages.views.LastModifiedMixin(**kwargs)[source]¶
Mixin that adds last-modified timestamps to response for detail views.
Uses Django’s get_conditional_response to return a 304 if object has not been modified since time specified in the HTTP if-modified-since header.
- class cdhweb.pages.views.OpenSearchDescriptionView(**kwargs)[source]¶
Basic open search description for searching the site via browser or other tools.
- class cdhweb.pages.views.SiteSearchView(**kwargs)[source]¶
Search across all pages on the site.
- form_class¶
alias of
cdhweb.pages.forms.SiteSearchForm
- 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
wagtail.core.models.Page
People¶
People app for the CDH webapp. Provides a profile related to Django User, along with job titles and position information.
Models¶
- class cdhweb.people.models.PeopleLandingPage(*args, **kwargs)[source]¶
LandingPage subtype for People that holds Profiles.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.people.models.Person(id, first_name, last_name, email, user, cdh_staff, job_title, department, institution, phone_number, office_location, pu_status, image, updated_at)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- property current_title¶
Return the first of any non-expired titles held by this Person.
- property lastname_first¶
display person as lastname, first for sorting
- property latest_grant¶
most recent grants where this person has director role
- property most_recent_title¶
Return the most recent of any titles held by this Person.
- property profile_url¶
Provide the link to published profile on this site if there is one; otherwise look for an associated website url
- updated_at¶
update timestamp
- class cdhweb.people.models.PersonQuerySet(model=None, query=None, using=None, hints=None)[source]¶
- affiliates()[source]¶
Faculty and staff affiliates based on PU status and Project Director project role. Excludes CDH staff.
- current()[source]¶
Return people with a current position or current grant based on start and end dates.
- current_position_nonexec()[source]¶
Return profiles for users with a current position, excluding current executive committee positions.
- director_roles = ['Project Director', 'Co-PI: Research Lead']¶
position titles that indicate a person is a project director
- exec_member_title = 'Executive Committee Member'¶
executive committee member titles
- grant_years()[source]¶
Annotate with first start and last end grant year for grants that a person was project director.
- postdoc_titles = ['Postdoctoral Fellow', 'Postdoctoral Fellow and Communications Lead']¶
position titles that indicate a person is a postdoc
- project_manager_years()[source]¶
Annotate with first start and last end grant year for grants that a person was project manager.
- project_roles = ['Project Director', 'Project Manager', 'Co-PI: Research Lead']¶
membership roles that indicate someone is an affiliate
- student_affiliates()[source]¶
Return CDH student staff members, grantees, and PGRAs based on Project Director or Project Manager role.
- student_pu_status = ['graduate', 'undergraduate']¶
student status codes from LDAP
- student_titles = ['Graduate Fellow', 'Graduate Assistant', 'Undergraduate Assistant', 'Postgraduate Research Associate']¶
position titles that indicate a staff person is a student
- class cdhweb.people.models.PersonRelatedLink(*args, **kwargs)[source]¶
Through-model for associating people with resource types and corresponding URLs for the specified resource type.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.people.models.Position(*args, **kwargs)[source]¶
Through model for many-to-many relation between people and titles. Adds start and end dates to the join table.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.people.models.Profile(*args, **kwargs)[source]¶
Profile page for a Person, managed via wagtail.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.people.models.Title(*args, **kwargs)[source]¶
Job titles for people
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
Views¶
- class cdhweb.people.views.AffiliateListView(**kwargs)[source]¶
Display current and past faculty & staff affiliates
- class cdhweb.people.views.ExecListView(**kwargs)[source]¶
Display current and past executive committee members.
- class cdhweb.people.views.PersonListView(**kwargs)[source]¶
Base class for person list views
- current_title = ''¶
title for non-past people in this category of people
- get_current()[source]¶
Get current people from the queryset. Override to customize which filter is used. By default, uses generic current logic that checks both positions and grants.
- get_past()[source]¶
Get past people. Override to customize filters and ordering. By default, assumes any profiles that aren’t current are past.
- 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
cdhweb.people.models.Person
- page_title = ''¶
title for this category of people
- past_title = ''¶
label for past people in this category of people
- class cdhweb.people.views.StaffListView(**kwargs)[source]¶
Display current and past CDH staff
Projects¶
Projects app for the CDH website. Handles project data and members associated with projects.
Models¶
- class cdhweb.projects.models.Grant(*args, **kwargs)[source]¶
A specific grant associated with a project
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.projects.models.GrantType(*args, **kwargs)[source]¶
Model to track kinds of grants
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.projects.models.Membership(*args, **kwargs)[source]¶
Project membership - joins project, user, and role.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.projects.models.Project(*args, **kwargs)[source]¶
Page type for a CDH sponsored project or working group.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- get_sitemap_urls(request)[source]¶
Override sitemap to prioritize projects built by CDH with a website.
- property website_url¶
URL for this Project’s website, if set
- class cdhweb.projects.models.ProjectQuerySet(*args, **kwargs)[source]¶
-
- order_by_newest_grant()[source]¶
order by grant start date, most recent grants first; secondary sort by project title
- staff_postdoc_grants = ['Staff R&D', 'Staff Project', 'Postdoctoral Research Project']¶
grant types that indicate staff or postdoc project
- class cdhweb.projects.models.ProjectRelatedLink(*args, **kwargs)[source]¶
Through-model for associating projects with relatedlinks
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.projects.models.ProjectTag(*args, **kwargs)[source]¶
Tags for Project pages.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
Views¶
- class cdhweb.projects.views.ProjectListView(**kwargs)[source]¶
Base class for project list views.
- get_current()[source]¶
Get current projects from the queryset. Override to customize which filter is used.
- get_past()[source]¶
Get past projects from the queryset. Override to customize which filter is used.
- model¶
alias of
cdhweb.projects.models.Project
- page_title = 'Projects'¶
title for this category of projects
- past_title = 'Past Projects'¶
title for past projects in this category of projects
- class cdhweb.projects.views.SponsoredProjectListView(**kwargs)[source]¶
Main project list, i.e. not staff/postdoc/working group.
Events¶
Events app for the CDH webapp. Provides event types, locations, and events
Models¶
- class cdhweb.events.models.Event(*args, **kwargs)[source]¶
Page type for an event, such as a workshop, lecture, or conference.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- duration()[source]¶
duration between start and end time as
datetime.timedelta
- get_url_parts(*args, **kwargs)[source]¶
Custom event page URLs of the form /events/2014/03/my-event.
- ical_event()[source]¶
Return the current event as a
icalendar.Event
for inclusion in aicalendar.Calendar
- property speaker_list¶
Comma-separated list of speaker names.
- class cdhweb.events.models.EventQuerySet(*args, **kwargs)[source]¶
- class cdhweb.events.models.EventTag(*args, **kwargs)[source]¶
Tags for Event pages.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.events.models.EventType(id, name)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.events.models.EventsLinkPage(*args, **kwargs)[source]¶
Container page that defines where Project pages can be created.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.events.models.Location(id, name, short_name, address, is_virtual)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- 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.
- property display_name¶
A name for template display
Views¶
- class cdhweb.events.views.EventMixinView[source]¶
View mixin that sets model to Event and returns a published Event queryset.
- model¶
alias of
cdhweb.events.models.Event
- class cdhweb.events.views.EventSemesterArchiveView(**kwargs)[source]¶
Display events by semester
- class cdhweb.events.views.EventSemesterDates[source]¶
Mixin to return list of event semester dates based on event dates in the system.
Blog¶
Blog app for the CDH website. Similar to the built-in grappelli blog, but allows multiple authors (other than the current user) to be associated with a post.
Models¶
- class cdhweb.blog.models.Author(*args, **kwargs)[source]¶
Ordered relationship between Person and BlogPost.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.blog.models.BlogLinkPage(*args, **kwargs)[source]¶
Container page that defines where blog posts can be created.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class cdhweb.blog.models.BlogPost(*args, **kwargs)[source]¶
A Blog post, implemented as a Wagtail page.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- property author_list¶
Comma-separated list of author names.
- get_url_parts(*args, **kwargs)[source]¶
Custom blog post URLs of the form /updates/2014/03/01/my-post.
- property short_description¶
Shorter description with ellipsis.
- property short_title¶
Shorter title with ellipsis.
Views¶
- class cdhweb.blog.views.AtomBlogPostFeed[source]¶
Blog post Atom feed
- feed_type¶
alias of
django.utils.feedgenerator.Atom1Feed
- class cdhweb.blog.views.BlogPostArchiveMixin(**kwargs)[source]¶
Mixin with common settings for blogpost archive views
- class cdhweb.blog.views.BlogPostMixinView[source]¶
Mixin that sets model to BlogPost and orders/filters queryset.
- model¶
alias of
cdhweb.blog.models.BlogPost