Skip to content

Commit 40441ed

Browse files
committed
Merge branch 'master' into release
2 parents ab0d461 + f9face5 commit 40441ed

File tree

71 files changed

+9005
-1811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+9005
-1811
lines changed

.env.example

Lines changed: 270 additions & 136 deletions
Large diffs are not rendered by default.

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
- name: Export the env variables file
6363
run: |
6464
cp .env.example .env
65+
sed -ri 's/^ENVIRONMENT=(.*)/ENVIRONMENT=test/g' .env
6566
sed -ri 's/^COMPOSE_FILE=(.*)/COMPOSE_FILE=\1:docker-compose.override.test.yml/g' .env
6667
eval $(egrep "^[^#;]" .env | xargs -d'\n' -n1 | sed -E 's/(\w+)=(.*)/export \1='"'"'\2'"'"'/g')
6768

README.md

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,8 @@ To fetch upstream development, don't forget to update the submodules too:
4949
cp .env.example .env
5050
```
5151

52-
2. Change the `ENVIRONMENT` variable to `development`.
5352

54-
```shell
55-
ENVIRONMENT=development
56-
```
57-
58-
3. Build development images and run the containers:
53+
2. Build development images and run the containers:
5954

6055
```shell
6156
docker compose up -d --build
@@ -64,31 +59,31 @@ docker compose up -d --build
6459
The command will read the `docker-compose*.yml` files specified in the `COMPOSE_FILE` variable from the `.env` file. Then Django built-in server will be directly reachable at `http://localhost:8011` or through `nginx` at `https://localhost`.
6560
You should avoid using the Django's built-in server and better always develop and test QFieldCloud through the `nginx` [reverse proxy with SSL](#add-root-certificate).
6661

67-
4. (OPTIONAL) In case you have a database dump, you can directly load some data in your development database.
62+
3. (OPTIONAL) In case you have a database dump, you can directly load some data in your development database.
6863

6964
```shell
7065
psql 'service=localhost.qfield.cloud' < ./qfc_dump_20220304.sql
7166
```
7267

73-
5. Run Django database migrations.
68+
4. Run Django database migrations.
7469

7570
```shell
7671
docker compose exec app python manage.py migrate
7772
```
7873

79-
6. And collect the static files (CSS, JS etc):
74+
5. And collect the static files (CSS, JS etc):
8075

8176
```shell
8277
docker compose run app python manage.py collectstatic --noinput
8378
```
8479

85-
7. Now you can get started by adding your super user that has access to the Django Admin interface:
80+
6. Now you can get started by adding your super user that has access to the Django Admin interface:
8681

8782
```shell
8883
docker compose run app python manage.py createsuperuser --username super_user --email super@user.com
8984
```
9085

91-
8. If QFieldCloud needs to be translated, you can compile the translations using Django's tooling:
86+
7. If QFieldCloud needs to be translated, you can compile the translations using Django's tooling:
9287

9388
```shell
9489
docker compose run --user root app python manage.py compilemessages
@@ -191,8 +186,6 @@ Create an <code>.env.test</code> file with the following variables that override
191186
WEB_HTTP_PORT=8101
192187
WEB_HTTPS_PORT=8102
193188
HOST_POSTGRES_PORT=8103
194-
HOST_GEODB_PORT=8107
195-
MEMCACHED_PORT=11212
196189
QFIELDCLOUD_DEFAULT_NETWORK=qfieldcloud_test_default
197190
QFIELDCLOUD_SUBSCRIPTION_MODEL=subscription.Subscription
198191
DJANGO_DEV_PORT=8111
@@ -219,6 +212,17 @@ Don't forget to update the `port` value in [`[test.localhost.qfield.cloud]` in y
219212

220213
</details>
221214

215+
216+
#### Test coverage
217+
218+
To get information about the current test coverage, run:
219+
220+
```
221+
docker compose exec app coverage run manage.py test --keepdb
222+
docker compose exec app coverage report
223+
```
224+
225+
222226
### Debugging
223227

224228
> [!NOTE]
@@ -377,8 +381,6 @@ Based on this example
377381
| nginx https | 443 | WEB_HTTPS_PORT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
378382
| django http | 8011 | DJANGO_DEV_PORT | :white_check_mark: | :x: | :x: |
379383
| postgres | 5433 | HOST_POSTGRES_PORT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
380-
| memcached | 11211 | MEMCACHED_PORT | :white_check_mark: | :x: | :x: |
381-
| geodb | 5432 | HOST_GEODB_PORT | :white_check_mark: | :white_check_mark: | :x: |
382384
| minio API | 8009 | MINIO_API_PORT | :white_check_mark: | :x: | :x: |
383385
| minio browser | 8010 | MINIO_BROWSER_PORT | :white_check_mark: | :x: | :x: |
384386
| smtp web | 8012 | SMTP4DEV_WEB_PORT | :white_check_mark: | :x: | :x: |
@@ -398,23 +400,6 @@ For great `nginx` logs, use:
398400
docker compose logs nginx -f --no-log-prefix | grep ':"nginx"' | jq -r $QFC_JQ
399401

400402

401-
### Geodb
402-
403-
The geodb (database for the users projects data) is installed on
404-
separated machines (db1.qfield.cloud, db2.qfield.cloud, db3&#x2026;)
405-
and they are load balanced and available through the
406-
db.qfield.cloud address.
407-
408-
There is a template database called
409-
`template_postgis` that is used to create the databases for the
410-
users. The template db has the following extensions installed:
411-
412-
- fuzzystrmatch
413-
- plpgsql
414-
- postgis
415-
- postgis<sub>tiger</sub><sub>geocoder</sub>
416-
- postgis<sub>topology</sub>
417-
418403
### Storage
419404

420405
You can use either the integrated `minio` object storage, or use an external provider (e. g. S3) with versioning enabled. Check the corresponding `STORAGE_*` environment variables for more info.
@@ -436,10 +421,38 @@ Migration to a newer database version is a risky operation to your data, so prep
436421

437422
Contributions welcome!
438423

439-
Any PR including the `[WIP]` should be:
440-
- able to be checked-out without breaking the stack;
424+
425+
### Before considering a new PR
426+
427+
For the best chance of having your PR merged, you must first communicate your idea(s) and clarify the details with the QFieldCloud developers.
428+
429+
1) Create a dedicated [issue in the QFieldCloud repository](https://github.com/opengisch/QFieldCloud/issues) detailing your suggestion.
430+
2) Engage in the feedback and guidance provided by the development team during their review of your issue.
431+
432+
Discussing it first is crucial. Not every idea is accepted, and these steps will save you the time and energy of creating a PR that wouldn't be merged.
433+
434+
Any new, follow-up discussions should be opened in a new issue that references the original.
435+
436+
437+
### Before opening a new PR
438+
439+
- Make sure you prepare a small focused branch with your changes, properly referencing the source issue and add a detailed description to the PR opening message.
440+
- If the change addresses a UI/UX change, provide a before and after screenshot.
441+
- Your branch should be based on the latest `master` branch.
442+
- In the rare occurances when it is not based on `master`, please base your PR on the respective branch.
443+
444+
445+
### Pull requests
446+
447+
If your PR is not ready to be merged, please mark it as a [draft PR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#converting-a-pull-request-to-a-draft).
448+
449+
A draft PR can allow QFieldCloud developers to provide you early feedback.
450+
However, make sure a draft PR:
451+
452+
- can be checked-out without breaking the stack;
441453
- the specific feature being developed/modified should be testable locally (does not mean it should work correctly).
442454

455+
443456
## Resources
444457

445458
- [QField Cloud "marketing" page](https://qfield.cloud)

docker-app/.coveragerc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ branch = True
33
source =
44
qfieldcloud
55
omit =
6-
**migrations*
7-
**tests*
8-
**/admin.py
9-
**/wsgi.py
6+
*/tests/*
7+
*/migrations/*
8+
*/wsgi.py
109

1110
[report]
1211
precision = 2
@@ -19,6 +18,3 @@ exclude_lines =
1918
raise NotImplementedError
2019
if 0:
2120
if __name__ == .__main__.:
22-
23-
[html]
24-
directory = .htmlcov

docker-app/qfieldcloud/authentication/tests/test_list_auth_providers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from allauth.socialaccount.models import SocialApp
55
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
66
from allauth.socialaccount.providers.oauth2.views import OAuth2Adapter
7+
from django.conf import settings
78
from django.http import HttpRequest
89
from django.test import override_settings
910
from rest_framework.test import APITestCase
@@ -141,7 +142,8 @@ def test_lists_configured_social_providers(self):
141142
"redirect_port": 7070,
142143
"redirect_url": "",
143144
"client_id": "keycloak-client-id",
144-
"extra_tokens": {"id_token": "X-QFC-ID-Token"},
145+
"extra_tokens": {"id_token": settings.QFIELDCLOUD_ID_TOKEN_HEADER_NAME},
146+
"idp_id_header": settings.QFIELDCLOUD_IDP_ID_HEADER_NAME,
145147
"styles": {},
146148
},
147149
]

docker-app/qfieldcloud/authentication/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ def get_provider_data(self, provider: Provider, request: HttpRequest) -> dict:
189189
"redirect_port": self.QGIS_REDIRECT_PORT,
190190
"redirect_url": self.QGIS_REDIRECT_URL,
191191
"client_id": provider.app.client_id,
192-
"extra_tokens": {"id_token": "X-QFC-ID-Token"},
192+
"extra_tokens": {"id_token": settings.QFIELDCLOUD_ID_TOKEN_HEADER_NAME},
193+
"idp_id_header": settings.QFIELDCLOUD_IDP_ID_HEADER_NAME,
193194
"styles": SSOProviderStyles(request).get(provider_id),
194195
}
195196
return provider_data

docker-app/qfieldcloud/core/admin.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
ApplyJobDelta,
5252
Delta,
5353
FaultyDeltaFile,
54-
Geodb,
5554
Job,
5655
Organization,
5756
OrganizationMember,
@@ -366,18 +365,6 @@ def format_pre_json(value):
366365
return format_pre(value)
367366

368367

369-
class GeodbInline(admin.TabularInline):
370-
model = Geodb
371-
extra = 0
372-
has_direct_delete_permission = False
373-
374-
def has_add_permission(self, request, obj):
375-
return False
376-
377-
def has_change_permission(self, request, obj):
378-
return False
379-
380-
381368
class MemberOrganizationInline(admin.TabularInline):
382369
model = OrganizationMember
383370
extra = 0
@@ -521,10 +508,7 @@ class PersonAdmin(QFieldCloudModelAdmin):
521508
"storage_usage__field",
522509
)
523510

524-
inlines = (
525-
UserAccountInline,
526-
GeodbInline,
527-
)
511+
inlines = (UserAccountInline,)
528512

529513
add_form_template = "admin/change_form.html"
530514
change_form_template = "admin/person_change_form.html"
@@ -1416,7 +1400,6 @@ def has_change_permission(self, request, obj):
14161400
class OrganizationAdmin(QFieldCloudModelAdmin):
14171401
inlines = (
14181402
UserAccountInline,
1419-
GeodbInline,
14201403
ProjectInline,
14211404
OrganizationMemberInline,
14221405
TeamInline,

docker-app/qfieldcloud/core/geodb_utils.py

Lines changed: 0 additions & 128 deletions
This file was deleted.

docker-app/qfieldcloud/core/management/commands/calcprojectstorage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def handle(self, *args, **options):
2525
extra_filters["file_storage_bytes"] = 0
2626

2727
projects_qs = Project.objects.filter(
28-
the_qgis_filename__isnull=False,
28+
the_qgis_file_name__isnull=False,
2929
**extra_filters,
3030
).order_by("-updated_at")
3131
total_count = projects_qs.count()

0 commit comments

Comments
 (0)