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

Ground observations data #1

Merged
merged 17 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 13 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@
"../deployment/docker-compose.override.devcontainer.yml"
],
"service": "dev",
"runServices": ["db", "redis", "celery_beat", "worker", "dev"],
"workspaceFolder": "/home/web/project",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
},
"runArgs": [
"--env-file",
"../deployment/.env"
Expand All @@ -25,6 +20,16 @@
}
},
"forwardPorts": [8000, 9000],
"extensions": ["ms-python.python", "ms-azuretools.vscode-docker"],
"shutdownAction": "stopCompose"
"shutdownAction": "stopCompose",
"customizations": {
"vscode": {
"extensions": ["ms-python.python", "ms-azuretools.vscode-docker"],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
}
}
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ docs/site/*
docks/mkdocs.yml
.direnv
docs/mkdocs.yml

# ignore .env in root project for vscode
.env
27 changes: 0 additions & 27 deletions .run/Run Server.run.xml

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
],
"django": true,
"justMyCode": true,
"env": {
"DJANGO_SETTINGS_MODULE": "core.settings.dev"
}
},
{
"command": "npm run serve",
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"django_project"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "React: Install dependencies",
"type": "shell",
"command": "npm install",
"command": "npm install --legacy-peer-deps",
"options": {
"cwd": "${workspaceFolder}/django_project/frontend"
},
Expand Down
13 changes: 13 additions & 0 deletions deployment/docker-compose.override.devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
volumes:
- ./volumes/database:/opt/postgres/data
- ./volumes/backups:/backups
ports:
- "${DATABASE_PORT:-6432}:5432"

dbbackups:
volumes:
Expand All @@ -20,6 +22,17 @@ services:
- ./volumes/static:/home/web/static
- ./volumes/media:/home/web/media

celery_beat:
image: kartoza/${COMPOSE_PROJECT_NAME:-django_project}_dev
build:
context: ../
dockerfile: deployment/docker/Dockerfile
target: vscode
volumes:
- ../:/home/web/project
- ./volumes/static:/home/web/static
- ./volumes/media:/home/web/media

dev:
image: kartoza/${COMPOSE_PROJECT_NAME:-django_project}_dev
build:
Expand Down
39 changes: 37 additions & 2 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,24 @@ volumes:
x-common-django:
&default-common-django
image: kartoza/${COMPOSE_PROJECT_NAME:-django_project}:${DJANGO_TAG:-1.0.0}
env_file:
- .env
environment:
- DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-core.settings.dev}

- ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
- ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
- ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com}

- DATABASE_NAME=${DATABASE_NAME:-django}
- DATABASE_USERNAME=${DATABASE_USERNAME:-docker}
- DATABASE_PASSWORD=${DATABASE_PASSWORD:-docker}
- DATABASE_HOST=${DATABASE_HOST:-db}
- DATABASE_PORT=${DATABASE_PORT:-5432}
- REDIS_HOST=${REDIS_HOST:-redis}
- REDIS_PASSWORD=${REDIS_PASSWORD:-redis_password}

- RABBITMQ_HOST=${RABBITMQ_HOST:-rabbitmq}
- SENTRY_DSN=${SENTRY_DSN:-}
- SECRET_KEY=SECRET_KEY
volumes:
- static-data:/home/web/static
- media-data:/home/web/media
Expand All @@ -36,6 +52,15 @@ services:
- POSTGRES_USER=${DATABASE_USERNAME:-docker}
- POSTGRES_PASS=${DATABASE_PASSWORD:-docker}

dbbackups:
image: kartoza/postgis:14-3.3
volumes:
- data-volume:/backups
environment:
- POSTGRES_DBNAME=${DATABASE_NAME:-django}
- POSTGRES_USER=${DATABASE_USERNAME:-docker}
- POSTGRES_PASS=${DATABASE_PASSWORD:-docker}

django:
<<: *default-common-django
command: 'uwsgi --ini /uwsgi.conf'
Expand Down Expand Up @@ -70,3 +95,13 @@ services:
- nginx-cache:/home/web/nginx_cache
links:
- django

dev:
<<: *default-common-django
entrypoint: []
volumes:
- static-data:/home/web/static
- media-data:/home/web/media
links:
- db
- redis
Empty file.
30 changes: 30 additions & 0 deletions django_project/core/models/general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# coding=utf-8
"""
Tomorrow Now GAP.

.. note:: General models
"""

from django.db import models


class Definition(models.Model):
"""Abstract model for Model that has name and description.

Attributes:
name (str): Name of object.
description (str): Description of object.
"""

name = models.CharField(
max_length=512
)
description = models.TextField(
null=True, blank=True
)

def __str__(self):
return self.name

class Meta: # noqa: D106
abstract = True
13 changes: 5 additions & 8 deletions django_project/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import os

from .utils import absolute_path
from .utils import absolute_path, ensure_secret_key_file

ensure_secret_key_file()

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
Expand Down Expand Up @@ -122,7 +124,7 @@
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.gis',
'django.contrib.messages',
'django.contrib.messages'
)

SITE_ID = 1
Expand All @@ -143,9 +145,4 @@
LOGIN_URL = '/account/login/'
LOGIN_REDIRECT_URL = '/'

try:
SECRET_KEY = os.environ['SECRET_KEY']
if SECRET_KEY in ['', "''"]:
raise Exception('SECRET_KEY is required in env.')
except KeyError:
raise Exception('SECRET_KEY is required in env.')
from .secret import SECRET_KEY # noqa
2 changes: 1 addition & 1 deletion django_project/core/settings/contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'django.contrib.auth.backends.ModelBackend', # default
'guardian.backends.ObjectPermissionBackend',
)
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CELERY_RESULT_BACKEND = 'django-db'

TEMPLATES[0]['OPTIONS']['context_processors'] += [
Expand Down
1 change: 1 addition & 0 deletions django_project/core/settings/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
INSTALLED_APPS = INSTALLED_APPS + (
'core',
'frontend',
'gap'
)

TEMPLATES[0]['DIRS'] += [
Expand Down
4 changes: 3 additions & 1 deletion django_project/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-scripts": "5.0.1",
"typescript": "4.9.5",
"web-vitals": "^2.1.4",
"webpack": "^5.78.0",
"webpack-bundle-tracker": "^1.5.0",
Expand Down Expand Up @@ -48,6 +49,7 @@
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.7.3",
"sass": "^1.60.0",
"ts-loader": "^9.4.2"
"ts-loader": "^9.4.2",
"webpack-dev-server": "^4.9.0"
}
}
Empty file added django_project/gap/__init__.py
Empty file.
63 changes: 63 additions & 0 deletions django_project/gap/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# coding=utf-8
"""
Tomorrow Now GAP.

.. note:: Admins
"""
from django.contrib import admin

from .models import (
Attribute, Country, Provider, Measurement, Station
)


@admin.register(Attribute)
class AttributeAdmin(admin.ModelAdmin):
"""Attribute admin."""

list_display = (
'name', 'description'
)
search_fields = ('name',)


@admin.register(Country)
class CountryAdmin(admin.ModelAdmin):
"""Country admin."""

list_display = (
'name', 'description'
)
search_fields = ('name',)


@admin.register(Provider)
class ProviderAdmin(admin.ModelAdmin):
"""Provider admin."""

list_display = (
'name', 'description'
)
search_fields = ('name',)


@admin.register(Measurement)
class MeasurementAdmin(admin.ModelAdmin):
"""Measurement admin."""

list_display = (
'station', 'attribute', 'date', 'value'
)
list_filter = ('station', 'attribute')
search_fields = ('name',)


@admin.register(Station)
class StationAdmin(admin.ModelAdmin):
"""Station admin."""

list_display = (
'name', 'country', 'provider'
)
list_filter = ('country',)
search_fields = ('name',)
16 changes: 16 additions & 0 deletions django_project/gap/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# coding=utf-8
"""
Tomorrow Now GAP.

.. note:: App Config
"""

from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _


class GAPConfig(AppConfig):
"""App Config for GroundObservations."""

name = 'gap'
verbose_name = _('Ground Observations')
Loading
Loading