Skip to content

Commit

Permalink
feat: wire in facility and program report placeholder pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Jul 17, 2021
1 parent 6f68f17 commit b418365
Show file tree
Hide file tree
Showing 38 changed files with 828 additions and 378 deletions.
77 changes: 10 additions & 67 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,17 @@

# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool("DJANGO_DEBUG", False)
# Local time zone. Choices are
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# though not all of them may be available with every OS.
# In Windows, this must be set to your system time zone.
TIME_ZONE = "Africa/Nairobi"
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
LANGUAGE_CODE = "en-us"
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True
# https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
# https://docs.djangoproject.com/en/dev/ref/settings/#locale-paths
LOCALE_PATHS = [str(ROOT_DIR / "locale")]

# DATABASES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
"default": {
"NAME": env.str("POSTGRES_DB"),
Expand All @@ -63,15 +51,9 @@

# URLS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
ROOT_URLCONF = "config.urls"
# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = "config.wsgi.application"

# BigAutoField needs migration of existing data and either changes to
# dependencies or overriding dependencies
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# APPS
# ------------------------------------------------------------------------------
DJANGO_APPS = [
Expand Down Expand Up @@ -105,40 +87,32 @@
"pepfar_mle.retention.apps.RetentionConfig",
"pepfar_mle.tb.apps.TBConfig",
"pepfar_mle.treatment.apps.TreatmentConfig",
"pepfar_mle.ops.apps.OpsConfig",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

# MIGRATIONS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
MIGRATION_MODULES = {"sites": "pepfar_mle.contrib.sites.migrations"}

# AUTHENTICATION
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#authentication-backends
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
AUTH_USER_MODEL = "users.User"
# https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
LOGIN_REDIRECT_URL = "users:redirect"
# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
LOGIN_URL = "account_login"

# PASSWORDS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
PASSWORD_HASHERS = [
# https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
Expand All @@ -148,7 +122,6 @@

# MIDDLEWARE
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
Expand All @@ -165,42 +138,30 @@

# STATIC
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = str(ROOT_DIR / "staticfiles")
# https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = "/static/"
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = [str(APPS_DIR / "static")]
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]

# MEDIA
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = str(APPS_DIR / "media")
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = "/media/"

# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
TEMPLATES = [
{
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
"BACKEND": "django.template.backends.django.DjangoTemplates",
# https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
"DIRS": [str(APPS_DIR / "templates")],
"OPTIONS": {
# https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
"loaders": [
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
],
# https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
Expand All @@ -215,77 +176,57 @@
},
}
]

# https://docs.djangoproject.com/en/dev/ref/settings/#form-renderer
FORM_RENDERER = "django.forms.renderers.TemplatesSetting"

# http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
CRISPY_TEMPLATE_PACK = "bootstrap4"

# FIXTURES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
FIXTURE_DIRS = (str(APPS_DIR / "fixtures"),)

# SECURITY
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
SESSION_COOKIE_HTTPONLY = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
CSRF_COOKIE_HTTPONLY = True
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-browser-xss-filter
SECURE_BROWSER_XSS_FILTER = True
# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
X_FRAME_OPTIONS = "SAMEORIGIN" # needs to be SAMEORIGIN for the jet admin to work

# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND",
# alternative for local dev with mailhog: django.core.mail.backends.smtp.EmailBackend
default="anymail.backends.mailgun.EmailBackend",
)
DEFAULT_FROM_EMAIL = env(
"DJANGO_DEFAULT_FROM_EMAIL",
default="Fahari ya Jamii M&E System <mle@savannahghi.org>",
default="Fahari System <mle@savannahghi.org>",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
EMAIL_SUBJECT_PREFIX = env(
"DJANGO_EMAIL_SUBJECT_PREFIX",
default="[Fahari ya Jamii M&E System ]",
default="[Fahari System ]",
)
# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
# https://anymail.readthedocs.io/en/stable/esps/mailgun/
ANYMAIL = {
"MAILGUN_API_KEY": env("MAILGUN_API_KEY", default=""), # blank default for local dev and tests
"MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN", default="mle.savannahghi.org"),
"MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"),
}
# https://docs.djangoproject.com/en/dev/ref/settings/#email-timeout
EMAIL_TIMEOUT = 5

# ADMIN
# ------------------------------------------------------------------------------
# Django Admin URL.
ADMIN_URL = "admin/"
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = [
(
"""Savannah Informatics Global Health Institute""",
"info@savannahghi.org",
)
]
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS

# LOGGING
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
# See https://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
Expand Down Expand Up @@ -323,24 +264,26 @@

# django-compressor
# ------------------------------------------------------------------------------
# https://django-compressor.readthedocs.io/en/latest/quickstart/#installation
INSTALLED_APPS += ["compressor"]
STATICFILES_FINDERS += ["compressor.finders.CompressorFinder"]
# django-rest-framework
# -------------------------------------------------------------------------------
# django-rest-framework - https://www.django-rest-framework.org/api-guide/settings/
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.TokenAuthentication",
),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
}

# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
CORS_URLS_REGEX = r"^/api/.*$"
# Your stuff...

# Project specific settings
# ------------------------------------------------------------------------------
# these are used by the base model classes for validation
DECIMAL_PLACES = 4
MAX_IMAGE_HEIGHT = 4320
MAX_IMAGE_WIDTH = 7680

# BigAutoField needs migration of existing data and either changes to
# dependencies or overriding dependencies
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
3 changes: 3 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
# User management
path("users/", include("pepfar_mle.users.urls", namespace="users")),
path("accounts/", include("allauth.urls")),
# our apps
path("common/", include("pepfar_mle.common.urls", namespace="common")),
path("ops/", include("pepfar_mle.ops.urls", namespace="ops")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG:
# Static file serving when using Gunicorn + Uvicorn for local web socket development
Expand Down
7 changes: 6 additions & 1 deletion pepfar_mle/common/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from .models import Facility, FacilityAttachment, Organisation
from .models import Facility, FacilityAttachment, Organisation, System


class BaseAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -34,6 +34,11 @@ class OrganisationAdmin(BaseAdmin):
pass


class SystemAdmin(BaseAdmin):
pass


admin.site.register(Facility, FacilityAdmin)
admin.site.register(FacilityAttachment, FacilityAttachmentAdmin)
admin.site.register(Organisation, OrganisationAdmin)
admin.site.register(System, SystemAdmin)
34 changes: 34 additions & 0 deletions pepfar_mle/common/migrations/0006_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.5 on 2021-07-17 06:46

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import uuid


class Migration(migrations.Migration):

dependencies = [
('common', '0005_auto_20210714_1633'),
]

operations = [
migrations.CreateModel(
name='System',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('active', models.BooleanField(default=True)),
('created', models.DateTimeField(default=django.utils.timezone.now)),
('created_by', models.UUIDField(blank=True, null=True)),
('updated', models.DateTimeField(default=django.utils.timezone.now)),
('updated_by', models.UUIDField(blank=True, null=True)),
('name', models.CharField(max_length=128, unique=True)),
('description', models.TextField()),
('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='common_system_related', to='common.organisation')),
],
options={
'ordering': ('name',),
'abstract': False,
},
),
]
17 changes: 17 additions & 0 deletions pepfar_mle/common/migrations/0007_alter_system_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.5 on 2021-07-17 08:34

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('common', '0006_system'),
]

operations = [
migrations.AlterModelOptions(
name='system',
options={'ordering': ('name', '-updated')},
),
]
17 changes: 15 additions & 2 deletions pepfar_mle/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.db import models, transaction
from django.db.models.base import ModelBase
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from phonenumber_field.modelfields import PhoneNumberField
from PIL import Image

Expand Down Expand Up @@ -411,7 +411,20 @@ class FacilityAttachment(Attachment):

organisation_verify = ["facility"]

class Meta:
class Meta(AbstractBase.Meta):
"""Define ordering and other attributes for attachments."""

ordering = ("-updated", "-created")


class System(AbstractBase):
"""List of systems used in the public sector e.g Kenya EMR."""

name = models.CharField(max_length=128, null=False, blank=False, unique=True)
description = models.TextField()

class Meta(AbstractBase.Meta):
ordering = (
"name",
"-updated",
)
9 changes: 9 additions & 0 deletions pepfar_mle/common/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path

from .views import FacilityView, SystemsView

app_name = "common"
urlpatterns = [
path("facilities", view=FacilityView.as_view(), name="facilities"),
path("systems", view=SystemsView.as_view(), name="systems"),
]
8 changes: 8 additions & 0 deletions pepfar_mle/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ class HomeView(LoginRequiredMixin, ApprovedMixin, TemplateView):

class AboutView(LoginRequiredMixin, ApprovedMixin, TemplateView):
template_name = "pages/about.html"


class FacilityView(LoginRequiredMixin, ApprovedMixin, TemplateView):
template_name = "pages/common/facilities.html"


class SystemsView(LoginRequiredMixin, ApprovedMixin, TemplateView):
template_name = "pages/common/systems.html"
Empty file added pepfar_mle/ops/__init__.py
Empty file.

0 comments on commit b418365

Please sign in to comment.