diff --git a/.gitignore b/.gitignore index d1239a66..fdd13a6e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ erl_crash.dump *.ez # Ignore package tarball (built via "mix hex.build"). -bones73k-*.tar +shift73k-*.tar # If NPM crashes, it generates a log, let's ignore it too. npm-debug.log diff --git a/.iex.exs b/.iex.exs index 31d540a4..02446b6d 100644 --- a/.iex.exs +++ b/.iex.exs @@ -1,5 +1,5 @@ import Ecto.Query -# alias Bones73kWeb.Router.Helpers, as: Routes -alias Bones73k.Repo -alias Bones73k.Accounts -alias Bones73k.Accounts.User +# alias Shift73kWeb.Router.Helpers, as: Routes +alias Shift73k.Repo +alias Shift73k.Accounts +alias Shift73k.Accounts.User diff --git a/README.md b/README.md index 1f402854..fa1aab6f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bones73k +# Shift73k See full article [here](https://www.leanpanda.com/blog/authentication-and-authorisation-in-phoenix-liveview/). diff --git a/config/config.exs b/config/config.exs index f78efc3f..83f8b26b 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,21 +7,21 @@ # General application configuration use Mix.Config -config :bones73k, - ecto_repos: [Bones73k.Repo] +config :shift73k, + ecto_repos: [Shift73k.Repo] # Custom application global variables -config :bones73k, :app_global_vars, +config :shift73k, :app_global_vars, time_zone: "America/New_York", mailer_reply_to: "reply_to@example.com", mailer_from: "app_name@example.com" # Configures the endpoint -config :bones73k, Bones73kWeb.Endpoint, +config :shift73k, Shift73kWeb.Endpoint, url: [host: "localhost"], secret_key_base: "LdIQmzV5UCWSbB2SdiWFHLgxYNObKq9Za/VyguoILxfOAMDb5IsptKCKtXTRn+Tf", - render_errors: [view: Bones73kWeb.ErrorView, accepts: ~w(html json), layout: false], - pubsub_server: Bones73k.PubSub, + render_errors: [view: Shift73kWeb.ErrorView, accepts: ~w(html json), layout: false], + pubsub_server: Shift73k.PubSub, live_view: [signing_salt: "2D4GC4ac"] # Configures Elixir's Logger diff --git a/config/dev.exs b/config/dev.exs index 6345a719..bc81cdc2 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,10 +1,10 @@ use Mix.Config # Configure your database -config :bones73k, Bones73k.Repo, +config :shift73k, Shift73k.Repo, username: "postgres", password: "postgres", - database: "bones73k_dev", + database: "shift73k_dev", hostname: "localhost", show_sensitive_data_on_connection_error: true, pool_size: 10 @@ -15,7 +15,7 @@ config :bones73k, Bones73k.Repo, # The watchers configuration can be used to run external # watchers to your application. For example, we use it # with webpack to recompile .js and .css sources. -config :bones73k, Bones73kWeb.Endpoint, +config :shift73k, Shift73kWeb.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, @@ -56,13 +56,13 @@ config :bones73k, Bones73kWeb.Endpoint, # different ports. # Watch static and templates for browser reloading. -config :bones73k, Bones73kWeb.Endpoint, +config :shift73k, Shift73kWeb.Endpoint, live_reload: [ patterns: [ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", - ~r"lib/bones73k_web/(live|views)/.*(ex)$", - ~r"lib/bones73k_web/templates/.*(eex)$" + ~r"lib/shift73k_web/(live|views)/.*(ex)$", + ~r"lib/shift73k_web/templates/.*(eex)$" ] ] diff --git a/config/prod.exs b/config/prod.exs index 5a396275..7999baac 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -9,7 +9,7 @@ use Mix.Config # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. -config :bones73k, Bones73kWeb.Endpoint, +config :shift73k, Shift73kWeb.Endpoint, url: [host: "example.com", port: 80], cache_static_manifest: "priv/static/cache_manifest.json" @@ -21,7 +21,7 @@ config :logger, level: :info # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # -# config :bones73k, Bones73kWeb.Endpoint, +# config :shift73k, Shift73kWeb.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [ @@ -45,7 +45,7 @@ config :logger, level: :info # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # -# config :bones73k, Bones73kWeb.Endpoint, +# config :shift73k, Shift73kWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. diff --git a/config/prod.secret.exs b/config/prod.secret.exs index 5eeea741..d55940bb 100644 --- a/config/prod.secret.exs +++ b/config/prod.secret.exs @@ -11,7 +11,7 @@ database_url = For example: ecto://USER:PASS@HOST/DATABASE """ -config :bones73k, Bones73k.Repo, +config :shift73k, Shift73k.Repo, # ssl: true, url: database_url, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10") @@ -23,7 +23,7 @@ secret_key_base = You can generate one by calling: mix phx.gen.secret """ -config :bones73k, Bones73kWeb.Endpoint, +config :shift73k, Shift73kWeb.Endpoint, http: [ port: String.to_integer(System.get_env("PORT") || "4000"), transport_options: [socket_opts: [:inet6]] @@ -35,7 +35,7 @@ config :bones73k, Bones73kWeb.Endpoint, # If you are doing OTP releases, you need to instruct Phoenix # to start each relevant endpoint: # -# config :bones73k, Bones73kWeb.Endpoint, server: true +# config :shift73k, Shift73kWeb.Endpoint, server: true # # Then you can assemble a release by calling `mix release`. # See `mix help release` for more information. diff --git a/config/test.exs b/config/test.exs index cfc07d04..d8a5429a 100644 --- a/config/test.exs +++ b/config/test.exs @@ -8,16 +8,16 @@ config :bcrypt_elixir, :log_rounds, 1 # The MIX_TEST_PARTITION environment variable can be used # to provide built-in test partitioning in CI environment. # Run `mix help test` for more information. -config :bones73k, Bones73k.Repo, +config :shift73k, Shift73k.Repo, username: "postgres", password: "postgres", - database: "bones73k_test#{System.get_env("MIX_TEST_PARTITION")}", + database: "shift73k_test#{System.get_env("MIX_TEST_PARTITION")}", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox # We don't run a server during test. If one is required, # you can enable the server option below. -config :bones73k, Bones73kWeb.Endpoint, +config :shift73k, Shift73kWeb.Endpoint, http: [port: 4002], server: false @@ -25,7 +25,7 @@ config :bones73k, Bones73kWeb.Endpoint, config :logger, level: :warn # Bamboo test mailer config -config :bones73k, Bones73k.Mailer, adapter: Bamboo.TestAdapter +config :shift73k, Shift73k.Mailer, adapter: Bamboo.TestAdapter # Import secret config import_config "test.secret.exs" diff --git a/lib/bones73k/mailer.ex b/lib/bones73k/mailer.ex deleted file mode 100644 index 3baf0c9b..00000000 --- a/lib/bones73k/mailer.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Bones73k.Mailer do - use Bamboo.Mailer, otp_app: :bones73k -end diff --git a/lib/bones73k_web/controllers/user_registration_controller.ex b/lib/bones73k_web/controllers/user_registration_controller.ex deleted file mode 100644 index 108915c3..00000000 --- a/lib/bones73k_web/controllers/user_registration_controller.ex +++ /dev/null @@ -1,8 +0,0 @@ -defmodule Bones73kWeb.UserRegistrationController do - use Bones73kWeb, :controller - import Phoenix.LiveView.Controller - - def new(conn, _params) do - live_render(conn, Bones73kWeb.UserLive.Registration) - end -end diff --git a/lib/bones73k_web/views/other_view.ex b/lib/bones73k_web/views/other_view.ex deleted file mode 100644 index a103c3b1..00000000 --- a/lib/bones73k_web/views/other_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Bones73kWeb.OtherView do - use Bones73kWeb, :view -end diff --git a/lib/bones73k_web/views/user_confirmation_view.ex b/lib/bones73k_web/views/user_confirmation_view.ex deleted file mode 100644 index 3001318f..00000000 --- a/lib/bones73k_web/views/user_confirmation_view.ex +++ /dev/null @@ -1,4 +0,0 @@ -defmodule Bones73kWeb.UserConfirmationView do - use Bones73kWeb, :view - alias Bones73k.Accounts.User -end diff --git a/lib/bones73k_web/views/user_reset_password_view.ex b/lib/bones73k_web/views/user_reset_password_view.ex deleted file mode 100644 index a2c1d190..00000000 --- a/lib/bones73k_web/views/user_reset_password_view.ex +++ /dev/null @@ -1,4 +0,0 @@ -defmodule Bones73kWeb.UserResetPasswordView do - use Bones73kWeb, :view - alias Bones73k.Accounts.User -end diff --git a/lib/bones73k_web/views/user_session_view.ex b/lib/bones73k_web/views/user_session_view.ex deleted file mode 100644 index a7f878cf..00000000 --- a/lib/bones73k_web/views/user_session_view.ex +++ /dev/null @@ -1,4 +0,0 @@ -defmodule Bones73kWeb.UserSessionView do - use Bones73kWeb, :view - alias Bones73k.Accounts.User -end diff --git a/lib/bones73k.ex b/lib/shift73k.ex similarity index 69% rename from lib/bones73k.ex rename to lib/shift73k.ex index 01655ac1..500bfb21 100644 --- a/lib/bones73k.ex +++ b/lib/shift73k.ex @@ -1,6 +1,6 @@ -defmodule Bones73k do +defmodule Shift73k do @moduledoc """ - Bones73k keeps the contexts that define your domain + Shift73k keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless diff --git a/lib/bones73k/accounts.ex b/lib/shift73k/accounts.ex similarity index 98% rename from lib/bones73k/accounts.ex rename to lib/shift73k/accounts.ex index 52306d9c..52c94a3e 100644 --- a/lib/bones73k/accounts.ex +++ b/lib/shift73k/accounts.ex @@ -1,12 +1,12 @@ -defmodule Bones73k.Accounts do +defmodule Shift73k.Accounts do @moduledoc """ The Accounts context. """ import Ecto.Query, warn: false - alias Bones73k.Repo - alias Bones73k.Accounts.{User, UserToken, UserNotifier} - alias Bones73kWeb.UserAuth + alias Shift73k.Repo + alias Shift73k.Accounts.{User, UserToken, UserNotifier} + alias Shift73kWeb.UserAuth ## Database getters @@ -121,7 +121,7 @@ defmodule Bones73k.Accounts do Repo.delete_all(UserToken.user_and_contexts_query(user, :all)) # Broadcast to all liveviews to immediately disconnect the user - Bones73kWeb.Endpoint.broadcast_from( + Shift73kWeb.Endpoint.broadcast_from( self(), UserAuth.pubsub_topic(), "logout_user", diff --git a/lib/bones73k/accounts/user.ex b/lib/shift73k/accounts/user.ex similarity index 93% rename from lib/bones73k/accounts/user.ex rename to lib/shift73k/accounts/user.ex index 63f9da3a..57e0df45 100644 --- a/lib/bones73k/accounts/user.ex +++ b/lib/shift73k/accounts/user.ex @@ -1,4 +1,4 @@ -defmodule Bones73k.Accounts.User do +defmodule Shift73k.Accounts.User do use Ecto.Schema import Ecto.Changeset import EctoEnum @@ -19,12 +19,12 @@ defmodule Bones73k.Accounts.User do @primary_key {:id, :binary_id, autogenerate: true} # @foreign_key_type :binary_id schema "users" do - field :email, :string - field :password, :string, virtual: true - field :hashed_password, :string - field :confirmed_at, :naive_datetime + field(:email, :string) + field(:password, :string, virtual: true) + field(:hashed_password, :string) + field(:confirmed_at, :naive_datetime) - field :role, RolesEnum, default: :user + field(:role, RolesEnum, default: :user) timestamps() end @@ -102,7 +102,7 @@ defmodule Bones73k.Accounts.User do defp validate_email(changeset) do changeset |> validate_email_format() - |> unsafe_validate_unique(:email, Bones73k.Repo) + |> unsafe_validate_unique(:email, Shift73k.Repo) |> unique_constraint(:email) end @@ -173,7 +173,7 @@ defmodule Bones73k.Accounts.User do If there is no user or the user doesn't have a password, we call `Bcrypt.no_user_verify/0` to avoid timing attacks. """ - def valid_password?(%Bones73k.Accounts.User{hashed_password: hashed_password}, password) + def valid_password?(%Shift73k.Accounts.User{hashed_password: hashed_password}, password) when is_binary(hashed_password) and byte_size(password) > 0 do Bcrypt.verify_pass(password, hashed_password) end diff --git a/lib/bones73k/accounts/user_notifier.ex b/lib/shift73k/accounts/user_notifier.ex similarity index 93% rename from lib/bones73k/accounts/user_notifier.ex rename to lib/shift73k/accounts/user_notifier.ex index eed57d31..9c2f03f2 100644 --- a/lib/bones73k/accounts/user_notifier.ex +++ b/lib/shift73k/accounts/user_notifier.ex @@ -1,6 +1,6 @@ -defmodule Bones73k.Accounts.UserNotifier do - alias Bones73k.Mailer - alias Bones73k.Mailer.UserEmail +defmodule Shift73k.Accounts.UserNotifier do + alias Shift73k.Mailer + alias Shift73k.Mailer.UserEmail @doc """ Deliver instructions to confirm account. diff --git a/lib/bones73k/accounts/user_token.ex b/lib/shift73k/accounts/user_token.ex similarity index 82% rename from lib/bones73k/accounts/user_token.ex rename to lib/shift73k/accounts/user_token.ex index 7114f32c..a81905bc 100644 --- a/lib/bones73k/accounts/user_token.ex +++ b/lib/shift73k/accounts/user_token.ex @@ -1,4 +1,4 @@ -defmodule Bones73k.Accounts.UserToken do +defmodule Shift73k.Accounts.UserToken do use Ecto.Schema import Ecto.Query @@ -15,10 +15,10 @@ defmodule Bones73k.Accounts.UserToken do @primary_key {:id, :binary_id, autogenerate: true} @foreign_key_type :binary_id schema "users_tokens" do - field :token, :binary - field :context, :string - field :sent_to, :string - belongs_to :user, Bones73k.Accounts.User + field(:token, :binary) + field(:context, :string) + field(:sent_to, :string) + belongs_to(:user, Shift73k.Accounts.User) timestamps(updated_at: false) end @@ -30,7 +30,7 @@ defmodule Bones73k.Accounts.UserToken do """ def build_session_token(user) do token = :crypto.strong_rand_bytes(@rand_size) - {token, %Bones73k.Accounts.UserToken{token: token, context: "session", user_id: user.id}} + {token, %Shift73k.Accounts.UserToken{token: token, context: "session", user_id: user.id}} end @doc """ @@ -40,10 +40,11 @@ defmodule Bones73k.Accounts.UserToken do """ def verify_session_token_query(token) do query = - from token in token_and_context_query(token, "session"), + from(token in token_and_context_query(token, "session"), join: user in assoc(token, :user), where: token.inserted_at > ago(@session_validity_in_days, "day"), select: user + ) {:ok, query} end @@ -65,7 +66,7 @@ defmodule Bones73k.Accounts.UserToken do hashed_token = :crypto.hash(@hash_algorithm, token) {Base.url_encode64(token, padding: false), - %Bones73k.Accounts.UserToken{ + %Shift73k.Accounts.UserToken{ token: hashed_token, context: context, sent_to: sent_to, @@ -85,10 +86,11 @@ defmodule Bones73k.Accounts.UserToken do days = days_for_context(context) query = - from token in token_and_context_query(hashed_token, context), + from(token in token_and_context_query(hashed_token, context), join: user in assoc(token, :user), where: token.inserted_at > ago(^days, "day") and token.sent_to == user.email, select: user + ) {:ok, query} @@ -111,8 +113,9 @@ defmodule Bones73k.Accounts.UserToken do hashed_token = :crypto.hash(@hash_algorithm, decoded_token) query = - from token in token_and_context_query(hashed_token, context), + from(token in token_and_context_query(hashed_token, context), where: token.inserted_at > ago(@change_email_validity_in_days, "day") + ) {:ok, query} @@ -125,17 +128,17 @@ defmodule Bones73k.Accounts.UserToken do Returns the given token with the given context. """ def token_and_context_query(token, context) do - from Bones73k.Accounts.UserToken, where: [token: ^token, context: ^context] + from(Shift73k.Accounts.UserToken, where: [token: ^token, context: ^context]) end @doc """ Gets all tokens for the given user for the given contexts. """ def user_and_contexts_query(user, :all) do - from t in Bones73k.Accounts.UserToken, where: t.user_id == ^user.id + from(t in Shift73k.Accounts.UserToken, where: t.user_id == ^user.id) end def user_and_contexts_query(user, [_ | _] = contexts) do - from t in Bones73k.Accounts.UserToken, where: t.user_id == ^user.id and t.context in ^contexts + from(t in Shift73k.Accounts.UserToken, where: t.user_id == ^user.id and t.context in ^contexts) end end diff --git a/lib/bones73k/application.ex b/lib/shift73k/application.ex similarity index 63% rename from lib/bones73k/application.ex rename to lib/shift73k/application.ex index ea0a70ba..c4370285 100644 --- a/lib/bones73k/application.ex +++ b/lib/shift73k/application.ex @@ -1,4 +1,4 @@ -defmodule Bones73k.Application do +defmodule Shift73k.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false @@ -8,27 +8,27 @@ defmodule Bones73k.Application do def start(_type, _args) do children = [ # Start the Ecto repository - Bones73k.Repo, + Shift73k.Repo, # Start the Telemetry supervisor - Bones73kWeb.Telemetry, + Shift73kWeb.Telemetry, # Start the PubSub system - {Phoenix.PubSub, name: Bones73k.PubSub}, + {Phoenix.PubSub, name: Shift73k.PubSub}, # Start the Endpoint (http/https) - Bones73kWeb.Endpoint - # Start a worker by calling: Bones73k.Worker.start_link(arg) - # {Bones73k.Worker, arg} + Shift73kWeb.Endpoint + # Start a worker by calling: Shift73k.Worker.start_link(arg) + # {Shift73k.Worker, arg} ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options - opts = [strategy: :one_for_one, name: Bones73k.Supervisor] + opts = [strategy: :one_for_one, name: Shift73k.Supervisor] Supervisor.start_link(children, opts) end # Tell Phoenix to update the endpoint configuration # whenever the application is updated. def config_change(changed, _new, removed) do - Bones73kWeb.Endpoint.config_change(changed, removed) + Shift73kWeb.Endpoint.config_change(changed, removed) :ok end end diff --git a/lib/shift73k/mailer.ex b/lib/shift73k/mailer.ex new file mode 100644 index 00000000..589b722e --- /dev/null +++ b/lib/shift73k/mailer.ex @@ -0,0 +1,3 @@ +defmodule Shift73k.Mailer do + use Bamboo.Mailer, otp_app: :shift73k +end diff --git a/lib/bones73k/mailer/user_email.ex b/lib/shift73k/mailer/user_email.ex similarity index 67% rename from lib/bones73k/mailer/user_email.ex rename to lib/shift73k/mailer/user_email.ex index ce51875f..0dfc4005 100644 --- a/lib/bones73k/mailer/user_email.ex +++ b/lib/shift73k/mailer/user_email.ex @@ -1,9 +1,9 @@ -defmodule Bones73k.Mailer.UserEmail do +defmodule Shift73k.Mailer.UserEmail do import Bamboo.Email - @mailer_vars Application.get_env(:bones73k, :app_global_vars, + @mailer_vars Application.get_env(:shift73k, :app_global_vars, mailer_reply_to: "admin@example.com", - mailer_from: {"Bones73k", "bones73k@example.com"} + mailer_from: {"Shift73k", "shift73k@example.com"} ) def compose(user, subject, body_text) do diff --git a/lib/bones73k/properties.ex b/lib/shift73k/properties.ex similarity index 95% rename from lib/bones73k/properties.ex rename to lib/shift73k/properties.ex index 6b58584f..4a7e4362 100644 --- a/lib/bones73k/properties.ex +++ b/lib/shift73k/properties.ex @@ -1,12 +1,12 @@ -defmodule Bones73k.Properties do +defmodule Shift73k.Properties do @moduledoc """ The Properties context. """ import Ecto.Query, warn: false - alias Bones73k.Repo + alias Shift73k.Repo - alias Bones73k.Properties.Property + alias Shift73k.Properties.Property @doc """ Returns the list of properties. diff --git a/lib/bones73k/properties/property.ex b/lib/shift73k/properties/property.ex similarity index 77% rename from lib/bones73k/properties/property.ex rename to lib/shift73k/properties/property.ex index 7b5a6888..cde8a4b5 100644 --- a/lib/bones73k/properties/property.ex +++ b/lib/shift73k/properties/property.ex @@ -1,14 +1,14 @@ -defmodule Bones73k.Properties.Property do +defmodule Shift73k.Properties.Property do use Ecto.Schema import Ecto.Changeset @primary_key {:id, :binary_id, autogenerate: true} @foreign_key_type :binary_id schema "properties" do - field :description, :string - field :name, :string - field :price, :decimal - field :user_id, :binary_id + field(:description, :string) + field(:name, :string) + field(:price, :decimal) + field(:user_id, :binary_id) timestamps() end diff --git a/lib/bones73k/repo.ex b/lib/shift73k/repo.ex similarity index 63% rename from lib/bones73k/repo.ex rename to lib/shift73k/repo.ex index 3bd6cb8b..24add415 100644 --- a/lib/bones73k/repo.ex +++ b/lib/shift73k/repo.ex @@ -1,6 +1,6 @@ -defmodule Bones73k.Repo do +defmodule Shift73k.Repo do use Ecto.Repo, - otp_app: :bones73k, + otp_app: :shift73k, adapter: Ecto.Adapters.Postgres use Scrivener, page_size: 10 diff --git a/lib/bones73k/util/dt.ex b/lib/shift73k/util/dt.ex similarity index 77% rename from lib/bones73k/util/dt.ex rename to lib/shift73k/util/dt.ex index 24e26df0..9287b4a5 100644 --- a/lib/bones73k/util/dt.ex +++ b/lib/shift73k/util/dt.ex @@ -1,5 +1,5 @@ -defmodule Bones73k.Util.Dt do - @app_vars Application.get_env(:bones73k, :app_global_vars, time_zone: "America/New_York") +defmodule Shift73k.Util.Dt do + @app_vars Application.get_env(:shift73k, :app_global_vars, time_zone: "America/New_York") @time_zone @app_vars[:time_zone] def ndt_to_local(%NaiveDateTime{} = ndt), do: Timex.to_datetime(ndt, @time_zone) diff --git a/lib/bones73k_web.ex b/lib/shift73k_web.ex similarity index 77% rename from lib/bones73k_web.ex rename to lib/shift73k_web.ex index 6113dfa1..5fe8f241 100644 --- a/lib/bones73k_web.ex +++ b/lib/shift73k_web.ex @@ -1,12 +1,12 @@ -defmodule Bones73kWeb do +defmodule Shift73kWeb do @moduledoc """ The entrypoint for defining your web interface, such as controllers, views, channels and so on. This can be used in your application as: - use Bones73kWeb, :controller - use Bones73kWeb, :view + use Shift73kWeb, :controller + use Shift73kWeb, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused @@ -19,19 +19,19 @@ defmodule Bones73kWeb do def controller do quote do - use Phoenix.Controller, namespace: Bones73kWeb + use Phoenix.Controller, namespace: Shift73kWeb import Plug.Conn - import Bones73kWeb.Gettext - alias Bones73kWeb.Router.Helpers, as: Routes + import Shift73kWeb.Gettext + alias Shift73kWeb.Router.Helpers, as: Routes end end def view do quote do use Phoenix.View, - root: "lib/bones73k_web/templates", - namespace: Bones73kWeb, + root: "lib/shift73k_web/templates", + namespace: Shift73kWeb, pattern: "**/*" # Import convenience functions from controllers @@ -46,12 +46,12 @@ defmodule Bones73kWeb do def live_view do quote do use Phoenix.LiveView, - layout: {Bones73kWeb.LayoutView, "live.html"} + layout: {Shift73kWeb.LayoutView, "live.html"} unquote(view_helpers()) - import Bones73kWeb.LiveHelpers + import Shift73kWeb.LiveHelpers - alias Bones73k.Accounts.User + alias Shift73k.Accounts.User @impl true def handle_info(%{event: "logout_user", payload: %{user: %User{id: id}}}, socket) do @@ -71,7 +71,7 @@ defmodule Bones73kWeb do use Phoenix.LiveComponent # Import General Custom Live Helpers - import Bones73kWeb.LiveHelpers + import Shift73kWeb.LiveHelpers unquote(view_helpers()) end @@ -90,7 +90,7 @@ defmodule Bones73kWeb do def channel do quote do use Phoenix.Channel - import Bones73kWeb.Gettext + import Shift73kWeb.Gettext end end @@ -106,11 +106,11 @@ defmodule Bones73kWeb do import Phoenix.View # Import SVG Icon helper - import Bones73kWeb.IconHelpers + import Shift73kWeb.IconHelpers - import Bones73kWeb.ErrorHelpers - import Bones73kWeb.Gettext - alias Bones73kWeb.Router.Helpers, as: Routes + import Shift73kWeb.ErrorHelpers + import Shift73kWeb.Gettext + alias Shift73kWeb.Router.Helpers, as: Routes end end diff --git a/lib/bones73k_web/channels/user_socket.ex b/lib/shift73k_web/channels/user_socket.ex similarity index 86% rename from lib/bones73k_web/channels/user_socket.ex rename to lib/shift73k_web/channels/user_socket.ex index c9fbafae..e0670c26 100644 --- a/lib/bones73k_web/channels/user_socket.ex +++ b/lib/shift73k_web/channels/user_socket.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserSocket do +defmodule Shift73kWeb.UserSocket do use Phoenix.Socket ## Channels - # channel "room:*", Bones73kWeb.RoomChannel + # channel "room:*", Shift73kWeb.RoomChannel # Socket params are passed from the client and can # be used to verify and authenticate a user. After @@ -27,7 +27,7 @@ defmodule Bones73kWeb.UserSocket do # Would allow you to broadcast a "disconnect" event and terminate # all active sockets and channels for a given user: # - # Bones73kWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) + # Shift73kWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) # # Returning `nil` makes this socket anonymous. @impl true diff --git a/lib/bones73k_web/controllers/other_controller.ex b/lib/shift73k_web/controllers/other_controller.ex similarity index 89% rename from lib/bones73k_web/controllers/other_controller.ex rename to lib/shift73k_web/controllers/other_controller.ex index 8576b753..942377cf 100644 --- a/lib/bones73k_web/controllers/other_controller.ex +++ b/lib/shift73k_web/controllers/other_controller.ex @@ -1,5 +1,5 @@ -defmodule Bones73kWeb.OtherController do - use Bones73kWeb, :controller +defmodule Shift73kWeb.OtherController do + use Shift73kWeb, :controller def index(conn, _params) do conn diff --git a/lib/bones73k_web/controllers/user_auth.ex b/lib/shift73k_web/controllers/user_auth.ex similarity index 96% rename from lib/bones73k_web/controllers/user_auth.ex rename to lib/shift73k_web/controllers/user_auth.ex index 390d6bb3..b7a3557e 100644 --- a/lib/bones73k_web/controllers/user_auth.ex +++ b/lib/shift73k_web/controllers/user_auth.ex @@ -1,9 +1,9 @@ -defmodule Bones73kWeb.UserAuth do +defmodule Shift73kWeb.UserAuth do import Plug.Conn import Phoenix.Controller - alias Bones73k.Accounts - alias Bones73kWeb.Router.Helpers, as: Routes + alias Shift73k.Accounts + alias Shift73kWeb.Router.Helpers, as: Routes @pubsub_topic "user_updates" @@ -76,7 +76,7 @@ defmodule Bones73kWeb.UserAuth do user_token && Accounts.delete_session_token(user_token) if live_socket_id = get_session(conn, :live_socket_id) do - Bones73kWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{}) + Shift73kWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{}) end conn diff --git a/lib/bones73k_web/controllers/user_confirmation_controller.ex b/lib/shift73k_web/controllers/user_confirmation_controller.ex similarity index 90% rename from lib/bones73k_web/controllers/user_confirmation_controller.ex rename to lib/shift73k_web/controllers/user_confirmation_controller.ex index c6774979..4c6e4764 100644 --- a/lib/bones73k_web/controllers/user_confirmation_controller.ex +++ b/lib/shift73k_web/controllers/user_confirmation_controller.ex @@ -1,7 +1,7 @@ -defmodule Bones73kWeb.UserConfirmationController do - use Bones73kWeb, :controller +defmodule Shift73kWeb.UserConfirmationController do + use Shift73kWeb, :controller - alias Bones73k.Accounts + alias Shift73k.Accounts def new(conn, _params) do render(conn, "new.html") diff --git a/lib/shift73k_web/controllers/user_registration_controller.ex b/lib/shift73k_web/controllers/user_registration_controller.ex new file mode 100644 index 00000000..d759d444 --- /dev/null +++ b/lib/shift73k_web/controllers/user_registration_controller.ex @@ -0,0 +1,8 @@ +defmodule Shift73kWeb.UserRegistrationController do + use Shift73kWeb, :controller + import Phoenix.LiveView.Controller + + def new(conn, _params) do + live_render(conn, Shift73kWeb.UserLive.Registration) + end +end diff --git a/lib/bones73k_web/controllers/user_reset_password_controller.ex b/lib/shift73k_web/controllers/user_reset_password_controller.ex similarity index 86% rename from lib/bones73k_web/controllers/user_reset_password_controller.ex rename to lib/shift73k_web/controllers/user_reset_password_controller.ex index d7d289b5..aef6bdab 100644 --- a/lib/bones73k_web/controllers/user_reset_password_controller.ex +++ b/lib/shift73k_web/controllers/user_reset_password_controller.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserResetPasswordController do - use Bones73kWeb, :controller +defmodule Shift73kWeb.UserResetPasswordController do + use Shift73kWeb, :controller import Phoenix.LiveView.Controller - alias Bones73k.Accounts + alias Shift73k.Accounts plug(:get_user_by_reset_password_token when action in [:edit]) @@ -28,7 +28,7 @@ defmodule Bones73kWeb.UserResetPasswordController do end def edit(conn, _params) do - live_render(conn, Bones73kWeb.UserLive.ResetPassword) + live_render(conn, Shift73kWeb.UserLive.ResetPassword) end defp get_user_by_reset_password_token(conn, _opts) do diff --git a/lib/bones73k_web/controllers/user_session_controller.ex b/lib/shift73k_web/controllers/user_session_controller.ex similarity index 86% rename from lib/bones73k_web/controllers/user_session_controller.ex rename to lib/shift73k_web/controllers/user_session_controller.ex index 546943a4..3cb3b975 100644 --- a/lib/bones73k_web/controllers/user_session_controller.ex +++ b/lib/shift73k_web/controllers/user_session_controller.ex @@ -1,10 +1,10 @@ -defmodule Bones73kWeb.UserSessionController do - use Bones73kWeb, :controller +defmodule Shift73kWeb.UserSessionController do + use Shift73kWeb, :controller alias Phoenix.HTML - alias Bones73k.Accounts - alias Bones73k.Accounts.User - alias Bones73kWeb.UserAuth + alias Shift73k.Accounts + alias Shift73k.Accounts.User + alias Shift73kWeb.UserAuth def new(conn, _params) do render(conn, "new.html", error_message: nil) @@ -24,7 +24,7 @@ defmodule Bones73kWeb.UserSessionController do end def create(conn, %{"user" => %{"params_token" => token} = user_params}) do - with {:ok, params} <- Phoenix.Token.decrypt(Bones73kWeb.Endpoint, "login_params", token), + with {:ok, params} <- Phoenix.Token.decrypt(Shift73kWeb.Endpoint, "login_params", token), %User{} = user <- Accounts.get_user(params.user_id) do conn |> collect_messages(params.messages) diff --git a/lib/bones73k_web/controllers/user_settings_controller.ex b/lib/shift73k_web/controllers/user_settings_controller.ex similarity index 81% rename from lib/bones73k_web/controllers/user_settings_controller.ex rename to lib/shift73k_web/controllers/user_settings_controller.ex index 4aefacc0..d6d03030 100644 --- a/lib/bones73k_web/controllers/user_settings_controller.ex +++ b/lib/shift73k_web/controllers/user_settings_controller.ex @@ -1,7 +1,7 @@ -defmodule Bones73kWeb.UserSettingsController do - use Bones73kWeb, :controller +defmodule Shift73kWeb.UserSettingsController do + use Shift73kWeb, :controller - alias Bones73k.Accounts + alias Shift73k.Accounts def confirm_email(conn, %{"token" => token}) do case Accounts.update_user_email(conn.assigns.current_user, token) do diff --git a/lib/bones73k_web/endpoint.ex b/lib/shift73k_web/endpoint.ex similarity index 84% rename from lib/bones73k_web/endpoint.ex rename to lib/shift73k_web/endpoint.ex index d20b9945..b74d04ff 100644 --- a/lib/bones73k_web/endpoint.ex +++ b/lib/shift73k_web/endpoint.ex @@ -1,16 +1,16 @@ -defmodule Bones73kWeb.Endpoint do - use Phoenix.Endpoint, otp_app: :bones73k +defmodule Shift73kWeb.Endpoint do + use Phoenix.Endpoint, otp_app: :shift73k # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. @session_options [ store: :cookie, - key: "_bones73k_key", + key: "_shift73k_key", signing_salt: "9CKxo0VJ" ] - socket("/socket", Bones73kWeb.UserSocket, + socket("/socket", Shift73kWeb.UserSocket, websocket: true, longpoll: false ) @@ -23,7 +23,7 @@ defmodule Bones73kWeb.Endpoint do # when deploying your static files in production. plug(Plug.Static, at: "/", - from: :bones73k, + from: :shift73k, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) ) @@ -34,7 +34,7 @@ defmodule Bones73kWeb.Endpoint do socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket) plug(Phoenix.LiveReloader) plug(Phoenix.CodeReloader) - plug(Phoenix.Ecto.CheckRepoStatus, otp_app: :bones73k) + plug(Phoenix.Ecto.CheckRepoStatus, otp_app: :shift73k) end plug(Phoenix.LiveDashboard.RequestLogger, @@ -54,5 +54,5 @@ defmodule Bones73kWeb.Endpoint do plug(Plug.MethodOverride) plug(Plug.Head) plug(Plug.Session, @session_options) - plug(Bones73kWeb.Router) + plug(Shift73kWeb.Router) end diff --git a/lib/bones73k_web/gettext.ex b/lib/shift73k_web/gettext.ex similarity index 85% rename from lib/bones73k_web/gettext.ex rename to lib/shift73k_web/gettext.ex index 6d6d65b3..e08cabc8 100644 --- a/lib/bones73k_web/gettext.ex +++ b/lib/shift73k_web/gettext.ex @@ -1,11 +1,11 @@ -defmodule Bones73kWeb.Gettext do +defmodule Shift73kWeb.Gettext do @moduledoc """ A module providing Internationalization with a gettext-based API. By using [Gettext](https://hexdocs.pm/gettext), your module gains a set of macros for translations, for example: - import Bones73kWeb.Gettext + import Shift73kWeb.Gettext # Simple translation gettext("Here is the string to translate") @@ -20,5 +20,5 @@ defmodule Bones73kWeb.Gettext do See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. """ - use Gettext, otp_app: :bones73k + use Gettext, otp_app: :shift73k end diff --git a/lib/bones73k_web/live/admin_dashboard_live.ex b/lib/shift73k_web/live/admin_dashboard_live.ex similarity index 79% rename from lib/bones73k_web/live/admin_dashboard_live.ex rename to lib/shift73k_web/live/admin_dashboard_live.ex index 21eb4409..6ba8da39 100644 --- a/lib/bones73k_web/live/admin_dashboard_live.ex +++ b/lib/shift73k_web/live/admin_dashboard_live.ex @@ -1,5 +1,5 @@ -defmodule Bones73kWeb.AdminDashboardLive do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.AdminDashboardLive do + use Shift73kWeb, :live_view @impl true def mount(_params, session, socket) do diff --git a/lib/bones73k_web/live/live_helpers.ex b/lib/shift73k_web/live/live_helpers.ex similarity index 81% rename from lib/bones73k_web/live/live_helpers.ex rename to lib/shift73k_web/live/live_helpers.ex index 67e2dbea..6667f05a 100644 --- a/lib/bones73k_web/live/live_helpers.ex +++ b/lib/shift73k_web/live/live_helpers.ex @@ -1,10 +1,10 @@ -defmodule Bones73kWeb.LiveHelpers do +defmodule Shift73kWeb.LiveHelpers do import Phoenix.LiveView import Phoenix.LiveView.Helpers - alias Bones73k.Accounts - alias Bones73k.Accounts.User - alias Bones73kWeb.UserAuth + alias Shift73k.Accounts + alias Shift73k.Accounts.User + alias Shift73kWeb.UserAuth @doc """ Performs the {:noreply, socket} for a given socket. @@ -19,14 +19,14 @@ defmodule Bones73kWeb.LiveHelpers do def live_okreply(socket), do: {:ok, socket} @doc """ - Renders a component inside the `Bones73kWeb.ModalComponent` component. + Renders a component inside the `Shift73kWeb.ModalComponent` component. The rendered modal receives a `:return_to` option to properly update the URL when the modal is closed. ## Examples - <%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent, + <%= live_modal @socket, Shift73kWeb.PropertyLive.FormComponent, id: @property.id || :new, action: @live_action, property: @property, @@ -36,14 +36,14 @@ defmodule Bones73kWeb.LiveHelpers do modal_opts = [id: :modal, component: component, opts: opts] # dirty little workaround for elixir complaining about socket being unused _socket = socket - live_component(socket, Bones73kWeb.ModalComponent, modal_opts) + live_component(socket, Shift73kWeb.ModalComponent, modal_opts) end @doc """ Loads default assigns for liveviews """ def assign_defaults(socket, session) do - Bones73kWeb.Endpoint.subscribe(UserAuth.pubsub_topic()) + Shift73kWeb.Endpoint.subscribe(UserAuth.pubsub_topic()) assign_current_user(socket, session) end diff --git a/lib/bones73k_web/live/modal_component.ex b/lib/shift73k_web/live/modal_component.ex similarity index 92% rename from lib/bones73k_web/live/modal_component.ex rename to lib/shift73k_web/live/modal_component.ex index 83363592..3fc7d984 100644 --- a/lib/bones73k_web/live/modal_component.ex +++ b/lib/shift73k_web/live/modal_component.ex @@ -1,5 +1,5 @@ -defmodule Bones73kWeb.ModalComponent do - use Bones73kWeb, :live_component +defmodule Shift73kWeb.ModalComponent do + use Shift73kWeb, :live_component @impl true def render(assigns) do diff --git a/lib/bones73k_web/live/page_live.ex b/lib/shift73k_web/live/page_live.ex similarity index 89% rename from lib/bones73k_web/live/page_live.ex rename to lib/shift73k_web/live/page_live.ex index c694d507..aba5f081 100644 --- a/lib/bones73k_web/live/page_live.ex +++ b/lib/shift73k_web/live/page_live.ex @@ -1,5 +1,5 @@ -defmodule Bones73kWeb.PageLive do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.PageLive do + use Shift73kWeb, :live_view @impl true def mount(_params, session, socket) do @@ -27,7 +27,7 @@ defmodule Bones73kWeb.PageLive do end defp search(query) do - if not Bones73kWeb.Endpoint.config(:code_reloader) do + if not Shift73kWeb.Endpoint.config(:code_reloader) do raise "action disabled when not in development" end diff --git a/lib/bones73k_web/live/page_live.html.leex b/lib/shift73k_web/live/page_live.html.leex similarity index 100% rename from lib/bones73k_web/live/page_live.html.leex rename to lib/shift73k_web/live/page_live.html.leex diff --git a/lib/bones73k_web/live/property_live/form_component.ex b/lib/shift73k_web/live/property_live/form_component.ex similarity index 94% rename from lib/bones73k_web/live/property_live/form_component.ex rename to lib/shift73k_web/live/property_live/form_component.ex index 7ab0c914..69d00f44 100644 --- a/lib/bones73k_web/live/property_live/form_component.ex +++ b/lib/shift73k_web/live/property_live/form_component.ex @@ -1,7 +1,7 @@ -defmodule Bones73kWeb.PropertyLive.FormComponent do - use Bones73kWeb, :live_component +defmodule Shift73kWeb.PropertyLive.FormComponent do + use Shift73kWeb, :live_component - alias Bones73k.Properties + alias Shift73k.Properties @impl true def update(%{property: property} = assigns, socket) do diff --git a/lib/bones73k_web/live/property_live/form_component.html.leex b/lib/shift73k_web/live/property_live/form_component.html.leex similarity index 100% rename from lib/bones73k_web/live/property_live/form_component.html.leex rename to lib/shift73k_web/live/property_live/form_component.html.leex diff --git a/lib/bones73k_web/live/property_live/index.ex b/lib/shift73k_web/live/property_live/index.ex similarity index 90% rename from lib/bones73k_web/live/property_live/index.ex rename to lib/shift73k_web/live/property_live/index.ex index 9f1e89b2..a27cfe47 100644 --- a/lib/bones73k_web/live/property_live/index.ex +++ b/lib/shift73k_web/live/property_live/index.ex @@ -1,9 +1,9 @@ -defmodule Bones73kWeb.PropertyLive.Index do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.PropertyLive.Index do + use Shift73kWeb, :live_view - alias Bones73k.Properties - alias Bones73k.Properties.Property - alias Bones73kWeb.Roles + alias Shift73k.Properties + alias Shift73k.Properties.Property + alias Shift73kWeb.Roles @impl true def mount(_params, session, socket) do @@ -54,7 +54,7 @@ defmodule Bones73kWeb.PropertyLive.Index do current_user = socket.assigns.current_user property = Properties.get_property!(id) - if Bones73kWeb.Roles.can?(current_user, property, :delete) do + if Shift73kWeb.Roles.can?(current_user, property, :delete) do property = Properties.get_property!(id) {:ok, _} = Properties.delete_property(property) diff --git a/lib/bones73k_web/live/property_live/index.html.leex b/lib/shift73k_web/live/property_live/index.html.leex similarity index 96% rename from lib/bones73k_web/live/property_live/index.html.leex rename to lib/shift73k_web/live/property_live/index.html.leex index 7fda0fec..fdbc8ffc 100644 --- a/lib/bones73k_web/live/property_live/index.html.leex +++ b/lib/shift73k_web/live/property_live/index.html.leex @@ -1,5 +1,5 @@ <%= if @live_action in [:new, :edit] do %> - <%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent, + <%= live_modal @socket, Shift73kWeb.PropertyLive.FormComponent, id: @property.id || :new, title: @page_title, action: @live_action, diff --git a/lib/bones73k_web/live/property_live/show.ex b/lib/shift73k_web/live/property_live/show.ex similarity index 90% rename from lib/bones73k_web/live/property_live/show.ex rename to lib/shift73k_web/live/property_live/show.ex index d5809cde..033a2a99 100644 --- a/lib/bones73k_web/live/property_live/show.ex +++ b/lib/shift73k_web/live/property_live/show.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.PropertyLive.Show do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.PropertyLive.Show do + use Shift73kWeb, :live_view - alias Bones73k.Properties - alias Bones73kWeb.Roles + alias Shift73k.Properties + alias Shift73kWeb.Roles @impl true def mount(_params, session, socket) do diff --git a/lib/bones73k_web/live/property_live/show.html.leex b/lib/shift73k_web/live/property_live/show.html.leex similarity index 93% rename from lib/bones73k_web/live/property_live/show.html.leex rename to lib/shift73k_web/live/property_live/show.html.leex index 18a61458..ce6c35a2 100644 --- a/lib/bones73k_web/live/property_live/show.html.leex +++ b/lib/shift73k_web/live/property_live/show.html.leex @@ -1,7 +1,7 @@

Show Property

<%= if @live_action in [:edit] do %> - <%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent, + <%= live_modal @socket, Shift73kWeb.PropertyLive.FormComponent, id: @property.id, title: @page_title, action: @live_action, diff --git a/lib/bones73k_web/live/user/registration.ex b/lib/shift73k_web/live/user/registration.ex similarity index 92% rename from lib/bones73k_web/live/user/registration.ex rename to lib/shift73k_web/live/user/registration.ex index d964fde5..e9d8976a 100644 --- a/lib/bones73k_web/live/user/registration.ex +++ b/lib/shift73k_web/live/user/registration.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserLive.Registration do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.UserLive.Registration do + use Shift73kWeb, :live_view - alias Bones73k.Accounts - alias Bones73k.Accounts.User + alias Shift73k.Accounts + alias Shift73k.Accounts.User @impl true def mount(_params, session, socket) do diff --git a/lib/bones73k_web/live/user/registration.html.leex b/lib/shift73k_web/live/user/registration.html.leex similarity index 97% rename from lib/bones73k_web/live/user/registration.html.leex rename to lib/shift73k_web/live/user/registration.html.leex index 412a78cc..8d547cef 100644 --- a/lib/bones73k_web/live/user/registration.html.leex +++ b/lib/shift73k_web/live/user/registration.html.leex @@ -63,7 +63,7 @@ <%# hidden form for initial login after registration %> <%= form_for :user, Routes.user_session_path(@socket, :create), [phx_trigger_action: @trigger_submit, id: "reg_trigger"], fn f -> %> - <%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", @login_params) %> + <%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", @login_params) %> <% end %> diff --git a/lib/bones73k_web/live/user/reset_password.ex b/lib/shift73k_web/live/user/reset_password.ex similarity index 88% rename from lib/bones73k_web/live/user/reset_password.ex rename to lib/shift73k_web/live/user/reset_password.ex index 05945461..2c2b801c 100644 --- a/lib/bones73k_web/live/user/reset_password.ex +++ b/lib/shift73k_web/live/user/reset_password.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserLive.ResetPassword do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.UserLive.ResetPassword do + use Shift73kWeb, :live_view - alias Bones73k.Accounts - alias Bones73k.Accounts.User + alias Shift73k.Accounts + alias Shift73k.Accounts.User @impl true def mount(_params, session, socket) do diff --git a/lib/bones73k_web/live/user/reset_password.html.leex b/lib/shift73k_web/live/user/reset_password.html.leex similarity index 100% rename from lib/bones73k_web/live/user/reset_password.html.leex rename to lib/shift73k_web/live/user/reset_password.html.leex diff --git a/lib/bones73k_web/live/user/settings.ex b/lib/shift73k_web/live/user/settings.ex similarity index 89% rename from lib/bones73k_web/live/user/settings.ex rename to lib/shift73k_web/live/user/settings.ex index 2821f362..aa25bbf5 100644 --- a/lib/bones73k_web/live/user/settings.ex +++ b/lib/shift73k_web/live/user/settings.ex @@ -1,7 +1,7 @@ -defmodule Bones73kWeb.UserLive.Settings do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.UserLive.Settings do + use Shift73kWeb, :live_view - alias Bones73k.Accounts.User + alias Shift73k.Accounts.User @impl true def mount(_params, session, socket) do diff --git a/lib/bones73k_web/live/user/settings.html.leex b/lib/shift73k_web/live/user/settings.html.leex similarity index 68% rename from lib/bones73k_web/live/user/settings.html.leex rename to lib/shift73k_web/live/user/settings.html.leex index 31b344d7..6e615e69 100644 --- a/lib/bones73k_web/live/user/settings.html.leex +++ b/lib/shift73k_web/live/user/settings.html.leex @@ -4,6 +4,6 @@
- <%= live_component @socket, Bones73kWeb.UserLive.Settings.Email, id: "email-#{@current_user.id}", current_user: @current_user %> - <%= live_component @socket, Bones73kWeb.UserLive.Settings.Password, id: "password-#{@current_user.id}", current_user: @current_user %> + <%= live_component @socket, Shift73kWeb.UserLive.Settings.Email, id: "email-#{@current_user.id}", current_user: @current_user %> + <%= live_component @socket, Shift73kWeb.UserLive.Settings.Password, id: "password-#{@current_user.id}", current_user: @current_user %>
diff --git a/lib/bones73k_web/live/user/settings/email.ex b/lib/shift73k_web/live/user/settings/email.ex similarity index 89% rename from lib/bones73k_web/live/user/settings/email.ex rename to lib/shift73k_web/live/user/settings/email.ex index 49915d6f..cf59273a 100644 --- a/lib/bones73k_web/live/user/settings/email.ex +++ b/lib/shift73k_web/live/user/settings/email.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserLive.Settings.Email do - use Bones73kWeb, :live_component +defmodule Shift73kWeb.UserLive.Settings.Email do + use Shift73kWeb, :live_component - alias Bones73k.Accounts - alias Bones73k.Accounts.User + alias Shift73k.Accounts + alias Shift73k.Accounts.User @impl true def update(%{current_user: user} = assigns, socket) do @@ -23,7 +23,7 @@ defmodule Bones73kWeb.UserLive.Settings.Email do {:noreply, assign(socket, changeset: %{cs | action: :validate})} end - # user_settings_path GET /users/settings/confirm_email/:token Bones73kWeb.UserSettingsController :confirm_email + # user_settings_path GET /users/settings/confirm_email/:token Shift73kWeb.UserSettingsController :confirm_email @impl true def handle_event("save", %{"user" => user_params}, socket) do diff --git a/lib/bones73k_web/live/user/settings/email.html.leex b/lib/shift73k_web/live/user/settings/email.html.leex similarity index 100% rename from lib/bones73k_web/live/user/settings/email.html.leex rename to lib/shift73k_web/live/user/settings/email.html.leex diff --git a/lib/bones73k_web/live/user/settings/password.ex b/lib/shift73k_web/live/user/settings/password.ex similarity index 91% rename from lib/bones73k_web/live/user/settings/password.ex rename to lib/shift73k_web/live/user/settings/password.ex index 4a670af5..9fd28ae4 100644 --- a/lib/bones73k_web/live/user/settings/password.ex +++ b/lib/shift73k_web/live/user/settings/password.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserLive.Settings.Password do - use Bones73kWeb, :live_component +defmodule Shift73kWeb.UserLive.Settings.Password do + use Shift73kWeb, :live_component - alias Bones73k.Accounts - alias Bones73k.Accounts.User + alias Shift73k.Accounts + alias Shift73k.Accounts.User @impl true def update(%{current_user: user} = assigns, socket) do diff --git a/lib/bones73k_web/live/user/settings/password.html.leex b/lib/shift73k_web/live/user/settings/password.html.leex similarity index 96% rename from lib/bones73k_web/live/user/settings/password.html.leex rename to lib/shift73k_web/live/user/settings/password.html.leex index e6afacdd..05f529fa 100644 --- a/lib/bones73k_web/live/user/settings/password.html.leex +++ b/lib/shift73k_web/live/user/settings/password.html.leex @@ -65,12 +65,12 @@ <%# hidden form for initial login after registration %> <%= form_for :user, Routes.user_session_path(@socket, :create), [phx_trigger_action: @trigger_submit, id: "settings_pw_change_trigger"], fn f -> %> - <%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", @login_params) %> + <%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", @login_params) %> <% end %> <%# hidden form to submit user for relogin after password change %> <%#= form_for :user_login, Routes.user_session_path(@socket, :create), [phx_trigger_action: @trigger_submit], fn f -> %> - <%#= hidden_input f, :login_params_token, value: Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", @login_params) %> + <%#= hidden_input f, :login_params_token, value: Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", @login_params) %> <%#= hidden_input f, :remember_me, value: false %> <%# end %> diff --git a/lib/bones73k_web/live/user_dashboard_live.ex b/lib/shift73k_web/live/user_dashboard_live.ex similarity index 79% rename from lib/bones73k_web/live/user_dashboard_live.ex rename to lib/shift73k_web/live/user_dashboard_live.ex index 4b79a71c..70a91ae3 100644 --- a/lib/bones73k_web/live/user_dashboard_live.ex +++ b/lib/shift73k_web/live/user_dashboard_live.ex @@ -1,5 +1,5 @@ -defmodule Bones73kWeb.UserDashboardLive do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.UserDashboardLive do + use Shift73kWeb, :live_view @impl true def mount(_params, session, socket) do diff --git a/lib/bones73k_web/live/user_management/delete_component.ex b/lib/shift73k_web/live/user_management/delete_component.ex similarity index 89% rename from lib/bones73k_web/live/user_management/delete_component.ex rename to lib/shift73k_web/live/user_management/delete_component.ex index 548f7498..d781c145 100644 --- a/lib/bones73k_web/live/user_management/delete_component.ex +++ b/lib/shift73k_web/live/user_management/delete_component.ex @@ -1,7 +1,7 @@ -defmodule Bones73kWeb.UserManagement.DeleteComponent do - use Bones73kWeb, :live_component +defmodule Shift73kWeb.UserManagement.DeleteComponent do + use Shift73kWeb, :live_component - alias Bones73k.Accounts + alias Shift73k.Accounts @impl true def update(assigns, socket) do diff --git a/lib/bones73k_web/live/user_management/delete_component.html.leex b/lib/shift73k_web/live/user_management/delete_component.html.leex similarity index 100% rename from lib/bones73k_web/live/user_management/delete_component.html.leex rename to lib/shift73k_web/live/user_management/delete_component.html.leex diff --git a/lib/bones73k_web/live/user_management/form_component.ex b/lib/shift73k_web/live/user_management/form_component.ex similarity index 93% rename from lib/bones73k_web/live/user_management/form_component.ex rename to lib/shift73k_web/live/user_management/form_component.ex index e7866542..fa41df90 100644 --- a/lib/bones73k_web/live/user_management/form_component.ex +++ b/lib/shift73k_web/live/user_management/form_component.ex @@ -1,9 +1,9 @@ -defmodule Bones73kWeb.UserManagement.FormComponent do - use Bones73kWeb, :live_component +defmodule Shift73kWeb.UserManagement.FormComponent do + use Shift73kWeb, :live_component - alias Bones73k.Accounts - alias Bones73k.Accounts.User - alias Bones73kWeb.Roles + alias Shift73k.Accounts + alias Shift73k.Accounts.User + alias Shift73kWeb.Roles @impl true def update(assigns, socket) do diff --git a/lib/bones73k_web/live/user_management/form_component.html.leex b/lib/shift73k_web/live/user_management/form_component.html.leex similarity index 100% rename from lib/bones73k_web/live/user_management/form_component.html.leex rename to lib/shift73k_web/live/user_management/form_component.html.leex diff --git a/lib/bones73k_web/live/user_management/index.ex b/lib/shift73k_web/live/user_management/index.ex similarity index 95% rename from lib/bones73k_web/live/user_management/index.ex rename to lib/shift73k_web/live/user_management/index.ex index d1da3b40..4fefe001 100644 --- a/lib/bones73k_web/live/user_management/index.ex +++ b/lib/shift73k_web/live/user_management/index.ex @@ -1,14 +1,14 @@ -defmodule Bones73kWeb.UserManagementLive.Index do - use Bones73kWeb, :live_view +defmodule Shift73kWeb.UserManagementLive.Index do + use Shift73kWeb, :live_view import Ecto.Query - import Bones73kWeb.Pagination - import Bones73k.Util.Dt + import Shift73kWeb.Pagination + import Shift73k.Util.Dt - alias Bones73k.Repo - alias Bones73k.Accounts - alias Bones73k.Accounts.User - alias Bones73kWeb.Roles + alias Shift73k.Repo + alias Shift73k.Accounts + alias Shift73k.Accounts.User + alias Shift73kWeb.Roles @impl true def mount(_params, session, socket) do diff --git a/lib/bones73k_web/live/user_management/index.html.leex b/lib/shift73k_web/live/user_management/index.html.leex similarity index 98% rename from lib/bones73k_web/live/user_management/index.html.leex rename to lib/shift73k_web/live/user_management/index.html.leex index a8f200b6..ef589c5e 100644 --- a/lib/bones73k_web/live/user_management/index.html.leex +++ b/lib/shift73k_web/live/user_management/index.html.leex @@ -1,5 +1,5 @@ <%= if @live_action in [:new, :edit] do %> - <%= live_modal @socket, Bones73kWeb.UserManagement.FormComponent, + <%= live_modal @socket, Shift73kWeb.UserManagement.FormComponent, id: @user.id || :new, title: @page_title, action: @live_action, @@ -8,7 +8,7 @@ <% end %> <%= if @delete_user do %> - <%= live_modal @socket, Bones73kWeb.UserManagement.DeleteComponent, + <%= live_modal @socket, Shift73kWeb.UserManagement.DeleteComponent, id: @delete_user.id, title: "Delete User", delete_user: @delete_user, diff --git a/lib/bones73k_web/plugs/ensure_role_plug.ex b/lib/shift73k_web/plugs/ensure_role_plug.ex similarity index 86% rename from lib/bones73k_web/plugs/ensure_role_plug.ex rename to lib/shift73k_web/plugs/ensure_role_plug.ex index 8edd2ad4..9c604e11 100644 --- a/lib/bones73k_web/plugs/ensure_role_plug.ex +++ b/lib/shift73k_web/plugs/ensure_role_plug.ex @@ -1,4 +1,4 @@ -defmodule Bones73kWeb.EnsureRolePlug do +defmodule Shift73kWeb.EnsureRolePlug do @moduledoc """ This plug ensures that a user has a particular role before accessing a given route. @@ -6,15 +6,15 @@ defmodule Bones73kWeb.EnsureRolePlug do Let's suppose we have three roles: :admin, :manager and :user. If you want a user to have at least manager role, so admins and managers are authorised to access a given route - plug Bones73kWeb.EnsureRolePlug, [:admin, :manager] + plug Shift73kWeb.EnsureRolePlug, [:admin, :manager] If you want to give access only to an admin: - plug Bones73kWeb.EnsureRolePlug, :admin + plug Shift73kWeb.EnsureRolePlug, :admin """ import Plug.Conn - alias Bones73k.Accounts - alias Bones73k.Accounts.User + alias Shift73k.Accounts + alias Shift73k.Accounts.User alias Phoenix.Controller alias Plug.Conn diff --git a/lib/bones73k_web/roles.ex b/lib/shift73k_web/roles.ex similarity index 90% rename from lib/bones73k_web/roles.ex rename to lib/shift73k_web/roles.ex index 372adb91..2c9cc66b 100644 --- a/lib/bones73k_web/roles.ex +++ b/lib/shift73k_web/roles.ex @@ -1,10 +1,10 @@ -defmodule Bones73kWeb.Roles do +defmodule Shift73kWeb.Roles do @moduledoc """ Defines roles related functions. """ - alias Bones73k.Accounts.User - alias Bones73k.Properties.Property + alias Shift73k.Accounts.User + alias Shift73k.Properties.Property @type entity :: struct() @type action :: :new | :index | :edit | :show | :delete | :edit_role diff --git a/lib/bones73k_web/router.ex b/lib/shift73k_web/router.ex similarity index 80% rename from lib/bones73k_web/router.ex rename to lib/shift73k_web/router.ex index 4986a67b..12e5e3b9 100644 --- a/lib/bones73k_web/router.ex +++ b/lib/shift73k_web/router.ex @@ -1,13 +1,13 @@ -defmodule Bones73kWeb.Router do - use Bones73kWeb, :router - import Bones73kWeb.UserAuth - alias Bones73kWeb.EnsureRolePlug +defmodule Shift73kWeb.Router do + use Shift73kWeb, :router + import Shift73kWeb.UserAuth + alias Shift73kWeb.EnsureRolePlug pipeline :browser do plug(:accepts, ["html"]) plug(:fetch_session) plug(:fetch_live_flash) - plug(:put_root_layout, {Bones73kWeb.LayoutView, :root}) + plug(:put_root_layout, {Shift73kWeb.LayoutView, :root}) plug(:protect_from_forgery) plug(:put_secure_browser_headers) plug(:fetch_current_user) @@ -29,15 +29,15 @@ defmodule Bones73kWeb.Router do plug(EnsureRolePlug, :admin) end - scope "/", Bones73kWeb do - pipe_through [:browser] + scope "/", Shift73kWeb do + pipe_through([:browser]) - live "/", PageLive, :index - get "/other", OtherController, :index + live("/", PageLive, :index) + get("/other", OtherController, :index) end # Other scopes may use custom stacks. - # scope "/api", Bones73kWeb do + # scope "/api", Shift73kWeb do # pipe_through :api # end @@ -53,11 +53,11 @@ defmodule Bones73kWeb.Router do scope "/" do pipe_through(:browser) - live_dashboard("/dashboard", metrics: Bones73kWeb.Telemetry) + live_dashboard("/dashboard", metrics: Shift73kWeb.Telemetry) end end - scope "/", Bones73kWeb do + scope "/", Shift73kWeb do pipe_through([:browser, :redirect_if_user_is_authenticated]) get("/users/register", UserRegistrationController, :new) @@ -68,17 +68,17 @@ defmodule Bones73kWeb.Router do get("/users/reset_password/:token", UserResetPasswordController, :edit) end - scope "/", Bones73kWeb do + scope "/", Shift73kWeb do pipe_through([:browser, :require_authenticated_user]) # # liveview user settings - live "/users/settings", UserLive.Settings, :edit + live("/users/settings", UserLive.Settings, :edit) # original user routes from phx.gen.auth get("/users/settings/confirm_email/:token", UserSettingsController, :confirm_email) end - scope "/", Bones73kWeb do + scope "/", Shift73kWeb do pipe_through([:browser]) delete("/users/log_out", UserSessionController, :delete) @@ -88,7 +88,7 @@ defmodule Bones73kWeb.Router do get("/users/confirm/:token", UserConfirmationController, :confirm) end - scope "/", Bones73kWeb do + scope "/", Shift73kWeb do pipe_through([:browser, :require_authenticated_user, :user]) live("/user_dashboard", UserDashboardLive, :index) @@ -100,15 +100,15 @@ defmodule Bones73kWeb.Router do live("/properties/:id/show/edit", PropertyLive.Show, :edit) end - scope "/", Bones73kWeb do + scope "/", Shift73kWeb do pipe_through([:browser, :require_authenticated_user, :admin]) live("/admin_dashboard", AdminDashboardLive, :index) end # Users Management - scope "/users", Bones73kWeb do - pipe_through [:browser, :require_authenticated_user, :manager, :require_email_confirmed] + scope "/users", Shift73kWeb do + pipe_through([:browser, :require_authenticated_user, :manager, :require_email_confirmed]) live("/", UserManagementLive.Index, :index) live("/new", UserManagementLive.Index, :new) diff --git a/lib/bones73k_web/telemetry.ex b/lib/shift73k_web/telemetry.ex similarity index 78% rename from lib/bones73k_web/telemetry.ex rename to lib/shift73k_web/telemetry.ex index 6a6c17bb..d762df58 100644 --- a/lib/bones73k_web/telemetry.ex +++ b/lib/shift73k_web/telemetry.ex @@ -1,4 +1,4 @@ -defmodule Bones73kWeb.Telemetry do +defmodule Shift73kWeb.Telemetry do use Supervisor import Telemetry.Metrics @@ -31,11 +31,11 @@ defmodule Bones73kWeb.Telemetry do ), # Database Metrics - summary("bones73k.repo.query.total_time", unit: {:native, :millisecond}), - summary("bones73k.repo.query.decode_time", unit: {:native, :millisecond}), - summary("bones73k.repo.query.query_time", unit: {:native, :millisecond}), - summary("bones73k.repo.query.queue_time", unit: {:native, :millisecond}), - summary("bones73k.repo.query.idle_time", unit: {:native, :millisecond}), + summary("shift73k.repo.query.total_time", unit: {:native, :millisecond}), + summary("shift73k.repo.query.decode_time", unit: {:native, :millisecond}), + summary("shift73k.repo.query.query_time", unit: {:native, :millisecond}), + summary("shift73k.repo.query.queue_time", unit: {:native, :millisecond}), + summary("shift73k.repo.query.idle_time", unit: {:native, :millisecond}), # VM Metrics summary("vm.memory.total", unit: {:byte, :kilobyte}), @@ -49,7 +49,7 @@ defmodule Bones73kWeb.Telemetry do [ # A module, function and arguments to be invoked periodically. # This function must call :telemetry.execute/3 and a metric must be added above. - # {Bones73kWeb, :count_users, []} + # {Shift73kWeb, :count_users, []} ] end end diff --git a/lib/bones73k_web/templates/layout/_navbar.html.eex b/lib/shift73k_web/templates/layout/_navbar.html.eex similarity index 97% rename from lib/bones73k_web/templates/layout/_navbar.html.eex rename to lib/shift73k_web/templates/layout/_navbar.html.eex index 998e9cc9..ef8aaefa 100644 --- a/lib/bones73k_web/templates/layout/_navbar.html.eex +++ b/lib/shift73k_web/templates/layout/_navbar.html.eex @@ -4,7 +4,7 @@

<%= link to: Routes.page_path(@conn, :index), class: "navbar-brand fs-4" do %> <%= icon_div @conn, "mdi-skull-crossbones", [class: "icon baseline fs-3"] %> - Bones73k + Shift73k <% end %>

diff --git a/lib/bones73k_web/templates/layout/app.html.eex b/lib/shift73k_web/templates/layout/app.html.eex similarity index 100% rename from lib/bones73k_web/templates/layout/app.html.eex rename to lib/shift73k_web/templates/layout/app.html.eex diff --git a/lib/bones73k_web/templates/layout/live.html.leex b/lib/shift73k_web/templates/layout/live.html.leex similarity index 100% rename from lib/bones73k_web/templates/layout/live.html.leex rename to lib/shift73k_web/templates/layout/live.html.leex diff --git a/lib/bones73k_web/templates/layout/navbar/_user_menu.html.eex b/lib/shift73k_web/templates/layout/navbar/_user_menu.html.eex similarity index 100% rename from lib/bones73k_web/templates/layout/navbar/_user_menu.html.eex rename to lib/shift73k_web/templates/layout/navbar/_user_menu.html.eex diff --git a/lib/bones73k_web/templates/layout/root.html.leex b/lib/shift73k_web/templates/layout/root.html.leex similarity index 90% rename from lib/bones73k_web/templates/layout/root.html.leex rename to lib/shift73k_web/templates/layout/root.html.leex index 4cfa7310..0650e836 100644 --- a/lib/bones73k_web/templates/layout/root.html.leex +++ b/lib/shift73k_web/templates/layout/root.html.leex @@ -5,7 +5,7 @@ <%= csrf_meta_tag() %> - <%= live_title_tag assigns[:page_title] || "Bones73k", suffix: " · Phoenix Framework" %> + <%= live_title_tag assigns[:page_title] || "Shift73k", suffix: " · Phoenix Framework" %> "/> diff --git a/lib/bones73k_web/templates/other/index.html.eex b/lib/shift73k_web/templates/other/index.html.eex similarity index 100% rename from lib/bones73k_web/templates/other/index.html.eex rename to lib/shift73k_web/templates/other/index.html.eex diff --git a/lib/bones73k_web/templates/user_confirmation/new.html.eex b/lib/shift73k_web/templates/user_confirmation/new.html.eex similarity index 100% rename from lib/bones73k_web/templates/user_confirmation/new.html.eex rename to lib/shift73k_web/templates/user_confirmation/new.html.eex diff --git a/lib/bones73k_web/templates/user_reset_password/new.html.eex b/lib/shift73k_web/templates/user_reset_password/new.html.eex similarity index 100% rename from lib/bones73k_web/templates/user_reset_password/new.html.eex rename to lib/shift73k_web/templates/user_reset_password/new.html.eex diff --git a/lib/bones73k_web/templates/user_session/new.html.eex b/lib/shift73k_web/templates/user_session/new.html.eex similarity index 100% rename from lib/bones73k_web/templates/user_session/new.html.eex rename to lib/shift73k_web/templates/user_session/new.html.eex diff --git a/lib/bones73k_web/views/error_helpers.ex b/lib/shift73k_web/views/error_helpers.ex similarity index 91% rename from lib/bones73k_web/views/error_helpers.ex rename to lib/shift73k_web/views/error_helpers.ex index fb44ac65..655859c9 100644 --- a/lib/bones73k_web/views/error_helpers.ex +++ b/lib/shift73k_web/views/error_helpers.ex @@ -1,4 +1,4 @@ -defmodule Bones73kWeb.ErrorHelpers do +defmodule Shift73kWeb.ErrorHelpers do @moduledoc """ Conveniences for translating and building error messages. """ @@ -31,7 +31,9 @@ defmodule Bones73kWeb.ErrorHelpers do def input_class(form, field, classes \\ "") do case form.source.action do - nil -> classes + nil -> + classes + _ -> case Keyword.has_key?(form.errors, field) do true -> "#{classes} is-invalid" @@ -62,9 +64,9 @@ defmodule Bones73kWeb.ErrorHelpers do # should be written to the errors.po file. The :count option is # set by Ecto and indicates we should also apply plural rules. if count = opts[:count] do - Gettext.dngettext(Bones73kWeb.Gettext, "errors", msg, msg, count, opts) + Gettext.dngettext(Shift73kWeb.Gettext, "errors", msg, msg, count, opts) else - Gettext.dgettext(Bones73kWeb.Gettext, "errors", msg, opts) + Gettext.dgettext(Shift73kWeb.Gettext, "errors", msg, opts) end end end diff --git a/lib/bones73k_web/views/error_view.ex b/lib/shift73k_web/views/error_view.ex similarity index 87% rename from lib/bones73k_web/views/error_view.ex rename to lib/shift73k_web/views/error_view.ex index 67ce167e..85a50aa4 100644 --- a/lib/bones73k_web/views/error_view.ex +++ b/lib/shift73k_web/views/error_view.ex @@ -1,5 +1,5 @@ -defmodule Bones73kWeb.ErrorView do - use Bones73kWeb, :view +defmodule Shift73kWeb.ErrorView do + use Shift73kWeb, :view # If you want to customize a particular status code # for a certain format, you may uncomment below. diff --git a/lib/bones73k_web/views/icon_helpers.ex b/lib/shift73k_web/views/icon_helpers.ex similarity index 90% rename from lib/bones73k_web/views/icon_helpers.ex rename to lib/shift73k_web/views/icon_helpers.ex index e86389d8..32f15b37 100644 --- a/lib/bones73k_web/views/icon_helpers.ex +++ b/lib/shift73k_web/views/icon_helpers.ex @@ -1,10 +1,10 @@ -defmodule Bones73kWeb.IconHelpers do +defmodule Shift73kWeb.IconHelpers do @moduledoc """ Generate SVG sprite use tags for SVG icons """ use Phoenix.HTML - alias Bones73kWeb.Router.Helpers, as: Routes + alias Shift73kWeb.Router.Helpers, as: Routes def icon_div(conn, name, div_opts \\ [], svg_opts \\ []) do content_tag(:div, tag_opts(name, div_opts)) do diff --git a/lib/bones73k_web/views/layout_view.ex b/lib/shift73k_web/views/layout_view.ex similarity index 79% rename from lib/bones73k_web/views/layout_view.ex rename to lib/shift73k_web/views/layout_view.ex index f4d57e51..2548d26b 100644 --- a/lib/bones73k_web/views/layout_view.ex +++ b/lib/shift73k_web/views/layout_view.ex @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.LayoutView do - use Bones73kWeb, :view +defmodule Shift73kWeb.LayoutView do + use Shift73kWeb, :view - alias Bones73k.Accounts.User - alias Bones73kWeb.Roles + alias Shift73k.Accounts.User + alias Shift73kWeb.Roles def nav_link_opts(conn, opts) do case Keyword.get(opts, :to) == Phoenix.Controller.current_path(conn) do diff --git a/lib/shift73k_web/views/other_view.ex b/lib/shift73k_web/views/other_view.ex new file mode 100644 index 00000000..9bfb1801 --- /dev/null +++ b/lib/shift73k_web/views/other_view.ex @@ -0,0 +1,3 @@ +defmodule Shift73kWeb.OtherView do + use Shift73kWeb, :view +end diff --git a/lib/bones73k_web/views/pagination.ex b/lib/shift73k_web/views/pagination.ex similarity index 95% rename from lib/bones73k_web/views/pagination.ex rename to lib/shift73k_web/views/pagination.ex index 7850cc1d..76247d76 100644 --- a/lib/bones73k_web/views/pagination.ex +++ b/lib/shift73k_web/views/pagination.ex @@ -1,4 +1,4 @@ -defmodule Bones73kWeb.Pagination do +defmodule Shift73kWeb.Pagination do def generate_page_list(_, total_pages) when total_pages < 5, do: 1..total_pages |> Enum.to_list() diff --git a/lib/shift73k_web/views/user_confirmation_view.ex b/lib/shift73k_web/views/user_confirmation_view.ex new file mode 100644 index 00000000..0c02ca8f --- /dev/null +++ b/lib/shift73k_web/views/user_confirmation_view.ex @@ -0,0 +1,4 @@ +defmodule Shift73kWeb.UserConfirmationView do + use Shift73kWeb, :view + alias Shift73k.Accounts.User +end diff --git a/lib/shift73k_web/views/user_reset_password_view.ex b/lib/shift73k_web/views/user_reset_password_view.ex new file mode 100644 index 00000000..940a55bb --- /dev/null +++ b/lib/shift73k_web/views/user_reset_password_view.ex @@ -0,0 +1,4 @@ +defmodule Shift73kWeb.UserResetPasswordView do + use Shift73kWeb, :view + alias Shift73k.Accounts.User +end diff --git a/lib/shift73k_web/views/user_session_view.ex b/lib/shift73k_web/views/user_session_view.ex new file mode 100644 index 00000000..32055191 --- /dev/null +++ b/lib/shift73k_web/views/user_session_view.ex @@ -0,0 +1,4 @@ +defmodule Shift73kWeb.UserSessionView do + use Shift73kWeb, :view + alias Shift73k.Accounts.User +end diff --git a/mix.exs b/mix.exs index 2a939c41..95b7dd28 100644 --- a/mix.exs +++ b/mix.exs @@ -1,9 +1,9 @@ -defmodule Bones73k.MixProject do +defmodule Shift73k.MixProject do use Mix.Project def project do [ - app: :bones73k, + app: :shift73k, version: "0.1.0", elixir: "~> 1.7", elixirc_paths: elixirc_paths(Mix.env()), @@ -19,7 +19,7 @@ defmodule Bones73k.MixProject do # Type `mix help compile.app` for more information. def application do [ - mod: {Bones73k.Application, []}, + mod: {Shift73k.Application, []}, extra_applications: [:logger, :runtime_tools] ] end diff --git a/priv/repo/migrations/20200913000515_create_users_auth_tables.exs b/priv/repo/migrations/20200913000515_create_users_auth_tables.exs index efc5f616..27fe40a8 100644 --- a/priv/repo/migrations/20200913000515_create_users_auth_tables.exs +++ b/priv/repo/migrations/20200913000515_create_users_auth_tables.exs @@ -1,4 +1,4 @@ -defmodule Bones73k.Repo.Migrations.CreateUsersAuthTables do +defmodule Shift73k.Repo.Migrations.CreateUsersAuthTables do use Ecto.Migration def change do diff --git a/priv/repo/migrations/20200913000905_add_role_to_users.exs b/priv/repo/migrations/20200913000905_add_role_to_users.exs index 68b32a65..6ec24b9a 100644 --- a/priv/repo/migrations/20200913000905_add_role_to_users.exs +++ b/priv/repo/migrations/20200913000905_add_role_to_users.exs @@ -1,7 +1,7 @@ -defmodule Bones73k.Repo.Migrations.AddRoleToUsers do +defmodule Shift73k.Repo.Migrations.AddRoleToUsers do use Ecto.Migration - alias Bones73k.Accounts.User.RolesEnum + alias Shift73k.Accounts.User.RolesEnum def up do RolesEnum.create_type() diff --git a/priv/repo/migrations/20200914162043_create_properties.exs b/priv/repo/migrations/20200914162043_create_properties.exs index 979606e0..291e19cf 100644 --- a/priv/repo/migrations/20200914162043_create_properties.exs +++ b/priv/repo/migrations/20200914162043_create_properties.exs @@ -1,4 +1,4 @@ -defmodule Bones73k.Repo.Migrations.CreateProperties do +defmodule Shift73k.Repo.Migrations.CreateProperties do use Ecto.Migration def change do diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index 72f4671f..7fd17c40 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -5,16 +5,16 @@ # Inside the script, you can read and write to any of your # repositories directly: # -# Bones73k.Repo.insert!(%Bones73k.SomeSchema{}) +# Shift73k.Repo.insert!(%Shift73k.SomeSchema{}) # # We recommend using the bang functions (`insert!`, `update!` # and so on) as they will fail if something goes wrong. import Ecto.Query -alias Bones73k.Repo -alias Bones73k.Accounts -alias Bones73k.Accounts.User -alias Bones73k.Properties.Property +alias Shift73k.Repo +alias Shift73k.Accounts +alias Shift73k.Accounts.User +alias Shift73k.Properties.Property ############################################################################ ## INSERTING MOCK USER DATA @@ -86,7 +86,7 @@ Enum.each(1..10, fn i -> description: "Property that belongs to user 1", user_id: user_1.id } - |> Bones73k.Properties.create_property() + |> Shift73k.Properties.create_property() %{ name: "Property #{i} - User 2", @@ -94,7 +94,7 @@ Enum.each(1..10, fn i -> description: "Property that belongs to user 2", user_id: user_2.id } - |> Bones73k.Properties.create_property() + |> Shift73k.Properties.create_property() %{ name: "Property #{i} - Admin", @@ -102,7 +102,7 @@ Enum.each(1..10, fn i -> description: "Property that belongs to admin", user_id: admin.id } - |> Bones73k.Properties.create_property() + |> Shift73k.Properties.create_property() end) # if Mix.env() == :dev do @@ -114,7 +114,7 @@ count_to_take = 123 mock_props = props_json |> File.read!() |> Jason.decode!() |> Enum.take_random(count_to_take) -random_user_query = from User, order_by: fragment("RANDOM()"), limit: 1 +random_user_query = from(User, order_by: fragment("RANDOM()"), limit: 1) mock_props = Enum.map(mock_props, fn e -> diff --git a/test/bones73k/accounts_test.exs b/test/shift73k/accounts_test.exs similarity index 99% rename from test/bones73k/accounts_test.exs rename to test/shift73k/accounts_test.exs index b36dd274..c93a910f 100644 --- a/test/bones73k/accounts_test.exs +++ b/test/shift73k/accounts_test.exs @@ -1,9 +1,9 @@ -defmodule Bones73k.AccountsTest do - use Bones73k.DataCase +defmodule Shift73k.AccountsTest do + use Shift73k.DataCase - alias Bones73k.Accounts - import Bones73k.AccountsFixtures - alias Bones73k.Accounts.{User, UserToken} + alias Shift73k.Accounts + import Shift73k.AccountsFixtures + alias Shift73k.Accounts.{User, UserToken} describe "get_user_by_email/1" do test "does not return the user if the email does not exist" do diff --git a/test/bones73k/properties_test.exs b/test/shift73k/properties_test.exs similarity index 94% rename from test/bones73k/properties_test.exs rename to test/shift73k/properties_test.exs index f930a793..e29ee506 100644 --- a/test/bones73k/properties_test.exs +++ b/test/shift73k/properties_test.exs @@ -1,11 +1,11 @@ -defmodule Bones73k.PropertiesTest do - use Bones73k.DataCase +defmodule Shift73k.PropertiesTest do + use Shift73k.DataCase - alias Bones73k.Properties - import Bones73k.AccountsFixtures + alias Shift73k.Properties + import Shift73k.AccountsFixtures describe "properties" do - alias Bones73k.Properties.Property + alias Shift73k.Properties.Property @valid_attrs %{description: "some description", name: "some name", price: "120.5"} @update_attrs %{ diff --git a/test/bones73k_web/controllers/user_auth_test.exs b/test/shift73k_web/controllers/user_auth_test.exs similarity index 95% rename from test/bones73k_web/controllers/user_auth_test.exs rename to test/shift73k_web/controllers/user_auth_test.exs index 30e0d9ff..56ec4724 100644 --- a/test/bones73k_web/controllers/user_auth_test.exs +++ b/test/shift73k_web/controllers/user_auth_test.exs @@ -1,14 +1,14 @@ -defmodule Bones73kWeb.UserAuthTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.UserAuthTest do + use Shift73kWeb.ConnCase, async: true - alias Bones73k.Accounts - alias Bones73kWeb.UserAuth - import Bones73k.AccountsFixtures + alias Shift73k.Accounts + alias Shift73kWeb.UserAuth + import Shift73k.AccountsFixtures setup %{conn: conn} do conn = conn - |> Map.replace!(:secret_key_base, Bones73kWeb.Endpoint.config(:secret_key_base)) + |> Map.replace!(:secret_key_base, Shift73kWeb.Endpoint.config(:secret_key_base)) |> init_test_session(%{}) %{user: user_fixture(), conn: conn} @@ -63,7 +63,7 @@ defmodule Bones73kWeb.UserAuthTest do test "broadcasts to the given live_socket_id", %{conn: conn} do live_socket_id = "users_sessions:abcdef-token" - Bones73kWeb.Endpoint.subscribe(live_socket_id) + Shift73kWeb.Endpoint.subscribe(live_socket_id) conn |> put_session(:live_socket_id, live_socket_id) diff --git a/test/bones73k_web/controllers/user_confirmation_controller_test.exs b/test/shift73k_web/controllers/user_confirmation_controller_test.exs similarity index 94% rename from test/bones73k_web/controllers/user_confirmation_controller_test.exs rename to test/shift73k_web/controllers/user_confirmation_controller_test.exs index ec8812f8..4f900753 100644 --- a/test/bones73k_web/controllers/user_confirmation_controller_test.exs +++ b/test/shift73k_web/controllers/user_confirmation_controller_test.exs @@ -1,9 +1,9 @@ -defmodule Bones73kWeb.UserConfirmationControllerTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.UserConfirmationControllerTest do + use Shift73kWeb.ConnCase, async: true - alias Bones73k.Accounts - alias Bones73k.Repo - import Bones73k.AccountsFixtures + alias Shift73k.Accounts + alias Shift73k.Repo + import Shift73k.AccountsFixtures setup do %{user: user_fixture()} diff --git a/test/bones73k_web/controllers/user_registration_controller_test.exs b/test/shift73k_web/controllers/user_registration_controller_test.exs similarity index 81% rename from test/bones73k_web/controllers/user_registration_controller_test.exs rename to test/shift73k_web/controllers/user_registration_controller_test.exs index 9d053915..80667e76 100644 --- a/test/bones73k_web/controllers/user_registration_controller_test.exs +++ b/test/shift73k_web/controllers/user_registration_controller_test.exs @@ -1,7 +1,7 @@ -defmodule Bones73kWeb.UserRegistrationControllerTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.UserRegistrationControllerTest do + use Shift73kWeb.ConnCase, async: true - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures describe "GET /users/register" do test "renders registration page", %{conn: conn} do diff --git a/test/bones73k_web/controllers/user_reset_password_controller_test.exs b/test/shift73k_web/controllers/user_reset_password_controller_test.exs similarity index 93% rename from test/bones73k_web/controllers/user_reset_password_controller_test.exs rename to test/shift73k_web/controllers/user_reset_password_controller_test.exs index c09eb1ca..c98206b2 100644 --- a/test/bones73k_web/controllers/user_reset_password_controller_test.exs +++ b/test/shift73k_web/controllers/user_reset_password_controller_test.exs @@ -1,9 +1,9 @@ -defmodule Bones73kWeb.UserResetPasswordControllerTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.UserResetPasswordControllerTest do + use Shift73kWeb.ConnCase, async: true - alias Bones73k.Accounts - alias Bones73k.Repo - import Bones73k.AccountsFixtures + alias Shift73k.Accounts + alias Shift73k.Repo + import Shift73k.AccountsFixtures setup do %{user: user_fixture()} diff --git a/test/bones73k_web/controllers/user_session_controller_test.exs b/test/shift73k_web/controllers/user_session_controller_test.exs similarity index 97% rename from test/bones73k_web/controllers/user_session_controller_test.exs rename to test/shift73k_web/controllers/user_session_controller_test.exs index 763cd6b2..4acb70fb 100644 --- a/test/bones73k_web/controllers/user_session_controller_test.exs +++ b/test/shift73k_web/controllers/user_session_controller_test.exs @@ -1,7 +1,7 @@ -defmodule Bones73kWeb.UserSessionControllerTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.UserSessionControllerTest do + use Shift73kWeb.ConnCase, async: true - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures setup do %{user: user_fixture()} diff --git a/test/bones73k_web/controllers/user_settings_controller_test.exs b/test/shift73k_web/controllers/user_settings_controller_test.exs similarity index 93% rename from test/bones73k_web/controllers/user_settings_controller_test.exs rename to test/shift73k_web/controllers/user_settings_controller_test.exs index 55815e66..cbdfb363 100644 --- a/test/bones73k_web/controllers/user_settings_controller_test.exs +++ b/test/shift73k_web/controllers/user_settings_controller_test.exs @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserSettingsControllerTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.UserSettingsControllerTest do + use Shift73kWeb.ConnCase, async: true - alias Bones73k.Accounts - import Bones73k.AccountsFixtures + alias Shift73k.Accounts + import Shift73k.AccountsFixtures setup :register_and_log_in_user diff --git a/test/bones73k_web/live/admin_dashboard_live_test.exs b/test/shift73k_web/live/admin_dashboard_live_test.exs similarity index 93% rename from test/bones73k_web/live/admin_dashboard_live_test.exs rename to test/shift73k_web/live/admin_dashboard_live_test.exs index 1f3c50a6..405c5045 100644 --- a/test/bones73k_web/live/admin_dashboard_live_test.exs +++ b/test/shift73k_web/live/admin_dashboard_live_test.exs @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.AdminDashboardLiveTest do - use Bones73kWeb.ConnCase +defmodule Shift73kWeb.AdminDashboardLiveTest do + use Shift73kWeb.ConnCase import Phoenix.LiveViewTest - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures test "disconnected and connected render without authentication should redirect to login page", %{conn: conn} do @@ -38,7 +38,7 @@ defmodule Bones73kWeb.AdminDashboardLiveTest do assert disconnected_html =~ "Welcome to the admin dashboard!" assert render(admin_dashboard) =~ "Welcome to the admin dashboard!" - Bones73k.Accounts.logout_user(admin) + Shift73k.Accounts.logout_user(admin) # Assert our liveview process is down ref = Process.monitor(admin_dashboard.pid) @@ -67,7 +67,7 @@ defmodule Bones73kWeb.AdminDashboardLiveTest do assert disconnected_html =~ "Welcome to the admin dashboard!" assert render(admin_dashboard) =~ "Welcome to the admin dashboard!" - Bones73k.Accounts.logout_user(admin2) + Shift73k.Accounts.logout_user(admin2) # Assert our liveview is alive ref = Process.monitor(admin_dashboard.pid) diff --git a/test/bones73k_web/live/page_live_test.exs b/test/shift73k_web/live/page_live_test.exs similarity index 91% rename from test/bones73k_web/live/page_live_test.exs rename to test/shift73k_web/live/page_live_test.exs index a271747e..716bccab 100644 --- a/test/bones73k_web/live/page_live_test.exs +++ b/test/shift73k_web/live/page_live_test.exs @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.PageLiveTest do - use Bones73kWeb.ConnCase +defmodule Shift73kWeb.PageLiveTest do + use Shift73kWeb.ConnCase import Phoenix.LiveViewTest - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures test "disconnected and connected render with authentication should redirect to index page", %{ conn: conn @@ -24,7 +24,7 @@ defmodule Bones73kWeb.PageLiveTest do assert disconnected_html =~ "Welcome to Phoenix!" assert render(page_live) =~ "Welcome to Phoenix!" - Bones73k.Accounts.logout_user(user) + Shift73k.Accounts.logout_user(user) # Assert our liveview process is down ref = Process.monitor(page_live.pid) @@ -53,7 +53,7 @@ defmodule Bones73kWeb.PageLiveTest do assert disconnected_html =~ "Welcome to Phoenix!" assert render(page_live) =~ "Welcome to Phoenix!" - Bones73k.Accounts.logout_user(user1) + Shift73k.Accounts.logout_user(user1) # Assert our liveview is alive ref = Process.monitor(page_live.pid) diff --git a/test/bones73k_web/live/property_live_test.exs b/test/shift73k_web/live/property_live_test.exs similarity index 97% rename from test/bones73k_web/live/property_live_test.exs rename to test/shift73k_web/live/property_live_test.exs index f9dc9660..650c04f9 100644 --- a/test/bones73k_web/live/property_live_test.exs +++ b/test/shift73k_web/live/property_live_test.exs @@ -1,10 +1,10 @@ -defmodule Bones73kWeb.PropertyLiveTest do - use Bones73kWeb.ConnCase +defmodule Shift73kWeb.PropertyLiveTest do + use Shift73kWeb.ConnCase import Phoenix.LiveViewTest - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures - alias Bones73k.Properties + alias Shift73k.Properties @create_attrs %{description: "some description", name: "some name", price: "120.5"} @update_attrs %{ @@ -208,7 +208,7 @@ defmodule Bones73kWeb.PropertyLiveTest do assert html =~ "Listing Properties" assert render(index_live) =~ "Listing Properties" - Bones73k.Accounts.logout_user(user) + Shift73k.Accounts.logout_user(user) # Assert our liveview process is down ref = Process.monitor(index_live.pid) @@ -238,7 +238,7 @@ defmodule Bones73kWeb.PropertyLiveTest do assert html =~ "Listing Properties" assert render(index_live) =~ "Listing Properties" - Bones73k.Accounts.logout_user(user1) + Shift73k.Accounts.logout_user(user1) # Assert our liveview is alive ref = Process.monitor(index_live.pid) @@ -366,7 +366,7 @@ defmodule Bones73kWeb.PropertyLiveTest do assert html =~ property.description assert render(show_live) =~ property.description - Bones73k.Accounts.logout_user(user) + Shift73k.Accounts.logout_user(user) # Assert our liveview process is down ref = Process.monitor(show_live.pid) @@ -395,7 +395,7 @@ defmodule Bones73kWeb.PropertyLiveTest do assert html =~ property.description assert render(show_live) =~ property.description - Bones73k.Accounts.logout_user(user1) + Shift73k.Accounts.logout_user(user1) # Assert our liveview is alive ref = Process.monitor(show_live.pid) diff --git a/test/bones73k_web/live/user/registration_test.exs b/test/shift73k_web/live/user/registration_test.exs similarity index 83% rename from test/bones73k_web/live/user/registration_test.exs rename to test/shift73k_web/live/user/registration_test.exs index 88b747c4..359e830c 100644 --- a/test/bones73k_web/live/user/registration_test.exs +++ b/test/shift73k_web/live/user/registration_test.exs @@ -1,11 +1,11 @@ -defmodule Bones73kWeb.UserLive.RegistrationTest do - use Bones73kWeb.ConnCase +defmodule Shift73kWeb.UserLive.RegistrationTest do + use Shift73kWeb.ConnCase import Phoenix.LiveViewTest - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures - alias Bones73k.Accounts - alias Bones73k.Accounts.User + alias Shift73k.Accounts + alias Shift73k.Accounts.User describe "Registration" do setup %{conn: conn} do @@ -15,14 +15,14 @@ defmodule Bones73kWeb.UserLive.RegistrationTest do end test "displays registration form", %{conn: conn} do - {:ok, _view, html} = live_isolated(conn, Bones73kWeb.UserLive.Registration) + {:ok, _view, html} = live_isolated(conn, Shift73kWeb.UserLive.Registration) assert html =~ "Register\n " assert html =~ "Email" end test "render errors for invalid data", %{conn: conn} do - {:ok, view, _html} = live_isolated(conn, Bones73kWeb.UserLive.Registration) + {:ok, view, _html} = live_isolated(conn, Shift73kWeb.UserLive.Registration) html = view @@ -40,7 +40,7 @@ defmodule Bones73kWeb.UserLive.RegistrationTest do conn: conn, user_return_to: user_return_to } do - {:ok, view, html} = live_isolated(conn, Bones73kWeb.UserLive.Registration) + {:ok, view, html} = live_isolated(conn, Shift73kWeb.UserLive.Registration) # Login trigger form not triggered yet refute html =~ "phx-trigger-action=\"phx-trigger-action\"" @@ -59,7 +59,7 @@ defmodule Bones73kWeb.UserLive.RegistrationTest do # Collect the rendered login params token [params_token] = Floki.attribute(html, "input#user_params_token", "value") - {:ok, params} = Phoenix.Token.decrypt(Bones73kWeb.Endpoint, "login_params", params_token) + {:ok, params} = Phoenix.Token.decrypt(Shift73kWeb.Endpoint, "login_params", params_token) %{user_id: param_user_id, user_return_to: param_return_path} = params # Token in login trigger form has correct user ID? diff --git a/test/bones73k_web/live/user/reset_password_test.exs b/test/shift73k_web/live/user/reset_password_test.exs similarity index 79% rename from test/bones73k_web/live/user/reset_password_test.exs rename to test/shift73k_web/live/user/reset_password_test.exs index c6d9be59..d789e02e 100644 --- a/test/bones73k_web/live/user/reset_password_test.exs +++ b/test/shift73k_web/live/user/reset_password_test.exs @@ -1,12 +1,12 @@ -defmodule Bones73kWeb.UserLive.ResetPasswordTest do - use Bones73kWeb.ConnCase +defmodule Shift73kWeb.UserLive.ResetPasswordTest do + use Shift73kWeb.ConnCase import Phoenix.LiveViewTest - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures - alias Bones73k.Repo - alias Bones73k.Accounts - alias Bones73k.Accounts.{User, UserToken} + alias Shift73k.Repo + alias Shift73k.Accounts + alias Shift73k.Accounts.{User, UserToken} setup %{conn: conn} do user = user_fixture() @@ -15,7 +15,7 @@ defmodule Bones73kWeb.UserLive.ResetPasswordTest do end test "displays registration form", %{conn: conn, user: user} do - {:ok, _view, html} = live_isolated(conn, Bones73kWeb.UserLive.ResetPassword) + {:ok, _view, html} = live_isolated(conn, Shift73kWeb.UserLive.ResetPassword) assert html =~ "Reset password\n " assert html =~ user.email @@ -23,7 +23,7 @@ defmodule Bones73kWeb.UserLive.ResetPasswordTest do end test "render errors for invalid data", %{conn: conn} do - {:ok, view, _html} = live_isolated(conn, Bones73kWeb.UserLive.ResetPassword) + {:ok, view, _html} = live_isolated(conn, Shift73kWeb.UserLive.ResetPassword) form_data = %{"user" => %{"password" => "abc", "password_confirmation" => "def"}} html = form(view, "#pw_reset_form", form_data) |> render_change() @@ -36,7 +36,7 @@ defmodule Bones73kWeb.UserLive.ResetPasswordTest do @tag :capture_log test "saves new password once", %{conn: conn, user: user} do - {:ok, view, _html} = live_isolated(conn, Bones73kWeb.UserLive.ResetPassword) + {:ok, view, _html} = live_isolated(conn, Shift73kWeb.UserLive.ResetPassword) # Render submitting a new password new_pw = "valid_new_pass_123" diff --git a/test/bones73k_web/live/user_dashboard_live_test.exs b/test/shift73k_web/live/user_dashboard_live_test.exs similarity index 93% rename from test/bones73k_web/live/user_dashboard_live_test.exs rename to test/shift73k_web/live/user_dashboard_live_test.exs index d2fea218..d94a889e 100644 --- a/test/bones73k_web/live/user_dashboard_live_test.exs +++ b/test/shift73k_web/live/user_dashboard_live_test.exs @@ -1,8 +1,8 @@ -defmodule Bones73kWeb.UserDashboardLiveTest do - use Bones73kWeb.ConnCase +defmodule Shift73kWeb.UserDashboardLiveTest do + use Shift73kWeb.ConnCase import Phoenix.LiveViewTest - import Bones73k.AccountsFixtures + import Shift73k.AccountsFixtures test "disconnected and connected render without authentication should redirect to login page", %{conn: conn} do @@ -40,7 +40,7 @@ defmodule Bones73kWeb.UserDashboardLiveTest do assert disconnected_html =~ "Welcome to the user dashboard!" assert render(user_dashboard) =~ "Welcome to the user dashboard!" - Bones73k.Accounts.logout_user(user) + Shift73k.Accounts.logout_user(user) # Assert our liveview process is down ref = Process.monitor(user_dashboard.pid) @@ -69,7 +69,7 @@ defmodule Bones73kWeb.UserDashboardLiveTest do assert disconnected_html =~ "Welcome to the user dashboard!" assert render(user_dashboard) =~ "Welcome to the user dashboard!" - Bones73k.Accounts.logout_user(user2) + Shift73k.Accounts.logout_user(user2) # Assert our liveview is alive ref = Process.monitor(user_dashboard.pid) diff --git a/test/bones73k_web/views/error_view_test.exs b/test/shift73k_web/views/error_view_test.exs similarity index 50% rename from test/bones73k_web/views/error_view_test.exs rename to test/shift73k_web/views/error_view_test.exs index 2959ea22..271e18b1 100644 --- a/test/bones73k_web/views/error_view_test.exs +++ b/test/shift73k_web/views/error_view_test.exs @@ -1,14 +1,14 @@ -defmodule Bones73kWeb.ErrorViewTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.ErrorViewTest do + use Shift73kWeb.ConnCase, async: true # Bring render/3 and render_to_string/3 for testing custom views import Phoenix.View test "renders 404.html" do - assert render_to_string(Bones73kWeb.ErrorView, "404.html", []) == "Not Found" + assert render_to_string(Shift73kWeb.ErrorView, "404.html", []) == "Not Found" end test "renders 500.html" do - assert render_to_string(Bones73kWeb.ErrorView, "500.html", []) == "Internal Server Error" + assert render_to_string(Shift73kWeb.ErrorView, "500.html", []) == "Internal Server Error" end end diff --git a/test/bones73k_web/views/layout_view_test.exs b/test/shift73k_web/views/layout_view_test.exs similarity index 70% rename from test/bones73k_web/views/layout_view_test.exs rename to test/shift73k_web/views/layout_view_test.exs index ce5c67e2..b3b3b310 100644 --- a/test/bones73k_web/views/layout_view_test.exs +++ b/test/shift73k_web/views/layout_view_test.exs @@ -1,5 +1,5 @@ -defmodule Bones73kWeb.LayoutViewTest do - use Bones73kWeb.ConnCase, async: true +defmodule Shift73kWeb.LayoutViewTest do + use Shift73kWeb.ConnCase, async: true # When testing helpers, you may want to import Phoenix.HTML and # use functions such as safe_to_string() to convert the helper diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index c3a7bdbb..e63ab116 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -1,4 +1,4 @@ -defmodule Bones73kWeb.ChannelCase do +defmodule Shift73kWeb.ChannelCase do @moduledoc """ This module defines the test case to be used by channel tests. @@ -11,7 +11,7 @@ defmodule Bones73kWeb.ChannelCase do we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously - by setting `use Bones73kWeb.ChannelCase, async: true`, although + by setting `use Shift73kWeb.ChannelCase, async: true`, although this option is not recommended for other databases. """ @@ -21,18 +21,18 @@ defmodule Bones73kWeb.ChannelCase do quote do # Import conveniences for testing with channels import Phoenix.ChannelTest - import Bones73kWeb.ChannelCase + import Shift73kWeb.ChannelCase # The default endpoint for testing - @endpoint Bones73kWeb.Endpoint + @endpoint Shift73kWeb.Endpoint end end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo) + :ok = Ecto.Adapters.SQL.Sandbox.checkout(Shift73k.Repo) unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()}) + Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, {:shared, self()}) end :ok diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 479ae8d2..87774b34 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -1,4 +1,4 @@ -defmodule Bones73kWeb.ConnCase do +defmodule Shift73kWeb.ConnCase do @moduledoc """ This module defines the test case to be used by tests that require setting up a connection. @@ -11,7 +11,7 @@ defmodule Bones73kWeb.ConnCase do we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously - by setting `use Bones73kWeb.ConnCase, async: true`, although + by setting `use Shift73kWeb.ConnCase, async: true`, although this option is not recommended for other databases. """ @@ -22,20 +22,20 @@ defmodule Bones73kWeb.ConnCase do # Import conveniences for testing with connections import Plug.Conn import Phoenix.ConnTest - import Bones73kWeb.ConnCase + import Shift73kWeb.ConnCase - alias Bones73kWeb.Router.Helpers, as: Routes + alias Shift73kWeb.Router.Helpers, as: Routes # The default endpoint for testing - @endpoint Bones73kWeb.Endpoint + @endpoint Shift73kWeb.Endpoint end end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo) + :ok = Ecto.Adapters.SQL.Sandbox.checkout(Shift73k.Repo) unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()}) + Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, {:shared, self()}) end {:ok, conn: Phoenix.ConnTest.build_conn()} @@ -50,7 +50,7 @@ defmodule Bones73kWeb.ConnCase do test context. """ def register_and_log_in_user(%{conn: conn}) do - user = Bones73k.AccountsFixtures.user_fixture() + user = Shift73k.AccountsFixtures.user_fixture() %{conn: log_in_user(conn, user), user: user} end @@ -60,7 +60,7 @@ defmodule Bones73kWeb.ConnCase do It returns an updated `conn`. """ def log_in_user(conn, user) do - token = Bones73k.Accounts.generate_user_session_token(user) + token = Shift73k.Accounts.generate_user_session_token(user) conn |> Phoenix.ConnTest.init_test_session(%{}) diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 99793023..03504bfe 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -1,4 +1,4 @@ -defmodule Bones73k.DataCase do +defmodule Shift73k.DataCase do @moduledoc """ This module defines the setup for tests requiring access to the application's data layer. @@ -10,7 +10,7 @@ defmodule Bones73k.DataCase do we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously - by setting `use Bones73k.DataCase, async: true`, although + by setting `use Shift73k.DataCase, async: true`, although this option is not recommended for other databases. """ @@ -18,20 +18,20 @@ defmodule Bones73k.DataCase do using do quote do - alias Bones73k.Repo + alias Shift73k.Repo import Ecto import Ecto.Changeset import Ecto.Query - import Bones73k.DataCase + import Shift73k.DataCase end end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo) + :ok = Ecto.Adapters.SQL.Sandbox.checkout(Shift73k.Repo) unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()}) + Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, {:shared, self()}) end :ok diff --git a/test/support/fixtures/accounts_fixtures.ex b/test/support/fixtures/accounts_fixtures.ex index 1983ee7f..c4e7b5e4 100644 --- a/test/support/fixtures/accounts_fixtures.ex +++ b/test/support/fixtures/accounts_fixtures.ex @@ -1,7 +1,7 @@ -defmodule Bones73k.AccountsFixtures do +defmodule Shift73k.AccountsFixtures do @moduledoc """ This module defines test helpers for creating - entities via the `Bones73k.Accounts` context. + entities via the `Shift73k.Accounts` context. """ def unique_user_email, do: "user#{System.unique_integer()}@example.com" @@ -14,7 +14,7 @@ defmodule Bones73k.AccountsFixtures do email: unique_user_email(), password: valid_user_password() }) - |> Bones73k.Accounts.register_user() + |> Shift73k.Accounts.register_user() user end @@ -27,7 +27,7 @@ defmodule Bones73k.AccountsFixtures do email: unique_user_email(), password: valid_user_password() }) - |> Bones73k.Accounts.register_user() + |> Shift73k.Accounts.register_user() user end @@ -42,7 +42,7 @@ defmodule Bones73k.AccountsFixtures do end def login_params_token(user, return_path) do - Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", %{ + Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", %{ user_id: user.id, user_return_to: return_path, messages: [ diff --git a/test/test_helper.exs b/test/test_helper.exs index d5564048..7725a829 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,2 +1,2 @@ ExUnit.start() -Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, :manual) +Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, :manual)