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

Make Kobocat a Django app inside KPI #4888

Merged
merged 159 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
e2f81d6
WIP - initial migration
noliveleger Jan 29, 2024
e27e91c
Separate openrosa models from shadow models
noliveleger Jan 30, 2024
a487b72
refactor kobocat app to openrosa
noliveleger Feb 1, 2024
d985887
Make migrate, showmigrations work with both databases
noliveleger Feb 1, 2024
aea64c4
Use new decorator to use specific database
noliveleger Feb 1, 2024
918d1ac
Use custom User model
noliveleger Feb 1, 2024
0a6ba72
Use django-digest fork and new guardian backend
noliveleger Feb 2, 2024
cd0829e
backport kobocat#913 PR
noliveleger Feb 2, 2024
bc5c8f6
Simulate auth_user Admin section
noliveleger Feb 2, 2024
c7fa7d4
Update FIXME
noliveleger Feb 2, 2024
30a0ad0
Bring Kobocat API v1 to life with its own DRF settings
noliveleger Feb 2, 2024
1883aa3
Add kobocat dependencies
noliveleger Feb 5, 2024
d5da412
Add other KC dependencies
noliveleger Feb 5, 2024
ee9c772
Merge TESTING_MODE and TESTING variables
noliveleger Feb 5, 2024
711f90f
Replace forgotten auth.User imports
noliveleger Feb 5, 2024
44ae7f7
Rename Kobocat FormDisclaimer table
noliveleger Feb 5, 2024
74e2d8c
Allow Kobocat models to migrate in tests
noliveleger Feb 5, 2024
f46f106
Move kobocat URLs at KPI root
noliveleger Feb 6, 2024
02fd104
Import Kobocat settings for tests
noliveleger Feb 6, 2024
047f553
Add apt packages needed for Kobocat
noliveleger Feb 6, 2024
9f799ac
Fix misspelled path variable
noliveleger Feb 6, 2024
7760bcc
Add pandas pip dependencies
noliveleger Feb 28, 2024
7b1c6ff
Fix typo with apt install java
noliveleger Mar 11, 2024
7812521
Fix enketo unit tests
noliveleger Mar 11, 2024
9465bcf
Skip unit tests on KC login
noliveleger Mar 11, 2024
ea64a3d
Fix CSV import unit tests
noliveleger Mar 11, 2024
7c7508c
Fix Kobocat tests
noliveleger Mar 12, 2024
22e7fa5
Fix wrong paths
noliveleger Mar 19, 2024
e24b4e7
misc. bugfixes for unit tests
noliveleger Mar 20, 2024
d5fce80
Merge branch 'beta' into django-kobocat-app
noliveleger Mar 20, 2024
e9ee099
Reorganize imports (User model shortcut)
noliveleger Mar 20, 2024
5a4ac9d
Use 'user-kpi-detail' instead of 'user-detail'
noliveleger Mar 20, 2024
2bcf00e
Merge settings
noliveleger Mar 20, 2024
b6cb411
Use KPI celery app in openrosa app
noliveleger Mar 21, 2024
64d45d3
Fix wrong database selection with guardian
noliveleger Mar 21, 2024
c53a890
Get rid of kobocat form disclaimer django app, use only the KPI one
noliveleger Mar 21, 2024
9916921
Use Kobocat worker
noliveleger Mar 21, 2024
842381e
Cleanup Kobocat static
noliveleger Mar 21, 2024
79a541b
Fix missing KPI url in kobocat templates
noliveleger Mar 21, 2024
81d82ec
Kobocat templates clean-up
noliveleger Mar 22, 2024
090ed9c
Delete useless templates
noliveleger Mar 22, 2024
089213f
Add missing settings
noliveleger Mar 22, 2024
fd6adb0
Fix conditional redirect
noliveleger Mar 22, 2024
771e2c1
Backport latest Kobocat changes
noliveleger Mar 22, 2024
7d74340
Merge branch 'release/2.024.09' into django-kobocat-app
noliveleger Mar 22, 2024
7ab087e
Fix failing tests after merge
noliveleger Mar 22, 2024
6372677
Backport kobotoolbox/kobocat#921
noliveleger Mar 22, 2024
8299ff9
Extend KobocatS3Boto3Storage from fork
noliveleger Mar 26, 2024
215fc76
Use KobocatFileStorage when needed
noliveleger Mar 26, 2024
263df4e
Fix race-condictions with User model signals between KC and KPI
noliveleger Mar 27, 2024
81c32e4
Fix restricted view with weak password
noliveleger Mar 27, 2024
6b166fa
Merge branch 'django-4.2' into django-4.2-kobocat-app
noliveleger Apr 2, 2024
794e9de
Get rid of deprecated "get_storage_class" (backport commit 7ab9529 fr…
noliveleger Apr 2, 2024
824b497
Remove duplicate pip dependency
noliveleger Apr 2, 2024
dbffad5
Remove redundant pip dependency
noliveleger Apr 2, 2024
0abe2ae
Fix Django 4.2 issues after merge
noliveleger Apr 2, 2024
bd7d834
Remove runsv, simplify Dockerfile
noliveleger Apr 5, 2024
aa0e2fd
Use env vars SENTRY_DSN and ENKETO_API_KEY, instead of RAVEN_DSN and …
noliveleger Apr 5, 2024
91564df
Update/Create entrypoints for celery workers
noliveleger Apr 5, 2024
7f533a5
Rename celery workers
noliveleger Apr 5, 2024
55ad7f6
Fix WSGI detection
noliveleger Apr 5, 2024
acd258c
WIP first migration
noliveleger Apr 16, 2024
3fd16f6
Change main.0014 migration to handle kobocat connection
noliveleger Apr 18, 2024
67459ef
Merge branch 'django-4.2' into django-4.2-kobocat-app
noliveleger Apr 24, 2024
6fb02d1
Merge branch 'django-4.2-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Apr 24, 2024
fc3c092
Merge branch 'django-4.2' into django-4.2-kobocat-app
noliveleger Apr 24, 2024
97d4381
Merge branch 'django-4.2-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Apr 24, 2024
05ace41
Merge branch 'release/2.024.12' into django-4.2-kobocat-app
noliveleger May 7, 2024
8ca040a
Merge branch 'release/2.024.17' into django-kobocat-app
noliveleger May 7, 2024
66a8125
Merge branch 'release/2.024.19' into django-kobocat-app
noliveleger May 13, 2024
47a9be5
Fix fix-migrations script
noliveleger May 23, 2024
9d6a96b
Merge branch 'release/2.024.19' into django-kobocat-app
noliveleger May 23, 2024
e5dd11d
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger May 23, 2024
08cc7bb
Remove old auth.User import
noliveleger May 23, 2024
84a52c8
Update pip requirements
noliveleger May 23, 2024
a2d8cdb
Update kobo-service-account dependencies
noliveleger May 24, 2024
97342b8
Remove Python 3.12 from CI matrix
noliveleger May 24, 2024
588e4d5
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger May 24, 2024
d9ff556
Fix typo
noliveleger May 24, 2024
95b6029
Fix media path for Kobocat unit tests
noliveleger May 27, 2024
acbd53a
Fix attachment resize
noliveleger May 27, 2024
6f6e761
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger May 27, 2024
76477a0
Build kobocat media root based on KPI root
noliveleger May 27, 2024
77c2c31
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger May 27, 2024
7b0e1c2
Make attachment resizing work again
noliveleger May 28, 2024
70cda9e
Add tests for resize
noliveleger May 28, 2024
b37ba0b
Handle encoded media path with S3 and FileSystem
noliveleger May 28, 2024
5eb5748
Remove XFRAME_OPTION header from legacy views
noliveleger May 28, 2024
c88d1cf
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger May 28, 2024
5ee0b9e
Merge branch 'refactor-kobo-docker-env-vars' into fix-attachment-resize
noliveleger May 28, 2024
0c77285
Make Gallery use the small picture
noliveleger May 28, 2024
5b149e1
Remove CSV imports from Kobocat API v1
noliveleger May 29, 2024
1d286e8
Update README
noliveleger May 29, 2024
d294378
Stop redirecting to API v1 root when reaching a 404
noliveleger May 29, 2024
8563bd3
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger May 29, 2024
de69f49
Merge branch 'refactor-kobo-docker-env-vars' into fix-attachment-resize
noliveleger May 29, 2024
80bdb47
Fix deleting kobocat form_disclaimer migration endlessly
noliveleger May 30, 2024
fa9bf9b
Merge branch 'refactor-kobo-docker-env-vars' into fix-attachment-resize
noliveleger May 30, 2024
72264de
Fix migrations
noliveleger May 30, 2024
b4aba7b
Fix race conditions related to shadow model writes
noliveleger May 30, 2024
57edb32
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger May 31, 2024
c658388
Merge branch 'release/2.024.19' into django-kobocat-app
noliveleger Jun 17, 2024
f4c4b04
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Jun 17, 2024
b817b0d
Merge branch 'refactor-kobo-docker-env-vars' into fix-migrations-new-…
noliveleger Jun 17, 2024
57aae47
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 17, 2024
12562b1
Add taggit to shared django apps
noliveleger Jun 17, 2024
cd66c3a
Better detection of database from permission codename
noliveleger Jun 17, 2024
c84c7a6
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 17, 2024
d12339e
Replace auth.User refs with kobo_auth.User
noliveleger Jun 17, 2024
29f51a3
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Jun 17, 2024
12249c1
Merge branch 'refactor-kobo-docker-env-vars' into fix-migrations-new-…
noliveleger Jun 17, 2024
a093d65
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 17, 2024
f617366
Create user's profile when validation password from admin
noliveleger Jun 18, 2024
d13d49e
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 18, 2024
3c41f73
Remove FormDisclaimer shadow model
noliveleger Jun 20, 2024
ac270b0
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Jun 20, 2024
cef4dfb
Merge branch 'refactor-kobo-docker-env-vars' into fix-migrations-new-…
noliveleger Jun 20, 2024
c65e6b0
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 20, 2024
a226fd9
Remove useless FormDisclaimer.save() overload
noliveleger Jun 20, 2024
caff490
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Jun 20, 2024
0ba7dce
Merge branch 'refactor-kobo-docker-env-vars' into fix-migrations-new-…
noliveleger Jun 20, 2024
312253d
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 20, 2024
f28d9dc
Remove DigestAuthentication and TokenAuthentication from KoboCAT
noliveleger Jun 20, 2024
eae1349
Backport commit cec4da1 from Kobocat repo
noliveleger Jun 20, 2024
da7706e
Fix unit tests for SocialAppCustomData when migration add data from env
noliveleger Jun 20, 2024
c1ffd8a
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Jun 20, 2024
6033712
Merge branch 'refactor-kobo-docker-env-vars' into fix-migrations-new-…
noliveleger Jun 20, 2024
c12975e
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 20, 2024
3185384
Merge branch 'fix-attachment-resize' into drop-support-csv-import
noliveleger Jun 20, 2024
26e9664
Fix export deletion on KC storage
noliveleger Jun 20, 2024
995ac08
Merge branch 'django-kobocat-app' into refactor-kobo-docker-env-vars
noliveleger Jun 20, 2024
91d4121
Merge branch 'refactor-kobo-docker-env-vars' into fix-migrations-new-…
noliveleger Jun 20, 2024
250ef92
Merge branch 'fix-migrations-new-install' into fix-attachment-resize
noliveleger Jun 20, 2024
8bf8280
Merge branch 'fix-attachment-resize' into drop-support-csv-import
noliveleger Jun 20, 2024
e606fe5
Merge pull request #4981 from kobotoolbox/drop-support-csv-import
jnm Jun 21, 2024
5824225
Merge pull request #4952 from kobotoolbox/fix-attachment-resize
jnm Jun 21, 2024
0a021a8
Merge pull request #4960 from kobotoolbox/fix-migrations-new-install
jnm Jun 21, 2024
64cee41
Merge pull request #4948 from kobotoolbox/refactor-kobo-docker-env-vars
jnm Jun 21, 2024
5e1d710
Typo
noliveleger Jun 21, 2024
aaf91d7
Force use open_rosa db when updated sequences on user creation
noliveleger Jun 21, 2024
0d0bc4b
Move signals to their own files
noliveleger Jun 24, 2024
5e38781
Remove Django-Digest in Kobocat
noliveleger Jun 24, 2024
08114f4
Fix mock attachment absolute path and protected path properties
noliveleger Jun 24, 2024
78f5717
Merge branch 'main' into release/2.024.19
noliveleger Jun 24, 2024
70bd0c5
Merge branch 'release/2.024.19' into django-kobocat-app
noliveleger Jun 24, 2024
459dd9c
Merge branch 'release/2.024.25' into django-kobocat-app
noliveleger Jun 25, 2024
a6826fc
Update README
noliveleger Jun 25, 2024
4065c43
Update README for openrosa
noliveleger Jun 25, 2024
20d83de
Merge branch 'release/2.024.25' into django-kobocat-app
noliveleger Jun 25, 2024
097fee2
Remove useless comments
noliveleger Jun 26, 2024
6a0e582
Fix KML exports
noliveleger Jul 10, 2024
193c579
Force root route to be handled by KPI for password validation
noliveleger Jul 10, 2024
1608a62
Overload createsuperuser command to support user profile creation at …
noliveleger Jul 10, 2024
b720c6c
Remove Useless Celery pid GC
noliveleger Jul 10, 2024
1b8c99c
Add defusexml to requirements.in
noliveleger Jul 22, 2024
98de7cf
Merge branch 'release/2.024.25' into django-kobocat-app
noliveleger Jul 22, 2024
bd598fc
Remove KPI_ prefix from broker and storage settings
bufke Jul 23, 2024
6191e65
quote
bufke Jul 23, 2024
1b75bc6
Merge pull request #5028 from kobotoolbox/django-kobocat-app-rename-s…
noliveleger Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
SERVICE_ACCOUNT_BACKEND_URL: redis://localhost:6379/4
CACHE_URL: redis://localhost:6379/3
ENKETO_REDIS_MAIN_URL: redis://localhost:6379/0
KOBOCAT_MEDIA_ROOT: /tmp/test_media
strategy:
matrix:
python-version: ['3.8', '3.10', '3.12']
python-version: ['3.8', '3.10']
services:
postgres:
image: postgis/postgis:14-3.4
Expand Down
29 changes: 4 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ ENV KPI_LOGS_DIR=/srv/logs \
TMP_DIR=/srv/tmp \
UWSGI_USER=kobo \
UWSGI_GROUP=kobo \
SERVICES_DIR=/etc/service \
CELERY_PID_DIR=/var/run/celery \
INIT_PATH=/srv/init

##########################################
Expand All @@ -40,13 +38,7 @@ ENV KPI_LOGS_DIR=/srv/logs \
RUN mkdir -p "${NGINX_STATIC_DIR}" && \
mkdir -p "${KPI_SRC_DIR}" && \
mkdir -p "${KPI_NODE_PATH}" && \
mkdir -p "${TMP_DIR}" && \
mkdir -p ${CELERY_PID_DIR} && \
mkdir -p ${SERVICES_DIR}/uwsgi && \
mkdir -p ${SERVICES_DIR}/celery && \
mkdir -p ${SERVICES_DIR}/celery_low_priority && \
mkdir -p ${SERVICES_DIR}/celery_beat && \
mkdir -p "${INIT_PATH}"
mkdir -p "${TMP_DIR}"

##########################################
# Install `apt` packages. #
Expand All @@ -63,6 +55,7 @@ RUN apt-get -qq update && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" \
| tee /etc/apt/sources.list.d/nodesource.list && \
apt-get -qq update && \
apt-get -qq -y install openjdk-17-jre && \
apt-get -qq -y install --no-install-recommends \
ffmpeg \
gdal-bin \
Expand All @@ -76,7 +69,6 @@ RUN apt-get -qq update && \
postgresql-client \
procps \
rsync \
runit-init \
vim-tiny \
wait-for-it && \
apt-get clean && \
Expand Down Expand Up @@ -161,28 +153,15 @@ RUN echo "export PATH=${PATH}" >> /etc/profile && \
echo 'source /etc/profile' >> /root/.bashrc && \
echo 'source /etc/profile' >> /home/${UWSGI_USER}/.bashrc


# Remove getty* services to avoid errors of absent tty at sv start-up
RUN rm -rf /etc/runit/runsvdir/default/getty-tty*

# Create symlinks for runsv services
RUN ln -s "${KPI_SRC_DIR}/docker/run_uwsgi.bash" "${SERVICES_DIR}/uwsgi/run" && \
ln -s "${KPI_SRC_DIR}/docker/run_celery.bash" "${SERVICES_DIR}/celery/run" && \
ln -s "${KPI_SRC_DIR}/docker/run_celery_low_priority.bash" "${SERVICES_DIR}/celery_low_priority/run" && \
ln -s "${KPI_SRC_DIR}/docker/run_celery_beat.bash" "${SERVICES_DIR}/celery_beat/run"


# Add/Restore `UWSGI_USER`'s permissions
# chown of `${TMP_DIR}/.npm` is a hack needed for kobo-install-based staging deployments;
# see internal discussion at https://chat.kobotoolbox.org/#narrow/stream/4-Kobo-Dev/topic/Unu.2C.20du.2C.20tri.2C.20kvar.20deployments/near/322075
RUN chown -R ":${UWSGI_GROUP}" ${CELERY_PID_DIR} && \
chmod g+w ${CELERY_PID_DIR} && \
chown -R "${UWSGI_USER}:${UWSGI_GROUP}" ${KPI_SRC_DIR}/emails/ && \
RUN chown -R "${UWSGI_USER}:${UWSGI_GROUP}" ${KPI_SRC_DIR}/emails/ && \
chown -R "${UWSGI_USER}:${UWSGI_GROUP}" ${KPI_LOGS_DIR} && \
chown -R "${UWSGI_USER}:${UWSGI_GROUP}" ${TMP_DIR} && \
chown -R root:root "${TMP_DIR}/.npm"


EXPOSE 8000

CMD ["/bin/bash", "-c", "exec ${KPI_SRC_DIR}/docker/init.bash"]
CMD ["/bin/bash", "docker/entrypoint.sh"]
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@

We're open for [contributions](./CONTRIBUTING.md)!

## Important notice when upgrading from any release older than [`2.024.19`](https://github.com/kobotoolbox/kpi/releases/tag/2.024.19)

Prior to release [`2.024.19`](https://github.com/kobotoolbox/kpi/releases/tag/2.024.19), this project (KPI) and [KoboCAT](https://github.com/kobotoolbox/kobocat) were two separated projects.
KoboCAT is now part of KPI code base and its repository has been archived.

KoboCAT deprecation notices will be maintained in this repository.
[More details here](./kobo/apps/openrosa/README.md)

## Important notice when upgrading from any release older than [`2.020.18`](https://github.com/kobotoolbox/kpi/releases/tag/2.020.18)

Prior to release [`2.020.18`](https://github.com/kobotoolbox/kpi/releases/tag/2.020.18), this project (KPI) and [KoBoCAT](https://github.com/kobotoolbox/kobocat) both shared a common Postgres database. They now each have their own. **If you are upgrading an existing single-database installation, you must follow [these instructions](https://community.kobotoolbox.org/t/upgrading-to-separate-databases-for-kpi-and-kobocat/7202)** to migrate the KPI tables to a new database and adjust your configuration appropriately.
Prior to release [`2.020.18`](https://github.com/kobotoolbox/kpi/releases/tag/2.020.18), this project (KPI) and [KoboCAT](https://github.com/kobotoolbox/kobocat) both shared a common Postgres database. They now each have their own. **If you are upgrading an existing single-database installation, you must follow [these instructions](https://community.kobotoolbox.org/t/upgrading-to-separate-databases-for-kpi-and-kobocat/7202)** to migrate the KPI tables to a new database and adjust your configuration appropriately.

If you do not want to upgrade at this time, please use the [`shared-database-obsolete`](https://github.com/kobotoolbox/kpi/tree/shared-database-obsolete) branch instead.

Expand All @@ -35,7 +43,7 @@ syntax, see the documentation at the top of

## Admin reports

There are several types of data reports available to superusers.
There are several types of data reports available to superusers.
* Full list of users including their details provided during signup, number of deployed projects (XForm count), number of submissions, date joined, and last login: `<kpi base url>/superuser_stats/user_report/`. File being created is a CSV, so don't download immediately to wait for server to be finished writing to the file (it will download even if incomplete).
* Monthly aggregate figures for number of forms, deployed projects, and submissions (from kobocat): `<kc server domain>/<superuser username>/superuser_stats/`

Expand Down
5 changes: 5 additions & 0 deletions dependencies/pip/dev_requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ pytest
pytest-cov
pytest-django
pytest-env


# Kobocat
httmock
simplejson
Loading
Loading