Commit graph

111 commits

Author SHA1 Message Date
f8a3cc4c47 Run seeds only once (#475)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing
continuous-integration/drone/tag Build is passing
## Description of the implemented changes
The changes were:
- [ ] Bugfixing
- [x] New Feature
- [ ] Breaking Change
- [x] Refactoring

**Seeds run only on first startup.** On every application start (e.g. `just run`, Docker entrypoint), seed scripts are still invoked, but they exit immediately when the admin user already exists. This avoids duplicate seed data (e.g. join requests), keeps startup fast after the first run, and works the same in dev and production.

## What has been changed?

- **`lib/mv/release.ex`**
  - Added `bootstrap_seeds_applied?/0`: returns whether the admin user (from `ADMIN_EMAIL` or default `admin@localhost`) exists. We check the admin *user*, not the Admin *role*, so we do not skip when only migrations have run (migrations can create the Admin role for the system actor).
  - `run_seeds/0`: if `bootstrap_seeds_applied?()` is true, prints “Seeds already applied (admin user exists). Skipping.” and returns without running bootstrap or dev seeds; otherwise unchanged behaviour.
  - Module docs updated for the new function and the skip behaviour.

- **`priv/repo/seeds.exs`**
  - Ensures the app is started (`Application.ensure_all_started(:mv)`).
  - If `Mv.Release.bootstrap_seeds_applied?()` is true, prints the same skip message and does not run bootstrap or dev seeds; otherwise runs as before (bootstrap + dev seeds in dev/test).
  - Comment at the top updated to describe the skip behaviour.

- **Documentation**
  - `CODE_GUIDELINES.md` §1.2.1: seeds run on every start but exit early when already applied; mentions `bootstrap_seeds_applied?/0`.
  - `docs/admin-bootstrap-and-oidc-role-sync.md`: run_seeds skips when admin user exists; description of `run_seeds/0` updated.
  - `CHANGELOG.md` [Unreleased]: new “Seeds run only when needed” entry under Changed.

## Definition of Done
### Code Quality
- [x] No new technical depths
- [x] Linting passed
- [x] Documentation is added where needed

### Accessibility
- [x] New elements are properly defined with html-tags *(no new UI)*
- [x] Colour contrast follows WCAG criteria *(no new UI)*
- [x] Aria labels are added when needed *(no new UI)*
- [x] Everything is accessible by keyboard *(no new UI)*
- [x] Tab-Order is comprehensible *(no new UI)*
- [x] All interactive elements have a visible focus *(no new UI)*

### Testing
- [x] Tests for new code are written *(existing seeds and release tests cover behaviour; idempotency test still passes when second run skips)*
- [x] All tests pass
- [x] axe-core dev tools show no critical or major issues *(no UI changes)*

## Additional Notes

- **Review focus:** Logic in `Mv.Release` and `priv/repo/seeds.exs`; the “already applied” check is a single DB read for the admin user. On failure (e.g. DB down), `bootstrap_seeds_applied?/0` returns `false`, so seeds run (safe for first deploy).
- **Suggested check:** Run `mix test test/seeds_test.exs test/mv/release_test.exs` to confirm seeds and release behaviour.

Reviewed-on: #475
Co-authored-by: Simon <s.thiessen@local-it.org>
Co-committed-by: Simon <s.thiessen@local-it.org>
2026-03-16 19:27:31 +01:00
09e4b64663
feat: allow disabling registration
Some checks failed
continuous-integration/drone/push Build is failing
2026-03-13 16:40:39 +01:00
086ecdcb1b
feat: prevent join requests with equal mail
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-13 11:18:34 +01:00
a7481f6ab1
feat: improve field order for approvals and add seeds
Some checks failed
continuous-integration/drone/push Build is failing
2026-03-12 16:15:57 +01:00
a4f3aa5d6f
feat: add smtp settings
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-12 13:39:48 +01:00
28f97184b3 Merge branch 'main' into feature/308-web-form
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-11 02:05:13 +01:00
86d9242d83
feat: add approval ui for join requests
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-11 02:04:03 +01:00
5eb7c9c4b2
seeds: distribute fee types at create, add exit dates for 5 members
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/promote/production Build is passing
2026-03-10 20:36:06 +01:00
fa738aae88
feat: add join form settings
Some checks failed
continuous-integration/drone/push Build is failing
2026-03-10 14:29:49 +01:00
ad6ef169ac
Merge remote-tracking branch 'origin/main' into feature/308-web-form
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing
2026-03-09 15:40:02 +01:00
a41d8498ac
refactor: apply review changes to joinrequest
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-09 15:36:19 +01:00
d032f1ca0c
Run bootstrap seeds in production; add RUN_DEV_SEEDS support
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/promote/production Build is passing
2026-03-09 15:16:02 +01:00
2515a679b8
feat: add join request resource
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-09 14:44:45 +01:00
ea350ab315
Seeds: robust default fee type lookup; no fee type overwrite on re-run
Bootstrap: filter default fee type by name and interval (yearly).
Dev: do not send membership_fee_type_id in member upsert; set only
via update when nil so re-runs do not overwrite existing assignments.
2026-03-04 17:11:51 +01:00
a98d921848
Seeds: scope compiler_options to seed run, restore in after
Remove global ignore_module_conflict from mix.exs. Set it only in
seeds.exs during eval_file and restore via try/after so crashes
do not leave the option enabled.
2026-03-04 17:11:43 +01:00
f0a8dfcc21
Suppress redefining module warnings via compiler_options 2026-03-04 16:21:14 +01:00
edd8657c92
Split seeds into bootstrap and dev-only 2026-03-04 16:21:14 +01:00
bfc078d5aa Merge branch 'main' into feat/299_plz
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing
2026-02-24 16:02:56 +01:00
c8d7dd3e55 Merge branch 'main' into feat/299_plz
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is failing
2026-02-24 15:38:50 +01:00
adb44241d9
Add migration: oidc_only boolean to settings table 2026-02-24 15:12:45 +01:00
8edbbac95f
feat: OIDC configuration in global Settings (ENV or DB)
- Add oidc_* attributes to Setting, migration and Config helpers
- Secrets and OidcRoleSyncConfig read from Config (ENV overrides DB)
- GlobalSettingsLive: OIDC section with disabled fields when ENV set
- OIDC role sync tests use DataCase for DB access
2026-02-24 13:58:24 +01:00
623543b7bd
fix: add missing postal_code in seeds
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing
postal_code is a Vereinfacht-required field. When Vereinfacht is
configured, seeds failed for members without postal_code.
2026-02-24 12:06:56 +01:00
63040afee7 Merge branch 'main' into feat/299_plz
All checks were successful
continuous-integration/drone/push Build is passing
2026-02-24 10:40:26 +01:00
1fd1880424 chore: adds country memberfield 2026-02-24 09:33:42 +01:00
c86781c32b
Setting: add member_field_required and update_single_member_field
Add JSONB attribute member_field_required, migration, Change and
Membership code interface for atomic per-field required flag.
2026-02-23 22:13:08 +01:00
9d3c72acff
Add Vereinfacht app URL setting and contact view URL
- Setting attribute vereinfacht_app_url, migration, .env.example
- Config: vereinfacht_app_url() from env/setting or derived from API URL
- Contact view URL uses app URL with /en/admin/finances/contacts/{id}
- Global settings: App URL field, read-only when VEREINFACHT_APP_URL set
- Tests: update contact view URL expectations
2026-02-23 19:54:43 +01:00
a5a4d66655
feat(vereinfacht): add DB schema, config and setting attributes
- Migrations: vereinfacht_contact_id on members, vereinfacht_* on settings
- Mv.Config: Vereinfacht ENV/Settings helpers, vereinfacht_configured?, contact_view_url
- Setting: vereinfacht_api_url, api_key, club_id
2026-02-23 19:51:31 +01:00
8430069b45
chore: add dev db seeds for groups
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing
2026-02-20 17:16:29 +01:00
63b8e70e62
fix: adress review comments
Some checks failed
continuous-integration/drone/push Build is failing
2026-02-18 13:05:31 +01:00
f6575319f7
feat: add groups to search vector
Some checks reported errors
continuous-integration/drone/push Build was killed
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-18 12:47:23 +01:00
a263cb4954 Pass actor through CycleGenerator so seeds can use admin
- get_actor(opts): use opts[:actor] or system actor
- load_member, do_generate_cycles, create_cycles pass opts
- Seeds pass admin_user_with_role for Ash.load! and cycle updates
2026-02-12 19:35:48 +01:00
50c8a0dc9a Seeds: call Mv.Release.seed_admin to avoid duplication
Replaces inline admin creation with seed_admin(); exercises same path as entrypoint.
Dev/test: set ADMIN_EMAIL default and ADMIN_PASSWORD fallback before calling.
2026-02-04 18:13:30 +01:00
09a4b7c937 Seeds: use ADMIN_PASSWORD/ADMIN_PASSWORD_FILE; fallback only in dev/test
No fallback in production; prod uses Release.seed_admin in entrypoint.
2026-02-04 18:13:30 +01:00
b6d1a27bc9 Seeds: only admin gets password; additional users without password
- Additional users (hans, greta, maria, thomas) created without admin_set_password.
- Removed no-password@example.de user.
2026-02-04 11:06:59 +01:00
5ed41555e9 Member/Setting/validations: domain, actor, and seeds
- setting.ex: domain/authorize for default_membership_fee_type_id check
- validate_same_interval: require membership_fee_type (no None)
- set_membership_fee_start_date: domain/actor for fee type lookup
- Validations: domain/authorize for cross-resource checks
- helpers.ex, email_sync change, seeds.exs actor/authorize fixes
- Update related tests
2026-02-03 23:52:16 +01:00
5a2f035ecc CustomField policies: actor required, no system-actor fallback, error handling
- list_required_custom_fields: require actor (two clauses, no default)
- Member validation: use context.actor only, differentiate Forbidden vs transient errors
- stream_custom_fields: log + send flash on error instead of returning []
- GlobalSettingsLive: handle_info for custom_fields_load_error, put_flash
- Seeds: use Membership.update_member with actor, format
2026-01-29 16:10:12 +01:00
1d17c4f2dd fix: CustomField policies, no system-actor fallback, guidelines
- Tests and UI pass actor for CustomField create/read/destroy; seeds use actor
- Member required-custom-fields validation uses context.actor only (no fallback)
- CODE_GUIDELINES: add rule forbidding system-actor fallbacks
2026-01-29 16:10:12 +01:00
462bc21ec3
fix(migration): use INSERT..SELECT for system user role_id in CI
All checks were successful
continuous-integration/drone/push Build is passing
Avoid nil/empty-string UUID when repo().one lags after role insert.
2026-01-27 17:47:05 +01:00
92ee7fcc63 fix(seeds): use :update_internal for system user admin-role
Some checks failed
continuous-integration/drone/push Build is failing
:update is blocked for system-actor user; use :update_internal in bootstrap.
2026-01-27 17:39:04 +01:00
a10c770ca7 chore(migration): ensure_system_actor_user_exists
Use admin_role_id, consistent UUID and timestamps.
2026-01-27 17:39:04 +01:00
acb33b9f3b Ensure system actor user exists via migration
Creates user system@mila.local with Admin role if missing. Idempotent;
guarantees system actor in production without relying on seeds.
2026-01-27 17:39:04 +01:00
e92c98b559
refactor: fix review issues - member_count aggregate, migration down, docs, actor handling
All checks were successful
continuous-integration/drone/push Build is passing
2026-01-27 17:09:07 +01:00
6db64bf996
feat: add groups resource #371
Some checks failed
continuous-integration/drone/push Build is failing
2026-01-27 16:03:21 +01:00
2d446f63ea
Add NOT NULL constraint to users.role_id and optimize default_role_id
All checks were successful
continuous-integration/drone/push Build is passing
- Add database-level NOT NULL constraint for users.role_id
- Update SystemActor tests to verify NOT NULL constraint enforcement
- Add process dictionary caching for default_role_id/0 to reduce DB queries
2026-01-25 17:04:48 +01:00
a9b1d794d2
fix: bind role_name variable before using in Ash.Query.filter
Avoid macro pinning issues by binding role_data.name to role_name
before using it in the filter query.
2026-01-25 13:42:28 +01:00
e982271880
fix: improve migration to create 'Mitglied' role if missing
Make migration more robust by creating the 'Mitglied' role if it doesn't
exist, ensuring it works regardless of seed execution order.
2026-01-25 13:42:19 +01:00
9557d8ae6b
Update seeds to create all 5 authorization roles 2026-01-24 19:16:35 +01:00
c7e0181e02
Add migration to assign 'Mitglied' role to existing users 2026-01-24 19:14:51 +01:00
079d270768 Fix authorization bypass in seeds and validations
All checks were successful
continuous-integration/drone/push Build is passing
- Add authorize?: false to all bootstrap operations in seeds.exs
- Fix user-linking validation to respect authorize? context flag
- Prevents authorization errors during initial setup when no actor exists yet
2026-01-23 02:08:11 +01:00
ea399612be Make system actor email configurable via SYSTEM_ACTOR_EMAIL
Allow system user email to be configured via environment variable
with fallback to default 'system@mila.local'
2026-01-21 08:02:35 +01:00