Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update Models and Views for Councilmatic 2.5 #499

Closed
wants to merge 40 commits into from

Conversation

fgregg
Copy link
Collaborator

@fgregg fgregg commented Oct 11, 2019

Overview

This PR updates the models and views for councilmatic 2.5, as well as search and management commands.

It is nearly feature complete (modulo bugs), but not completely. I want to discuss with @hancush what we want to bring into this PR versus what we should wait on to make things more reviewable.

Notes

This PR depends on changes to the scrapers and django-councilmatic. I believe they can be reviewed separately

Also, we are bit out of synch with LA metro master, we should discuss how we want to handle that.

Testing Instructions

Move councilmatic/settings_deployment.py.example to councilmatic/settings_deployment.py and add a GOOGLE_API_KEY setting so that the maps will work.

docker-compose up scrapers
docker-compose run --rm -e DJANGO_MANAGEPY_MIGRATE=off app python manage.py migrate
docker-compose run --rm -e DJANGO_MANAGEPY_MIGRATE=off app python manage.py compile_pdfs
docker-compose run --rm -e DJANGO_MANAGEPY_MIGRATE=off app python manage.py convert_attachment_text
docker-compose run --rm -e DJANGO_MANAGEPY_MIGRATE=off app python manage.py update_index --batch-size=100
docker-compose up

visit http://localhost:8011/

The local site should be the same as the production site with a few exceptions:

  • headshots
  • biographies of people
  • descriptions of committees

Headshots

We have changed the way we handle head shots. Now, you upload headshots through the admin interface.

  1. Create and admin user docker-compose run --rm -e DJANGO_MANAGEPY_MIGRATE=off app python manage.py createsuperuser
  2. Login into the admin interface at http://localhost:8011/ and update an person with a url for their headshot

Screenshot_2019-11-18 Change person Django site admin

  1. docker-compose run --rm -e DJANGO_MANAGEPY_MIGRATE=off app python manage.py update_headshots

Descriptions of committees and people

Currently, the settings_jurisdiction.py contains descriptions of committees and biographies of people. These get associated with the individual views by keying off of slugs. As the slugs for people and committees depend on their OCD id the slugs will be different in your local development version.

To test that the current approach works, you can edit the settings_jurisdiction.py and update the slugs to line up with your local database.

Going forward, I would recommend making these types of data attributes of the appropriate models, which will be updated and edited in an admin interface. Then we can pull the data for people and orgs as fixtures and load them as part of an initial ETL. (this can be addressed in the data migration scope item).

Issue Tracking

Some tests won't pass until I get these sorted out, but I wanted to huddle with @hancush before pushing forward.

@@ -485,21 +484,6 @@ def board_event_minutes(self):
return doc.url


class LAMetroEventMedia(EventMedia):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a work around a data import issue, and I think it will not be necessary. I'll keep track of it though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't need this model.

@@ -1,5 +1,4 @@
psycopg2==2.7.6.1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

psycopg2 is properly a dependency of django-councilmatic.

fgregg added 27 commits October 11, 2019 22:40
Following the pattern described in the Caktus post: https://www.caktusgroup.com/blog/2017/03/14/production-ready-dockerfile-your-python-django-app/'

The migration is part of the entrypoint instead of a separate management
command.

+ I think this is pretty clear, but I familiar with bash scripting
+ uses the docker-compose health checks (which are v. good)
+ makes controlling when to migrate simpler (env var in app context)

- you need to understand some bash to understand the docker-entrypoint.sh
@@ -119,3 +119,7 @@
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

ADV_CACHE_INCLUDE_PK = True

import socket
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stuff allows the django toolbar to work with docker.

@@ -166,19 +166,12 @@ <h4><i class='fa fa-fw fa-calendar-o'></i> Board of Directors Meetings</h4>
"info": false,
"bLengthChange": false,
"paging": false,
"aaSorting": [ [3,'asc'] ],
"aaSorting": [ [1,'asc'] ],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has our data table sort by last name of the person.

@@ -1,4 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = tests.test_config
filterwarnings =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes a fatal error in django 2.1

@fgregg
Copy link
Collaborator Author

fgregg commented Dec 6, 2019

this monster has been broken up.

@fgregg fgregg closed this Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant