Skip to content

Commit

Permalink
Merge branch 'master' into 769-feature-håndtering-af-frivillige
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewel committed Nov 17, 2024
2 parents 1518463 + 3729709 commit 01ca1cc
Show file tree
Hide file tree
Showing 82 changed files with 2,423 additions and 374 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ DATABASE_URL=postgres://postgres_user:postgres_password@database/database_name
POSTGRES_USER=postgres_user
POSTGRES_PASSWORD=postgres_password
POSTGRES_DB=database_name

DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240
33 changes: 17 additions & 16 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You are more than welcome to contribute to the system. This guide documents how

## Getting a local setup

- Installing Docker: Download and install [docker-compose][docker-guide]. If
- Installing Docker: Download and install [Docker Compose][docker-guide]. If
you use Ubuntu 18.04 (LTS), you can use [this guide][docker-ubuntu-guide] to
set up Docker.

Expand All @@ -13,15 +13,16 @@ You are more than welcome to contribute to the system. This guide documents how
- The setup adheres to the [twelve-factor-app][12f] principles. To get a
local development configuration, copy the file `.env.example` to `.env`

- Run `docker-compose up` to start your local system.
- Run `docker compose up` to start your local system.
(If on Apple Silicon machine, run `docker compose -f docker-compose.yml -f docker-compose.arm64.yml up --build`)

- Run `docker-compose run web ./manage.py get_live_data` to download public
- Run `docker compose run web ./manage.py get_live_data` to download public
data and insert it into your local database.

- To get some dummy members, families, etc. you can use the [factories][factories] to create them.

```bash
docker-compose run web ./manage.py shell
docker compose run web ./manage.py shell
from members.tests.factories import MemberFactory
MemberFactory.create_batch(20)
```
Expand All @@ -31,7 +32,7 @@ You are more than welcome to contribute to the system. This guide documents how
with the real world. For instance each member belongs to their own department.

- To create a super user for the admin interface you can run
`docker-compose run web ./manage.py createsuperuser`
`docker compose run web ./manage.py createsuperuser`

- A pgAdmin container is configured as part of Docker Compose, and can be accessed on <http://localhost:5050>.
Log in with credentials `[email protected]`/`admin`. Connection to database has been configured in
Expand Down Expand Up @@ -65,15 +66,15 @@ You are more than welcome to contribute to the system. This guide documents how

- [Django][django]: The base web framework used. The link is to their great
tutorial which takes an hour or two to complete.
- [Docker][docker-tutorial]: We use `docker-compose` to setup database,
- [Docker][docker-tutorial]: We use `docker compose` to setup database,
environment and dependencies. The following commands is all that's required
to work on the system.
- `docker-compose build` -- Builds the system.
- `docker-compose up` -- Starts the systems.
- `docker-compose down && docker volume rm backend_database`
- `docker compose build` -- Builds the system.
- `docker compose up` -- Starts the systems.
- `docker compose down && docker volume rm backend_database`
\-- Deletes your local database
- `docker-compose run web command` -- Replace `command` with what you want
- `docker compose run web command` -- Replace `command` with what you want
to run in the system.
- [SASS][sass]: CSS files belong in `members/static/members/sass`,
Expand All @@ -82,7 +83,7 @@ You are more than welcome to contribute to the system. This guide documents how
following command in a separate terminal:
```bash
docker-compose run web node_modules/.bin/sass --watch members/static/members/sass/main.scss members/static/members/css/main.css
docker compose run web node_modules/.bin/sass --watch members/static/members/sass/main.scss members/static/members/css/main.css
```
It will compile SASS when you save a file.
Expand All @@ -94,15 +95,15 @@ You are more than welcome to contribute to the system. This guide documents how
- [Selenium][selenium]: runs the functional tests. To run a specific test run
```bash
docker-compose run web ./manage.py test members.tests.test_functional.test_create_family
docker compose run web ./manage.py test members.tests.test_functional.test_create_family
```
where the name of your tests replaces the last part.
- [Unit tests][unittest]: runs the unittests. You run the unit tests the same way as the selenium tests. To run a specific test run
```bash
docker-compose run web ./manage.py test members.tests.test_dump_data
docker compose run web ./manage.py test members.tests.test_dump_data
```
where the name of your tests replaces the last part.
Expand All @@ -122,7 +123,7 @@ Pragmatic development is to use docker for database and run server and/or tests
- Install npm dependencies: `npm install`
- Copy the sample environment file: `cp .env.example .env`
- boot the database with `docker-compose start database`
- boot the database with `docker compose start database`
- boot a selenium docker with `docker run -it -p 4444:4444 -p 7900:7900 --network="host" -v /dev/shm:/dev/shm selenium/standalone-chrome`
- start the virtual env shell and work from there further on with `poetry shell`
- Run sass: `./node_modules/.bin/sass members/static/members/sass/main.scss`
Expand Down Expand Up @@ -159,13 +160,13 @@ p.user.username # show login email
discussion happens before the code and limits duplicate work.
4. Help us specify the requirements specification.
5. Code the features with tests, see the [testing guide][test_guide]
6. Run the entire test suite with: `docker-compose run web ./manage.py test`
6. Run the entire test suite with: `docker compose run web ./manage.py test`
7. Check that the following requirements are meet:
- The code has tests, code without tests is not accepted. (Except for
minimal CSS and text changes). Use the existing test as inspiration and
the [factories][factories] to create dummy data.
- The code conforms to the [black][black] formatting rules. To format your
code run `docker-compose run web black .`. Consider looking for an
code run `docker compose run web black .`. Consider looking for an
editor integration.
- The code passes [flake8][flake8] checks.
8. Submit the pull request.
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ jobs:
- name: Setup Enviroment
run: cp .env.example .env
- name: Builds the stack
run: docker-compose build
run: docker compose build
- name: Check formatting (Black)
run: docker-compose run web black --check .
run: docker compose run web black --check .
- name: Static error check (Flake8)
run: docker-compose run web flake8
run: docker compose run web flake8
- name: Test
run: docker-compose run web ./manage.py test
- uses: actions/upload-artifact@v2.1.4
run: docker compose run web ./manage.py test
- uses: actions/upload-artifact@v4.4.0
if: always()
with:
name: selenium-screens
path: ./test-screens
- name: Create and upload UML diagram
run: mkdir -p UML && docker-compose run web ./manage.py graph_models members -o UML/UML_diagram.png
- uses: actions/upload-artifact@v2.1.4
run: mkdir -p UML && docker compose run web ./manage.py graph_models members -o UML/UML_diagram.png
- uses: actions/upload-artifact@v4.4.0
with:
name: UML_diagram.png
path: UML
11 changes: 11 additions & 0 deletions docker-compose.arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# use this file as override, if on Arm64 architecture, e.g. Mac M1
# example commands:
# - docker compose -f docker-compose.yml -f docker-compose.arm64.yml up --build
# - docker compose -f docker-compose.yml -f docker-compose.arm64.yml run --build web ./manage.py test
services:
selenium:
image: seleniarm/standalone-chromium
networks:
- webnet
ports:
- "4444:4444"
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.3"

services:
web:
build: .
Expand Down
4 changes: 4 additions & 0 deletions forenings_medlemmer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
CRISPY_TEMPLATE_PACK = "bootstrap5"

DATA_UPLOAD_MAX_NUMBER_FIELDS = int(os.environ["DATA_UPLOAD_MAX_NUMBER_FIELDS"])

MIDDLEWARE = (
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
Expand Down Expand Up @@ -229,6 +231,8 @@

SECURE_SSL_REDIRECT = env.bool("FORCE_HTTPS")
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True


LOGIN_URL = "/account/login/"
Expand Down
6 changes: 6 additions & 0 deletions members/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
EmailTemplate,
Equipment,
Family,
Municipality,
Payment,
Person,
Union,
VolunteerRequest,
VolunteerRequestDepartment,
WaitingList,
EmailItem,
)

from .activity_admin import ActivityAdmin
Expand All @@ -26,13 +28,15 @@
from .department_admin import DepartmentAdmin
from .equipment_admin import EquipmentAdmin
from .family_admin import FamilyAdmin
from .municipality_admin import MunicipalityAdmin
from .payment_admin import PaymentAdmin
from .person_admin import PersonAdmin
from .union_admin import UnionAdmin
from .user_admin import UserAdmin
from .volunteerrequest_admin import VolunteerRequestAdmin
from .volunteerrequestdepartment_admin import VolunteerRequestDepartmentAdmin
from .waitinglist_admin import WaitingListAdmin
from .emailitem_admin import EmailItemAdmin

admin.site.site_header = "Coding Pirates Medlemsdatabase"
admin.site.index_title = "Afdelings admin"
Expand All @@ -45,12 +49,14 @@
admin.site.register(EmailTemplate)
admin.site.register(Equipment, EquipmentAdmin)
admin.site.register(Family, FamilyAdmin)
admin.site.register(Municipality, MunicipalityAdmin)
admin.site.register(Payment, PaymentAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Union, UnionAdmin)
admin.site.register(WaitingList, WaitingListAdmin)
admin.site.register(VolunteerRequest, VolunteerRequestAdmin)
admin.site.register(VolunteerRequestDepartment, VolunteerRequestDepartmentAdmin)
admin.site.register(EmailItem, EmailItemAdmin)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
# admin.site.register(AdminUserInformation, AdminUserInformationAdmin)
Loading

0 comments on commit 01ca1cc

Please sign in to comment.