Skip to content

Commit aa5e9c0

Browse files
committed
Add back the gettext fix in ViewHelpers. closes #391
1 parent 2bf0157 commit aa5e9c0

File tree

9 files changed

+207
-95
lines changed

9 files changed

+207
-95
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ See these [0.5.x to 0.6.x upgrade instructions](https://gist.github.com/smpallen
2020
* Fixed detection of remember me checkbox on session new page
2121
* Fixed compiled gettext in view helpers
2222
* Fix new session screen issue on newly generated project #390
23+
* Add back the gettext fix in ViewHelpers
2324

2425
* Deprecations
2526
* Removed the coherence.make_templates task since its no longer needed with the new controller design

lib/mix/tasks/coh.install.ex

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,19 @@ defmodule Mix.Tasks.Coh.Install do
985985
block = """
986986
You might want to add the following to your priv/repo/seeds.exs file.
987987
988-
#{repo}.delete_all #{user_schema}
989-
990-
#{user_schema}.changeset(%#{user_schema}{}, %{name: "Test User", email: "testuser@example.com", password: "secret", password_confirmation: "secret"})
991-
|> #{repo}.insert!
988+
#{repo}.delete_all(#{user_schema})
989+
990+
%#{user_schema}{}
991+
|> #{user_schema}.changeset(%{
992+
name: "Test User",
993+
email: "testuser@example.com",
994+
password: "secret",
995+
password_confirmation: "secret"
996+
})
997+
|> #{repo}.insert!()
992998
"""
993999

994-
confirm = if config[:confirmable], do: "|> Coherence.Controller.confirm!\n", else: ""
1000+
confirm = if config[:confirmable], do: "|> Coherence.Controller.confirm!()\n", else: ""
9951001
block <> confirm
9961002
end
9971003

@@ -1003,12 +1009,14 @@ defmodule Mix.Tasks.Coh.Install do
10031009
10041010
defmodule #{base}.User do
10051011
use Ecto.Schema
1006-
use Coherence.Schema # Add this
1012+
# Add this
1013+
use Coherence.Schema
10071014
10081015
schema "users" do
10091016
field :name, :string
10101017
field :email, :string
1011-
coherence_schema() # Add this
1018+
# Add this
1019+
coherence_schema()
10121020
10131021
timestamps()
10141022
end
@@ -1018,12 +1026,16 @@ defmodule Mix.Tasks.Coh.Install do
10181026
|> cast(params, [:name, :email] ++ coherence_fields)
10191027
|> validate_required([:name, :email])
10201028
|> unique_constraint(:email)
1021-
|> validate_coherence(params) # Add this
1029+
# Add this
1030+
|> validate_coherence(params)
10221031
end
10231032
10241033
def changeset(model, params, :password) do
10251034
model
1026-
|> cast(params, ~w(password password_confirmation reset_password_token reset_password_sent_at))
1035+
|> cast(
1036+
params,
1037+
~w(password password_confirmation reset_password_token reset_password_sent_at)
1038+
)
10271039
|> validate_coherence_password_reset(params)
10281040
end
10291041
end
@@ -1050,24 +1062,27 @@ defmodule Mix.Tasks.Coh.Install do
10501062
10511063
defmodule #{router} do
10521064
use #{web_base}, :router
1053-
use Coherence.Router # Add this
1065+
# Add this
1066+
use Coherence.Router
10541067
10551068
pipeline :browser do
10561069
plug(:accepts, ["html"])
10571070
plug(:fetch_session)
10581071
plug(:fetch_flash)
10591072
plug(:protect_from_forgery)
10601073
plug(:put_secure_browser_headers)
1061-
plug(Coherence.Authentication.Session) # Add this
1074+
# Add this
1075+
plug(Coherence.Authentication.Session)
10621076
end
10631077
1078+
# Add this block
10641079
pipeline :protected do
10651080
plug(:accepts, ["html"])
10661081
plug(:fetch_session)
10671082
plug(:fetch_flash)
10681083
plug(:protect_from_forgery)
10691084
plug(:put_secure_browser_headers)
1070-
plug(Coherence.Authentication.Session, protected: true) # Add this
1085+
plug(Coherence.Authentication.Session, protected: true)
10711086
end
10721087
10731088
# Add this block

priv/templates/coh.install/coherence_messages.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule <%= web_base %>.Coherence.Messages do
66
messages used in the coherence application except those in other generated
77
files like the view and templates.
88
9-
To assist in upgrading Coherence, the `Coherence.Messages behaviour will
9+
To assist in upgrading Coherence, the `Coherence.Messages` behaviour will
1010
alway contain every message for the current version. This will help in upgrades
1111
to ensure the user had added new the new messages from the current version.
1212
"""

priv/templates/coh.install/models/coherence/invitation.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ defmodule <%= base %>.Coherence.Invitation do
44
"""
55
use Ecto.Schema
66
import Ecto.Changeset
7-
87
<%= if use_binary_id? do %>
98
@primary_key {:id, :binary_id, autogenerate: true}
109
@foreign_key_type :binary_id
11-
<% end %>
12-
10+
<% else %><% end %>
1311
schema "invitations" do
1412
field(:name, :string)
1513
field(:email, :string)
@@ -24,7 +22,7 @@ defmodule <%= base %>.Coherence.Invitation do
2422
If no params are provided, an invalid changeset is returned
2523
with no validation performed.
2624
"""
27-
@spec changeset(Ecto.Schema.t, Map.t) :: Ecto.Changeset.t
25+
@spec changeset(Ecto.Schema.t(), Map.t()) :: Ecto.Changeset.t()
2826
def changeset(model, params \\ %{}) do
2927
model
3028
|> cast(params, ~w(name email token))
@@ -36,7 +34,7 @@ defmodule <%= base %>.Coherence.Invitation do
3634
@doc """
3735
Creates a changeset for a new schema
3836
"""
39-
@spec new_changeset(Map.t) :: Ecto.Changeset.t
37+
@spec new_changeset(Map.t()) :: Ecto.Changeset.t()
4038
def new_changeset(params \\ %{}) do
4139
changeset(%__MODULE__{}, params)
4240
end

priv/templates/coh.install/models/coherence/rememberable.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ defmodule <%= base %>.Coherence.Rememberable do
66
import Ecto.Query
77

88
alias Coherence.Config
9-
109
<%= if use_binary_id? do %>
1110
@primary_key {:id, :binary_id, autogenerate: true}
1211
@foreign_key_type :binary_id
13-
<% end %>
14-
12+
<% else %><% end %>
1513
schema "rememberables" do
1614
field(:series_hash, :string)
1715
field(:token_hash, :string)
@@ -29,7 +27,7 @@ defmodule <%= base %>.Coherence.Rememberable do
2927
If no params are provided, an invalid changeset is returned
3028
with no validation performed.
3129
"""
32-
@spec changeset(Ecto.Schema.t, Map.t) :: Ecto.Changeset.t
30+
@spec changeset(Ecto.Schema.t(), Map.t()) :: Ecto.Changeset.t()
3331
def changeset(model, params \\ %{}) do
3432
model
3533
|> cast(params, ~w(series_hash token_hash token_created_at user_id))
@@ -39,7 +37,7 @@ defmodule <%= base %>.Coherence.Rememberable do
3937
@doc """
4038
Creates a changeset for a new schema
4139
"""
42-
@spec new_changeset(Map.t) :: Ecto.Changeset.t
40+
@spec new_changeset(Map.t()) :: Ecto.Changeset.t()
4341
def new_changeset(params \\ %{}) do
4442
changeset(%Rememberable{}, params)
4543
end

priv/templates/coh.install/models/coherence/trackable.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ defmodule <%= base %>.Coherence.Trackable do
88
alias Coherence.Config
99

1010
@fields ~w(action sign_in_count current_sign_in_ip current_sign_in_at last_sign_in_ip last_sign_in_at user_id)a
11-
1211
<%= if use_binary_id? do %>
1312
@primary_key {:id, :binary_id, autogenerate: true}
1413
@foreign_key_type :binary_id
15-
<% end %>
16-
14+
<% else %><% end %>
1715
schema "trackables" do
1816
field(:action, :string, null: false)
1917
field(:sign_in_count, :integer, default: 0)
@@ -32,7 +30,7 @@ defmodule <%= base %>.Coherence.Trackable do
3230
If no params are provided, an invalid changeset is returned
3331
with no validation performed.
3432
"""
35-
@spec changeset(Ecto.Schema.t, Map.t) :: Ecto.Changeset.t
33+
@spec changeset(Ecto.Schema.t(), Map.t()) :: Ecto.Changeset.t()
3634
def changeset(model, params \\ %{}) do
3735
model
3836
|> cast(params, @fields)
@@ -42,7 +40,7 @@ defmodule <%= base %>.Coherence.Trackable do
4240
@doc """
4341
Creates a changeset for a new schema
4442
"""
45-
@spec new_changeset(Map.t) :: Ecto.Changeset.t
43+
@spec new_changeset(Map.t()) :: Ecto.Changeset.t()
4644
def new_changeset(params \\ %{}) do
4745
changeset(%__MODULE__{}, params)
4846
end

priv/templates/coh.install/models/coherence/user.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ defmodule <%= user_schema %> do
22
@moduledoc false
33
use Ecto.Schema
44
use Coherence.Schema
5-
65
<%= if use_binary_id? do %>
76
@primary_key {:id, :binary_id, autogenerate: true}
87
@foreign_key_type :binary_id
9-
<% end %>
10-
8+
<% else %><% end %>
119
schema "<%= user_table_name %>" do
1210
field(:name, :string)
1311
field(:email, :string)
@@ -16,6 +14,8 @@ defmodule <%= user_schema %> do
1614
timestamps()
1715
end
1816

17+
@doc false
18+
@spec changeset(Ecto.Schema.t(), Map.t()) :: Ecto.Changeset.t()
1919
def changeset(model, params \\ %{}) do
2020
model
2121
|> cast(params, [:name, :email] ++ coherence_fields())
@@ -25,6 +25,8 @@ defmodule <%= user_schema %> do
2525
|> validate_coherence(params)
2626
end
2727

28+
@doc false
29+
@spec changeset(Ecto.Schema.t(), Map.t(), atom) :: Ecto.Changeset.t()
2830
def changeset(model, params, :password) do
2931
model
3032
|> cast(

priv/templates/coh.install/templates/coherence/password/new.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<br \>
22

3-
<h3><%%= dgettext "coherence", "Send reset password link" %></h3>
3+
<h3><%%= dgettext "coherence", "Send Reset Password Instructions" %></h3>
44

55
<%%= form_for @changeset, password_path(@conn, :create), [as: :password], fn f -> %>
66

0 commit comments

Comments
 (0)