tidying stray dev code
This commit is contained in:
parent
326b6624b5
commit
3b5794a401
1 changed files with 14 additions and 17 deletions
|
@ -13,22 +13,21 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
|
|||
|
||||
socket
|
||||
|> assign_defaults(session)
|
||||
|> assign(:url_valid, :false)
|
||||
|> assign(:url_validated, :false)
|
||||
|> assign(:tz_valid, :true)
|
||||
|> assign(:url_valid, false)
|
||||
|> assign(:url_validated, false)
|
||||
|> assign(:tz_valid, true)
|
||||
|> live_okreply()
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_event("validate", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
|
||||
socket
|
||||
|> assign(:url_valid, Regex.match?(@url_regex, url) |> IO.inspect(label: "url valid?"))
|
||||
|> assign(:url_valid, Regex.match?(@url_regex, url))
|
||||
|> assign(:url_validated, true)
|
||||
|> assign(:tz_valid, Enum.member?(Tzdata.zone_list(), tz))
|
||||
|> live_noreply()
|
||||
end
|
||||
|
||||
|
||||
@impl true
|
||||
def handle_event("save", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
|
||||
url
|
||||
|
@ -57,10 +56,6 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
|
|||
defp handle_parsed_ics_data([], socket, tz), do: handle_http_ics_response(false, socket, tz)
|
||||
|
||||
defp handle_parsed_ics_data(events, socket, tz) do
|
||||
IO.inspect(events, label: "We got some ical events! :")
|
||||
IO.inspect(tz, label: "time zone was :")
|
||||
|
||||
to_insert =
|
||||
events
|
||||
|> Stream.map(&shift_from_event(&1, tz, socket.assigns.current_user.id))
|
||||
|> Enum.map(&Repo.timestamp/1)
|
||||
|
@ -81,14 +76,16 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
|
|||
if n == event_count do
|
||||
{:success, "Successfully imported #{n} event#{s}"}
|
||||
else
|
||||
{:warning, "Some error, only #{n} event#{s} imported but seemed like iCal contained #{event_count}?"}
|
||||
{:warning,
|
||||
"Some error, only #{n} event#{s} imported but seemed like iCal contained #{
|
||||
event_count
|
||||
}?"}
|
||||
end
|
||||
end
|
||||
|
||||
put_flash(socket, status, msg)
|
||||
end
|
||||
|
||||
|
||||
defp content_type_calendar?(headers) do
|
||||
headers
|
||||
|> List.keyfind("Content-Type", 0)
|
||||
|
|
Loading…
Reference in a new issue