Beacons: - Scaffolded with phx.gen.live then reworked so reads are public and mutations go through a live_session gated by the new :require_admin on_mount hook in UserAuth - Beacon schema stores frequency (MHz), callsign, grid, lat/lon, power (W), and height above ground (m); grid auto-derives from lat/lon when left blank via Maidenhead.from_latlon - Adds Maidenhead.from_latlon/3 so we can compute grids locally instead of hitting an external API Users admin page: - /users and /users/:id/edit (admin-only) for listing, editing (callsign/name/email/is_admin), and deleting other users - Adds Accounts.list_users, admin_update_user, delete_user, and a dedicated admin_changeset on the User schema - Nav gains a "Users" link for admins and a "Beacons" link for everyone
23 lines
502 B
Elixir
23 lines
502 B
Elixir
defmodule Microwaveprop.BeaconsFixtures do
|
|
@moduledoc """
|
|
Test helpers for creating beacon records.
|
|
"""
|
|
|
|
alias Microwaveprop.Beacons
|
|
|
|
def valid_beacon_attrs(attrs \\ %{}) do
|
|
Enum.into(attrs, %{
|
|
frequency_mhz: 10_368.1,
|
|
callsign: "W5HN",
|
|
lat: 32.897,
|
|
lon: -97.038,
|
|
power_watts: 10.0,
|
|
height_m: 30.0
|
|
})
|
|
end
|
|
|
|
def beacon_fixture(user, attrs \\ %{}) do
|
|
{:ok, beacon} = Beacons.create_beacon(user, valid_beacon_attrs(attrs))
|
|
beacon
|
|
end
|
|
end
|