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

2.5 models, views, templates and ancillary files #510

Merged
merged 8 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ ENV PYTHONUNBUFFERED=1
RUN apt-get update && \
apt-get install -y libxml2-dev libxslt1-dev antiword unrtf poppler-utils \
pstotext tesseract-ocr flac ffmpeg lame libmad0 \
libsox-fmt-mp3 sox libjpeg-dev swig
libsox-fmt-mp3 sox libjpeg-dev swig gdal-bin

RUN mkdir /app
WORKDIR /app

COPY ./requirements.txt /app/requirements.txt
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install textract==1.6.3
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

COPY . /app

RUN DATABASE_URL='' python manage.py collectstatic --noinput

ENTRYPOINT ["/app/docker-entrypoint.sh"]
14 changes: 7 additions & 7 deletions councilmatic/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'haystack',
'lametro',
'opencivicdata.core',
'opencivicdata.legislative',
'councilmatic_core',
'lametro',
'adv_cache_tag',
'debug_toolbar',
)
Expand All @@ -54,26 +56,23 @@
except NameError:
pass

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
# 'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
# 'django.middleware.cache.FetchFromCacheMiddleware',
)

ROOT_URLCONF = 'councilmatic.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'lametro/templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand All @@ -87,6 +86,7 @@
},
]


WSGI_APPLICATION = 'councilmatic.wsgi.application'


Expand Down
6 changes: 5 additions & 1 deletion councilmatic/settings_deployment.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DEBUG = True

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'lametro',
'USER': 'postgres',
'HOST': 'postgres',
Expand Down Expand Up @@ -85,3 +85,7 @@ LOGGING = {

# Set to False in production!
SHOW_TEST_EVENTS = True

import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS = [ip[:-1] + '1' for ip in ips] + ['127.0.0.1', '10.0.2.2']
15 changes: 8 additions & 7 deletions councilmatic/settings_jurisdiction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# These settings are required #
###############################

OCD_CITY_COUNCIL_ID = 'ocd-organization/42e23f04-de78-436a-bec5-ab240c1b977c'
OCD_CITY_COUNCIL_NAME = 'Board of Directors'
CITY_COUNCIL_NAME = 'Metro'
OCD_JURISDICTION_IDS = ['ocd-jurisdiction/country:us/state:ca/county:los_angeles/transit_authority']
LEGISLATIVE_SESSIONS = ['2014', '2015', '2016', '2017', '2018', '2019'] # the last one in this list should be the current legislative session
Expand Down Expand Up @@ -47,12 +47,13 @@

BOUNDARY_SET = ['la-metro-supervisory-districts', 'la-metro-committee-districts', 'city-of-la']

MAP_CONFIG = {
'center': [34.0522, -118.2437],
'zoom': 10,
'color': "#54afe8",
'highlight_color': '#eb6864'
}
MAP_CONFIG = False
# MAP_CONFIG = {
hancush marked this conversation as resolved.
Show resolved Hide resolved
# 'center': [34.0522, -118.2437],
# 'zoom': 10,
# 'color': "#54afe8",
# 'highlight_color': '#eb6864'
# }

# FOOTER_CREDITS = [
# {
Expand Down
9 changes: 5 additions & 4 deletions councilmatic/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles import views as staticviews
from django.views.static import serve
from django.views.generic.base import RedirectView
from django.conf import settings
from django.views.decorators.cache import never_cache
Expand Down Expand Up @@ -39,7 +39,7 @@

urlpatterns = [
url(r'', include(patterns)),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
url(r'^metro-login/$', metro_login, name='metro_login'),
url(r'^metro-logout/$', metro_logout, name='metro_logout'),
url(r'^delete-submission/(?P<event_slug>[^/]+)/$', delete_submission, name='delete_submission'),
Expand All @@ -49,6 +49,7 @@
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
url(r'^static/(?P<path>.*)/$', staticviews.serve),
url(r'^__debug__/', include(debug_toolbar.urls)),
url(r'^static/(?P<path>.*)/$', serve),
url(r'^images/(?P<path>.*)/$', serve, {'document_root': settings.STATIC_ROOT + '/images/'}),
url(r'^__debug__/', include(debug_toolbar.urls)),
]
32 changes: 17 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,24 @@ services:
stdin_open: true
tty: true
ports:
- 8000:8000
- 8011:8000
depends_on:
postgres:
condition: service_healthy
solr:
condition: service_started
volumes:
- .:/app
- ${PWD}/councilmatic/settings_deployment.py.example:/app/councilmatic/settings_deployment.py
- ${PWD}/councilmatic/settings_deployment.py:/app/councilmatic/settings_deployment.py
environment:
POSTGRES_HOST: postgres
DJANGO_MANAGEPY_MIGRATE: "on"
command: python manage.py runserver 0.0.0.0:8000

migration:
container_name: lametro-migration
image: lametro:latest
depends_on:
- app
- postgres
volumes:
- .:/app
- ${PWD}/councilmatic/settings_deployment.py.example:/app/councilmatic/settings_deployment.py
command: python manage.py migrate

postgres:
container_name: lametro-postgres
restart: always
image: postgres:9.6
image: mdillon/postgis:9.6
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
Expand All @@ -46,7 +36,7 @@ services:
volumes:
- lametro-db-data:/var/lib/postgresql/data
ports:
- 32001:5432
- 32005:5432

solr:
image: solr:7.5
Expand All @@ -61,6 +51,18 @@ services:
SOLR_LOG_LEVEL: INFO
restart: on-failure

scrapers:
hancush marked this conversation as resolved.
Show resolved Hide resolved
build: https://github.com/datamade/scrapers-us-municipal.git#la_metro_upgrade
stdin_open: true
tty: true
depends_on:
postgres:
condition: service_healthy
environment:
SHARED_DB: 'True'
DATABASE_URL: 'postgis://postgres:@postgres/lametro'
command: sh -c 'pupa update --rpm=600 lametro people && pupa update --rpm=600 lametro bills window=30 && pupa update --rpm=600 lametro events'

volumes:
lametro-solr-data:
lametro-db-data:
8 changes: 8 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

if [ "$DJANGO_MANAGEPY_MIGRATE" = 'on' ]; then
hancush marked this conversation as resolved.
Show resolved Hide resolved
python manage.py migrate --noinput
fi

exec "$@"
2 changes: 1 addition & 1 deletion lametro/feeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse, reverse_lazy
from django.urls import reverse, reverse_lazy
from django.utils.feedgenerator import Rss201rev2Feed
from django.conf import settings

Expand Down
62 changes: 57 additions & 5 deletions lametro/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,78 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-10-13 20:46
from __future__ import unicode_literals
# Generated by Django 2.1.13 on 2019-10-11 17:36

from django.db import migrations
from django.db import migrations, models
import lametro.models


class Migration(migrations.Migration):

initial = True

dependencies = [
('councilmatic_core', '0010_auto_20160120_1248'),
('councilmatic_core', '0048_post_shape'),
]

operations = [
migrations.CreateModel(
name='SubjectGuid',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('guid', models.CharField(max_length=256)),
('name', models.CharField(max_length=256, unique=True)),
],
),
migrations.CreateModel(
name='LAMetroBill',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('councilmatic_core.bill',),
),
migrations.CreateModel(
name='LAMetroEvent',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('councilmatic_core.event', lametro.models.LiveMediaMixin),
),
migrations.CreateModel(
name='LAMetroOrganization',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('councilmatic_core.organization',),
),
migrations.CreateModel(
name='LAMetroPerson',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('councilmatic_core.person',),
),
migrations.CreateModel(
name='LAMetroPost',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('councilmatic_core.post',),
),
migrations.AlterUniqueTogether(
name='subjectguid',
unique_together={('guid', 'name')},
),
]
25 changes: 0 additions & 25 deletions lametro/migrations/0002_lametropost.py

This file was deleted.

25 changes: 0 additions & 25 deletions lametro/migrations/0003_lametroperson.py

This file was deleted.

25 changes: 0 additions & 25 deletions lametro/migrations/0004_lametroevent.py

This file was deleted.

Loading