Skip to content

Commit 71e9f1d

Browse files
committed
fixes regex mass update
1 parent 57ac21d commit 71e9f1d

File tree

5 files changed

+233
-3
lines changed

5 files changed

+233
-3
lines changed

Makefile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.PHONY: docs
2+
3+
help:
4+
@echo help
5+
6+
reset_db:
7+
dropdb --if-exists country_workspace
8+
createdb country_workspace
9+
./manage.py makemigrations
10+
./manage.py upgrade
11+
./manage.py sync
12+
./manage.py demo
13+
14+
15+
clean:
16+
rm -fr dist coverage.xml db.sqlite3 .coverage ./~build build
17+
find . -name __pycache__ | xargs rm -fr
18+
find . -name *.min.min.js | xargs rm
19+
20+
lint:
21+
pre-commit run --all-files
22+
23+
24+
docs:
25+
./manage.py env -f "{key} \
26+
\\n \n{value}\n\n{help}" > ./docs/src/settings.md
27+
#mkdocs serve
28+
29+
commit-all:
30+
cd /Users/sax/Documents/data/PROGETTI/UNICEF/hope-flex-fields && git commit -m "updates" && git push
31+
cd /Users/sax/Documents/data/PROGETTI/UNICEF/hope-smart-export && git commit -m "updates" && git push
32+
cd /Users/sax/Documents/data/PROGETTI/UNICEF/hope-smart-import && git commit -m "updates" && git push
33+
34+
35+
i18n: ## i18n support
36+
# get and sync weblate
37+
git checkout weblate
38+
git pull
39+
git checkout develop
40+
git merge weblate
41+
# process po
42+
cd src && django-admin makemessages --all --settings=sos.config.settings -d djangojs --pythonpath=. --ignore=~*
43+
cd src && django-admin makemessages --all --settings=sos.config.settings --pythonpath=. --ignore=~*
44+
cd src && django-admin compilemessages --settings=sos.config.settings --pythonpath=. --ignore=~*
45+
git add src/sos/LOCALE
46+
git commit -am "Update translations"
47+
git push
48+
# add changes to weblate
49+
git checkout weblate
50+
git merge develop
51+
git push
52+
git checkout develop

docker/Makefile

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# envs to set before use this script
2+
.ONESHELL:
3+
4+
#BASE?=$(shell echo "${VERSION}" | sed "s/\([0-9]*\)\.\([0-9]*\)\.\(.*\)/\1.\2/g" )
5+
VERSION := $(shell grep -m 1 version ../pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
6+
RELEASE = $(shell grep -m 1 version ../pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
7+
LOCK_CHECKSUM?=$(shell sha1sum ../uv.lock | awk '{print $$1}')
8+
LOCK_HASH?=$(shell echo ${LOCK_CHECKSUM} | cut -c 1-8)
9+
10+
DOCKER_IMAGE_NAME?=unicef/hope-country-workspace
11+
12+
CMD?=run
13+
VERSION?=dev
14+
STAGE?=dist
15+
16+
RUN_OPTIONS?=
17+
BUILD_OPTIONS?=
18+
19+
BUILD_DATE:="$(shell date +"%Y-%m-%d %H:%M")"
20+
SOURCE_COMMIT=$(shell git rev-parse --short HEAD)
21+
22+
.PHONY: help runlocal tests
23+
.DEFAULT_GOAL := help
24+
25+
26+
define PRINT_HELP_PYSCRIPT
27+
import re, sys
28+
29+
for line in sys.stdin:
30+
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
31+
if match:
32+
target, help = match.groups()
33+
print("%-20s %s" % (target, help))
34+
endef
35+
export PRINT_HELP_PYSCRIPT
36+
37+
BROWSER := python -c "$$BROWSER_PYSCRIPT"
38+
39+
help:
40+
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
41+
42+
43+
.build:
44+
DOCKER_BUILDKIT=1 cd .. && docker build \
45+
--build-arg VERSION=${VERSION} \
46+
--build-arg RELEASE=${RELEASE} \
47+
--build-arg BUILD_DATE=${BUILD_DATE} \
48+
--build-arg GIT_SHA=${SOURCE_COMMIT} \
49+
--target ${STAGE} \
50+
${BUILD_OPTIONS} \
51+
-t ${DOCKER_IMAGE} \
52+
-f docker/Dockerfile .
53+
docker images | grep "${DOCKER_IMAGE_NAME}" | grep ${VERSION}-${STAGE}
54+
docker inspect ${DOCKER_IMAGE} | jq -r '.[0].Config.Labels'
55+
56+
build: ## build image
57+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-${STAGE} \
58+
$(MAKE) .build
59+
60+
.build-stage:
61+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-${STAGE} \
62+
$(MAKE) .build
63+
64+
base_os:
65+
STAGE=base_os $(MAKE) .build-stage
66+
67+
builder:
68+
STAGE=builder $(MAKE) .build-stage
69+
70+
tests:
71+
STAGE=tests $(MAKE) .build-stage
72+
73+
production:
74+
STAGE=production $(MAKE) .build-stage
75+
76+
dist:
77+
STAGE=dist $(MAKE) .build-stage
78+
79+
80+
step1: base_os
81+
step2: builder
82+
step3: tests
83+
step4: production
84+
step5: dist
85+
86+
build1: base_os
87+
build2: builder
88+
build3: tests
89+
build4: production
90+
build5: dist
91+
92+
.run:
93+
cd .. && docker run \
94+
--rm \
95+
-p 8000:8000 \
96+
-e HOPE_API_TOKEN=${HOPE_API_TOKEN} \
97+
-e ADMIN_EMAIL="${ADMIN_EMAIL}" \
98+
-e ADMIN_PASSWORD="${ADMIN_PASSWORD}" \
99+
-e ALLOWED_HOSTS="*" \
100+
-e AUTHENTICATION_BACKENDS=\
101+
-e CACHE_URL="redis://192.168.66.66:6379/0" \
102+
-e CELERY_BROKER_URL=redis://192.168.66.66:6379/0 \
103+
-e CSRF_COOKIE_SECURE=False \
104+
-e CSRF_TRUSTED_ORIGINS=http://localhost \
105+
-e DATABASE_URL="${DATABASE_URL}" \
106+
-e DEBUG="1" \
107+
-e DJANGO_ADMIN_URL=admin/ \
108+
-e LOGGING_LEVEL="DEBUG" \
109+
-e SECRET_KEY=liujhljhlkjhlkjhlkj \
110+
-e SOCIAL_AUTH_REDIRECT_IS_HTTPS="False" \
111+
-e SENTRY_DSN="${SENTRY_DSN}" \
112+
-e SUPERUSERS="sax," \
113+
${RUN_OPTIONS} \
114+
-t ${DOCKER_IMAGE} \
115+
${CMD}
116+
117+
run:
118+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-dist \
119+
STAGE='dist' \
120+
CMD='run' \
121+
$(MAKE) .run
122+
123+
.run-step:
124+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-${STAGE} \
125+
RUN_OPTIONS="-it" \
126+
CMD='/bin/bash' \
127+
$(MAKE) .run
128+
129+
130+
131+
run1:
132+
STAGE=base_os \
133+
$(MAKE) .run-step
134+
135+
run2:
136+
STAGE=builder \
137+
$(MAKE) .run-step
138+
139+
run3:
140+
STAGE=tests \
141+
$(MAKE) .run-step
142+
143+
run4:
144+
STAGE=production \
145+
$(MAKE) .run-step
146+
147+
run5:
148+
STAGE=dist \
149+
$(MAKE) .run-step
150+
151+
all: step1 step2 step3 step4 step5
152+
153+
154+
.shell:
155+
RUN_OPTIONS=-it \
156+
CMD=/bin/bash \
157+
$(MAKE) .run
158+
159+
shell1:
160+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-base_os \
161+
$(MAKE) .shell
162+
163+
shell2:
164+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-builder \
165+
$(MAKE) .shell
166+
167+
shell3:
168+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-tests \
169+
$(MAKE) .shell
170+
171+
shell4:
172+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-production \
173+
$(MAKE) .shell
174+
175+
shell5:
176+
DOCKER_IMAGE=${DOCKER_IMAGE_NAME}:${VERSION}-dist \
177+
$(MAKE) .shell

src/country_workspace/workspaces/admin/cleaners/regex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class UpdateResult(NamedTuple):
4747
updated: Any
4848
data_type: str
4949

50+
5051
def update_json(json: dict[str, Any], key: str, pattern: re.Pattern[str], replacement: str) -> UpdateResult:
5152
original_value = json.get(key)
5253
if isinstance(original_value, int):

src/country_workspace/workspaces/templates/workspace/actions/regex.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
<td>
4747
{{ new }}
4848
</td>
49-
<td>
50-
{{ data_type }}
51-
</td>
49+
<td>
50+
{{ data_type }}
51+
</td>
5252
</tr>
5353
{% endfor %}
5454
</table>

worker

12 KB
Binary file not shown.

0 commit comments

Comments
 (0)