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

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,9 +6,23 @@ defmodule Runosaari.RegistrationTest do
describe "performers" do
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"}
@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"}
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, performerId: nil, tel: nil}
@valid_attrs %{
confirmed: true,
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
{:ok, performer} =
@@ -36,7 +50,6 @@ defmodule Runosaari.RegistrationTest do
assert performer.fname == "some fname"
assert performer.lname == "some lname"
assert performer.notes == "some notes"
assert performer.performerId == 42
assert performer.tel == "some tel"
end
@@ -46,19 +59,24 @@ defmodule Runosaari.RegistrationTest do
test "update_performer/2 with valid data updates the performer" do
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.email == "some updated email"
assert performer.fname == "some updated fname"
assert performer.lname == "some updated lname"
assert performer.notes == "some updated notes"
assert performer.performerId == 43
assert performer.tel == "some updated tel"
end
test "update_performer/2 with invalid data returns error changeset" do
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)
end

View File

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