Commit Graph

63 Commits

Author SHA1 Message Date
0daf413b47 Prevent sole admin from deleting their account
Without this guard, the last admin in the system could delete their own
account, making the application unmanageable. This adds a model method
`User#sole_admin?`, a controller guard in `RegistrationsController#destroy`,
and disables the delete button in the profile edit view when the current
user is the only remaining admin.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 06:52:14 +00:00
7904ff3ef9 Add web-based installation wizard
Replace the CLI-only setup (db:seed + manual application.rb edits)
with a web wizard shown automatically on first visit when no admin
account exists yet.

SetupController (GET/POST /setup) collects the admin e-mail and
password, a "skip e-mail confirmation" toggle, and an option to
seed the built-in default units.  Once submitted it creates the
admin User, persists the chosen options as Setting records, and
redirects to the sign-in page.

ApplicationController gains a redirect_to_setup_if_needed
before_action that catches every request (including Devise routes)
when no admin exists, so a fresh installation always lands on the
wizard rather than an empty sign-in form.

A new Setting model provides a lightweight key-value store for
runtime options that were previously hard-coded in application.rb
(e.g. skip_email_confirmation).  RegistrationsController now reads
that flag from the database instead of from the application config.

Seeds.rb is kept for headless / automated deployments and skips
admin creation when an admin already exists (idempotent), with a
comment pointing to the web wizard as the preferred path.

Also extends the SQLite nil-limit fix (|| Float::INFINITY) to the
Quantity model, which suffered the same ArgumentError as Unit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 17:19:24 +00:00
9ad922e3a1 Add skip_email_confirmation option; fix SQLite length validation
Introduce config.skip_email_confirmation in application.rb.dist.
When set to true, new registrations are automatically confirmed
without requiring email verification — useful for installations
where outgoing email is not configured or for development/testing.
Implemented by calling skip_confirmation! in build_resource before
the record is saved, so no confirmation email is ever sent.

Also fix ArgumentError raised in length validations when
type_for_attribute(:column).limit returns nil, which happens with
SQLite for string columns that have no explicit limit in the
migration. Guard with || Float::INFINITY so the validation is
effectively skipped when the database imposes no limit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 15:57:50 +00:00
84945fa4b4 Simplify and improve labeled form 2026-02-22 00:53:18 +01:00
bd1a664caa Measurement form based on select-styled <details> 2026-01-31 17:22:09 +01:00
ef3484dfdf Update Measurements#new form pathnames on actions 2025-05-07 00:24:05 +02:00
cd9a64b5ad Merge corrections provided by Bambuch 2025-04-26 18:32:45 +02:00
1cddc794d2 Cleanup Quantity :pathname related code 2025-03-23 13:11:14 +01:00
8401424efa Partial refresh of Measurements#new form 2025-02-18 18:27:47 +01:00
c48bf290fd Implement Measurements#new 2025-02-18 11:25:32 +01:00
9d60eee16b Add Measurements tab and #new form 2025-01-25 16:34:04 +01:00
6300273186 Cleanup 2025-01-16 21:37:58 +01:00
cb69629276 Use associations in finders 2025-01-15 14:06:00 +01:00
27038a74d0 Return Quantity progenies as a result of partial ordering
Separate scope only provided some optimisation by reducing the count of
records :numbered and should be unnecessary in future once numbering
can be merged with ordering into one recursive query
2025-01-14 23:25:26 +01:00
201359de3e Allow to reparent Quantity everywhere
Closes #61
2025-01-14 21:13:35 +01:00
644d1f4b9a Add Quantity #reparent action 2025-01-14 15:02:38 +01:00
17b4e4f8a7 Don't duplicate ancestors search in #successive 2025-01-12 18:11:37 +01:00
421515e5ce ancestors() sets depth for self, instead of returning new instance 2025-01-12 18:09:34 +01:00
d5e7ccacf5 Add Quantity #edit and #update 2025-01-11 22:51:49 +01:00
adcc6699ce Avoid N+1 queries on index 2025-01-11 21:58:12 +01:00
57f10c94a4 Add Quantity #new, #create, #destroy actions 2025-01-11 17:01:34 +01:00
aa862f0e90 Quantities index WIP 2025-01-05 20:47:49 +01:00
b3aea97087 Add Quantities tab 2025-01-05 03:18:39 +01:00
b8bcbee1e9 Separate root routes for un- and authenticated users
Closes #34
Closes #47
2025-01-02 15:19:33 +01:00
8552571526 Disable Unit destuction for base units with subunits
Closes #40
2024-12-28 23:57:47 +01:00
0659c1e1c1 Don't render index on Unit actions 2024-12-22 01:31:14 +01:00
d726e92445 Allow opening multiple new/edit forms
Closes #30
2024-12-21 17:52:45 +01:00
e5cf3dc0ae Avoid refreshing whole index on create 2024-12-19 03:46:29 +01:00
b38d72e9b0 Return to per-action permission filters 2024-11-30 20:15:30 +01:00
13685aa476 Update error handling according to new rules 2024-11-30 16:28:43 +01:00
2cbae12fa2 Implement Units default destroy 2024-11-30 16:11:31 +01:00
f9bd81c6ab Implement Unit defaults export
Disable import_all until implemented
2024-11-26 02:31:25 +01:00
76ce2eeedd Display Unit name using #to_s 2024-11-23 02:24:08 +01:00
bdc4ec4644 Specify user modifiable ATTRIBUTES 2024-11-22 15:48:09 +01:00
1d439928e2 Import with proper base 2024-11-22 15:18:27 +01:00
f0e28deea2 Implement 'import' action 2024-11-17 03:39:39 +01:00
4447735dce First part of portability checks 2024-11-15 02:02:19 +01:00
817b1a4376 Update permission checking 2024-11-10 17:34:02 +01:00
537cd18336 Change namespace for defaults controllers
To allow proper path prefix for view partials when using
config.action_view.prefix_partial_path_with_controller_namespace
2024-11-09 21:50:50 +01:00
aa83f17a4c Allow specifying navigation tab for controllers 2024-05-06 19:01:54 +02:00
965cb76f1d Generate Units::Defaults controller
bin/rails g controller Units/Defaults index
2024-05-04 01:53:57 +02:00
1966c782bc Unit rebase as a separate action 2024-04-02 22:16:27 +02:00
05b0c66216 Change unit base with drag and drop 2024-03-24 17:38:56 +01:00
3a3ae71320 Fix layout rendering for turbo_streams
Closes #22
2024-02-13 20:48:00 +01:00
0e8bc18620 Enable creation of subunits 2024-01-22 02:09:46 +01:00
1227c54e0e Fix flashes display after grid introduction
Closes #5
2024-01-17 21:57:18 +01:00
5047d4909f Render units from collection, without redirects 2024-01-15 18:45:30 +01:00
9a9a139aa7 Handle exceptions during TURBO_STREAM requests 2024-01-15 01:59:30 +01:00
ce4770a25c Run #create action 2024-01-06 03:59:09 +01:00
a4745c9cb8 Add Units 2023-07-06 18:34:16 +02:00