Skip to content

Commit

Permalink
Merge branch 'dev' into 'main'
Browse files Browse the repository at this point in the history
Add pyscopg to package list

See merge request project-thea/project-thea-api!4
  • Loading branch information
erssebaggala committed Sep 23, 2024
2 parents 3d7c0df + 7ed1820 commit 9daf1ae
Show file tree
Hide file tree
Showing 41 changed files with 1,450 additions and 20 deletions.
Empty file added .dockerignore
Empty file.
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_DATABASE: thea
POSTGRES_USER: postgres
POSTGRES_PASSWORD:
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
__pycache__/
24 changes: 24 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
image: python:3.11.9

stages:
- build
- test

build:
stage: build
script:
- echo "build"

test:
stage: test
before_script:
- python --version ; pip --version # For debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install tox
- pip install -r requirements.txt
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
script:
- tox
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.11.9
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip3 install -r requirements.txt
COPY . /app/
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# project-thea-api

Welcome to the the project-thea-api!

## Development

Start the containers in dev
```bash
docker compose -f docker-compose-dev.yml up -d
```

You can use the following commands to view the logs
```bash
docker-composer -f docker-compose-[dev,prod].yml logs --follow --tail 10 project-thea-api
```

Add the fixture data to your database
```bash
python manage.py load_all_fixtures
```
Empty file added api/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
38 changes: 38 additions & 0 deletions api/fixtures/diseases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"model": "api.Disease",
"pk": "167722a9-aa55-4399-8351-61d69f358e23",
"fields": {
"name": "COVID-19",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Disease",
"pk": "167722a9-aa55-4300-8351-61d69f358e23",
"fields": {
"name": "Mumps",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Disease",
"pk": "167722a9-aa55-4399-8353-61d69f358e24",
"fields": {
"name": "Measles",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Disease",
"pk": "167722a9-aa55-4399-8351-61d68d358e23",
"fields": {
"name": "Rubella",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
26 changes: 26 additions & 0 deletions api/fixtures/hotspots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"model": "api.Hotspot",
"pk": "33f982b-64f2-43b3-8aef-6348e8df40b53",
"fields": {
"latitude": 123.6,
"longitude": 87.9,
"datetime": "2024-09-04",
"strength": 20,
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Hotspot",
"pk": "e47fa4cc-5c0e-4211-8ddb-b995edf6e014",
"fields": {
"latitude": 132.6,
"longitude": 27.9,
"datetime": "2024-09-04",
"strength": 20,
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
22 changes: 22 additions & 0 deletions api/fixtures/hotspotusermaps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"model": "api.HotspotUserMap",
"pk": "22f982b-64f2-43b3-8aef-6348e8df40b53",
"fields": {
"hotspot":"33f982b-64f2-43b3-8aef-6348e8df40b53",
"user": "809e4ea8-4eae-48f1-acf6-c3c1e3a648c2",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.HotspotUserMap",
"pk": "e47fa4cc-5c0e-8811-8ddb-b995edf6e014",
"fields": {
"hotspot":"e47fa4cc-5c0e-4211-8ddb-b995edf6e014",
"user": "809e4ea8-4eae-48f1-acf6-c3c1e3a648c2",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
28 changes: 28 additions & 0 deletions api/fixtures/infectionrates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"model": "api.InfectionRate",
"pk": "33f982b-64f2-43b3-8aef-6348e8df40b53",
"fields": {
"hotspot":"e47fa4cc-5c0e-4211-8ddb-b995edf6e014",
"date": "2024-09-04",
"num_of_drivers_exposed": 20,
"num_of_drivers_infected": 12,
"transmission_rate": 0.6,
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.InfectionRate",
"pk": "48a49255-ee82-4c9c-ae6e-a86f069e9f62",
"fields": {
"hotspot":"e47fa4cc-5c0e-4211-8ddb-b995edf6e014",
"date": "2024-09-04",
"num_of_drivers_exposed": 20,
"num_of_drivers_infected": 12,
"transmission_rate": 0.6,
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
24 changes: 24 additions & 0 deletions api/fixtures/locations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{
"model": "api.Location",
"pk": "33f982b-64f2-43b3-8aef-6348e8df40b53",
"fields": {
"latitude": 123.6,
"longitude": 87.9,
"user": "167733a9-aa55-4399-8351-61d69f358e23",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Location",
"pk": "e47fa4cc-5c0e-4211-8ddb-b995edf6e014",
"fields": {
"latitude": 132.6,
"longitude": 27.9,
"user": "167733a9-aa55-4399-8351-61d69f358e23",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
38 changes: 38 additions & 0 deletions api/fixtures/results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"model": "api.Result",
"pk": "167733a9-aa55-4399-8351-61d69f358e23",
"fields": {
"user": "167733a9-aa55-4399-8351-61d69f358e23",
"result_status": "Negative",
"test_id": "167733a9-aa55-4399-8351-61d69f358e23",
"test_center": "Kampala Hospital",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Result",
"pk": "167733a9-aa55-4399-8351-61d69f358e23",
"fields": {
"user": "167733a9-aa55-4399-8351-61d69f358e23",
"result_status": "Positive",
"test_id": "167733a9-aa55-4399-8351-61d69f358e23",
"test_center": "Kirombe Health Center IV",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Result",
"pk": "167733a9-aa55-4399-8351-61d69f358e23",
"fields": {
"user": "167733a9-aa55-4399-8351-61d69f358e23",
"result_status": "Negative",
"test_id": "167733a9-aa55-4399-8351-61d69f358e23",
"test_center": "Busia POE Clinic",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
32 changes: 32 additions & 0 deletions api/fixtures/tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"model": "api.Test",
"pk": "167733a9-aa55-4399-8351-61d69f358e23",
"fields": {
"user": "167733a9-aa55-4399-8351-61d69f358e23",
"disease_id": "167722a9-aa55-4399-8351-61d69f358e23",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Test",
"pk": "8b0a407b-f659-4f29-9cd1-5949b46392c9",
"fields": {
"user": "167733a9-aa55-4399-8351-61d69f358e23",
"disease_id": "167722a9-aa55-4399-8351-61d69f358e23",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.Test",
"pk": "809e4ea8-4eae-48f1-acf6-c3c1e3a648c2",
"fields": {
"user": "809e4ea8-4eae-48f1-acf6-c3c1e3a648c2",
"disease_id": "167722a9-aa55-4399-8351-61d69f358e23",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
35 changes: 35 additions & 0 deletions api/fixtures/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"model": "api.User",
"pk": "167733a9-aa55-4399-8351-61d69f358e23",
"fields": {
"name": "Okello Gabriel",
"email": "[email protected]",
"password": "pbkdf2_sha256$870000$ar4a27h4fUytXHQatOijs5$Thm9y0bzdlELav7gvJJxIHECvtClP/vP1igHK1yNp9s=",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.User",
"pk": "8b0a407b-f659-4f29-9cd1-5949b46392c9",
"fields": {
"name": "Ashaba Christine",
"email": "[email protected]",
"password": "pbkdf2_sha256$870000$6GRxv3WkioZZ3NUHgngmtq$kgxA8i3C7U+UteyeaLsq8jvAOjxz4hJ1aCCSpV5DdEU=",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
},
{
"model": "api.User",
"pk": "809e4ea8-4eae-48f1-acf6-c3c1e3a648c2",
"fields": {
"name": "Kimuli Ivan",
"email": "[email protected]",
"password": "pbkdf2_sha256$870000$72XEj1Zx0dyiT5nlsQiWm0$Lsk6yYWXqCelV5UojvHa0atBLpN1j+HJVWndLjPbjoY=",
"created_at": "2024-09-04 12:16:10.443782+00",
"modified_at": "2024-09-04 12:16:10.443782+00"
}
}
]
Empty file added api/management/__init__.py
Empty file.
Empty file.
20 changes: 20 additions & 0 deletions api/management/commands/load_all_fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.core.management.base import BaseCommand
from django.core.management import call_command

class Command(BaseCommand):
help = 'Load all fixtures'

def handle(self, *args, **kwargs):
fixtures = [
'users.json',
'locations.json',
'diseases.json',
'tests.json',
'results.json',
'hotspots.json',
'hotspotusermaps.json',
# 'infectionrates.json'
]
for fixture in fixtures:
call_command('loaddata', fixture)
self.stdout.write(self.style.SUCCESS(f'Loaded fixture: {fixture}'))
Loading

0 comments on commit 9daf1ae

Please sign in to comment.