diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d582192cd7811e37a144d54bd4cdad303b25375a..d3fe26497e5b526cf49a4e569823fbb0b5667569 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,9 @@ stages: - build - test + - deploy include: - local: "/ci/build.yml" - - local: "/ci/test.yml" \ No newline at end of file + - local: "/ci/test.yml" + - local: "/ci/deploy.yml" \ No newline at end of file diff --git a/assets/package.json b/assets/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4d15144c34ab54a3fa4a9cb710c86f3b728270e8 --- /dev/null +++ b/assets/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "deploy": "cd .. && mix assets.deploy && rm -f _build/esbuild*" + } +} \ No newline at end of file diff --git a/ci/deploy.yml b/ci/deploy.yml new file mode 100644 index 0000000000000000000000000000000000000000..efba1d6bdc5860b12c891523730b42a7b5e77e32 --- /dev/null +++ b/ci/deploy.yml @@ -0,0 +1,11 @@ +# Deploys the app to elixir +deploy: + stage: deploy + script: + - apk update && apk add git + - git remote remove gigalixir || true + - git remote add gigalixir https://${GIGALIXIR_EMAIL}:${GIGALIXIR_API_KEY}@git.gigalixir.com/${GIGALIXIR_APP_NAME}.git + - git fetch --unshallow + - "git -c http.extraheader='GIGALIXIR-CLEAN: true' push gigalixir HEAD:refs/heads/master" + only: + - main diff --git a/config/runtime.exs b/config/runtime.exs index d7efa9af75ede859a93da1588f191bad12f1a2ef..77843a3fef8ccfb0df8ccc3464c1624951d5c831 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -31,7 +31,7 @@ if config_env() == :prod do maybe_ipv6 = if System.get_env("ECTO_IPV6"), do: [:inet6], else: [] config :volt, Volt.Repo, - # ssl: true, + ssl: true, url: database_url, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), socket_options: maybe_ipv6 diff --git a/elixir_buildpack.config b/elixir_buildpack.config new file mode 100644 index 0000000000000000000000000000000000000000..1e4755591d1e89a61d4da1d8c8e581950219ade0 --- /dev/null +++ b/elixir_buildpack.config @@ -0,0 +1,2 @@ +elixir_version=1.12.3 +erlang_version=22.3 \ No newline at end of file diff --git a/lib/volt_web/controllers/courier_dashboard_controller.ex b/lib/volt_web/controllers/courier_dashboard_controller.ex index 171d35c807df2581693634dd61bb93136fa80074..a7c963fd89707937d35daeb598d47ad5617b74ff 100644 --- a/lib/volt_web/controllers/courier_dashboard_controller.ex +++ b/lib/volt_web/controllers/courier_dashboard_controller.ex @@ -66,7 +66,7 @@ defmodule VoltWeb.CourierDashboardController do - order |> Repo.preload([:courier, :restaurant, :customer]) |> Order.changeset(%{order_status: "CUNT"}) |> Ecto.Changeset.put_assoc(:courier, courier) |> Repo.update!() + order |> Repo.preload([:courier, :restaurant, :customer]) |> Order.changeset(%{}) |> Ecto.Changeset.put_assoc(:courier, courier) |> Repo.update!() conn |> put_flash(:info, "Order marked as yours successfully.") diff --git a/lib/volt_web/controllers/customer_dashboard_controller.ex b/lib/volt_web/controllers/customer_dashboard_controller.ex index 1c2c0ebf212ac377fb1c15d2c8710281016c8777..4644d3321139380ac1cce4b3a55a9615096bf782 100644 --- a/lib/volt_web/controllers/customer_dashboard_controller.ex +++ b/lib/volt_web/controllers/customer_dashboard_controller.ex @@ -227,6 +227,6 @@ defmodule VoltWeb.CustomerDashboardController do end end - defp get_map(), do: "http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=" <> System.get_env("BING_MAP_KEY") + defp get_map(), do: "https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=" <> System.get_env("BING_MAP_KEY") end diff --git a/lib/volt_web/controllers/customer_registration_controller.ex b/lib/volt_web/controllers/customer_registration_controller.ex index b2ea095d0999850aa52ae58ae795b4c81eabff30..d5c3a9fd801d2916cba1040cff44fb67b07c18d4 100644 --- a/lib/volt_web/controllers/customer_registration_controller.ex +++ b/lib/volt_web/controllers/customer_registration_controller.ex @@ -28,5 +28,5 @@ defmodule VoltWeb.CustomerRegistrationController do end end - defp get_map(), do: "http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=" <> System.get_env("BING_MAP_KEY") + defp get_map(), do: "https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=" <> System.get_env("BING_MAP_KEY") end diff --git a/lib/volt_web/templates/customer_dashboard/basket.html.heex b/lib/volt_web/templates/customer_dashboard/basket.html.heex index e206f4ba48ca6b2f1f7c1b2d425b366a3125e5ef..245ab3cc244a949cde7ae1c40e5b7f3410222898 100644 --- a/lib/volt_web/templates/customer_dashboard/basket.html.heex +++ b/lib/volt_web/templates/customer_dashboard/basket.html.heex @@ -17,7 +17,7 @@ <td><%= item.description %></td> <td> + <%= if item.discount > 0 do "#{Float.floor(String.to_integer(item.price)*(1-(item.discount/100)),2)}"<>"€ ("<>"#{item.price}"<>"-"<>"#{item.discount}"<>"%)" else item.price end %></td> <td><%= item.quantity %> pcs</td> - <td> = <%= if item.discount > 0 do "#{Float.floor(String.to_integer(item.price)*(1-(item.discount/100)),2)*item.quantity}"else Float.parse(item.price) |> elem(0) |> Kernel.*(item.quantity) end %> € </td> + <td> = <%= if item.discount > 0 do "#{Float.floor(String.to_integer(item.price)*(1-(item.discount/100))*item.quantity,2)}"else Float.parse(item.price) |> elem(0) |> Kernel.*(item.quantity) end %> € </td> <td> <span><%= button "Delete", id: "item_delete", to: Routes.customer_dashboard_path(@conn, :delete, item.basket_id, item.item_id, item), method: :delete %></span> </td> diff --git a/lib/volt_web/templates/layout/_customer_menu.html.heex b/lib/volt_web/templates/layout/_customer_menu.html.heex index 9bb4ccecba3062462ced0903bd69afea6214c090..e6b28293d2f30b1ddf4fad6bb6e7001670ddd381 100644 --- a/lib/volt_web/templates/layout/_customer_menu.html.heex +++ b/lib/volt_web/templates/layout/_customer_menu.html.heex @@ -1,7 +1,7 @@ <ul> <%= if @current_customer do %> <h3>Greetings, <%= @current_customer.last_name%>!</h3> - <h5>Your account balance: <%= @current_customer.balance %> €</h5> + <h5>Your account balance: <%= Float.floor(@current_customer.balance,2) %> €</h5> <li><%= link "Add money", to: Routes.customer_balance_path(@conn, :index), method: :get, id: "deposit_button" %> </li> <li><%= link "Order history", to: Routes.customer_history_path(@conn, :index), method: :get, id: "history_button" %> </li> <li><%= link "Settings", to: Routes.customer_settings_path(@conn, :edit) %></li>