Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit response #68

Merged
merged 46 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c7916a5
adds log in to the feedback dashboard #21
jackcarlisle Apr 6, 2017
58569a7
adds permalinks and show page for individual feedback #12 #15 #16 #14
jackcarlisle Apr 7, 2017
56360bf
prioritises the feedback so that the ones that have been responded to…
jackcarlisle Apr 11, 2017
0b3d2ad
adds date of submission to the feedback #37
jackcarlisle Apr 11, 2017
cf164d6
adds response date to the feedback response #37
jackcarlisle Apr 11, 2017
47f479b
adds sockets to the response to feedback #41
jackcarlisle Apr 11, 2017
6a58277
adds channel tests #41
jackcarlisle Apr 11, 2017
9b579da
adds sockets for the feedback dashboard when someone leaves feedback #41
jackcarlisle Apr 11, 2017
a07ab8c
changes the console.log in the sockets #41
jackcarlisle Apr 11, 2017
b2db051
changes the look of the date on the feedback item #41
jackcarlisle Apr 11, 2017
4b075cb
changes the position of the tick on the feedback item #41
jackcarlisle Apr 11, 2017
5f0f0a9
removes responded flag if none have been responded to #41
jackcarlisle Apr 11, 2017
008206d
adds message to the feedback dashboard if there aren't any new respon…
jackcarlisle Apr 11, 2017
57d17fc
adds emotions as well as text input #20
jackcarlisle Apr 12, 2017
983df8d
tears down socket after test #20
jackcarlisle Apr 12, 2017
628ad3a
adds message to remind users to use short and concise sentences to re…
jackcarlisle Apr 12, 2017
88e7be6
halts the connection after redirect #10
jackcarlisle Apr 12, 2017
7aaff12
adds tests for the new dashboard #45
jackcarlisle Apr 12, 2017
c275310
refactors the feedback controller #45
jackcarlisle Apr 13, 2017
6e479ae
changes the title to an emotion on the feedback pages #45
jackcarlisle Apr 13, 2017
ef0331e
adds navbar and navigation links #47
jackcarlisle Apr 13, 2017
e5019e6
refactors feedback controller #47
jackcarlisle Apr 13, 2017
6b7356f
renames function #47
jackcarlisle Apr 13, 2017
f4a5ac3
changes the text inside the green box #47
jackcarlisle Apr 13, 2017
2f135fb
adds box shadows to elements #47
jackcarlisle Apr 13, 2017
9eb5d1f
adds public private toggle #9
jackcarlisle Apr 13, 2017
a9939d3
adds public forum for public feedback #9
jackcarlisle Apr 14, 2017
8b67a3d
changes the forum show to the id #51
jackcarlisle Apr 14, 2017
d909159
adds files for deployment to heroku #34
jackcarlisle Apr 17, 2017
1d3ea9e
removes unused params #34
jackcarlisle Apr 17, 2017
11f9e58
adds email notifications when a response has been made to some feedba…
jackcarlisle Apr 17, 2017
5a3373e
adds confused emotion #27
jackcarlisle Apr 17, 2017
537823a
changes the size of the emotions #27
jackcarlisle Apr 17, 2017
5c82378
adds email notifications when feedback is submitted #27
jackcarlisle Apr 17, 2017
81fe394
adds responded_at to the db #58
jackcarlisle Apr 18, 2017
c3ff010
removes unused responded from feedback table #58
jackcarlisle Apr 18, 2017
8de9123
adds functionality to edit feedback #60
jackcarlisle Apr 19, 2017
39142c8
changes the background color of textarea when editing #60
jackcarlisle Apr 19, 2017
35b34dd
refactors responses into their own table #65
jackcarlisle Apr 25, 2017
5f38b98
adds the ability to edit a response #61
jackcarlisle Apr 27, 2017
c5bfaac
changes colour of background of textarea #61
jackcarlisle Apr 27, 2017
19510f6
moves .env to gitignore
jackcarlisle May 5, 2017
af606f8
svg cleanup #61
jackcarlisle May 5, 2017
7b557fb
fixes readme #69
jackcarlisle May 10, 2017
8011d77
adds more information on how to run the project #70
jackcarlisle May 10, 2017
5f39aaa
adds extra information to the environment variables #70
jackcarlisle May 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .buildpacks
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/dscout/wkhtmltopdf-buildpack.git
https://github.com/HashNuke/heroku-buildpack-elixir.git
https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ erl_crash.dump
cover

# Environment Variables

.env
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: MIX_ENV=prod mix run priv/repo/seeds.exs && mix phoenix.server
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,21 @@ We recommend reading: https://github.com/dwyl/learn-phoenix-framework

### Get Started in _2 Minutes_


+ Clone the Git repository: `git clone [email protected]:dwyl/feedback.git && cd feedback`
+ Install dependencies with `mix deps.get && npm install`
+ Create and migrate your database with `mix ecto.create && mix ecto.migrate`
+ Set environment variables:
+ ADMIN_EMAIL - the email that you want to log in with (must also be verified by AWS)
+ ADMIN_PASSWORD - the password you want to log in with
+ SECRET_KEY_BASE - taken from `config.exs`
+ TARGET_EMAIL - verified SES email for testing
+ SES_SERVER - your SES server
+ SES_PORT - your SES port
+ SMTP_USERNAME - your SMTP username
+ SMTP_PASSWORD - your SMTP password
+ Run `priv/repo/seeds.exs`
+ Run `source .env` to load your environment variables
+ Start Phoenix endpoint with `mix phoenix.server`

Now visit [`localhost:4000`](http://localhost:4000) from your web browser.
Expand Down
13 changes: 12 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config :feedback,
# Configures the endpoint
config :feedback, Feedback.Endpoint,
url: [host: "localhost"],
secret_key_base: "aBi07mDCHwwdqkunV/mx7LlDilXqy7GeZlrXMOm1Qxtdx9e6KfZ2BsF7O+qpZXSs",
secret_key_base: System.get_env("SECRET_KEY_BASE"),
render_errors: [view: Feedback.ErrorView, accepts: ~w(html json)],
pubsub: [name: Feedback.PubSub,
adapter: Phoenix.PubSub.PG2]
Expand All @@ -22,6 +22,17 @@ config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]

# Configures mailing
config :feedback, Feedback.Mailer,
adapter: Bamboo.SMTPAdapter,
server: System.get_env("SES_SERVER"),
port: System.get_env("SES_PORT"),
username: System.get_env("SMTP_USERNAME"),
password: System.get_env("SMTP_PASSWORD"),
tls: :always, # can be `:always` or `:never`
ssl: false, # can be `true`
retries: 1

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
14 changes: 12 additions & 2 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ use Mix.Config
# which you typically run after static files are built.
config :feedback, Feedback.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: "example.com", port: 80],
url: [scheme: "https", host: "dwyl-feedback.herokuapp.com", port: 443],
force_ssl: [rewrite_on: [:x_forwarded_proto]],
secret_key_base: System.get_env("SECRET_KEY_BASE"),
cache_static_manifest: "priv/static/manifest.json"

# Configure the database

config :feedback, Feedback.Repo,
adapter: Ecto.Adapters.Postgres,
url: System.get_env("DATABASE_URL"),
pool_size: "10",
ssl: true

# Do not print debug messages in production
config :logger, level: :info

Expand Down Expand Up @@ -58,4 +68,4 @@ config :logger, level: :info

# Finally import the config/prod.secret.exs
# which should be versioned separately.
import_config "prod.secret.exs"
# import_config "prod.secret.exs"
9 changes: 9 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ config :feedback, Feedback.Repo,
database: "feedback_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox

# Configure password hashing

config :comeonin, :bcrypt_log_rounds, 4
config :comeonin, :pbkdf2_rounds, 1

# Configure Bamboo email
config :feedback, Feedback.Mailer,
adapter: Bamboo.TestAdapter
3 changes: 1 addition & 2 deletions coveralls.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"minimum_coverage": 100
},
"skip_files": [
"web/channels",
"lib/feedback.ex",
"test/support/model_case.ex",
"test/support/channel_case.ex",
"web/web.ex",
"web/views/error_helpers.ex",
"web/models/*"
"web/models/forum.ex"
]
}
1 change: 1 addition & 0 deletions elixir_buildpack.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
always_rebuild=true
11 changes: 11 additions & 0 deletions lib/email.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule Feedback.Email do
use Bamboo.Phoenix, view: Feedback.FeedbackView

def send_email(to_email_address, subject, message) do
new_email()
|> to(to_email_address)
|> from(System.get_env("ADMIN_EMAIL")) # also needs to be a validated email
|> subject(subject)
|> text_body(message)
end
end
3 changes: 3 additions & 0 deletions lib/feedback/mailer.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule Feedback.Mailer do
use Bamboo.Mailer, otp_app: :feedback
end
7 changes: 5 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Feedback.Mixfile do
def application do
[mod: {Feedback, []},
applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext,
:phoenix_ecto, :postgrex, :comeonin]]
:phoenix_ecto, :postgrex, :comeonin, :bamboo]]
end

# Specifies which paths to compile per environment.
Expand All @@ -44,7 +44,10 @@ defmodule Feedback.Mixfile do
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:comeonin, "~> 2.0"},
{:excoveralls, "~> 0.6.2"}]
{:excoveralls, "~> 0.6.2"},
{:bamboo, "~> 0.7"},
{:bamboo_smtp, "~> 1.2.1"},
{:mock, "~> 0.2.0", only: :test}]
end

# Aliases are shortcuts or tasks specific to the current project.
Expand Down
8 changes: 7 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
%{"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
%{"bamboo": {:hex, :bamboo, "0.7.0", "2722e395a396dfedc12d300c900f65b216f7d7bf9d430c5dd0235690997878b7", [:mix], [{:httpoison, "~> 0.9", [hex: :httpoison, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, optional: false]}]},
"bamboo_smtp": {:hex, :bamboo_smtp, "1.2.1", "47181e338cbee9d028e94f2bc5829816b26d719d8213b07d0fa107d95b591947", [:mix], [{:bamboo, "~> 0.7.0", [hex: :bamboo, optional: false]}, {:gen_smtp, "~> 0.11.0", [hex: :gen_smtp, optional: false]}]},
"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
"comeonin": {:hex, :comeonin, "2.6.0", "74c288338b33205f9ce97e2117bb9a2aaab103a1811d243443d76fdb62f904ac", [:make, :mix], []},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []},
"cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, optional: false]}]},
Expand All @@ -9,13 +11,17 @@
"excoveralls": {:hex, :excoveralls, "0.6.3", "894bf9254890a4aac1d1165da08145a72700ff42d8cb6ce8195a584cb2a4b374", [:mix], [{:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}]},
"exjsx": {:hex, :exjsx, "3.2.1", "1bc5bf1e4fd249104178f0885030bcd75a4526f4d2a1e976f4b428d347614f0f", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, optional: false]}]},
"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []},
"gen_smtp": {:hex, :gen_smtp, "0.11.0", "d90ff2f021fc86cb2a4259b1f2b177ab6e506676265e26454bf5755855adc956", [:rebar3], []},
"gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], []},
"hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, optional: false]}, {:idna, "4.0.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
"httpoison": {:hex, :httpoison, "0.11.1", "d06c571274c0e77b6cc50e548db3fd7779f611fbed6681fd60a331f66c143a0b", [:mix], [{:hackney, "~> 1.7.0", [hex: :hackney, optional: false]}]},
"idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], []},
"jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], []},
"meck": {:hex, :meck, "0.8.4", "59ca1cd971372aa223138efcf9b29475bde299e1953046a0c727184790ab1520", [:make, :rebar], []},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
"mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], []},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
"mock": {:hex, :mock, "0.2.1", "bfdba786903e77f9c18772dee472d020ceb8ef000783e737725a4c8f54ad28ec", [:mix], [{:meck, "~> 0.8.2", [hex: :meck, optional: false]}]},
"phoenix": {:hex, :phoenix, "1.2.3", "b68dd6a7e6ff3eef38ad59771007d2f3f344988ea6e658e9b2c6ffb2ef494810", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.4 or ~> 1.3.3 or ~> 1.2.4 or ~> 1.1.8 or ~> 1.0.5", [hex: :plug, optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}]},
"phoenix_ecto": {:hex, :phoenix_ecto, "3.2.3", "450c749876ff1de4a78fdb305a142a76817c77a1cd79aeca29e5fc9a6c630b26", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, optional: true]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}]},
"phoenix_html": {:hex, :phoenix_html, "2.9.3", "1b5a2122cbf743aa242f54dced8a4f1cc778b8bd304f4b4c0043a6250c58e258", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
Expand Down
9 changes: 9 additions & 0 deletions priv/repo/migrations/20170412151545_add_mood_to_feedback.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.AddMoodToFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
add :mood, :string
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.AddPrivacyToFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
add :private, :boolean
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.AddPublicToFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
add :public, :boolean
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.RemovePrivateFromFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
remove :private
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.AddRespondedAtToFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
add :responded_at, :date
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.RemoveRespondedFromFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
remove :responded
end
end
end
10 changes: 10 additions & 0 deletions priv/repo/migrations/20170419174138_add_edit_to_feedback.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule Feedback.Repo.Migrations.AddEditToFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
add :edit, :boolean
add :edited, :boolean
end
end
end
16 changes: 16 additions & 0 deletions priv/repo/migrations/20170425145025_create_response.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule Feedback.Repo.Migrations.CreateResponse do
use Ecto.Migration

def change do
create table(:response) do
add :response, :text
add :edit, :boolean
add :edited, :boolean
add :feedback_id, references(:feedback, on_delete: :delete_all)

timestamps()
end

create index(:response, [:feedback_id])
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.RemoveResponseFromFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
remove :response
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Feedback.Repo.Migrations.RemoveRespondedAtFromFeedback do
use Ecto.Migration

def change do
alter table(:feedback) do
remove :responded_at
end
end
end
24 changes: 13 additions & 11 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
# Feedback.Repo.insert!(%Feedback.SomeModel{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.
alias Feedback.{Repo, User}

case Repo.get_by(User, first_name: "Admin") do
nil ->
Repo.insert! %User{
first_name: "Admin",
last_name: "Account",
email: System.get_env("ADMIN_EMAIL"),
password: System.get_env("ADMIN_PASSWORD"),
password_hash: Comeonin.Bcrypt.hashpwsalt(System.get_env("ADMIN_PASSWORD"))
}
_user -> IO.puts "Admin already in database"
end
18 changes: 18 additions & 0 deletions test/channels/room_channel_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule Feedback.RoomChannelTest do
use Feedback.ChannelCase
alias Feedback.RoomChannel

setup do
{:ok, _, socket} =
socket("responded", %{body: "body"})
|> subscribe_and_join(RoomChannel, "room:lobby")

{:ok, socket: socket}
end

test "responded replies with status ok", %{socket: socket} do
push socket, "responded", %{body: "body"}
assert_broadcast "responded", %{body: "body"}
leave socket
end
end
Loading