Home

Awesome

Bow Valley SPCA Website

The Bow Valley SPCA's mission is to provide the community with an adoption centre following a no kill, no cage philosophy to shelter, care for and re-home stray and abandoned dogs and cats and promote humane attitudes and responsible pet companionship through educational programs and community leadership.

Sponsorship of the website build has been provided by the Calgary Foundation and Blue Hut. Read more here

The code for the website is open source and other SPCAs, in particular, are encouraged to make use of the code as they see fit.

Key Website Features

Technical Overview

The website is built with Wagtail and Django.

Experience with either Django or Wagtail will be required to make use of this code.

Code structure based on cookiecutter-django

Django Apps

core

animals

The animals app provides the main functionality for displaying animals available for adoption. The app is based around using PetPoint (http://www.petpoint.com/) for managing animal data. It provides a Django management command to synchronize current adoptable animals in the PetPoint data management system with an 'Animal' Wagtail page model.

A PETPOINT_AUTH_KEY environment variable needs to be set to enable access to the PetPoint SOAP API.

Photo galleries on the animal details page use Featherlight jQuery lightbox plugin.

The animals app can easily be modified for rescue centres that do not use PetPoint by modifying the Wagtail Animal page model to suit their specific requirements.

newsletter

The newsletter app provides a management command to construct and send a weekly newsletter listing recently arrived and adopten animals. The newsletter is published via MailChimp.

The newsletter includes:

social

The social app provides a simple queue where pages can be appended for later posting to social media. A management command is run to dequeue items and post them to Facebook.

Pages implementing the SocialMediaPostable abstract class can be added to the queue. Currently only the Animal page model implements this.

Deployment

<a name="venv"/>Evironment Variables

The following environment variables need to be set in a production environment

NameAppExampleNote
DJANGO_SECRET_KEY
DJANGO_SETTINGS_MODULEconfig.settings.production
DJANGO_ADMIN_URLr'my-secret-django-admin-path'Defaults to 'djadmin' in development
DATABASE_URL
WAGTAIL_ADMIN_URLr'my-secret-wagtail-admin-path'Defaults to 'admin' in development
RECAPTCHA_SITE_KEYGoogle Recaptcha
RECAPTCHA_SECRET_KEYGoogle Recaptcha
GOOGLE_ANALYTICS_IDcore
ADDTHIS_PUB_IDcore
MAILCHIMP_USERNAMEnewsletterRequired by 'newsletter' app
MAILCHIMP_SECRET_KEYnewsletterRequired by 'newsletter' app
MAILCHIMP_LIST_IDnewsletter83c4276af1MailChimp list ID that newsletter will be distributed to
MAILCHIMP_TEMPLATE_IDnewsletter351313MailChimp template ID that newsletter will be created with
MAILCHIMP_SUBJECTnewsletterSubject line of email
MAILCHIMP_FROM_NAMEnewsletterFrom name of email
MAILCHIMP_REPLY_TOnewsletterReply to address of email
PETPOINT_AUTH_KEYanimalsPetPoint Authorization Key
WAGTAILADMIN_NOTIFICATION_FROM_EMAILAdmin From email
FACEBOOK_PAGE_ACCESS_TOKENsocialFacebook page access token
FACEBOOK_PAGE_IDsocialFacebook page id
FB_PIXEL_IDcore

Development Commands

Code Style Checks

  $ flake8 bvspca

Tests

  $ pytest bvspca
  $ pytest bvspca --reuse-db       # reuses the existing test db
  $ pytest bvspca --create-db      # forces the test db to be recreated
  $ pytest bvspca -f               # watches for changes if pytest-xdist installed

Live reloading, Sass compilation and JS bundling

  $ npm start

Production Sass compilation and JS bundling

  $ npm run build

<a name="cronjobs"/>Manage.py Cron Jobs Summary

CommandRequired bySuggested FrequencyNote
clearsessionsdjangodaily
publish_scheduled_pageswagtailevery hour
sync_petpoint_dataanimals appevery 30 minutes
send_newsletternewsletter appweekly
post_social_mediasocial appdaily