Skip to content

Commit

Permalink
Add models and fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer committed Oct 24, 2024
1 parent 3de2aeb commit bee5805
Show file tree
Hide file tree
Showing 26 changed files with 759 additions and 13 deletions.
1 change: 1 addition & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ services:
- django

plumber:
image: kartoza/${COMPOSE_PROJECT_NAME:-django_project}_plumber
build:
context: ../
dockerfile: deployment/plumber/Dockerfile
Expand Down
3 changes: 3 additions & 0 deletions deployment/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ django-cleanup==7.0.0
# Celery result backends for Django.
django-celery-results==2.5.0

# Translation for model field
django-modeltranslation==0.19.10

# psycopg2 - Python-PostgreSQL Database Adapter
# psycopg2-binary==2.9.3

Expand Down
3 changes: 2 additions & 1 deletion deployment/docker/uwsgi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ env = DJANGO_SETTINGS_MODULE=core.settings.prod
#uid = 1000
#gid = 1000
memory-report = true
harakiri = 120
harakiri = 120

2 changes: 1 addition & 1 deletion django_project/_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.7
0.0.8
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import os

from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand

Expand All @@ -20,18 +21,18 @@ class Command(BaseCommand):
"""Command to load fixtures."""

help = 'Load all fixtures'
apps = ['gap', 'spw']

def handle(self, *args, **options):
"""Handle load fixtures."""
for app in self.apps:
for app in settings.PROJECT_APPS:
folder = os.path.join(
DJANGO_ROOT, app, 'fixtures'
)
for subdir, dirs, files in os.walk(folder):
files.sort()
for file in files:
if file.endswith('.json'):
logger.info(f"Loading {file}")
print(f"Loading {file}")
call_command('loaddata', file)
if os.path.exists(folder):
for subdir, dirs, files in os.walk(folder):
files.sort()
for file in files:
if file.endswith('.json'):
logger.info(f"Loading {file}")
print(f"Loading {app}/{file}")
call_command('loaddata', file)
8 changes: 8 additions & 0 deletions django_project/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import os

from django.conf.global_settings import gettext_noop

from .utils import absolute_path, ensure_secret_key_file

ensure_secret_key_file()
Expand Down Expand Up @@ -122,6 +124,7 @@
)

INSTALLED_APPS = (
'modeltranslation',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -152,3 +155,8 @@

LOGIN_URL = '/account/login/'
LOGIN_REDIRECT_URL = '/'

LANGUAGES = (
("en", gettext_noop("English")),
("sw", gettext_noop("Swahili")),
)
7 changes: 5 additions & 2 deletions django_project/core/settings/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@
DEBUG = TEMPLATE_DEBUG = False

# Extra installed apps
INSTALLED_APPS = INSTALLED_APPS + (
PROJECT_APPS = (
'core',
'frontend',
'gap',
'gap_api',
'spw'
'spw',
'prise',
'message',
)
INSTALLED_APPS = INSTALLED_APPS + PROJECT_APPS

TEMPLATES[0]['DIRS'] += [
absolute_path('frontend', 'templates'),
Expand Down
18 changes: 18 additions & 0 deletions django_project/gap/fixtures/10.pest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"model": "gap.pest",
"pk": 1,
"fields": {
"name": "Beanfly",
"description": "Beanfly (On bean)"
}
},
{
"model": "gap.pest",
"pk": 2,
"fields": {
"name": "Fall Armyworm",
"description": "Fall Armyworm (on maize and other hosts)"
}
}
]
Empty file.
32 changes: 32 additions & 0 deletions django_project/message/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# coding=utf-8
"""
Tomorrow Now GAP.
.. note:: Message admins
"""

from django.contrib import admin
from modeltranslation.admin import TranslationAdmin

from message.models import MessageTemplate


@admin.register(MessageTemplate)
class MessageTemplateAdmin(TranslationAdmin):
"""Admin page for MessageTemplate."""

list_display = ('code', 'application', 'group', 'template')
filter = ('application', 'group')

class Media: # noqa
js = (
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
(
'http://ajax.googleapis.com/'
'ajax/libs/jqueryui/1.10.2/jquery-ui.min.js'
),
'modeltranslation/js/tabbed_translation_fields.js',
)
css = {
'screen': ('modeltranslation/css/tabbed_translation_fields.css',),
}
25 changes: 25 additions & 0 deletions django_project/message/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding=utf-8
"""
Tomorrow Now GAP.
.. note:: Message Config
A comprehensive framework of messages,
categorized by group and application,
designed to be utilized in a scheduled system for distribution to other
users, sms, or appending to some API or files.
"""

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


class MessageConfig(AppConfig):
"""App Config for Message."""

name = 'message'
verbose_name = _('message')

def ready(self):
"""App ready handler."""
pass
Loading

0 comments on commit bee5805

Please sign in to comment.