Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotthall committed Apr 24, 2024
1 parent 75efb20 commit 6477cc2
Show file tree
Hide file tree
Showing 70 changed files with 3,571 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ __pycache__/
#volumes
volumes/elasticsearch-data
volumes/postgres
volumes/postgres_data/*
volumes/postgres_data_backups
volumes/django
# C extensions
*.so

Expand Down Expand Up @@ -283,6 +286,9 @@ field/media/

# field
.idea
static/*
media/*
legacy/*
/legacy/.gitignore
/config/settings/local.py
/legacy/.vagrant_provisioning/playbook.yml.bk
Expand Down
20 changes: 15 additions & 5 deletions compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ services:
image: field_liv_django
container_name: openstack_field_django
depends_on:
- postgres
- elasticsearch
postgres:
condition: service_healthy
elasticsearch:
condition: service_started
env_file:
- .env
restart: unless-stopped
volumes:
- ../volumes/django/static:/app/staticfiles
expose:
- 8000
environment:
Expand All @@ -49,7 +53,7 @@ services:
expose:
- "8001"
volumes:
- django_static:/usr/share/nginx/static:ro
- ../volumes/django/static:/usr/share/nginx/static:ro
environment:
VIRTUAL_HOST: "field.kdl.kcl.ac.uk,field.app.cch.kcl.ac.uk,localhost,127.0.0.1"
VIRTUAL_PATH: "~^/(static/|redist/|robots.txt)"
Expand All @@ -68,9 +72,15 @@ services:
#POSTGRES_USER: ${POSTGRES_USER}
#POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
PGDATA: /var/lib/postgresql/data/pgdata
healthcheck:
test: ["CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'"]
timeout: 10s
interval: 5s
retries: 10

volumes:
- postgres_data:/var/lib/postgresql/data:Z
- postgres_data_backups:/backups:z
- ../volumes/postgres_data:/var/lib/postgresql/data:Z
- ../volumes/postgres_data_backups:/backups:z
env_file:
- .env
expose:
Expand Down
6 changes: 4 additions & 2 deletions compose/production/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ USER django
WORKDIR /app

COPY --from=image-npm /app/node_modules.tar.gz /
RUN tar xzf /node_modules.tar.gz

ENTRYPOINT ["/entrypoint"]

#RUN tar xzf /node_modules.tar.gz
#
#ENTRYPOINT ["/entrypoint"]
Empty file.
3 changes: 3 additions & 0 deletions coverage_annotation/django_kdl_timeline_admin.py,cover
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.contrib import admin

# Register your models here.
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions coverage_annotation/field_timeline_urls.py,cover
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
> from django.urls import path

> from field_timeline import views

> urlpatterns = [
> path('json/', views.TimelineJSONView.as_view(),
> name='timeline_json'),
> ]
47 changes: 47 additions & 0 deletions coverage_annotation/field_timeline_views.py,cover
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
> import json

> from django.http import HttpResponse
> from django.views.generic import View

> from field_wagtail.models import FieldTimelineEvent


> class TimelineJSONView(View):
> """
> Return events as JSON for async requests
> """

> def get_events(self, request):
> """
> Get events based on http request
> Add them to the current context
> :param request:request with filter args
> :return: queryset of FieldTimelineEvent objects
> """

# get event objects
> events = FieldTimelineEvent.objects.all()
# Add filtering
> if 'category' in request.GET:
! if len(request.GET['category']) > 0:
! events.filter(category__category_name=request.GET['category'])
> return events

> def events_to_slides(self, events):
> """Convert a FieldTimelineEvent object queryset into a list of
> slides using FieldTimelineEvent.get_timeline_data()
> :return: list of dicts for timeline slides
> """
> slides = list()
> for event in events:
> slides.append(event.get_timeline_data())
> return slides

> def get(self, request, *args, **kwargs):
> events = self.get_events(request)
> slides = list()
> if events:
> slides = self.events_to_slides(events)
> timeline = {'events': slides}
> return HttpResponse(json.dumps(timeline),
> content_type='application/json')
Loading

0 comments on commit 6477cc2

Please sign in to comment.