-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
176 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
* | ||
|
||
!docker/bin | ||
!docker/conf | ||
!src/country_workspace/**/* | ||
|
||
!pyproject.toml | ||
!uv.lock | ||
!src | ||
|
||
!LICENSE | ||
!README.md | ||
!AUTHORS | ||
!CHANGES.md | ||
!MANIFEST.in | ||
|
||
*.egg-info | ||
.* | ||
~* | ||
**/~* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
exclude * | ||
exclude requirements.txt | ||
|
||
include README.md | ||
include MANIFEST.in | ||
include AUTHORS | ||
include CHANGES.md | ||
include LICENSE | ||
|
||
include pyproject.toml | ||
include *.py | ||
include uv.lock | ||
|
||
recursive-include src/country_workspace * | ||
recursive-include src/country_workspace *.html | ||
recursive-exclude tests * | ||
|
||
prune **/~* | ||
global-exclude .* | ||
global-exclude *~ | ||
global-exclude ~* | ||
exclude manage.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,28 @@ | ||
FROM python:3.12-slim-bookworm as python_base | ||
ARG GOSU_VERSION=1.17 | ||
ARG GOSU_SHA256=bbc4136d03ab138b1ad66fa4fc051bafc6cc7ffae632b069a53657279a450de3 | ||
|
||
|
||
RUN set -x \ | ||
&& runtimeDeps=" \ | ||
libxml2 \ | ||
" \ | ||
&& buildDeps=" \ | ||
wget \ | ||
" \ | ||
&& apt-get update && apt-get install -y --no-install-recommends ${buildDeps} ${runtimeDeps} \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& wget --quiet -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" \ | ||
&& echo "$GOSU_SHA256 /usr/local/bin/gosu" | sha256sum --check --status \ | ||
&& chmod +x /usr/local/bin/gosu \ | ||
&& apt-get purge -y --auto-remove $buildDeps | ||
|
||
RUN groupadd --gid 1024 app \ | ||
&& adduser --disabled-login --disabled-password --no-create-home --ingroup app -q user | ||
|
||
|
||
FROM python_base AS builder | ||
|
||
RUN set -x \ | ||
&& buildDeps="build-essential \ | ||
cmake \ | ||
|
@@ -16,39 +38,40 @@ RUN set -x \ | |
&& apt-get install -y --no-install-recommends $buildDeps \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
RUN pip install uwsgi uv | ||
RUN pip install uv | ||
|
||
|
||
COPY docker/conf /conf/ | ||
COPY docker/bin /usr/local/bin/ | ||
COPY pyproject.toml uv.lock AUTHORS LICENSE README.md MANIFEST.in /app/ | ||
COPY src /app/src | ||
|
||
WORKDIR /app | ||
COPY . /app/ | ||
|
||
RUN uv venv \ | ||
&& uv sync --no-dev --no-editable --frozen \ | ||
&& uv pip install . \ | ||
&& ls -al /app/.venv/ | ||
|
||
FROM python_base | ||
RUN uv sync --no-dev --no-editable --frozen | ||
#RUN ls -al .venv/lib/python3.12/site-packages/country_workspace/workspaces/ | ||
|
||
#RUN uv export --no-dev --no-editable --frozen --no-sources --no-hashes -o requirement.txt \ | ||
# && python -m venv .venv \ | ||
# && .venv/bin/pip install -r requirement.txt | ||
|
||
# | ||
FROM python_base | ||
ENV PATH=/app/.venv/bin:$PATH | ||
ENV PATH=/app/.venv/bin:$PATH \ | ||
DJANGO_SETTINGS_MODULE=country_workspace.config.settings \ | ||
UWSGI_PROCESSES=4 | ||
|
||
COPY docker/conf /conf/ | ||
COPY docker/bin /usr/local/bin/ | ||
COPY docker/bin/* /usr/local/bin/ | ||
COPY --chown=user:app --from=builder /app/.venv /app/.venv | ||
#COPY --chown=user:app --from=builder /usr/local/bin/uwsgi /usr/local/bin/uwsgi | ||
|
||
|
||
EXPOSE 8000 | ||
ENTRYPOINT exec docker-entrypoint.sh "$0" "$@" | ||
CMD ["run"] | ||
|
||
|
||
LABEL distro="final" | ||
LABEL maintainer="[email protected]" | ||
LABEL org.opencontainers.image.authors="[email protected]" | ||
LABEL org.opencontainers.image.created="$BUILD_DATE" | ||
#LABEL org.opencontainers.image.created="$BUILD_DATE" | ||
LABEL org.opencontainers.image.description="Hope Country Workspace" | ||
LABEL org.opencontainers.image.documentation="https://github.com/unicef/hope-country-workspace/" | ||
LABEL org.opencontainers.image.licenses="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/blob/${SOURCE_COMMIT:-master}/LICENSE" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
[uwsgi] | ||
http=0.0.0.0:8000 | ||
enable-threads=0 | ||
honour-range=1 | ||
master=1 | ||
;enable-threads=0 | ||
;honour-range=1 | ||
;master=1 | ||
module=country_workspace.config.wsgi | ||
processes=$(UWSGI_PROCESSES) | ||
;virtualenv=/code/.venv/ | ||
;processes=$(UWSGI_PROCESSES) | ||
;virtualenv=/app/.venv/ | ||
;pythonpath=/app/.venv/lib/python3.12/site-packages | ||
;virtualenv=%(_) | ||
;venv=%(_) | ||
;chdir=code/ | ||
username = user | ||
gropuname = app | ||
uid = user | ||
gid = app | ||
;username = user | ||
;gropuname = app | ||
;offload-threads=%k | ||
;static-gzip-all=true | ||
route = /static/(.*) static:$(STATIC_ROOT)/$1 | ||
http-keepalive = 1 | ||
collect-header=Content-Type RESPONSE_CONTENT_TYPE | ||
mimefile=/etc/mime.types | ||
;route = /static/(.*) static:$(STATIC_ROOT)/$1 | ||
;http-keepalive = 1 | ||
;collect-header=Content-Type RESPONSE_CONTENT_TYPE | ||
mimefile=/conf/mime.types | ||
;honour-stdin = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from django import forms | ||
from django.db import transaction | ||
from django.db.models import QuerySet | ||
from django.shortcuts import render | ||
from django.utils.translation import gettext as _ | ||
|
||
if TYPE_CHECKING: | ||
from hope_flex_fields.models import DataChecker | ||
|
||
from country_workspace.types import Beneficiary | ||
from country_workspace.workspaces.admin.hh_ind import CountryHouseholdIndividualBaseAdmin | ||
|
||
RegexRule = tuple[str, str] | ||
RegexRules = list(RegexRule) | ||
|
||
|
||
class RegexUpdateForm(forms.Form): | ||
action = forms.CharField(widget=forms.HiddenInput) | ||
select_across = forms.BooleanField(widget=forms.HiddenInput) | ||
_selected_action = forms.CharField(widget=forms.HiddenInput) | ||
field = forms.ChoiceField(choices=[]) | ||
|
||
def __init__(self, *args, **kwargs): | ||
checker: "DataChecker" = kwargs.pop("checker") | ||
super().__init__(*args, **kwargs) | ||
field_names = checker.get_form()().fields.keys() | ||
self.fields["field"].choices = zip(field_names, field_names) | ||
|
||
|
||
def regex_update_impl(records: "QuerySet[Beneficiary]", config: "RegexRules") -> None: | ||
with transaction.atomic(): | ||
for record in records: | ||
pass | ||
# for field_name, attrs in config.items(): | ||
# op, new_value = attrs | ||
# old_value = record.flex_fields[field_name] | ||
# func = operations.get_function_by_id(op) | ||
# record.flex_fields[field_name] = func(old_value, new_value) | ||
# record.save() | ||
|
||
|
||
def regex_update(model_admin: "CountryHouseholdIndividualBaseAdmin", request, queryset): | ||
ctx = model_admin.get_common_context(request, title=_("Mass update")) | ||
ctx["checker"] = checker = model_admin.get_checker(request) | ||
form = RegexUpdateForm(request.POST, checker=checker) | ||
ctx["form"] = form | ||
if "_apply" in request.POST: | ||
if form.is_valid(): | ||
regex_update_impl(queryset.all(), form.get_selected()) | ||
return render(request, "actions/mass_update.html", ctx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters