Skip to content

Commit

Permalink
Near final SI module - Validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Newton Mugaya committed Nov 16, 2023
1 parent a419cdb commit ef51843
Show file tree
Hide file tree
Showing 152 changed files with 47,036 additions and 12,791 deletions.
Binary file added assets/img/qr_code_9427.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions cpims/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

ALLOWED_HOSTS = []

DCS = ""


# Application definition

Expand All @@ -53,6 +51,7 @@
'cpovc_help',
'cpovc_ctip',
'cpovc_afc',
'cpovc_api',
'cpovc_missing_child',
'notifications',
'crispy_forms',
Expand Down Expand Up @@ -98,9 +97,9 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'cpims_dcs',
'USER': 'admin',
'PASSWORD': '123456',
'NAME': 'cpims_gok',
'USER': 'cpimsdbuser',
'PASSWORD': 'Xaen!ee8',
'HOST': '127.0.0.1',
'PORT': '5432', }
}
Expand Down Expand Up @@ -222,11 +221,13 @@
DCS['MINISTRY'] = 'MINISTRY OF LABOUR AND SOCIAL PROTECTION'
DCS['STATE_DEPT'] = 'STATE DEPARTMENT FOR SOCIAL PROTECTION '
DCS['STATE_DEPT'] += 'AND SENIOR CITIZENS AFFAIRS'
DCS['NAME'] = 'DIRECTORATE OF CHILDREN SERVICES'
DCS['NAME'] = "DIRECTORATE OF CHILDREN'S SERVICES"

MEDIA_PHOTOS = os.path.join(BASE_DIR, 'photos')

STATICFILES_DIRS = [BASE_DIR / "static", BASE_DIR / "photos", ]
STATICFILES_DIRS = [BASE_DIR / "static", BASE_DIR / "photos",
BASE_DIR / "reports", ]

# Do not include forward slash at the end
PHOTO_URL = '/static'
DOC_ROOT = os.path.join(BASE_DIR, 'static')
2 changes: 1 addition & 1 deletion cpims/views-.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def home(request):
tcases = float(dash['case_records'])
intervens = (pcases / tcases) if tcases > 0 else 0
interven = int(intervens * 100)
print(interven)
print interven
summary['interven'] = interven
# OVC care
odash = ovc_dashboard(request)
Expand Down
4 changes: 2 additions & 2 deletions cpovc_afc/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.db import migrations, models
import django.utils.timezone
Expand Down Expand Up @@ -35,7 +35,7 @@ class Migration(migrations.Migration):
fields=[
('form_id', models.UUIDField(default=uuid.uuid1, editable=False, primary_key=True, serialize=False)),
('question_id', models.CharField(max_length=12)),
('item_value', models.CharField(max_length=5)),
('item_value', models.CharField(max_length=10)),
('item_detail', models.TextField(blank=True, null=True)),
('timestamp_created', models.DateTimeField(default=django.utils.timezone.now)),
('timestamp_modified', models.DateTimeField(default=django.utils.timezone.now)),
Expand Down
6 changes: 3 additions & 3 deletions cpovc_afc/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.conf import settings
from django.db import migrations, models
Expand All @@ -10,9 +10,9 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cpovc_afc', '0001_initial'),
('cpovc_forms', '0001_initial'),
('cpovc_afc', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
Expand Down
6 changes: 3 additions & 3 deletions cpovc_afc/migrations/0003_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.conf import settings
from django.db import migrations, models
Expand All @@ -10,10 +10,10 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('cpovc_afc', '0002_initial'),
('cpovc_registry', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cpovc_forms', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cpovc_afc', '0002_initial'),
]

operations = [
Expand Down
13 changes: 13 additions & 0 deletions cpovc_api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.contrib import admin
from .models import DeviceManagement


class DeviceManagementAdmin(admin.ModelAdmin):
list_display = ('device_id', 'user', 'is_blocked', 'is_void',
'timestamp_created', 'timestamp_updated')
search_fields = ('device_id', 'timestamp_created')

list_filter = ['is_blocked', 'is_void']


admin.site.register(DeviceManagement, DeviceManagementAdmin)
8 changes: 8 additions & 0 deletions cpovc_api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class CpovcApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'cpovc_api'

verbose_name = 'API Management'
30 changes: 29 additions & 1 deletion cpovc_api/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
import uuid
from django.db import models
from django.utils import timezone

# Create your models here.
from cpovc_auth.models import AppUser


class DeviceManagement(models.Model):
"""Device Management Service for Mobile App"""

dm_id = models.UUIDField(
primary_key=True, default=uuid.uuid1, editable=False)
device_id = models.CharField(db_index=True, max_length=25)
user = models.ForeignKey(AppUser, on_delete=models.CASCADE)
timestamp_created = models.DateTimeField(default=timezone.now)
timestamp_updated = models.DateTimeField(auto_now=True)
is_blocked = models.BooleanField(default=False)
is_void = models.BooleanField(default=False)

class Meta:
"""Override Params."""

unique_together = ('device_id', 'user')

db_table = 'api_device_management'
verbose_name = 'API Device Management'
verbose_name_plural = 'API Device Managements'

def __str__(self):
"""To be returned by admin actions."""
return str(self.dm_id)
2 changes: 1 addition & 1 deletion cpovc_auth/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

import django.contrib.auth.models
from django.db import migrations, models
Expand Down
4 changes: 2 additions & 2 deletions cpovc_auth/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.conf import settings
from django.db import migrations, models
Expand All @@ -10,9 +10,9 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('cpovc_auth', '0001_initial'),
('cpovc_main', '0002_initial'),
('cpovc_registry', '0001_initial'),
('cpovc_auth', '0001_initial'),
('auth', '0012_alter_user_first_name_max_length'),
]

Expand Down
2 changes: 1 addition & 1 deletion cpovc_ctip/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.db import migrations, models
import django.utils.timezone
Expand Down
4 changes: 2 additions & 2 deletions cpovc_ctip/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -9,8 +9,8 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('cpovc_ctip', '0001_initial'),
('cpovc_forms', '0001_initial'),
('cpovc_ctip', '0001_initial'),
]

operations = [
Expand Down
4 changes: 2 additions & 2 deletions cpovc_ctip/migrations/0003_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -9,9 +9,9 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('cpovc_registry', '0001_initial'),
('cpovc_ctip', '0002_initial'),
('cpovc_forms', '0001_initial'),
('cpovc_registry', '0001_initial'),
]

operations = [
Expand Down
3 changes: 2 additions & 1 deletion cpovc_forms/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

import datetime
from django.db import migrations, models
Expand Down Expand Up @@ -1271,6 +1271,7 @@ class Migration(migrations.Migration):
('committing_court', models.CharField(max_length=100, null=True)),
('placement_notes', models.TextField(blank=True, max_length=1000, null=True)),
('ob_number', models.CharField(blank=True, max_length=20, null=True)),
('ob_police_station', models.CharField(blank=True, max_length=200, null=True)),
('placement_type', models.CharField(blank=True, default='Normal', max_length=10)),
('created_by', models.IntegerField(default=404, null=True)),
('is_active', models.BooleanField(default=True)),
Expand Down
6 changes: 3 additions & 3 deletions cpovc_forms/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.conf import settings
from django.db import migrations, models
Expand All @@ -11,11 +11,11 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cpovc_forms', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cpovc_main', '0002_initial'),
('cpovc_ovc', '0001_initial'),
('cpovc_registry', '0001_initial'),
('cpovc_ovc', '0001_initial'),
]

operations = [
Expand Down
1 change: 1 addition & 0 deletions cpovc_forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ class OVCPlacement(models.Model):
committing_court = models.CharField(max_length=100, null=True)
placement_notes = models.TextField(max_length=1000, null=True, blank=True)
ob_number = models.CharField(null=True, max_length=20, blank=True)
ob_police_station = models.CharField(null=True, max_length=200, blank=True)
placement_type = models.CharField(
max_length=10, default='Normal', blank=True) # Emergency/Normal
person = models.ForeignKey(RegPerson, on_delete=models.CASCADE)
Expand Down
2 changes: 2 additions & 0 deletions cpovc_forms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
name='case_record_sheet'),
path('crs/new/<int:id>/', views.new_case_record_sheet,
name='new_case_record_sheet'),
path('crs/<uuid:id>/', views.check_case_record_sheet,
name='check_case_record_sheet'),
re_path(r'^crs/view/(?P<id>\w+)/$', views.view_case_record_sheet,
name='view_case_record_sheet'),
re_path(r'^crs/edit/(?P<id>\w+)/$', views.edit_case_record_sheet,
Expand Down
11 changes: 10 additions & 1 deletion cpovc_forms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def userorgunits_lookup(request):
jsonOrgUnitsResults.append(
{'id': regorgunit.id,
'org_unit_name': str(regorgunit.org_unit_name)})
if types == 3:
if types == 3 or types == 31:
# This will be used for Residential Placements
ou_types = ['TNRH', 'TNRC', 'TNAP', 'TNRR', 'TNRB', 'TNRS']
orgunits = []
Expand All @@ -255,6 +255,8 @@ def userorgunits_lookup(request):
for regpersongeo in regpersonsgeo:
area_ids.append(regpersongeo.area_id)
print('AREAS', area_ids, appuser.reg_person.id)
if types == 31:
area_ids = []

if area_ids:
# print 'Non-national users ..'
Expand Down Expand Up @@ -2200,6 +2202,13 @@ def view_case_record_sheet(request, id):
return HttpResponseRedirect(redirect_url)


@login_required
@cache_control(no_cache=True, must_revalidate=True, no_store=True)
def check_case_record_sheet(request, id):
cid = str(id).replace('-', '')
return view_case_record_sheet(request, cid)


@login_required
@cache_control(no_cache=True, must_revalidate=True, no_store=True)
def delete_case_record_sheet(request, id):
Expand Down
2 changes: 1 addition & 1 deletion cpovc_help/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.db import migrations, models

Expand Down
2 changes: 1 addition & 1 deletion cpovc_help/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.7 on 2023-04-23 08:22
# Generated by Django 4.1.7 on 2023-10-30 06:33

from django.db import migrations, models
import django.db.models.deletion
Expand Down
32 changes: 32 additions & 0 deletions cpovc_main/fixtures/august_2023_releases.csv.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,37 @@
"sms_keyword": false,
"is_void": false
}
},
{
"pk": 41304,
"model": "cpovc_main.SetupList",
"fields": {
"the_order": 9,
"field_name": "ogo_cadre_type_id",
"item_category": "Employee cadre",
"item_id": "OGNPS",
"item_description": "Police Officer",
"item_description_short": "Police Officer",
"item_sub_category": "",
"user_configurable": false,
"sms_keyword": false,
"is_void": false
}
},
{
"pk": 41305,
"model": "cpovc_main.SetupList",
"fields": {
"the_order": 10,
"field_name": "ogo_cadre_type_id",
"item_category": "Employee cadre",
"item_id": "OGPRO",
"item_description": "Probation Officer",
"item_description_short": "Probation Officer",
"item_sub_category": "",
"user_configurable": false,
"sms_keyword": false,
"is_void": false
}
}
]
18 changes: 18 additions & 0 deletions cpovc_main/fixtures/initial_additions_sept2023.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"pk": 2000,
"model": "cpovc_main.SetupList",
"fields": {
"item_category": "Government Type",
"user_configurable": "False",
"sms_keyword": "True",
"item_sub_category": "",
"is_void": "False",
"item_id": "TNRG",
"item_description_short": "Regional Children Office",
"field_name": "government_unit_type_id",
"item_description": "Regional Children Office",
"the_order": 11
}
}
]
Loading

0 comments on commit ef51843

Please sign in to comment.