Skip to content

Commit

Permalink
seed
Browse files Browse the repository at this point in the history
  • Loading branch information
pb committed Nov 2, 2022
1 parent b0b5b7d commit fa103ad
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/bg1/accounts/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ defmodule Bg1.Accounts.User do
defp validate_password(changeset, opts) do
changeset
|> validate_required([:password])
|> validate_length(:password, min: 12, max: 72)
|> validate_length(:password, min: 2, max: 72)
# |> validate_format(:password, ~r/[a-z]/, message: "at least one lower case character")
# |> validate_format(:password, ~r/[A-Z]/, message: "at least one upper case character")
# |> validate_format(:password, ~r/[!?@#$%^&*_0-9]/, message: "at least one digit or punctuation character")
Expand Down
5 changes: 3 additions & 2 deletions lib/bg1_web/live/assign_user.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule Bg1Web.AssignUser do


alias Bg1.Accounts
import Phoenix.Component

Expand All @@ -11,13 +12,13 @@ defmodule Bg1Web.AssignUser do
:current_user,
fn ->
Accounts.get_user_by_session_token_with_parameter(session["user_token"])
end
end
)
|> assign_new(
:testvar,
fn ->
"test var from assign new"
end
end
)
}
end
Expand Down
7 changes: 5 additions & 2 deletions lib/bg1_web/live/row_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<%= inspect @testvar %>
</div>
<div>
<%= inspect @current_user %>
current_user preloaded parameter
<br>
<%= inspect @current_user.parameter %>
</div>
<a href="/parameters">parameters</a>
<a href="/rows">rows</a>
Expand Down Expand Up @@ -35,7 +37,8 @@
<td><%= row.title %></td>

<td>
<span><%= live_redirect "live redirect Show", to: Routes.row_show_path(@socket, :show, row) %></span>
<.link navigate={"/rows/#{row.id}"}> navigate link</.link> |
<.link patch={"/rows/#{row.id}"}> patch link</.link>
| <span><a href={"/rows/#{row.id}"}>full reload link</a></span>
| <span><%= live_patch "Edit", to: Routes.row_index_path(@socket, :edit, row) %></span>
<span><%= link "Delete", to: "#", phx_click: "delete", phx_value_id: row.id, data: [confirm: "Are you sure?"] %></span>
Expand Down
2 changes: 1 addition & 1 deletion lib/bg1_web/live/row_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<%= inspect @testvar %>
</div>
<div>
<%= inspect @current_user %>
<%= inspect @current_user.parameter %>
</div>

<br>
Expand Down
10 changes: 5 additions & 5 deletions lib/bg1_web/templates/components/contact_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ defmodule Bg1Web.ContactComponent do

@moduledoc """
component templates
component templates
"""
"""


attr :row, Row, required: true
attr :parameter, Parameter, default: %Parameter{}
def display(assigns) do
~H"""
<%= @row.title%>
<%= @row.title%>
<%= inspect Map.get(@parameter, :phonelink) %>
<%= inspect @parameter.phonelink %>
Phonelink <%= Map.get @parameter, :phonelink %>
<%#= inspect @parameter.phonelink %>
"""
end

Expand Down
22 changes: 11 additions & 11 deletions lib/bg1_web/templates/layout/_user_menu.html.heex
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<ul>
<%= if @current_user do %>
<li><%= @current_user.email %></li>
<li><%= link "Settings", to: Routes.user_settings_path(@conn, :edit) %></li>
<li><%= link "Log out", to: Routes.user_session_path(@conn, :delete), method: :delete %></li>
<li> ||| <%= link "Parameters", to: Routes.parameter_path(@conn, :index) %>
<%= link "Rows", to: Routes.row_index_path(@conn, :index) %>
<%= link "Home", to: "/"%></li>
<% else %>
<li><%= link "Register", to: Routes.user_registration_path(@conn, :new) %></li>
<li><%= link "Log in", to: Routes.user_session_path(@conn, :new) %></li>
<% end %>
<%= if @current_user do %>
<li><%= @current_user.email %></li>
<li><%= link "Settings", to: Routes.user_settings_path(@conn, :edit) %></li>
<li><%= link "Log out", to: Routes.user_session_path(@conn, :delete), method: :delete %></li>
<li> ||| <%= link "Parameters", to: Routes.parameter_path(@conn, :index) %>
<%= link "Rows", to: Routes.row_index_path(@conn, :index) %>
<%= link "Home", to: "/"%></li>
<% else %>
<li><%= link "Register", to: Routes.user_registration_path(@conn, :new) %></li>
<li><%= link "Log in", to: Routes.user_session_path(@conn, :new) %></li>
<% end %>
</ul>
8 changes: 8 additions & 0 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.
alias Bg1.{Accounts, Parameters, Rows}



Accounts.register_user(%{email: "[email protected]", password: "bg1"})
Rows.create_row( %{title: "row 1"})
Rows.create_row( %{title: "row 2"})
Parameters.create_parameter( %{signature: "signature", phonelink: "phonelink", user_id: 1})

0 comments on commit fa103ad

Please sign in to comment.