Skip to main content

Core functions for councilmatic.org family

Project description

django-councilmatic

The django-councilmatic app provides the core functionality for the Councilmatic family, a set of web apps for keeping tabs on local city council. It is built upon the Open Civic Data standard and ultimately makes Councilmatic easier to re-deploy in new cities.

Features

  • Models for bills, people, organizations, events, and more

  • Base views for Bill, Person, Organization, and Event listing and detail pages

  • Search infrastructure powered by django-haystack and Solr

The Councilmatic family includes:

Councilmatic in your city

If you’re interested in bringing Councilmatic to your city, contact us! We’d love to help.

Want to build your own Councilmatic? Check out our Starter Template. It contains everything you need to create your own Councilmatic from scratch.

Extending Open Civic Data/Councilmatic models

django-councilmatic leverages, and in some instaances, lightly extends the Open Civic Data Standard, implemented in Django as python-opencivicdata. If you’d like to add additional attributes or Python properties to your models, there are two approaches to be aware of: subclassing and proxying.

Subclassing

Leverage multi-table inheritance to add additional fields to OCD models. The primary use case in django-councilmatic is adding slugs to first-class models – Person, Event, Bill, and Organization - and adding metadata outside of the OCD standard, e.g., a headshot to Person and division boundaries to Post.

We recommend using pupa to scrape legislative data. Since pupa creates OCD objects, django-councilmatic includes Django signals to each of the subclassed models to create the related Councilmatic model on save. It also includes management commands to import metadata (see above).

If you subclass a model, be sure to include a signal to create instances of your subclass when the parent class is created, and, if applicable, some way to add any metadata, e.g., a management command or admin interface.

Proxying

django-councilmatic makes extensive use of proxy models to add custom managers and additional properties and methods to model classes. In order to take advantage of these elsewhere in the code, it is desirable for related objects to be returned as instances of other proxy classes or subclasses, rather than the upstream OCD model classes. In order to force related objects to be returned as Councilmatic models, django-councilmatic makes use of django-proxy-overrides.

If you wish to customize the class of related objects, first proxy an OCD model, then override one or more of its related object attributes with an instance of ProxyForeignKey. See councilmatic_core.models.BillAction for an example.

Running tests

Did you make changes to django-councilmatic? Before you make a pull request, run some tests.

First, install the test requirements:

pip install -r tests/requirements.txt

We test for style with flake8:

flake8 ./councilmatic_core/*.py

We test for functionality with pytest:

pytest

If you made material changes to the Councilmatic models, refresh the test fixture from a local instance database. From your instance directory (assuming you’ve already installed django-councilmatic with pip install -e /path/to/django-councilmatic), install the test requirements:

pip install -r /path/to/django-councilmatic/tests/test_requirements.txt

Add fixture_magic to your instance’s INSTALLED_APPS in settings.py.

Run the management command to update the test fixture.

python manage.py make_fixtures

Run the tests and commit your updated fixture with your PR!

Patches and Contributions

We continue to improve django-councilmatic, and we welcome your ideas! You can make suggestions in the form of github issues (bug reports, feature requests, general questions), or you can submit a code contribution via a pull request.

How to contribute code:

  • Fork the project.

  • Make your feature addition or bug fix.

  • Bonus points for running tests to check python style (pip install flake8 and then flake8 .).

  • Send us a pull request with a description of your work! Don’t worry if it isn’t perfect - think of a PR as a start of a conversation, rather than a finished product.

Project details


Release history Release notifications | RSS feed

This version

2.6.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-councilmatic-2.6.1.tar.gz (925.2 kB view details)

Uploaded Source

Built Distribution

django_councilmatic-2.6.1-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file django-councilmatic-2.6.1.tar.gz.

File metadata

  • Download URL: django-councilmatic-2.6.1.tar.gz
  • Upload date:
  • Size: 925.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for django-councilmatic-2.6.1.tar.gz
Algorithm Hash digest
SHA256 a4b2cea227cea118ce0058bebdf0abc368fc4f4fef1ba95a062412a84f4f55f9
MD5 1e72d7dfae9c381148689465c0cfe4a5
BLAKE2b-256 5ad9b915e9bd4451dbce79a85957139bd6320f5534497defb9454e8afbf94f2c

See more details on using hashes here.

File details

Details for the file django_councilmatic-2.6.1-py3-none-any.whl.

File metadata

  • Download URL: django_councilmatic-2.6.1-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for django_councilmatic-2.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfafd65346388a831c1731f1d2c956178e303fc1a5bca5944df1ff4c8ff92130
MD5 a1fec156aabe86ab92af84a1e6203424
BLAKE2b-256 fd0adc101f524f59e1b8adf6024529f561984ba7e7b8b132fe71a5d20589f545

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page