Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
f8ece34
PB-902 Align setup instructions with Makefile
asteiner-swisstopo Sep 9, 2024
f9bf0b7
PB-902 Create .env before launching subshell
asteiner-swisstopo Sep 9, 2024
0528de9
PB-902 Add module debugby to enable debugging
asteiner-swisstopo Sep 9, 2024
b923d30
PB-902 Add dedicated make target for debugging
asteiner-swisstopo Sep 9, 2024
2f368b1
PB-902 Set DEBUG flag to true by default
asteiner-swisstopo Sep 9, 2024
b1d0eff
PB-902 Set DB port to 5432 in order match other settings
asteiner-swisstopo Sep 9, 2024
1911a92
PB-902 Explain how to create launch.json in GUI
asteiner-swisstopo Sep 9, 2024
43b7dd8
PB-902 Explain how to apply first migration
asteiner-swisstopo Sep 9, 2024
c1b706b
PB-902 Unlist vscode config from version control
asteiner-swisstopo Sep 9, 2024
cc5ab8f
PB-902 Change order of instructions such that DB is up already
asteiner-swisstopo Sep 10, 2024
c7172c1
PB-902 Add make target test-debug as described in README
asteiner-swisstopo Sep 10, 2024
d193ee3
PB-902 Ignore the static files in "var"
asteiner-swisstopo Sep 10, 2024
82f762a
PB-902 Clarify how to make test discovery work in vs code
asteiner-swisstopo Sep 10, 2024
8709507
PB-902 Align fields for model Provider with API specs
asteiner-swisstopo Sep 11, 2024
1782558
PB-902 Add new stub application "distributions"
asteiner-swisstopo Sep 11, 2024
6dbb915
PB-902 Register app "distributions" for installation
asteiner-swisstopo Sep 11, 2024
67d5ff6
PB-902 Add Romansh to provider model
asteiner-swisstopo Sep 11, 2024
9dc5b84
PB-902 Make DE, FR and EN mandatory in a form
asteiner-swisstopo Sep 11, 2024
fb9ba6a
PB-902 Add model Attribution
asteiner-swisstopo Sep 11, 2024
fd87423
PB-902 Add Django model Dataset
asteiner-swisstopo Sep 12, 2024
ea59b45
PB-902 Apply automatic code formatting
asteiner-swisstopo Sep 12, 2024
fe8fe8f
PB-902 Remove unused import in stub module
asteiner-swisstopo Sep 16, 2024
84bcbc6
PB-902 Register new models for display in admin panel
asteiner-swisstopo Sep 16, 2024
eea5792
PB-902 Use fully qualified exception name
asteiner-swisstopo Sep 16, 2024
0b5d926
PB-902 Add context to texts marked for translation
asteiner-swisstopo Sep 16, 2024
904b045
PB-902 Add DB migrations after model changes
asteiner-swisstopo Sep 16, 2024
df5e3ce
PB-902 Make optional fields nullable in model Attribution
asteiner-swisstopo Sep 18, 2024
abe0de1
PB-902 Make optional fields nullable in model Provider
asteiner-swisstopo Sep 18, 2024
8e860e9
PB-902 Change test name to be in line with similar ones for other models
asteiner-swisstopo Sep 18, 2024
96b62d3
PB-902 Refactor test to be more succinct
asteiner-swisstopo Sep 23, 2024
a922e3c
Merge pull request #21 from geoadmin/feat-PB-902-setup-models-v1-in-s…
asteiner-swisstopo Sep 23, 2024
b2a3537
PB-903 Configure project to work with pytest
asteiner-swisstopo Sep 23, 2024
e3c5468
PB-903 Remove the unnecessary test-debug Makefile target
asteiner-swisstopo Sep 23, 2024
2522aa7
Merge pull request #22 from geoadmin/feat-PB-903-configure-pytest
asteiner-swisstopo Sep 23, 2024
7663b6a
PB-903 Move api object to dedicated module
asteiner-swisstopo Sep 23, 2024
c71355e
PB-903 Add draft of getProvider end point
asteiner-swisstopo Sep 23, 2024
24b978c
PB-903 Ignore warning from django-ninja
asteiner-swisstopo Sep 24, 2024
993e118
PB-903 Add function to get class field from language suffix
asteiner-swisstopo Sep 24, 2024
90679b7
PB-903 Add response fields that depend on query param "lang"
asteiner-swisstopo Sep 24, 2024
565ac2e
PB-903 Reset the DB to enable testing the primary keys
asteiner-swisstopo Sep 24, 2024
5aebdeb
PB-903 Mark variable that can be null consistently
asteiner-swisstopo Sep 25, 2024
7023ae8
PB-903 Remove optional type hints in tests to avoid mypy note
asteiner-swisstopo Sep 25, 2024
7f82a32
PB-903 Omit null fields in response
asteiner-swisstopo Sep 25, 2024
d6b434d
PB-903 Add function to get relevant language from HTTP header
asteiner-swisstopo Sep 25, 2024
accec33
PB-903 Take the HTTP header "Accept-Language" into account
asteiner-swisstopo Sep 25, 2024
aef98d5
PB-903 Ignore the q factor, just take the first valid language
asteiner-swisstopo Sep 26, 2024
a3f5236
PB-903 Fix path to match specs
asteiner-swisstopo Sep 26, 2024
b96e7e1
PB-903 Refer to object instead of hardcoded path
asteiner-swisstopo Sep 26, 2024
4e47e0a
PB-903 Prepend "api/" to all end point paths except "/checker"
asteiner-swisstopo Sep 26, 2024
b60a4aa
PB-903 Remove redundant "providers" from path in router
asteiner-swisstopo Sep 26, 2024
0a5ccf7
PB-903 Properly mark query param to be integer for validation
asteiner-swisstopo Sep 26, 2024
1b7fd81
PB-903 Take id from DB instead of resetting DB each time in test
asteiner-swisstopo Sep 26, 2024
a690793
PB-903 Rename "translation" to more general "language"
asteiner-swisstopo Sep 26, 2024
617d4d6
PB-903 Pass the valid languages and return None if value doesn't match
asteiner-swisstopo Sep 26, 2024
c04a67b
PB-903 Extract definition of language to one function
asteiner-swisstopo Sep 26, 2024
012145a
Merge pull request #24 from geoadmin/feat-PB-903-setup-api-endpoints-…
asteiner-swisstopo Sep 30, 2024
bfa712b
PB-903 Refer to constant for default language
asteiner-swisstopo Sep 30, 2024
4882585
PB-903 Extract mapping of Django model to NInja schema
asteiner-swisstopo Sep 30, 2024
7bc8514
PB-903 Add end point to list all providers
asteiner-swisstopo Sep 30, 2024
993c795
PB-903 Move conversion close to where it's used
asteiner-swisstopo Oct 2, 2024
7d0c1af
PB-903 Add response schema for Attribution
asteiner-swisstopo Oct 2, 2024
a37b0d7
PB-903 Add GET endpoint for Attribution
asteiner-swisstopo Oct 2, 2024
76d3079
PB-903 Add GET endpoint for Attributions
asteiner-swisstopo Oct 2, 2024
6d177f0
PB-903 Add "attributions" path to endpoint
asteiner-swisstopo Oct 2, 2024
3de6869
PB-903 Add GET endpoint for Dataset
asteiner-swisstopo Oct 2, 2024
edc4464
PB-903 Rename function to be in line with dataset_to_response
asteiner-swisstopo Oct 2, 2024
7db3fe3
PB-903 Add GET endpoint for all Datasets
asteiner-swisstopo Oct 2, 2024
209e15b
PB-903 Refactor tests to get model directly upon creation
asteiner-swisstopo Oct 7, 2024
c6d1716
PB-903 Fix test to use corresponding timestamp
asteiner-swisstopo Oct 7, 2024
fc25ea6
PB-903 Register new endpoints in API
asteiner-swisstopo Oct 7, 2024
2e012bb
PB-903 Extract object creation to shorten tests
asteiner-swisstopo Oct 7, 2024
2078261
PB-903 Rename function for consistency with similar functions
asteiner-swisstopo Oct 7, 2024
fa217c6
PB-903 Properly reflect that we use integers for the provider ID
asteiner-swisstopo Oct 8, 2024
7d3846a
PB-903 Properly reflect that we use int for the attribution ID
asteiner-swisstopo Oct 8, 2024
2be1192
PB-903 Properly reflect that we use int for the provider ID also as FK
asteiner-swisstopo Oct 8, 2024
a1b874b
PB-903 Properly reflect that we use int for the dataset ID
asteiner-swisstopo Oct 8, 2024
ef6e238
PB-903 Properly reflect that we use int for the provider/attribution …
asteiner-swisstopo Oct 8, 2024
a577e32
PB-903 Remove conversion as it's done implicitly by Ninja
asteiner-swisstopo Oct 8, 2024
30d13b7
PB-903 Return more succinct dict instead of explicit type
asteiner-swisstopo Oct 8, 2024
fa123ac
Merge pull request #25 from geoadmin/feat-PB-903-endpoints-for-attrib…
asteiner-swisstopo Oct 10, 2024
693088b
PB-1056 Tighten some mypy rules
msom Oct 9, 2024
663fef7
PB-1056 Use untyped_calls_exclude instead of disallow_untyped_calls
msom Oct 10, 2024
ed8bc3b
PB-1056 Use module specific ignore_missing_imports
msom Oct 10, 2024
60f04a7
Merge pull request #28 from geoadmin/feat-pb-1056-tighten-mypy
msom Oct 10, 2024
fa5a839
PB-897 Fix the checker URL
schtibe Oct 4, 2024
1ad812f
PB-897 Rewrite checker endpoint, don't use ninja
schtibe Oct 17, 2024
f5b2e6e
PB-897 Don't use reverse for the checker test
schtibe Oct 17, 2024
49596db
PB-897 Fix checker endpoint typing
schtibe Oct 17, 2024
270f231
PB-897 Fix code format
schtibe Oct 17, 2024
638e2ac
PB-897 Revert back to django test case
schtibe Oct 18, 2024
000c238
PB-897 Move checker test to separate folder
schtibe Oct 18, 2024
c0643ca
Merge pull request #26 from geoadmin/fix-pb-897-checker-url
schtibe Oct 21, 2024
68c5359
PB-1045 Add new app "access"
asteiner-swisstopo Oct 10, 2024
5f24118
PB-1045 Add User model
asteiner-swisstopo Oct 10, 2024
8b807aa
PB-1045 Register User model in Djanog-admin
asteiner-swisstopo Oct 10, 2024
349918f
PB-1045 Remove unused files generated by the Django manager
asteiner-swisstopo Oct 10, 2024
2a9f5d9
PB-1045 Add GET endpoint to get a specific user
asteiner-swisstopo Oct 10, 2024
cce18da
PB-1045 Register the router of app "access" in the Ninja API
asteiner-swisstopo Oct 10, 2024
0a6b8b2
PB-1045 Format migration file
asteiner-swisstopo Oct 10, 2024
88a0a8c
PB-1045 Add GET endpoint to get all users
asteiner-swisstopo Oct 10, 2024
0d5b5f0
PB-1045 Fix accidentally wrong value in test
asteiner-swisstopo Oct 10, 2024
c4c0fe8
PB-1045 Prepend "/providers" in end points instead of router
asteiner-swisstopo Oct 14, 2024
ef57601
PB-1045 Return dict for brevity
asteiner-swisstopo Oct 14, 2024
a6ac8ab
PB-1045 Add tests for new User model
asteiner-swisstopo Oct 14, 2024
1c43bad
PB-1045 Validate email for user
asteiner-swisstopo Oct 14, 2024
61063a3
PB-1045 Set textual username as primary key for User
asteiner-swisstopo Oct 14, 2024
78349c7
Revert "PB-1045 Validate email for user"
asteiner-swisstopo Oct 16, 2024
60bb72c
PB-1045 Add email validation on model level
asteiner-swisstopo Oct 16, 2024
4a79e6b
PB-1045 Remove obsolete f-string
asteiner-swisstopo Oct 16, 2024
1be7aa8
PB-1045 Set email validator as field type
asteiner-swisstopo Oct 17, 2024
01ea258
PB-1045 Keep numerical ID internally, use unique username internally
asteiner-swisstopo Oct 17, 2024
1aee531
PB-1045 Keep numerical ID internally, use unique username internally
asteiner-swisstopo Oct 17, 2024
89464a4
PB-1045 Create dedicated NinjaAPI object for "/checker"
asteiner-swisstopo Oct 21, 2024
3cb6025
PB-1045 Create dedicated NinjaAPI object for "/checker"
asteiner-swisstopo Oct 21, 2024
afd138f
PB-1045 Add namespace to NinjaAPI object to avoid ambiguity
asteiner-swisstopo Oct 21, 2024
1506cf8
PB-1045 Remove "api_" prefix from variable name to avoid confusion
asteiner-swisstopo Oct 21, 2024
1915ec8
Merge pull request #30 from geoadmin/feat-PB-1045-add-user-model-and-…
asteiner-swisstopo Oct 21, 2024
44cc535
PB-1026 Add settings for tests
msom Oct 24, 2024
3f99f85
Merge pull request #33 from geoadmin/feat-pb-1026-test-settings
schtibe Oct 24, 2024
6a35c2b
PB-1044 Add interface for cognito
msom Oct 2, 2024
778fe3a
PB-1044 Use username instead of id, cleanup log messages
msom Oct 14, 2024
3b64d40
PB-1044 Add managed flag and pagination
msom Oct 15, 2024
1ea48aa
PB-1044 Refactor cognito sync command
msom Oct 16, 2024
5f283eb
PB-1044 Use consistent naming
msom Oct 16, 2024
75548fd
PB-1044 Resolve typing issue
msom Oct 16, 2024
1a1034c
PB-1044 Fix typing, make flag customizable
msom Oct 22, 2024
c335b6b
PB-1044 Use user model
msom Oct 22, 2024
d57ac8a
PB-1044 Clearify log messages
msom Oct 22, 2024
3e53e2e
PB-1044 Rename managed flag
msom Oct 22, 2024
1c68348
PB-1044 Rename flag and update its default value
msom Oct 24, 2024
b980a9e
PB-1044 Also rename flag in environment and settings
msom Oct 24, 2024
f6d5866
Merge pull request #29 from geoadmin/feat-pb-1044-populate-cognito
msom Oct 24, 2024
9cf1f28
PB-1026 Add BOD import command
msom Sep 24, 2024
8b61560
PB-1026 Add legacy id to attribution
msom Oct 23, 2024
0162eaf
PB-1026 Use default database for bod tests
msom Oct 23, 2024
36b9a53
Merge pull request #23 from geoadmin/feat-pb-1026-bod-sync
msom Oct 24, 2024
b5bfcd9
PB-1045 Add POST endpoint to create a User
asteiner-swisstopo Oct 22, 2024
27e189a
PB-1045 Return 201 to signal successful creation
asteiner-swisstopo Oct 22, 2024
bff59bd
PB-1045 Only create test client once
asteiner-swisstopo Oct 22, 2024
0c91d3b
PB-1045 Fix accidentally wrong status codes in test names
asteiner-swisstopo Oct 23, 2024
be231d0
PB-1045 Move local exception handling to global exception handler
asteiner-swisstopo Oct 24, 2024
768a1b7
PB-1045 Also check content of response
asteiner-swisstopo Oct 28, 2024
3727993
PB-1045 Make exception handling testable
asteiner-swisstopo Oct 30, 2024
8857991
PB-1045 Also treat 404 errors and general exceptions
asteiner-swisstopo Oct 30, 2024
c32f534
PB-1045 Treat the case when ValidationError was initialized with a li…
asteiner-swisstopo Oct 30, 2024
6846c79
Merge pull request #31 from geoadmin/feat-PB-1045-create-user-endpoint
asteiner-swisstopo Oct 30, 2024
82a5ca1
PB-1114 Overwrite default ninja error handlers
msom Oct 30, 2024
1b8c462
Merge pull request #35 from geoadmin/feat-pb-1114-default-error-handlers
msom Nov 5, 2024
f33985b
PB-1090 Create user also in cognito
msom Oct 30, 2024
c8546a5
Merge pull request #36 from geoadmin/feat-pb-1090-add-user-in-cognito
msom Nov 5, 2024
df18c24
PB-1111 Add bandit security checker
msom Oct 23, 2024
b93e327
Merge pull request #32 from geoadmin/feat-bandit
msom Nov 5, 2024
81d691a
PB-1108 Add delete user endpoint
msom Oct 30, 2024
97ba93b
Merge pull request #34 from geoadmin/feat-pb-1108-delete-user
msom Nov 11, 2024
1f8eab5
PB-1124 Add django authentication and permission check to API
msom Nov 12, 2024
c572950
Merge pull request #39 from geoadmin/feat-PB-1124-djang-permissions-i…
msom Nov 13, 2024
8e53080
PB-1109 Insert "_cognito_" to function name to align with create_cogn…
asteiner-swisstopo Nov 5, 2024
fec1088
PB-1109 Rename test name to match tested function
asteiner-swisstopo Nov 5, 2024
cf6aa91
PB-1109 Add PUT endpoint to update user
asteiner-swisstopo Nov 5, 2024
96a69c4
PB-1109 Raise log level for failure updating user
asteiner-swisstopo Nov 6, 2024
1f8cfcf
PB-1109 Change HTTP status code to 404
asteiner-swisstopo Nov 6, 2024
81f36f9
PB-1109 Align function description with update to return code
asteiner-swisstopo Nov 6, 2024
2f96748
PB-1109 Return updated User upon success
asteiner-swisstopo Nov 12, 2024
7e6e9fc
PB-1109 Split test case to avoid pylint error too-many-public-methods
asteiner-swisstopo Nov 13, 2024
b977208
PB-1109 Return 400 instead of 404 when FK nonexistent
asteiner-swisstopo Nov 13, 2024
057b9d8
PB-1109 Add auth to PUT endpoint after rebase with develop branch
asteiner-swisstopo Nov 13, 2024
3cfedb9
Merge pull request #37 from geoadmin/feat-PB-1109-update-user-endpoint
asteiner-swisstopo Nov 13, 2024
afdd893
PB-1074: Cognito interface enable/disable users
benschs Nov 11, 2024
1ea3e06
PB-1074: Soft delete user
benschs Nov 12, 2024
8918cc6
PB-1074: Disable users
benschs Nov 12, 2024
36ed7bd
PB-1074: query active users by default
benschs Nov 13, 2024
d53ecb7
PB-1074: User deactivation improve code comments
benschs Nov 13, 2024
d063c2b
Merge pull request #38 from geoadmin/feat-PB-1074-user-deactivate
benschs Nov 13, 2024
2349843
PB-1115 Move cognito sync to user model
msom Nov 6, 2024
9a8db36
Merge pull request #40 from geoadmin/feat-PB-1115-cognito-in-user-model
msom Nov 20, 2024
147dc2f
Add PR template
msom Nov 20, 2024
2a1bac2
Merge pull request #42 from geoadmin/pr-template
msom Nov 20, 2024
7c6d4d8
PB-1112: Use pytest
msom Nov 13, 2024
c619fd2
Merge pull request #41 from geoadmin/feat-PB-1112-pytest
msom Nov 21, 2024
c5bc306
Improve the usability of the admin UI
msom Nov 26, 2024
3bded61
Merge pull request #44 from geoadmin/feat-improve-admin-ui
msom Nov 26, 2024
f77e988
PB-1115: Validate all models on save
msom Nov 27, 2024
75b70c0
Merge pull request #45 from geoadmin/fix-PB-1115-validate-models
msom Nov 27, 2024
271bf0f
PB-1106: Use cognito's preferred username
msom Nov 20, 2024
f7c1863
Merge pull request #43 from geoadmin/feat-PB-1106-preferred-username
msom Dec 3, 2024
8024636
PB-1085: Serve static files
msom Dec 3, 2024
996af0d
Merge pull request #47 from geoadmin/feat-PB-1085-static-files
msom Dec 3, 2024
a47d85f
Add SECURE_PROXY_SSL_HEADER configuration
schtibe Dec 10, 2024
b87599c
Merge pull request #48 from geoadmin/bug-secure-proxy-header
msom Dec 10, 2024
a2b08ed
PB-1158: Add package distribution model
msom Nov 26, 2024
b2d2e3f
Merge pull request #46 from geoadmin/feat-PB-1158-package-distribution
msom Dec 10, 2024
2d8159d
Update packages
msom Dec 11, 2024
6d3195a
Merge pull request #51 from geoadmin/bug-fix-dependabot-alerts
msom Dec 11, 2024
38970f5
Fix some bugs in the user admin UI and model
msom Dec 11, 2024
d31772a
Merge pull request #50 from geoadmin/bug-fix-cognito-sync-with-admin-ui
msom Dec 11, 2024
73cc053
Add a little command to create or update our superuser
schtibe Dec 10, 2024
4c0f209
Merge pull request #49 from geoadmin/feat-superuser-management
schtibe Dec 12, 2024
3255caf
Create superuser with is_staff=True obviously
schtibe Dec 12, 2024
44d7300
Merge pull request #52 from geoadmin/bug-superuser-is-staff
schtibe Dec 12, 2024
c98ab01
Create automatic superuser with is_superuser=True
schtibe Dec 12, 2024
7d20979
Merge pull request #54 from geoadmin/feat-superuser-really-superuser
schtibe Dec 12, 2024
ac56036
Install pytest-cov
schtibe Dec 12, 2024
fa39987
Merge pull request #53 from geoadmin/feat-pytest-cov
schtibe Dec 12, 2024
dab55cc
Add tests
msom Dec 17, 2024
e40acd1
Merge pull request #56 from geoadmin/feat-admin-ui-tests
msom Dec 17, 2024
facf2b5
Add coverage report
msom Dec 16, 2024
9ffabdd
Merge pull request #55 from geoadmin/feat-coverage-report
msom Dec 18, 2024
4abaf9d
PB-1288 Set e-mail as validated in cognito
msom Dec 18, 2024
8c4333a
Merge pull request #58 from geoadmin/feat-PB-1288-validate-email
msom Dec 19, 2024
64b5273
Use XML for coverage report
msom Dec 19, 2024
7d53cc7
Merge pull request #60 from geoadmin/bug-xml-coverage-report
msom Dec 19, 2024
8741521
Add branch coverage
msom Dec 19, 2024
56cc0ee
Merge pull request #61 from geoadmin/feat-add-branch-coverage
msom Dec 19, 2024
f5a8245
Fix updating user in cognito
msom Dec 19, 2024
1ff3ced
Merge pull request #62 from geoadmin/bug-fix-cognito-partial-user-update
msom Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bandit]
exclude = tests
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[report]
exclude_lines =
if TYPE_CHECKING:
17 changes: 17 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,22 @@ DB_PW=postgres
DB_PORT=15432
DB_HOST=localhost
DB_NAME_TEST=postgres_test
BOD_USER=postgres
BOD_NAME=bod_master
BOD_PW=postgres
BOD_PORT=15433
BOD_HOST=localhost
DJANGO_SETTINGS_MODULE=config.settings_dev
SECRET_KEY=django-insecure-6-72r#zx=sv6v@-4k@uf1gv32me@%yr*oqa*fu8&5l&a!ws)5#
COGNITO_POOL_ID=local_PoolPrty
COGNITO_PORT=9229
COGNITO_ENDPOINT_URL=http://localhost:9229
COGNITO_MANAGED_FLAG_NAME=dev:custom:managed_by_service

# used for local development
AWS_REGION=eu-central-2
AWS_DEFAULT_REGION=eu-central-2
AWS_ACCESS_KEY_ID=123
AWS_SECRET_ACCESS_KEY=123

DEBUG=True
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

- [ ] Model changes documented in the [business entity model](https://ltwiki.adr.admin.ch:8443/display/PB/Business+Entity+Model)
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
.env
# Byte-compiled / optimized / DLL files
__pycache__

# Distribution / packaging
.env
var/

# IDE config files
.vscode

# Local database
.volumes

# Coverage
coverage.xml
htmlcov/
6 changes: 3 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,6 @@ min-public-methods=2

# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception,
StandardError
overgeneral-exceptions=builtins.BaseException,
builtins.Exception,
builtins.StandardError
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Container that contains basic configurations used by all other containers
# It should only contain variables that don't change or change very infrequently
# so that the cache is not needlessly invalidated
FROM python:3.12-slim-bullseye as base
FROM python:3.12-slim-bullseye AS base
ENV HTTP_PORT=8080
ENV USER=geoadmin
ENV GROUP=geoadmin
Expand All @@ -18,7 +18,7 @@ RUN apt-get -qq update > /dev/null \

###########################################################
# Builder container
FROM base as builder
FROM base AS builder
RUN apt-get -qq update > /dev/null \
&& apt-get -qq -y install \
# dev dependencies
Expand All @@ -37,7 +37,7 @@ COPY --chown=${USER}:${GROUP} app/ ${INSTALL_DIR}/app/

###########################################################
# Container to perform tests/management/dev tasks
FROM base as debug
FROM base AS debug
LABEL target=debug
ENV DEBUG=1

Expand Down Expand Up @@ -81,6 +81,9 @@ ENV PYTHONHOME=""
ARG VERSION=unknown
RUN echo "APP_VERSION = '$VERSION'" > ${INSTALL_DIR}/app/config/version.py

# Collect static files.
RUN ${INSTALL_DIR}/app/manage.py collectstatic --noinput

ARG GIT_HASH=unknown
ARG GIT_BRANCH=unknown
ARG GIT_DIRTY=""
Expand All @@ -101,7 +104,7 @@ ENTRYPOINT ["python"]

###########################################################
# Container to use in production
FROM base as production
FROM base AS production
LABEL target=production
ENV DEBUG=0

Expand All @@ -121,6 +124,9 @@ ENV PYTHONHOME=""
ARG VERSION=unknown
RUN echo "APP_VERSION = '$VERSION'" > ${INSTALL_DIR}/app/config/version.py

# Collect static files.
RUN ${INSTALL_DIR}/app/manage.py collectstatic --noinput

ARG GIT_HASH=unknown
ARG GIT_BRANCH=unknown
ARG GIT_DIRTY=""
Expand Down
35 changes: 31 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ AUTHOR = $(USER)
# Django specific
APP_SRC_DIR := app
DJANGO_MANAGER := $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py
DJANGO_MANAGER_DEBUG := -m debugpy --listen localhost:5678 --wait-for-client $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py

# Commands
PIPENV_RUN := pipenv run
PYTHON := $(PIPENV_RUN) python3
TEST := $(PIPENV_RUN) pytest
YAPF := $(PIPENV_RUN) yapf
ISORT := $(PIPENV_RUN) isort
PYLINT := $(PIPENV_RUN) pylint
MYPY := $(PIPENV_RUN) mypy
PSQL := PGPASSWORD=postgres psql -h localhost -p 15433 -U postgres
PGRESTORE := PGPASSWORD=postgres pg_restore -h localhost -p 15433 -U postgres
BANDIT := $(PIPENV_RUN) bandit

# Find all python files that are not inside a hidden directory (directory starting with .)
PYTHON_FILES := $(shell find $(APP_SRC_DIR) -type f -name "*.py" -print)
Expand All @@ -55,8 +60,8 @@ ci:
.PHONY: setup
setup: $(SETTINGS_TIMESTAMP) ## Create virtualenv with all packages for development
pipenv install --dev
pipenv shell
cp .env.default .env
pipenv shell

.PHONY: format
format: ## Call yapf to make sure your code is easier to read and respects some conventions.
Expand Down Expand Up @@ -87,6 +92,9 @@ ci-check-format: format ## Check the format (CI)
serve: ## Serve the application locally
$(PYTHON) $(DJANGO_MANAGER) runserver

.PHONY: serve-debug
serve-debug: ## Serve the application locally for debugging
$(PYTHON) $(DJANGO_MANAGER_DEBUG) runserver

.PHONY: dockerlogin
dockerlogin: ## Login to the AWS Docker Registry (ECR)
Expand Down Expand Up @@ -140,11 +148,30 @@ type-check: ## Run the type-checker mypy
start-local-db: ## Run the local db as docker container
docker compose up -d

.PHONY: test-ci
test-ci: ## Run tests in the CI
$(TEST) --cov --cov-branch --cov-report=xml:coverage.xml

.PHONY: test
test: ## Run tests locally
# Collect static first to avoid warning in the test
# $(PYTHON) $(DJANGO_MANAGER) collectstatic --noinput
$(PYTHON) $(DJANGO_MANAGER) test --verbosity=2 --parallel 20 $(CI_TEST_OPT) $(TEST_DIR) $(APP_SRC_DIR)
$(TEST) --cov --cov-branch --cov-report=html

.PHONY: setup-bod
setup-bod: ## Set up the bod locally
$(PSQL) -c 'CREATE ROLE "pgkogis";'
$(PSQL) -c 'CREATE ROLE "www-data";'
$(PSQL) -c 'CREATE ROLE "bod_admin";'
$(PSQL) -c 'CREATE ROLE "rdsadmin";'

.PHONY: import-bod
import-bod: ## Import the bod locally
$(PSQL) -c 'DROP DATABASE IF EXISTS bod_master;'
$(PSQL) -c 'CREATE DATABASE bod_master;'
$(PGRESTORE) -d bod_master $(file) --v

.PHONY: security-check
security-check: ## Run bandit security checker locally
$(BANDIT) --recursive --ini .bandit app

.PHONY: help
help: ## Display this help
Expand Down
11 changes: 10 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ verify_ssl = true
name = "pypi"

[packages]
django = "~=5.0.7"
django = "~=5.0.10"
django-ninja = "~=1.1"
psycopg2-binary = "~=2.9.5"
django-environ = "~=0.11"
gunicorn = "~=23.0"
pyyaml = "~=6.0.2"
gevent = "~=24.2"
logging-utilities = "~=4.4.1"
boto3 = "~=1.35.78"
nanoid = "~=2.0.0"
whitenoise = "~=6.8.2"

[dev-packages]
yapf = "*"
Expand All @@ -29,6 +32,12 @@ pytest-django = "*"
mypy = "*"
types-gevent = "*"
django-stubs = "~=5.0.4"
debugpy = "*"
boto3-stubs = {extras = ["cognito-idp"], version = "~=1.35"}
bandit = "*"
pytest-xdist = "*"
types-nanoid = "*"
pytest-cov = "*"

[requires]
python_version = "3.12"
Loading
Loading