This switches the logic so that belongs_to parent objects must exist
by default, and marks the optional ones explicitly. This is reflected
in the null/not_null status on the relevant db columns.
Rails can't automatically detect bi-directional relationships when
`:foreign_key` is present. Adding the `inverse_of` helps when validating
traces and tags that haven't yet been saved.
This PR allows users to delete their own accounts. The logic implemented matches
that currently used by the admins when they manually close accounts, although
there is room to be more complex in future e.g. completely removing accounts
with no content.
The error handling has been slightly adapted for namespaced controllers, by
anchoring the controller name with a leading forward slash.
Login may redirect to ouath2_authorizations#create which may then
redirect to arbitrary schemes if the application is already authorized
so we need to allow login to redirect to any scheme.
Fixes#3424
The user status is a bit complex, since there are various states and
not all transitions between them make sense.
Using AASM means that we can name and restrict the transitions, which
hopefully makes them easier to reason about.
Without the ability defined, the user is still logged out, but then
the deny_access check redirects to the login page. The re-login attempt
would then fail anyway, with an error message, but let's fix the abilities
and use the intended page.
This allows rails to set the created_at automatically, and so avoids
us from having to do so in a callback. It also hides the unusual
db column name from the rest of the app.
"delete" is generally used for immediate SQL deletion without running
any callbacks or other ruby code, whereas "destroy" will trigger callbacks.
Although we don't currently use any callbacks, let's rename this method to
align better with the convention.
Because we are using an edge-to-edge layout for the flash messages,
the negative margins on the row were expanding the element offscreen.
Bootstrap provides a "no-gutter" class for removing these margins,
but that also drops the spacing between columns which we want to preserve.
So instead we use a margin override on the row only.
Additionally, drop some padding css in favour of a utility class
Fixes#3351
Bug was introduced in 3dd639c8d0
This avoids needing any floats. Also remove buttons class from two
locations, since there is a min-width on that class and it affects
the button styling negatively for standalone buttons