diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3f0bbdf --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.8' + +services: + web: + build: ./franklincce + command: gunicorn franklincce.wsgi:application --bind 0.0.0.0:8000 + volumes: + - ./franklincce/:/usr/src/franklincce + ports: + - 8000:8000 diff --git a/franklincce/Dockerfile b/franklincce/Dockerfile new file mode 100644 index 0000000..166c076 --- /dev/null +++ b/franklincce/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.11.4-slim-buster + +# set work directory +WORKDIR /usr/src/app + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# install dependencies +RUN pip install --upgrade pip +COPY ./requirements.txt . +RUN pip install -r requirements.txt + + +# copy project +COPY . . + +RUN mkdir /var/www/static -p +RUN python3 manage.py collectstatic --noinput diff --git a/franklincce/explorer/models.py b/franklincce/explorer/models.py index 37a110a..dd06a43 100644 --- a/franklincce/explorer/models.py +++ b/franklincce/explorer/models.py @@ -5,6 +5,8 @@ from .lib.parsers import HSYIG, HSMUN import io import fitz +from collections import namedtuple + class LegislationBook(models.Model): class ConferenceType(models.TextChoices): MIDDLE = "M", _("Middle School") @@ -106,3 +108,7 @@ class LegislativeText(models.Model): self.committee, self.docket_order, ) + + def get_lines(self): + cls = namedtuple('LegLine', ['linenumber', 'linetext']) + return [cls(i + 1, j) for i, j in enumerate(self.text.split('\n'))] diff --git a/franklincce/explorer/templates/explorer/all.html b/franklincce/explorer/templates/explorer/all.html new file mode 100644 index 0000000..53aa209 --- /dev/null +++ b/franklincce/explorer/templates/explorer/all.html @@ -0,0 +1,15 @@ +{% extends "explorer/base.html" %} + +{% block content %} +

All legislative texts

+ +{% if legislative_texts %} + +{% else %} +

No texts available

+{% endif %} +{% endblock content %} diff --git a/franklincce/explorer/templates/explorer/base.html b/franklincce/explorer/templates/explorer/base.html new file mode 100644 index 0000000..7b60f1e --- /dev/null +++ b/franklincce/explorer/templates/explorer/base.html @@ -0,0 +1,29 @@ + + + + {% if page_title %} + explorer - {{ title }} + {% else %} + explorer + {% endif %} + + + + + + + + {% block content %} + {% endblock content %} + + diff --git a/franklincce/explorer/templates/explorer/index.html b/franklincce/explorer/templates/explorer/index.html index 8c8a495..113cc45 100644 --- a/franklincce/explorer/templates/explorer/index.html +++ b/franklincce/explorer/templates/explorer/index.html @@ -1,3 +1,12 @@ +{% extends "explorer/base.html" %} + +{% block content %} +

Welcome to explorer

+ +

an interactive database for YMCA CCE legislation

+ +

Some randomly selected legislation

+ {% if legislative_texts %}