   alias Api.{Mailer, Repo}
   alias Api.Accounts.User
   alias Api.Competitions
+  alias Api.Teams
   alias Api.Teams.{Invite, Membership, Team}
   alias Api.Notifications.Emails
   alias Ecto.{Changeset}

    applied_true = Map.get(changeset.changes, :applied) == true

    if applied_change and applied_true do
      members = Repo.all Ecto.assoc(team, :members)
      Enum.map(members, fn(member) ->
        Emails.joined_hackathon_email(member, team) |> Mailer.deliver_later


    Team.admin_changeset(team, team_params, Repo)
    |> email_if_applying(team)
    |> email_if_accepted(team)
    |> Repo.update
  end

