Remove performerId.

This commit is contained in:
codevictory
2021-03-28 16:22:19 +03:00
parent da4ed0a6c1
commit 4a21ae7616
7 changed files with 46 additions and 28 deletions

View File

@@ -8,7 +8,6 @@ defmodule Runosaari.Registration.Performer do
field :fname, :string field :fname, :string
field :lname, :string field :lname, :string
field :notes, :string field :notes, :string
field :performerId, :integer
field :tel, :string field :tel, :string
timestamps() timestamps()
@@ -17,9 +16,8 @@ defmodule Runosaari.Registration.Performer do
@doc false @doc false
def changeset(performer, attrs) do def changeset(performer, attrs) do
performer performer
|> cast(attrs, [:performerId, :fname, :lname, :email, :tel, :confirmed, :notes]) |> cast(attrs, [:fname, :lname, :email, :tel, :confirmed, :notes])
|> validate_required([:performerId, :fname, :lname, :email, :tel, :confirmed, :notes]) |> validate_required([:fname, :lname, :email, :tel, :confirmed, :notes])
|> unique_constraint(:performerId)
|> unique_constraint(:email) |> unique_constraint(:email)
end end
end end

View File

@@ -5,10 +5,6 @@
</div> </div>
<% end %> <% end %>
<%= label f, :performerId %>
<%= number_input f, :performerId %>
<%= error_tag f, :performerId %>
<%= label f, :fname %> <%= label f, :fname %>
<%= text_input f, :fname %> <%= text_input f, :fname %>
<%= error_tag f, :fname %> <%= error_tag f, :fname %>

View File

@@ -3,7 +3,6 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Performerid</th>
<th>Fname</th> <th>Fname</th>
<th>Lname</th> <th>Lname</th>
<th>Email</th> <th>Email</th>
@@ -17,7 +16,6 @@
<tbody> <tbody>
<%= for performer <- @performers do %> <%= for performer <- @performers do %>
<tr> <tr>
<td><%= performer.performerId %></td>
<td><%= performer.fname %></td> <td><%= performer.fname %></td>
<td><%= performer.lname %></td> <td><%= performer.lname %></td>
<td><%= performer.email %></td> <td><%= performer.email %></td>

View File

@@ -2,11 +2,6 @@
<ul> <ul>
<li>
<strong>Performerid:</strong>
<%= @performer.performerId %>
</li>
<li> <li>
<strong>Fname:</strong> <strong>Fname:</strong>
<%= @performer.fname %> <%= @performer.fname %>

View File

@@ -3,10 +3,9 @@ defmodule Runosaari.Repo.Migrations.CreatePerformers do
def change do def change do
create table(:performers) do create table(:performers) do
add :performerId, :integer add :email, :string
add :fname, :string add :fname, :string
add :lname, :string add :lname, :string
add :email, :string
add :tel, :string add :tel, :string
add :confirmed, :boolean, default: false, null: false add :confirmed, :boolean, default: false, null: false
add :notes, :string add :notes, :string
@@ -14,7 +13,6 @@ defmodule Runosaari.Repo.Migrations.CreatePerformers do
timestamps() timestamps()
end end
create unique_index(:performers, [:performerId])
create unique_index(:performers, [:email]) create unique_index(:performers, [:email])
end end
end end

View File

@@ -6,9 +6,23 @@ defmodule Runosaari.RegistrationTest do
describe "performers" do describe "performers" do
alias Runosaari.Registration.Performer alias Runosaari.Registration.Performer
@valid_attrs %{confirmed: true, email: "some email", fname: "some fname", lname: "some lname", notes: "some notes", performerId: 42, tel: "some tel"} @valid_attrs %{
@update_attrs %{confirmed: false, email: "some updated email", fname: "some updated fname", lname: "some updated lname", notes: "some updated notes", performerId: 43, tel: "some updated tel"} confirmed: true,
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, performerId: nil, tel: nil} email: "some email",
fname: "some fname",
lname: "some lname",
notes: "some notes",
tel: "some tel"
}
@update_attrs %{
confirmed: false,
email: "some updated email",
fname: "some updated fname",
lname: "some updated lname",
notes: "some updated notes",
tel: "some updated tel"
}
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, tel: nil}
def performer_fixture(attrs \\ %{}) do def performer_fixture(attrs \\ %{}) do
{:ok, performer} = {:ok, performer} =
@@ -36,7 +50,6 @@ defmodule Runosaari.RegistrationTest do
assert performer.fname == "some fname" assert performer.fname == "some fname"
assert performer.lname == "some lname" assert performer.lname == "some lname"
assert performer.notes == "some notes" assert performer.notes == "some notes"
assert performer.performerId == 42
assert performer.tel == "some tel" assert performer.tel == "some tel"
end end
@@ -46,19 +59,24 @@ defmodule Runosaari.RegistrationTest do
test "update_performer/2 with valid data updates the performer" do test "update_performer/2 with valid data updates the performer" do
performer = performer_fixture() performer = performer_fixture()
assert {:ok, %Performer{} = performer} = Registration.update_performer(performer, @update_attrs)
assert {:ok, %Performer{} = performer} =
Registration.update_performer(performer, @update_attrs)
assert performer.confirmed == false assert performer.confirmed == false
assert performer.email == "some updated email" assert performer.email == "some updated email"
assert performer.fname == "some updated fname" assert performer.fname == "some updated fname"
assert performer.lname == "some updated lname" assert performer.lname == "some updated lname"
assert performer.notes == "some updated notes" assert performer.notes == "some updated notes"
assert performer.performerId == 43
assert performer.tel == "some updated tel" assert performer.tel == "some updated tel"
end end
test "update_performer/2 with invalid data returns error changeset" do test "update_performer/2 with invalid data returns error changeset" do
performer = performer_fixture() performer = performer_fixture()
assert {:error, %Ecto.Changeset{}} = Registration.update_performer(performer, @invalid_attrs)
assert {:error, %Ecto.Changeset{}} =
Registration.update_performer(performer, @invalid_attrs)
assert performer == Registration.get_performer!(performer.id) assert performer == Registration.get_performer!(performer.id)
end end

View File

@@ -3,9 +3,23 @@ defmodule RunosaariWeb.PerformerControllerTest do
alias Runosaari.Registration alias Runosaari.Registration
@create_attrs %{confirmed: true, email: "some email", fname: "some fname", lname: "some lname", notes: "some notes", performerId: 42, tel: "some tel"} @create_attrs %{
@update_attrs %{confirmed: false, email: "some updated email", fname: "some updated fname", lname: "some updated lname", notes: "some updated notes", performerId: 43, tel: "some updated tel"} confirmed: true,
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, performerId: nil, tel: nil} email: "some email",
fname: "some fname",
lname: "some lname",
notes: "some notes",
tel: "some tel"
}
@update_attrs %{
confirmed: false,
email: "some updated email",
fname: "some updated fname",
lname: "some updated lname",
notes: "some updated notes",
tel: "some updated tel"
}
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, tel: nil}
def fixture(:performer) do def fixture(:performer) do
{:ok, performer} = Registration.create_performer(@create_attrs) {:ok, performer} = Registration.create_performer(@create_attrs)
@@ -75,6 +89,7 @@ defmodule RunosaariWeb.PerformerControllerTest do
test "deletes chosen performer", %{conn: conn, performer: performer} do test "deletes chosen performer", %{conn: conn, performer: performer} do
conn = delete(conn, Routes.performer_path(conn, :delete, performer)) conn = delete(conn, Routes.performer_path(conn, :delete, performer))
assert redirected_to(conn) == Routes.performer_path(conn, :index) assert redirected_to(conn) == Routes.performer_path(conn, :index)
assert_error_sent 404, fn -> assert_error_sent 404, fn ->
get(conn, Routes.performer_path(conn, :show, performer)) get(conn, Routes.performer_path(conn, :show, performer))
end end