Skip to content

Commit 473b119

Browse files
authored
Merge pull request #91 from unicef/feature/adminfix2
Updated admin
2 parents 3699a87 + 57e1ab6 commit 473b119

5 files changed

Lines changed: 20 additions & 123 deletions

File tree

README.md

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,16 @@
1-
ABOUT HOPE Country Report
1+
HOPE Country Report
22
=========================
33

44

5-
## Contributing
5+
[![Ci Status](https://github.com/unicef/hope-country-report/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/unicef/hope-country-report/actions/workflows/ci.yml)
6+
[![codecov](https://codecov.io/github/unicef/hope-country-report/graph/badge.svg)](https://codecov.io/github/unicef/hope-country-report)
7+
[![Documentation](https://github.com/unicef/hope-country-report/actions/workflows/docs.yml/badge.svg)](https://unicef.github.io/hope-country-report/)
8+
[![Docker Pulls](https://img.shields.io/docker/pulls/unicef/hope-country-report)](https://hub.docker.com/r/unicef/hope-country-report/tags)
69

7-
### System Requirements
10+
Hope Country Report (HCR) is a pivotal component within the Hope platform, specifically designed to empower UNICEF country offices with the ability to generate customized reports tailored to their unique requirements.
811

9-
- python 3.12
10-
- [direnv](https://direnv.net/) - not mandatory but strongly recommended
11-
- [uv](https://docs.astral.sh/uv/)
1212

13-
## Configure development environment
13+
## Documentation
1414

15-
**WARNING**
16-
> HCR implements **security first** policy. It means that configuration default values are "almost" production compliant.
17-
>
18-
> Es. `DEBUG=False` or `SECURE_SSL_REDIRECT=True`.
19-
>
20-
> Be sure to run `./manage.py env --check` and `./manage.py env -g all` to check and display your configuration
21-
22-
23-
24-
### 1. Clone repo and install requirements
25-
git clone https://github.com/unicef/hope-country-report
26-
cd hope-country-report
27-
uv sync
28-
29-
### 2. configure your environment
30-
31-
Uses `./manage.py env` to configure your environment
32-
33-
./manage.py env > .evnvrc
34-
35-
Customize your env for development:
36-
37-
export DEBUG=True
38-
export SESSION_COOKIE_NAME="hcr_test_session"
39-
export SESSION_COOKIE_DOMAIN=""
40-
export SESSION_COOKIE_SECURE=False
41-
export SECURE_HSTS_SECONDS=0
42-
export SECURE_HSTS_PRELOAD=False
43-
export CSRF_COOKIE_SECURE=False
44-
export SECURE_SSL_REDIRECT=False
45-
export CELERY_TASK_ALWAYS_EAGER=True
46-
export AUTHENTICATION_BACKENDS="hope_country_report.utils.tests.backends.AnyUserAuthBackend"
47-
export SIGNING_BACKEND="hope_country_report.utils.signer.DebugSigner"
48-
49-
50-
and check required (and optional) variables to put
51-
52-
./manage.py env --check
53-
54-
55-
### 3. Run upgrade to run migrations and initial setup
56-
57-
./manage.py upgrade
58-
59-
### 4. (Optional) Create some sample data
60-
61-
./manage.py demo
62-
63-
> If `DEBUG=True` and `AUTHENTICATION_BACKENDS="hope_country_report.utils.tests.backends.AnyUserAuthBackend"` you can login using any username/password. Note that:
64-
65-
> - If the username is ADMIN_EMAIL you will be superuser
66-
> - If username starts with `admin` will be created a superuser
67-
> - If username starts with `user` will be created a standard user (no staff, no admin)
15+
- Documentation: https://unicef.github.io/hope-country-report/
16+
- Tutorials : https://unicef.github.io/hope-country-report/tutorials/

docker/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BASE_IMAGE?=hope-contry-report
2-
CHECKSUM?=$(shell sha1sum ../pdm.lock | awk '{print $$1}')
2+
CHECKSUM?=$(shell sha1sum ../uv.lock | awk '{print $$1}')
33
LOCK_SHA?=$(shell echo ${CHECKSUM} | cut -c 1-8)
44
COMMIT_SHA?=$(shell git rev-parse --short HEAD)
55
VERSION?=dev

pyproject.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[project]
22
name = "hcr"
33
version = "0.1"
4-
description = ""
4+
description = "Hope Country Report for displaying Hope data"
55
authors = [
66
{name = "sax", email = "s.apostolico@gmail.com"},
7+
{name = "stockman", email = "kuristockyrugano@gmail.com"},
78
]
89
readme = "README.md"
9-
license = {text = "Private"}
10+
license = {text = "MIT"}
1011
requires-python = ">=3.12"
1112

1213
dependencies = [
@@ -99,11 +100,8 @@ dependencies = [
99100
select = ["E4", "E7", "E9", "F"]
100101
ignore = ["F403",]
101102

102-
# Allow fix for all enabled rules (when `--fix`) is provided.
103103
fixable = ["ALL"]
104104
unfixable = []
105-
106-
# Allow unused variables when underscore-prefixed.
107105
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
108106

109107
[tool.ruff]
@@ -131,11 +129,9 @@ exclude = [
131129
"venv",
132130
]
133131

134-
# Same as Black.
135132
line-length = 120
136133
indent-width = 4
137134

138-
# Assume Python 3.12
139135
target-version = "py312"
140136

141137
[tool.isort]

src/hope_country_report/apps/core/admin.py

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from typing import Any, Optional, TYPE_CHECKING
1+
from typing import TYPE_CHECKING
22

33
from django import forms
44
from django.contrib import admin
55
from django.db.models.fields.json import JSONField
6-
from django.http import HttpRequest
7-
from django.utils.translation import gettext_lazy as _
86

97
from admin_extra_buttons.decorators import button
108
from admin_extra_buttons.mixins import ExtraButtonsMixin
@@ -27,53 +25,7 @@ class BaseAdmin(DisplayAllMixin, ExtraButtonsMixin, admin.ModelAdmin): # type:
2725

2826
@admin.register(User)
2927
class UserAdmin(_UserAdminPlus): # type: ignore
30-
fieldsets = (
31-
(None, {"fields": (("username", "azure_id"), "password")}),
32-
(
33-
_("Preferences"),
34-
{
35-
"fields": (
36-
(
37-
"language",
38-
"timezone",
39-
),
40-
("date_format", "time_format"),
41-
)
42-
},
43-
),
44-
(
45-
_("Personal info"),
46-
{
47-
"fields": (
48-
(
49-
"first_name",
50-
"last_name",
51-
),
52-
("email", "display_name"),
53-
("job_title",),
54-
)
55-
},
56-
),
57-
(_("Important dates"), {"fields": ("last_login", "date_joined")}),
58-
)
59-
60-
def get_fieldsets(self, request: HttpRequest, obj: Optional[Any] = None) -> Any:
61-
if not obj:
62-
return self.add_fieldsets
63-
fieldsets = list(_UserAdminPlus.fieldsets)
64-
if request.user.is_superuser:
65-
fieldsets.append(
66-
(
67-
_("Admin"),
68-
{
69-
"fields": (
70-
"is_staff",
71-
"groups",
72-
)
73-
},
74-
)
75-
)
76-
return fieldsets
28+
pass
7729

7830

7931
class UserRoleForm(forms.ModelForm): # type: ignore

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ setenv =
1818
PYTHONPATH={toxinidir}/src
1919

2020
deps =
21-
pdm
21+
uv
2222

2323
allowlist_externals =
2424
mkdir
2525

2626
commands =
27-
pdm install
28-
pdm run pytest tests \
27+
uv sync
28+
uv run pytest tests \
2929
-v \
3030
--create-db \
3131
--echo-version django
@@ -36,12 +36,12 @@ commands =
3636

3737
[testenv:package]
3838
deps =
39-
pdm
39+
uv
4040

4141
setenv =
4242
DJANGO_SETTINGS_MODULE=hope_country_report.config.settings
4343
SECRET_KEY=super-secret-key
4444

4545
commands =
46-
pdm sync --prod
46+
uv sync
4747
python -c "import django; django.setup(); from pkgutil import walk_packages; [loader.find_module(modname).load_module(modname) for loader, modname, _ in walk_packages(['./src/'])]"

0 commit comments

Comments
 (0)