diff --git a/.credo.exs b/.credo.exs new file mode 100644 index 0000000..cd58dcc --- /dev/null +++ b/.credo.exs @@ -0,0 +1,157 @@ +# This file contains the configuration for Credo and you are probably reading +# this after creating it with `mix credo.gen.config`. +# +# If you find anything wrong or unclear in this file, please report an +# issue on GitHub: https://github.com/rrrene/credo/issues +# +%{ + # + # You can have as many configs as you like in the `configs:` field. + configs: [ + %{ + # + # Run any exec using `mix credo -C `. If no exec name is given + # "default" is used. + # + name: "default", + # + # These are the files included in the analysis: + files: %{ + # + # You can give explicit globs or simply directories. + # In the latter case `**/*.{ex,exs}` will be used. + # + included: ["lib/", "test/"], + excluded: [ + ~r"/_build/", + ~r"/deps/", + ~r"web/channels", + "lib/afc/application.ex", + "test/support/*.ex", + "lib/afc_web/views/error_view.ex" + ] + }, + # + # If you create your own checks, you must specify the source files for + # them here, so they can be loaded by Credo before running the analysis. + # + requires: [], + # + # Credo automatically checks for updates, like e.g. Hex does. + # You can disable this behaviour below: + # + check_for_updates: true, + # + # If you want to enforce a style guide and need a more traditional linting + # experience, you can change `strict` to `true` below: + # + strict: true, + # + # If you want to use uncolored output by default, you can change `color` + # to `false` below: + # + color: true, + # + # You can customize the parameters of any check by adding a second element + # to the tuple. + # + # To disable a check put `false` as second element: + # + # {Credo.Check.Design.DuplicatedCode, false} + # + checks: [ + {Credo.Check.Consistency.ExceptionNames}, + {Credo.Check.Consistency.LineEndings}, + {Credo.Check.Consistency.ParameterPatternMatching}, + {Credo.Check.Consistency.SpaceAroundOperators}, + {Credo.Check.Consistency.SpaceInParentheses}, + {Credo.Check.Consistency.TabsOrSpaces}, + + # For some checks, like AliasUsage, you can only customize the priority + # Priority values are: `low, normal, high, higher` + # + {Credo.Check.Design.AliasUsage, priority: :low}, + + # For others you can set parameters + + # If you don't want the `setup` and `test` macro calls in ExUnit tests + # or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just + # set the `excluded_macros` parameter to `[:schema, :setup, :test]`. + # + {Credo.Check.Design.DuplicatedCode, excluded_macros: []}, + + # You can also customize the exit_status of each check. + # If you don't want TODO comments to cause `mix credo` to fail, just + # set this value to 0 (zero). + # + {Credo.Check.Design.TagTODO, exit_status: 2}, + {Credo.Check.Design.TagFIXME}, + + {Credo.Check.Readability.FunctionNames}, + {Credo.Check.Readability.LargeNumbers}, + {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80}, + {Credo.Check.Readability.ModuleAttributeNames}, + {Credo.Check.Readability.ModuleDoc}, + {Credo.Check.Readability.ModuleNames}, + {Credo.Check.Readability.ParenthesesOnZeroArityDefs}, + {Credo.Check.Readability.ParenthesesInCondition}, + {Credo.Check.Readability.PredicateFunctionNames}, + {Credo.Check.Readability.PreferImplicitTry}, + {Credo.Check.Readability.RedundantBlankLines}, + {Credo.Check.Readability.StringSigils}, + {Credo.Check.Readability.TrailingBlankLine}, + {Credo.Check.Readability.TrailingWhiteSpace}, + {Credo.Check.Readability.VariableNames}, + {Credo.Check.Readability.Semicolons}, + {Credo.Check.Readability.SpaceAfterCommas}, + + {Credo.Check.Refactor.DoubleBooleanNegation}, + {Credo.Check.Refactor.CondStatements}, + {Credo.Check.Refactor.CyclomaticComplexity}, + {Credo.Check.Refactor.FunctionArity}, + {Credo.Check.Refactor.LongQuoteBlocks}, + {Credo.Check.Refactor.MatchInCondition}, + {Credo.Check.Refactor.NegatedConditionsInUnless}, + {Credo.Check.Refactor.NegatedConditionsWithElse}, + {Credo.Check.Refactor.Nesting}, + {Credo.Check.Refactor.PipeChainStart}, + {Credo.Check.Refactor.UnlessWithElse}, + + {Credo.Check.Warning.BoolOperationOnSameValues}, + {Credo.Check.Warning.IExPry}, + {Credo.Check.Warning.IoInspect}, + {Credo.Check.Warning.LazyLogging}, + {Credo.Check.Warning.OperationOnSameValues}, + {Credo.Check.Warning.OperationWithConstantResult}, + {Credo.Check.Warning.UnusedEnumOperation}, + {Credo.Check.Warning.UnusedFileOperation}, + {Credo.Check.Warning.UnusedKeywordOperation}, + {Credo.Check.Warning.UnusedListOperation}, + {Credo.Check.Warning.UnusedPathOperation}, + {Credo.Check.Warning.UnusedRegexOperation}, + {Credo.Check.Warning.UnusedStringOperation}, + {Credo.Check.Warning.UnusedTupleOperation}, + {Credo.Check.Warning.RaiseInsideRescue}, + + # Controversial and experimental checks (opt-in, just remove `, false`) + # + {Credo.Check.Refactor.ABCSize, false}, + {Credo.Check.Refactor.AppendSingleItem, false}, + {Credo.Check.Refactor.VariableRebinding, false}, + {Credo.Check.Warning.MapGetUnsafePass, false}, + {Credo.Check.Consistency.MultiAliasImportRequireUse, false}, + + # Deprecated checks (these will be deleted after a grace period) + # + {Credo.Check.Readability.Specs, false}, + {Credo.Check.Warning.NameRedeclarationByAssignment, false}, + {Credo.Check.Warning.NameRedeclarationByCase, false}, + {Credo.Check.Warning.NameRedeclarationByDef, false}, + {Credo.Check.Warning.NameRedeclarationByFn, false}, + + # Custom checks can be created using `mix credo.gen.check`. + # + ] + } + ] +} diff --git a/assets/css/app.css b/assets/css/app.css index 5314c34..467039e 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -1 +1,25 @@ -/* This file is for your main application css. */ \ No newline at end of file +/* This file is for your main application css. */ + +.afc-bg-pink { + background-color: #F5BABF; +} + +.afc-b--pink { + border-color: #F5BABF; +} + +.emoji-font-size { + font-size: 64pt; +} + +.-mt2 { + margin-top: -0.5rem; +} + +.h-day-week-month { + height: 3rem; +} + +.mt-day-week-month { + margin-top: 3rem; +} diff --git a/coveralls.json b/coveralls.json new file mode 100644 index 0000000..89aab55 --- /dev/null +++ b/coveralls.json @@ -0,0 +1,14 @@ +{ + "coverage_options": { + "minimum_coverage": 10 + }, + "skip_files": [ + "lib/afc.ex", + "lib/afc_web.ex", + "lib/afc_web/channels", + "lib/afc_web/router.ex", + "lib/afc_web/views/error_helpers.ex", + "test/support/channel_case.ex", + "test/support/data_case.ex" + ] +} diff --git a/lib/afc/angry.ex b/lib/afc/angry.ex new file mode 100644 index 0000000..231ee83 --- /dev/null +++ b/lib/afc/angry.ex @@ -0,0 +1,27 @@ +defmodule Afc.Angry do + use Ecto.Schema + import Ecto.Changeset + + + schema "angry" do + field :bullying, :boolean, default: false + field :classwork, :boolean, default: false + field :community, :boolean, default: false + field :else, :boolean, default: false + field :exams, :boolean, default: false + field :"family/home", :boolean, default: false + field :friends, :boolean, default: false + field :homework, :boolean, default: false + field :school, :boolean, default: false + field :teachers, :boolean, default: false + field :reason, :string + + timestamps() + end + + @doc false + def changeset(angry, attrs) do + angry + |> cast(attrs, [:friends, :school, :"family/home", :community, :bullying, :exams, :teachers, :classwork, :homework, :else, :reason]) + end +end diff --git a/lib/afc/happy.ex b/lib/afc/happy.ex new file mode 100644 index 0000000..d7df008 --- /dev/null +++ b/lib/afc/happy.ex @@ -0,0 +1,17 @@ +defmodule Afc.Happy do + use Ecto.Schema + import Ecto.Changeset + + + schema "happy" do + field :reason_text, :string + + timestamps() + end + + @doc false + def changeset(happy, attrs) do + happy + |> cast(attrs, [:reason_text]) + end +end diff --git a/lib/afc/trusted_adult.ex b/lib/afc/trusted_adult.ex new file mode 100644 index 0000000..43d4b73 --- /dev/null +++ b/lib/afc/trusted_adult.ex @@ -0,0 +1,18 @@ +defmodule Afc.Trusted_adult do + use Ecto.Schema + import Ecto.Changeset + + + schema "trusted_adults" do + field :email, :string + + timestamps() + end + + @doc false + def changeset(trusted_adult, attrs) do + trusted_adult + |> cast(attrs, [:email]) + |> validate_required([:email]) + end +end diff --git a/lib/afc/user.ex b/lib/afc/user.ex new file mode 100644 index 0000000..3994243 --- /dev/null +++ b/lib/afc/user.ex @@ -0,0 +1,20 @@ +defmodule Afc.User do + use Ecto.Schema + import Ecto.Changeset + + + schema "users" do + field :pin, :integer + field :username, :string + field :trusted_adult_id, :id + + timestamps() + end + + @doc false + def changeset(user, attrs) do + user + |> cast(attrs, [:username, :pin]) + |> validate_required([:username, :pin]) + end +end diff --git a/lib/afc_web/controllers/emotion_controller.ex b/lib/afc_web/controllers/emotion_controller.ex new file mode 100644 index 0000000..2076823 --- /dev/null +++ b/lib/afc_web/controllers/emotion_controller.ex @@ -0,0 +1,42 @@ +defmodule AfcWeb.EmotionController do + use AfcWeb, :controller + alias Afc.{Angry, Happy, Repo} + + def show(conn, %{"id" => emotion}) do + {module, changeset} = get_page_module_and_changeset(emotion) + + render conn, "form.html", changeset: changeset, module: module + end + + def create(conn, params) do + submitted_emotion = + ~w(angry happy) + |> Enum.filter(&(Map.has_key?(params, &1))) + |> hd() + + form_info = Map.get(params, submitted_emotion) + + {module, changeset} = + get_page_module_and_changeset(submitted_emotion, form_info) + + case Repo.insert(changeset) do + {:ok, _captured_emotion} -> + + # The emotion itself has been captured at this point. Next step + # is to insert into the emotion_log table. + render conn, "captured.html" + + {:error, changeset} -> + render conn, "form.html", changeset: changeset, module: module + end + end + + defp get_page_module_and_changeset(page, params \\ %{}) do + case page do + "happy" -> + {Happy, Happy.changeset(%Happy{}, params)} + "angry" -> + {Angry, Angry.changeset(%Angry{}, params)} + end + end +end diff --git a/lib/afc_web/router.ex b/lib/afc_web/router.ex index 9166a1c..b53a832 100644 --- a/lib/afc_web/router.ex +++ b/lib/afc_web/router.ex @@ -17,6 +17,7 @@ defmodule AfcWeb.Router do pipe_through :browser # Use the default browser stack get "/", PageController, :index + resources "/emotion", EmotionController, only: [:show, :create] end # Other scopes may use custom stacks. diff --git a/lib/afc_web/templates/component/day_week_month_bar.html.eex b/lib/afc_web/templates/component/day_week_month_bar.html.eex new file mode 100644 index 0000000..146ef0f --- /dev/null +++ b/lib/afc_web/templates/component/day_week_month_bar.html.eex @@ -0,0 +1,15 @@ +
+ + + +

Daily

+
+ + +

Weekly

+
+ + +

Monthly

+
+
diff --git a/lib/afc_web/templates/component/emoji_helper.html.eex b/lib/afc_web/templates/component/emoji_helper.html.eex new file mode 100644 index 0000000..bbbd294 --- /dev/null +++ b/lib/afc_web/templates/component/emoji_helper.html.eex @@ -0,0 +1,6 @@ +
+ <%= link to: emotion_path(@conn, :show, @page), class: "pointer link black" do %> + <%= emoji_p_tag(@emoji) %> +

<%= @emotion %>

+ <%= end %> +
diff --git a/lib/afc_web/templates/component/navbar.html.eex b/lib/afc_web/templates/component/navbar.html.eex index 4addda2..9665cdc 100644 --- a/lib/afc_web/templates/component/navbar.html.eex +++ b/lib/afc_web/templates/component/navbar.html.eex @@ -1,13 +1,17 @@ -
- + diff --git a/lib/afc_web/templates/emotion/captured.html.eex b/lib/afc_web/templates/emotion/captured.html.eex new file mode 100644 index 0000000..35fb5ef --- /dev/null +++ b/lib/afc_web/templates/emotion/captured.html.eex @@ -0,0 +1,6 @@ +
+

Well done

+

Today's log has been completed.

+

Do you want to share it with someone?

+

no yes

+
diff --git a/lib/afc_web/templates/emotion/form.html.eex b/lib/afc_web/templates/emotion/form.html.eex new file mode 100644 index 0000000..d4c53d5 --- /dev/null +++ b/lib/afc_web/templates/emotion/form.html.eex @@ -0,0 +1,3 @@ +
+ <%= render_autoform(@conn, :create, @module, assigns: [changeset: @changeset]) %> +
diff --git a/lib/afc_web/templates/layout/app.html.eex b/lib/afc_web/templates/layout/app.html.eex index 02c84b7..b48e549 100644 --- a/lib/afc_web/templates/layout/app.html.eex +++ b/lib/afc_web/templates/layout/app.html.eex @@ -10,14 +10,16 @@ Action for Children "> - - + <%= component "navbar", [] %> -
- <%= render @view_module, @view_template, assigns %> -
+
+
+ <%= render @view_module, @view_template, assigns %> +
+
+ diff --git a/lib/afc_web/templates/page/index.html.eex b/lib/afc_web/templates/page/index.html.eex index e69de29..670bcab 100644 --- a/lib/afc_web/templates/page/index.html.eex +++ b/lib/afc_web/templates/page/index.html.eex @@ -0,0 +1,28 @@ +<%= component "day_week_month_bar", [] %> + +
+

10th Oct 2019 (placeholder)

+

How are you feeling today?

+
+ +
+ <%= component "emoji_helper", [emoji: "😆", emotion: "Happy", page: "happy", conn: @conn] %> + <%= component "emoji_helper", [emoji: "🤩", emotion: "Excited", page: "happy", conn: @conn] %> +
+ +
+ <%= component "emoji_helper", [emoji: "😡", emotion: "Angry", page: "angry", conn: @conn] %> + <%= component "emoji_helper", [emoji: "😭", emotion: "Sad", page: "happy", conn: @conn] %> +
+ +
+ <%= component "emoji_helper", [emoji: "😬", emotion: "Worried", page: "happy", conn: @conn] %> + <%= component "emoji_helper", [emoji: "😐", emotion: "I don't know", page: "happy", conn: @conn] %> +
+ +
+ <%= component "emoji_helper", [emoji: "😶", emotion: "Something else", page: "happy", conn: @conn] %> +
+ +
+
diff --git a/lib/afc_web/views/component_helpers.ex b/lib/afc_web/views/component_helpers.ex index aa8a011..a397ec8 100644 --- a/lib/afc_web/views/component_helpers.ex +++ b/lib/afc_web/views/component_helpers.ex @@ -1,7 +1,14 @@ defmodule AfcWeb.ComponentHelpers do alias AfcWeb.ComponentView + use Phoenix.HTML + + @moduledoc false def component(template, assigns) do ComponentView.render "#{template}.html", assigns end + + def emoji_p_tag(emoji) do + content_tag(:p, emoji, [class: "emoji-font-size"]) + end end diff --git a/lib/afc_web/views/emotion_view.ex b/lib/afc_web/views/emotion_view.ex new file mode 100644 index 0000000..39f9bed --- /dev/null +++ b/lib/afc_web/views/emotion_view.ex @@ -0,0 +1,5 @@ +defmodule AfcWeb.EmotionView do + use AfcWeb, :view + use Autoform + alias Afc.{Angry, Happy} +end diff --git a/mix.exs b/mix.exs index 9e79589..9f33678 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,9 @@ defmodule Afc.Mixfile do compilers: [:phoenix, :gettext] ++ Mix.compilers, start_permanent: Mix.env == :prod, aliases: aliases(), - deps: deps() + deps: deps(), + test_coverage: [tool: ExCoveralls], + preferred_cli_env: [coveralls: :test] ] end @@ -40,7 +42,10 @@ defmodule Afc.Mixfile do {:phoenix_html, "~> 2.10"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.11"}, - {:cowboy, "~> 1.0"} + {:cowboy, "~> 1.0"}, + {:excoveralls, "~> 0.10", only: :test}, + {:credo, "~> 0.10.0", only: [:dev, :test], runtime: false}, + {:autoform, git: "https://github.com/dwyl/autoform.git", tag: "0.1"} ] end @@ -54,7 +59,7 @@ defmodule Afc.Mixfile do [ "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], - "test": ["ecto.create --quiet", "ecto.migrate", "test"] + test: ["ecto.create --quiet", "ecto.migrate", "test"] ] end end diff --git a/mix.lock b/mix.lock index bc84f59..f09e151 100644 --- a/mix.lock +++ b/mix.lock @@ -1,13 +1,24 @@ %{ + "autoform": {:git, "https://github.com/dwyl/autoform.git", "eaa1d76e858d1ed5b042270c821e14932ba470e3", [tag: "0.1"]}, + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, + "certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, "cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"}, + "credo": {:hex, :credo, "0.10.2", "03ad3a1eff79a16664ed42fc2975b5e5d0ce243d69318060c626c34720a49512", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"}, "ecto": {:hex, :ecto, "2.2.11", "4bb8f11718b72ba97a2696f65d247a379e739a0ecabf6a13ad1face79844791c", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.10.1", "407d50ac8fc63dfee9175ccb4548e6c5512b5052afa63eedb9cd452a32a91495", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "file_system": {:hex, :file_system, "0.2.6", "fd4dc3af89b9ab1dc8ccbcc214a0e60c41f34be251d9307920748a14bf41f1d3", [:mix], [], "hexpm"}, "gettext": {:hex, :gettext, "0.16.0", "4a7e90408cef5f1bf57c5a39e2db8c372a906031cc9b1466e963101cb927dafc", [:mix], [], "hexpm"}, + "hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "phoenix": {:hex, :phoenix, "1.3.4", "aaa1b55e5523083a877bcbe9886d9ee180bf2c8754905323493c2ac325903dc5", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_ecto": {:hex, :phoenix_ecto, "3.4.0", "91cd39427006fe4b5588d69f0941b9c3d3d8f5e6477c563a08379de7de2b0c58", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_html": {:hex, :phoenix_html, "2.12.0", "1fb3c2e48b4b66d75564d8d63df6d53655469216d6b553e7e14ced2b46f97622", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, @@ -17,5 +28,8 @@ "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"}, "postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"}, + "pre_commit": {:hex, :pre_commit, "0.3.4", "e2850f80be8090d50ad8019ef2426039307ff5dfbe70c736ad0d4d401facf304", [:mix], [], "hexpm"}, "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, } diff --git a/priv/repo/migrations/20181014093533_create_trusted_adults.exs b/priv/repo/migrations/20181014093533_create_trusted_adults.exs new file mode 100644 index 0000000..c6d7cbe --- /dev/null +++ b/priv/repo/migrations/20181014093533_create_trusted_adults.exs @@ -0,0 +1,12 @@ +defmodule Afc.Repo.Migrations.CreateTrustedAdults do + use Ecto.Migration + + def change do + create table(:trusted_adults) do + add :email, :string + + timestamps() + end + + end +end diff --git a/priv/repo/migrations/20181014093822_create_users.exs b/priv/repo/migrations/20181014093822_create_users.exs new file mode 100644 index 0000000..d0efef9 --- /dev/null +++ b/priv/repo/migrations/20181014093822_create_users.exs @@ -0,0 +1,15 @@ +defmodule Afc.Repo.Migrations.CreateUsers do + use Ecto.Migration + + def change do + create table(:users) do + add :username, :string + add :pin, :integer + add :trusted_adult_id, references(:trusted_adults, on_delete: :nothing) + + timestamps() + end + + create index(:users, [:trusted_adult_id]) + end +end diff --git a/priv/repo/migrations/20181014104921_create_happy.exs b/priv/repo/migrations/20181014104921_create_happy.exs new file mode 100644 index 0000000..e14a5a8 --- /dev/null +++ b/priv/repo/migrations/20181014104921_create_happy.exs @@ -0,0 +1,12 @@ +defmodule Afc.Repo.Migrations.CreateHappy do + use Ecto.Migration + + def change do + create table(:happy) do + add :reason_text, :string + + timestamps() + end + + end +end diff --git a/priv/repo/migrations/20181014105259_create_angry.exs b/priv/repo/migrations/20181014105259_create_angry.exs new file mode 100644 index 0000000..6c15f60 --- /dev/null +++ b/priv/repo/migrations/20181014105259_create_angry.exs @@ -0,0 +1,22 @@ +defmodule Afc.Repo.Migrations.CreateAngry do + use Ecto.Migration + + def change do + create table(:angry) do + add :friends, :boolean, default: false, null: false + add :school, :boolean, default: false, null: false + add :"family/home", :boolean, default: false, null: false + add :community, :boolean, default: false, null: false + add :bullying, :boolean, default: false, null: false + add :exams, :boolean, default: false, null: false + add :teachers, :boolean, default: false, null: false + add :classwork, :boolean, default: false, null: false + add :homework, :boolean, default: false, null: false + add :else, :boolean, default: false, null: false + add :reason, :string + + timestamps() + end + + end +end diff --git a/test/afc_web/controllers/page_controller_test.exs b/test/afc_web/controllers/page_controller_test.exs index 7e042e3..42f3828 100644 --- a/test/afc_web/controllers/page_controller_test.exs +++ b/test/afc_web/controllers/page_controller_test.exs @@ -3,6 +3,6 @@ defmodule AfcWeb.PageControllerTest do test "GET /", %{conn: conn} do conn = get conn, "/" - assert html_response(conn, 200) =~ "Welcome to Phoenix!" + assert html_response(conn, 200) =~ "Home" end end diff --git a/test/test_helper.exs b/test/test_helper.exs index 58d1a08..1e0c75c 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,4 +1,3 @@ ExUnit.start() Ecto.Adapters.SQL.Sandbox.mode(Afc.Repo, :manual) -