initial commit

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2017-12-08 09:58:14 +01:00
commit 90ceb4f6fe
181 changed files with 8219 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
defmodule EventosWeb.UserSocket do
use Phoenix.Socket
## Channels
# channel "room:*", EventosWeb.RoomChannel
## Transports
transport :websocket, Phoenix.Transports.WebSocket
# transport :longpoll, Phoenix.Transports.LongPoll
# Socket params are passed from the client and can
# be used to verify and authenticate a user. After
# verification, you can put default assigns into
# the socket that will be set for all channels, ie
#
# {:ok, assign(socket, :user_id, verified_user_id)}
#
# To deny connection, return `:error`.
#
# See `Phoenix.Token` documentation for examples in
# performing token verification on connect.
def connect(_params, socket) do
{:ok, socket}
end
# Socket id's are topics that allow you to identify all sockets for a given user:
#
# def id(socket), do: "user_socket:#{socket.assigns.user_id}"
#
# Would allow you to broadcast a "disconnect" event and terminate
# all active sockets and channels for a given user:
#
# EventosWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
#
# Returning `nil` makes this socket anonymous.
def id(_socket), do: nil
end

View File

@@ -0,0 +1,79 @@
defmodule EventosWeb.Coherence.Messages do
@moduledoc """
Application facing messages generated by the Coherence application.
This module was created by the coh.install mix task. It contains all the
messages used in the coherence application except those in other generated
files like the view and templates.
To assist in upgrading Coherence, the `Coherence.Messages behaviour will
alway contain every message for the current version. This will help in upgrades
to ensure the user had added new the new messages from the current version.
"""
@behaviour Coherence.Messages
import EventosWeb.Gettext
# Change this to override the "coherence" gettext domain. If you would like
# the coherence message to be part of your projects domain change it to "default"
@domain "coherence"
##################
# Messages
def account_already_confirmed, do: dgettext(@domain, "Account already confirmed.")
def account_is_not_locked, do: dgettext(@domain, "Account is not locked.")
def account_updated_successfully, do: dgettext(@domain, "Account updated successfully.")
def already_confirmed, do: dgettext(@domain, "already confirmed")
def already_locked, do: dgettext(@domain, "already locked")
def already_logged_in, do: dgettext(@domain, "Already logged in.")
def cant_be_blank, do: dgettext(@domain, "can't be blank")
def cant_find_that_token, do: dgettext(@domain, "Can't find that token")
def confirmation_email_sent, do: dgettext(@domain, "Confirmation email sent.")
def confirmation_token_expired, do: dgettext(@domain, "Confirmation token expired.")
def could_not_find_that_email_address, do: dgettext(@domain, "Could not find that email address")
def forgot_your_password, do: dgettext(@domain, "Forgot your password?")
def http_authentication_required, do: dgettext(@domain, "HTTP Authentication Required")
def incorrect_login_or_password(opts), do: dgettext(@domain, "Incorrect %{login_field} or password.", opts)
def invalid_current_password, do: dgettext(@domain, "invalid current password")
def invalid_invitation, do: dgettext(@domain, "Invalid Invitation. Please contact the site administrator.")
def invalid_request, do: dgettext(@domain, "Invalid Request.")
def invalid_confirmation_token, do: dgettext(@domain, "Invalid confirmation token.")
def invalid_email_or_password, do: dgettext(@domain, "Invalid email or password.")
def invalid_invitation_token, do: dgettext(@domain, "Invalid invitation token.")
def invalid_reset_token, do: dgettext(@domain, "Invalid reset token.")
def invalid_unlock_token, do: dgettext(@domain, "Invalid unlock token.")
def invitation_already_sent, do: dgettext(@domain, "Invitation already sent.")
def invitation_sent, do: dgettext(@domain, "Invitation sent.")
def invite_someone, do: dgettext(@domain, "Invite Someone")
def maximum_login_attempts_exceeded, do: dgettext(@domain, "Maximum Login attempts exceeded. Your account has been locked.")
def need_an_account, do: dgettext(@domain, "Need An Account?")
def not_locked, do: dgettext(@domain, "not locked")
def password_reset_token_expired, do: dgettext(@domain, "Password reset token expired.")
def password_updated_successfully, do: dgettext(@domain, "Password updated successfully.")
def problem_confirming_user_account, do: dgettext(@domain, "Problem confirming user account. Please contact the system administrator.")
def registration_created_successfully, do: dgettext(@domain, "Registration created successfully.")
def required, do: dgettext(@domain, "required")
def resend_confirmation_email, do: dgettext(@domain, "Resend confirmation email")
def reset_email_sent, do: dgettext(@domain, "Reset email sent. Check your email for a reset link.")
def restricted_area, do: dgettext(@domain, "Restricted Area")
def send_an_unlock_email, do: dgettext(@domain, "Send an unlock email")
def sign_in, do: dgettext(@domain, "Sign In")
def sign_out, do: dgettext(@domain, "Sign Out")
def signed_in_successfully, do: dgettext(@domain, "Signed in successfully.")
def too_many_failed_login_attempts, do: dgettext(@domain, "Too many failed login attempts. Account has been locked.")
def unauthorized_ip_address, do: dgettext(@domain, "Unauthorized IP Address")
def unlock_instructions_sent, do: dgettext(@domain, "Unlock Instructions sent.")
def user_account_confirmed_successfully, do: dgettext(@domain, "User account confirmed successfully.")
def user_already_has_an_account, do: dgettext(@domain, "User already has an account!")
def you_must_confirm_your_account, do: dgettext(@domain, "You must confirm your account before you can login.")
def your_account_has_been_unlocked, do: dgettext(@domain, "Your account has been unlocked")
def your_account_is_not_locked, do: dgettext(@domain, "Your account is not locked.")
def verify_user_token(opts),
do: dgettext(@domain, "Invalid %{user_token} error: %{error}", opts)
def you_are_using_an_invalid_security_token,
do: dgettext(@domain, "You are using an invalid security token for this site! This security\n" <>
"violation has been logged.\n")
def mailer_required, do: dgettext(@domain, "Mailer configuration required!")
def account_is_inactive(), do: dgettext(@domain, "Account is inactive!")
end

View File

@@ -0,0 +1,47 @@
defmodule EventosWeb.Coherence do
@moduledoc false
def view do
quote do
use Phoenix.View, root: "lib/eventos_web/templates"
# Import convenience functions from controllers
import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
import EventosWeb.Router.Helpers
import EventosWeb.ErrorHelpers
import EventosWeb.Gettext
import EventosWeb.Coherence.ViewHelpers
end
end
def controller do
quote do
use Phoenix.Controller, except: [layout_view: 2]
use Coherence.Config
use Timex
import Ecto
import Ecto.Query
import Plug.Conn
import EventosWeb.Router.Helpers
import EventosWeb.Gettext
import Coherence.ControllerHelpers
alias Coherence.Config
alias Coherence.ControllerHelpers, as: Helpers
require Redirects
end
end
@doc """
When used, dispatch to the appropriate controller/view/etc.
"""
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.AccountController do
use EventosWeb, :controller
alias Eventos.Accounts
alias Eventos.Accounts.Account
def index(conn, _params) do
accounts = Accounts.list_accounts()
render(conn, "index.html", accounts: accounts)
end
def new(conn, _params) do
changeset = Accounts.change_account(%Account{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"account" => account_params}) do
case Accounts.create_account(account_params) do
{:ok, account} ->
conn
|> put_flash(:info, "Account created successfully.")
|> redirect(to: account_path(conn, :show, account))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
account = Accounts.get_account!(id)
render(conn, "show.html", account: account)
end
def edit(conn, %{"id" => id}) do
account = Accounts.get_account!(id)
changeset = Accounts.change_account(account)
render(conn, "edit.html", account: account, changeset: changeset)
end
def update(conn, %{"id" => id, "account" => account_params}) do
account = Accounts.get_account!(id)
case Accounts.update_account(account, account_params) do
{:ok, account} ->
conn
|> put_flash(:info, "Account updated successfully.")
|> redirect(to: account_path(conn, :show, account))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", account: account, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
account = Accounts.get_account!(id)
{:ok, _account} = Accounts.delete_account(account)
conn
|> put_flash(:info, "Account deleted successfully.")
|> redirect(to: account_path(conn, :index))
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.CategoryController do
use EventosWeb, :controller
alias Eventos.Events
alias Eventos.Events.Category
def index(conn, _params) do
categories = Events.list_categories()
render(conn, "index.html", categories: categories)
end
def new(conn, _params) do
changeset = Events.change_category(%Category{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"category" => category_params}) do
case Events.create_category(category_params) do
{:ok, category} ->
conn
|> put_flash(:info, "Category created successfully.")
|> redirect(to: category_path(conn, :show, category))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
category = Events.get_category!(id)
render(conn, "show.html", category: category)
end
def edit(conn, %{"id" => id}) do
category = Events.get_category!(id)
changeset = Events.change_category(category)
render(conn, "edit.html", category: category, changeset: changeset)
end
def update(conn, %{"id" => id, "category" => category_params}) do
category = Events.get_category!(id)
case Events.update_category(category, category_params) do
{:ok, category} ->
conn
|> put_flash(:info, "Category updated successfully.")
|> redirect(to: category_path(conn, :show, category))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", category: category, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
category = Events.get_category!(id)
{:ok, _category} = Events.delete_category(category)
conn
|> put_flash(:info, "Category deleted successfully.")
|> redirect(to: category_path(conn, :index))
end
end

View File

@@ -0,0 +1,54 @@
defmodule Coherence.Redirects do
@moduledoc """
Define controller action redirection functions.
This module contains default redirect functions for each of the controller
actions that perform redirects. By using this Module you get the following
functions:
* session_create/2
* session_delete/2
* password_create/2
* password_update/2,
* unlock_create_not_locked/2
* unlock_create_invalid/2
* unlock_create/2
* unlock_edit_not_locked/2
* unlock_edit/2
* unlock_edit_invalid/2
* registration_create/2
* invitation_create/2
* confirmation_create/2
* confirmation_edit_invalid/2
* confirmation_edit_expired/2
* confirmation_edit/2
* confirmation_edit_error/2
You can override any of the functions to customize the redirect path. Each
function is passed the `conn` and `params` arguments from the controller.
## Examples
import EventosWeb.Router.Helpers
# override the log out action back to the log in page
def session_delete(conn, _), do: redirect(conn, to: session_path(conn, :new))
# redirect the user to the login page after registering
def registration_create(conn, _), do: redirect(conn, to: session_path(conn, :new))
# disable the user_return_to feature on login
def session_create(conn, _), do: redirect(conn, to: landing_path(conn, :index))
"""
use Redirects
# Uncomment the import below if adding overrides
# import EventosWeb.Router.Helpers
# Add function overrides below
# Example usage
# Uncomment the following line to return the user to the login form after logging out
# def session_delete(conn, _), do: redirect(conn, to: session_path(conn, :new))
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.EventAccountsController do
use EventosWeb, :controller
alias Eventos.Events
alias Eventos.Events.EventAccounts
def index(conn, _params) do
event_accounts = Events.list_event_accounts()
render(conn, "index.html", event_accounts: event_accounts)
end
def new(conn, _params) do
changeset = Events.change_event_accounts(%EventAccounts{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"event_accounts" => event_accounts_params}) do
case Events.create_event_accounts(event_accounts_params) do
{:ok, event_accounts} ->
conn
|> put_flash(:info, "Event accounts created successfully.")
|> redirect(to: event_accounts_path(conn, :show, event_accounts))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
event_accounts = Events.get_event_accounts!(id)
render(conn, "show.html", event_accounts: event_accounts)
end
def edit(conn, %{"id" => id}) do
event_accounts = Events.get_event_accounts!(id)
changeset = Events.change_event_accounts(event_accounts)
render(conn, "edit.html", event_accounts: event_accounts, changeset: changeset)
end
def update(conn, %{"id" => id, "event_accounts" => event_accounts_params}) do
event_accounts = Events.get_event_accounts!(id)
case Events.update_event_accounts(event_accounts, event_accounts_params) do
{:ok, event_accounts} ->
conn
|> put_flash(:info, "Event accounts updated successfully.")
|> redirect(to: event_accounts_path(conn, :show, event_accounts))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", event_accounts: event_accounts, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
event_accounts = Events.get_event_accounts!(id)
{:ok, _event_accounts} = Events.delete_event_accounts(event_accounts)
conn
|> put_flash(:info, "Event accounts deleted successfully.")
|> redirect(to: event_accounts_path(conn, :index))
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.EventController do
use EventosWeb, :controller
alias Eventos.Events
alias Eventos.Events.Event
def index(conn, _params) do
events = Events.list_events()
render(conn, "index.html", events: events)
end
def new(conn, _params) do
changeset = Events.change_event(%Event{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"event" => event_params}) do
case Events.create_event(event_params) do
{:ok, event} ->
conn
|> put_flash(:info, "Event created successfully.")
|> redirect(to: event_path(conn, :show, event))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
event = Events.get_event!(id)
render(conn, "show.html", event: event)
end
def edit(conn, %{"id" => id}) do
event = Events.get_event!(id)
changeset = Events.change_event(event)
render(conn, "edit.html", event: event, changeset: changeset)
end
def update(conn, %{"id" => id, "event" => event_params}) do
event = Events.get_event!(id)
case Events.update_event(event, event_params) do
{:ok, event} ->
conn
|> put_flash(:info, "Event updated successfully.")
|> redirect(to: event_path(conn, :show, event))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", event: event, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
event = Events.get_event!(id)
{:ok, _event} = Events.delete_event(event)
conn
|> put_flash(:info, "Event deleted successfully.")
|> redirect(to: event_path(conn, :index))
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.EventRequestController do
use EventosWeb, :controller
alias Eventos.Events
alias Eventos.Events.EventRequest
def index(conn, _params) do
event_requests = Events.list_event_requests()
render(conn, "index.html", event_requests: event_requests)
end
def new(conn, _params) do
changeset = Events.change_event_request(%EventRequest{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"event_request" => event_request_params}) do
case Events.create_event_request(event_request_params) do
{:ok, event_request} ->
conn
|> put_flash(:info, "Event request created successfully.")
|> redirect(to: event_request_path(conn, :show, event_request))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
event_request = Events.get_event_request!(id)
render(conn, "show.html", event_request: event_request)
end
def edit(conn, %{"id" => id}) do
event_request = Events.get_event_request!(id)
changeset = Events.change_event_request(event_request)
render(conn, "edit.html", event_request: event_request, changeset: changeset)
end
def update(conn, %{"id" => id, "event_request" => event_request_params}) do
event_request = Events.get_event_request!(id)
case Events.update_event_request(event_request, event_request_params) do
{:ok, event_request} ->
conn
|> put_flash(:info, "Event request updated successfully.")
|> redirect(to: event_request_path(conn, :show, event_request))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", event_request: event_request, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
event_request = Events.get_event_request!(id)
{:ok, _event_request} = Events.delete_event_request(event_request)
conn
|> put_flash(:info, "Event request deleted successfully.")
|> redirect(to: event_request_path(conn, :index))
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.GroupAccountController do
use EventosWeb, :controller
alias Eventos.Accounts
alias Eventos.Accounts.GroupAccount
def index(conn, _params) do
group_accounts = Accounts.list_group_accounts()
render(conn, "index.html", group_accounts: group_accounts)
end
def new(conn, _params) do
changeset = Accounts.change_group_account(%GroupAccount{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"group_account" => group_account_params}) do
case Accounts.create_group_account(group_account_params) do
{:ok, group_account} ->
conn
|> put_flash(:info, "Group account created successfully.")
|> redirect(to: group_account_path(conn, :show, group_account))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
group_account = Accounts.get_group_account!(id)
render(conn, "show.html", group_account: group_account)
end
def edit(conn, %{"id" => id}) do
group_account = Accounts.get_group_account!(id)
changeset = Accounts.change_group_account(group_account)
render(conn, "edit.html", group_account: group_account, changeset: changeset)
end
def update(conn, %{"id" => id, "group_account" => group_account_params}) do
group_account = Accounts.get_group_account!(id)
case Accounts.update_group_account(group_account, group_account_params) do
{:ok, group_account} ->
conn
|> put_flash(:info, "Group account updated successfully.")
|> redirect(to: group_account_path(conn, :show, group_account))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", group_account: group_account, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
group_account = Accounts.get_group_account!(id)
{:ok, _group_account} = Accounts.delete_group_account(group_account)
conn
|> put_flash(:info, "Group account deleted successfully.")
|> redirect(to: group_account_path(conn, :index))
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.GroupController do
use EventosWeb, :controller
alias Eventos.Accounts
alias Eventos.Accounts.Group
def index(conn, _params) do
groups = Accounts.list_groups()
render(conn, "index.html", groups: groups)
end
def new(conn, _params) do
changeset = Accounts.change_group(%Group{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"group" => group_params}) do
case Accounts.create_group(group_params) do
{:ok, group} ->
conn
|> put_flash(:info, "Group created successfully.")
|> redirect(to: group_path(conn, :show, group))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
group = Accounts.get_group!(id)
render(conn, "show.html", group: group)
end
def edit(conn, %{"id" => id}) do
group = Accounts.get_group!(id)
changeset = Accounts.change_group(group)
render(conn, "edit.html", group: group, changeset: changeset)
end
def update(conn, %{"id" => id, "group" => group_params}) do
group = Accounts.get_group!(id)
case Accounts.update_group(group, group_params) do
{:ok, group} ->
conn
|> put_flash(:info, "Group updated successfully.")
|> redirect(to: group_path(conn, :show, group))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", group: group, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
group = Accounts.get_group!(id)
{:ok, _group} = Accounts.delete_group(group)
conn
|> put_flash(:info, "Group deleted successfully.")
|> redirect(to: group_path(conn, :index))
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.GroupRequestController do
use EventosWeb, :controller
alias Eventos.Accounts
alias Eventos.Accounts.GroupRequest
def index(conn, _params) do
group_request = Accounts.list_group_requests()
render(conn, "index.html", group_request: group_request)
end
def new(conn, _params) do
changeset = Accounts.change_group_request(%GroupRequest{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"group_request" => group_request_params}) do
case Accounts.create_group_request(group_request_params) do
{:ok, group_request} ->
conn
|> put_flash(:info, "Group request created successfully.")
|> redirect(to: group_request_path(conn, :show, group_request))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
group_request = Accounts.get_group_request!(id)
render(conn, "show.html", group_request: group_request)
end
def edit(conn, %{"id" => id}) do
group_request = Accounts.get_group_request!(id)
changeset = Accounts.change_group_request(group_request)
render(conn, "edit.html", group_request: group_request, changeset: changeset)
end
def update(conn, %{"id" => id, "group_request" => group_request_params}) do
group_request = Accounts.get_group_request!(id)
case Accounts.update_group_request(group_request, group_request_params) do
{:ok, group_request} ->
conn
|> put_flash(:info, "Group request updated successfully.")
|> redirect(to: group_request_path(conn, :show, group_request))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", group_request: group_request, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
group_request = Accounts.get_group_request!(id)
{:ok, _group_request} = Accounts.delete_group_request(group_request)
conn
|> put_flash(:info, "Group request deleted successfully.")
|> redirect(to: group_request_path(conn, :index))
end
end

View File

@@ -0,0 +1,7 @@
defmodule EventosWeb.PageController do
use EventosWeb, :controller
def index(conn, _params) do
render conn, "index.html"
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.TagController do
use EventosWeb, :controller
alias Eventos.Events
alias Eventos.Events.Tag
def index(conn, _params) do
tags = Events.list_tags()
render(conn, "index.html", tags: tags)
end
def new(conn, _params) do
changeset = Events.change_tag(%Tag{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"tag" => tag_params}) do
case Events.create_tag(tag_params) do
{:ok, tag} ->
conn
|> put_flash(:info, "Tag created successfully.")
|> redirect(to: tag_path(conn, :show, tag))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
tag = Events.get_tag!(id)
render(conn, "show.html", tag: tag)
end
def edit(conn, %{"id" => id}) do
tag = Events.get_tag!(id)
changeset = Events.change_tag(tag)
render(conn, "edit.html", tag: tag, changeset: changeset)
end
def update(conn, %{"id" => id, "tag" => tag_params}) do
tag = Events.get_tag!(id)
case Events.update_tag(tag, tag_params) do
{:ok, tag} ->
conn
|> put_flash(:info, "Tag updated successfully.")
|> redirect(to: tag_path(conn, :show, tag))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", tag: tag, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
tag = Events.get_tag!(id)
{:ok, _tag} = Events.delete_tag(tag)
conn
|> put_flash(:info, "Tag deleted successfully.")
|> redirect(to: tag_path(conn, :index))
end
end

View File

@@ -0,0 +1,60 @@
defmodule EventosWeb.UserController do
use EventosWeb, :controller
alias Eventos.Accounts
alias Eventos.Accounts.User
def index(conn, _params) do
users = Accounts.list_users()
render(conn, "index.html", users: users)
end
def new(conn, _params) do
changeset = Accounts.change_user(%User{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"user" => user_params}) do
case Accounts.create_user(user_params) do
{:ok, user} ->
conn
|> put_flash(:info, "User created successfully.")
|> redirect(to: user_path(conn, :show, user))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
user = Accounts.get_user!(id)
render(conn, "show.html", user: user)
end
def edit(conn, %{"id" => id}) do
user = Accounts.get_user!(id)
changeset = Accounts.change_user(user)
render(conn, "edit.html", user: user, changeset: changeset)
end
def update(conn, %{"id" => id, "user" => user_params}) do
user = Accounts.get_user!(id)
case Accounts.update_user(user, user_params) do
{:ok, user} ->
conn
|> put_flash(:info, "User updated successfully.")
|> redirect(to: user_path(conn, :show, user))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", user: user, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
user = Accounts.get_user!(id)
{:ok, _user} = Accounts.delete_user(user)
conn
|> put_flash(:info, "User deleted successfully.")
|> redirect(to: user_path(conn, :index))
end
end

View File

@@ -0,0 +1,6 @@
defmodule EventosWeb.Coherence.Mailer do
@moduledoc false
if Coherence.Config.mailer?() do
use Swoosh.Mailer, otp_app: :coherence
end
end

View File

@@ -0,0 +1,82 @@
Code.ensure_loaded Phoenix.Swoosh
defmodule EventosWeb.Coherence.UserEmail do
@moduledoc false
use Phoenix.Swoosh, view: EventosWeb.Coherence.EmailView, layout: {EventosWeb.Coherence.LayoutView, :email}
alias Swoosh.Email
require Logger
alias Coherence.Config
import EventosWeb.Gettext
defp site_name, do: Config.site_name(inspect Config.module)
def password(user, url) do
%Email{}
|> from(from_email())
|> to(user_email(user))
|> add_reply_to()
|> subject(dgettext("coherence", "%{site_name} - Reset password instructions", site_name: site_name()))
|> render_body("password.html", %{url: url, name: first_name(user.username)})
end
def confirmation(user, url) do
%Email{}
|> from(from_email())
|> to(user_email(user))
|> add_reply_to()
|> subject(dgettext("coherence", "%{site_name} - Confirm your new account", site_name: site_name()))
|> render_body("confirmation.html", %{url: url, name: first_name(user.username)})
end
def invitation(invitation, url) do
%Email{}
|> from(from_email())
|> to(user_email(invitation))
|> add_reply_to()
|> subject(dgettext("coherence", "%{site_name} - Invitation to create a new account", site_name: site_name()))
|> render_body("invitation.html", %{url: url, name: first_name(invitation.name)})
end
def unlock(user, url) do
%Email{}
|> from(from_email())
|> to(user_email(user))
|> add_reply_to()
|> subject(dgettext("coherence", "%{site_name} - Unlock Instructions", site_name: site_name()))
|> render_body("unlock.html", %{url: url, name: first_name(user.username)})
end
defp add_reply_to(mail) do
case Coherence.Config.email_reply_to do
nil -> mail
true -> reply_to mail, from_email()
address -> reply_to mail, address
end
end
defp first_name(name) do
case String.split(name, " ") do
[first_name | _] -> first_name
_ -> name
end
end
defp user_email(user) do
{user.username, user.email}
end
defp from_email do
case Coherence.Config.email_from do
nil ->
Logger.error ~s|Need to configure :coherence, :email_from_name, "Name", and :email_from_email, "me@example.com"|
nil
{name, email} = email_tuple ->
if is_nil(name) or is_nil(email) do
Logger.error ~s|Need to configure :coherence, :email_from_name, "Name", and :email_from_email, "me@example.com"|
nil
else
email_tuple
end
end
end
end

View File

@@ -0,0 +1,57 @@
defmodule EventosWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :eventos
socket "/socket", EventosWeb.UserSocket
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
plug Plug.Static,
at: "/", from: :eventos, gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
end
plug Plug.RequestId
plug Plug.Logger
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
plug Plug.MethodOverride
plug Plug.Head
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
plug Plug.Session,
store: :cookie,
key: "_eventos_key",
signing_salt: "F9CCTF22"
plug EventosWeb.Router
@doc """
Callback invoked for dynamically configuring the endpoint.
It receives the endpoint configuration and checks if
configuration should be loaded from the system environment.
"""
def init(_key, config) do
if config[:load_from_system_env] do
port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
{:ok, Keyword.put(config, :http, [:inet6, port: port])}
else
{:ok, config}
end
end
end

View File

@@ -0,0 +1,24 @@
defmodule EventosWeb.Gettext do
@moduledoc """
A module providing Internationalization with a gettext-based API.
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import EventosWeb.Gettext
# Simple translation
gettext "Here is the string to translate"
# Plural translation
ngettext "Here is the string to translate",
"Here are the strings to translate",
3
# Domain-based translation
dgettext "errors", "Here is the error message to translate"
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :eventos
end

63
lib/eventos_web/router.ex Normal file
View File

@@ -0,0 +1,63 @@
defmodule EventosWeb.Router do
use EventosWeb, :router
use Coherence.Router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Coherence.Authentication.Session
end
pipeline :protected do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Coherence.Authentication.Session, protected: true
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/" do
pipe_through :browser
coherence_routes()
end
# Add this block
scope "/" do
pipe_through :protected
coherence_routes :protected
end
scope "/", EventosWeb do
pipe_through :browser # Use the default browser stack
get "/", PageController, :index
resources "/users", UserController
resources "/accounts", AccountController
resources "/events", EventController
resources "/categories", CategoryController
resources "/tags", TagController
resources "/event_accounts", EventAccountsController
resources "/event_requests", EventRequestController
resources "/groups", GroupController
resources "/group_accounts", GroupAccountController
resources "/group_requests", GroupRequestController
end
scope "/", EventosWeb do
pipe_through :protected
# Add protected routes below
end
# Other scopes may use custom stacks.
scope "/api", EventosWeb do
pipe_through :api
end
end

View File

@@ -0,0 +1,5 @@
<h2>Edit Account</h2>
<%= render "form.html", Map.put(assigns, :action, account_path(@conn, :update, @account)) %>
<span><%= link "Back", to: account_path(@conn, :index) %></span>

View File

@@ -0,0 +1,65 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :username, class: "control-label" %>
<%= text_input f, :username, class: "form-control" %>
<%= error_tag f, :username %>
</div>
<div class="form-group">
<%= label f, :domain, class: "control-label" %>
<%= text_input f, :domain, class: "form-control" %>
<%= error_tag f, :domain %>
</div>
<div class="form-group">
<%= label f, :display_name, class: "control-label" %>
<%= text_input f, :display_name, class: "form-control" %>
<%= error_tag f, :display_name %>
</div>
<div class="form-group">
<%= label f, :description, class: "control-label" %>
<%= text_input f, :description, class: "form-control" %>
<%= error_tag f, :description %>
</div>
<div class="form-group">
<%= label f, :private_key, class: "control-label" %>
<%= text_input f, :private_key, class: "form-control" %>
<%= error_tag f, :private_key %>
</div>
<div class="form-group">
<%= label f, :public_key, class: "control-label" %>
<%= text_input f, :public_key, class: "form-control" %>
<%= error_tag f, :public_key %>
</div>
<div class="form-group">
<%= label f, :suspended, class: "control-label" %>
<%= checkbox f, :suspended, class: "checkbox" %>
<%= error_tag f, :suspended %>
</div>
<div class="form-group">
<%= label f, :uri, class: "control-label" %>
<%= text_input f, :uri, class: "form-control" %>
<%= error_tag f, :uri %>
</div>
<div class="form-group">
<%= label f, :url, class: "control-label" %>
<%= text_input f, :url, class: "form-control" %>
<%= error_tag f, :url %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,42 @@
<h2>Listing Accounts</h2>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Domain</th>
<th>Display name</th>
<th>Description</th>
<th>Private key</th>
<th>Public key</th>
<th>Suspended</th>
<th>Uri</th>
<th>Url</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for account <- @accounts do %>
<tr>
<td><%= account.username %></td>
<td><%= account.domain %></td>
<td><%= account.display_name %></td>
<td><%= account.description %></td>
<td><%= account.private_key %></td>
<td><%= account.public_key %></td>
<td><%= account.suspended %></td>
<td><%= account.uri %></td>
<td><%= account.url %></td>
<td class="text-right">
<span><%= link "Show", to: account_path(@conn, :show, account), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: account_path(@conn, :edit, account), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: account_path(@conn, :delete, account), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Account", to: account_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Account</h2>
<%= render "form.html", Map.put(assigns, :action, account_path(@conn, :create)) %>
<span><%= link "Back", to: account_path(@conn, :index) %></span>

View File

@@ -0,0 +1,53 @@
<h2>Show Account</h2>
<ul>
<li>
<strong>Username:</strong>
<%= @account.username %>
</li>
<li>
<strong>Domain:</strong>
<%= @account.domain %>
</li>
<li>
<strong>Display name:</strong>
<%= @account.display_name %>
</li>
<li>
<strong>Description:</strong>
<%= @account.description %>
</li>
<li>
<strong>Private key:</strong>
<%= @account.private_key %>
</li>
<li>
<strong>Public key:</strong>
<%= @account.public_key %>
</li>
<li>
<strong>Suspended:</strong>
<%= @account.suspended %>
</li>
<li>
<strong>Uri:</strong>
<%= @account.uri %>
</li>
<li>
<strong>Url:</strong>
<%= @account.url %>
</li>
</ul>
<span><%= link "Edit", to: account_path(@conn, :edit, @account) %></span>
<span><%= link "Back", to: account_path(@conn, :index) %></span>

View File

@@ -0,0 +1,5 @@
<h2>Edit Category</h2>
<%= render "form.html", Map.put(assigns, :action, category_path(@conn, :update, @category)) %>
<span><%= link "Back", to: category_path(@conn, :index) %></span>

View File

@@ -0,0 +1,23 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :title, class: "control-label" %>
<%= text_input f, :title, class: "form-control" %>
<%= error_tag f, :title %>
</div>
<div class="form-group">
<%= label f, :picture, class: "control-label" %>
<%= text_input f, :picture, class: "form-control" %>
<%= error_tag f, :picture %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,28 @@
<h2>Listing Categories</h2>
<table class="table">
<thead>
<tr>
<th>Title</th>
<th>Picture</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for category <- @categories do %>
<tr>
<td><%= category.title %></td>
<td><%= category.picture %></td>
<td class="text-right">
<span><%= link "Show", to: category_path(@conn, :show, category), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: category_path(@conn, :edit, category), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: category_path(@conn, :delete, category), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Category", to: category_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Category</h2>
<%= render "form.html", Map.put(assigns, :action, category_path(@conn, :create)) %>
<span><%= link "Back", to: category_path(@conn, :index) %></span>

View File

@@ -0,0 +1,18 @@
<h2>Show Category</h2>
<ul>
<li>
<strong>Title:</strong>
<%= @category.title %>
</li>
<li>
<strong>Picture:</strong>
<%= @category.picture %>
</li>
</ul>
<span><%= link "Edit", to: category_path(@conn, :edit, @category) %></span>
<span><%= link "Back", to: category_path(@conn, :index) %></span>

View File

@@ -0,0 +1,17 @@
<br \>
<h3><%= dgettext "coherence", "Resend Confirmation Instructions" %></h3>
<%= form_for @changeset, confirmation_path(@conn, :create), [as: :confirmation], fn f -> %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Email"), class: "control-label" %>
<%= text_input f, :email, class: "form-control", required: "" %>
<%= error_tag f, :email %>
</div>
<div class="form-group">
<%= submit dgettext("coherence", "Resend Email"), class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
</div>
<% end %>

View File

@@ -0,0 +1,11 @@
<div>
<p><%= dgettext "coherence", "Hello %{name}!", name: @name %><p>
<p>
<%= dgettext "coherence", "Your new account is almost ready. Click the link below to confirm you new account." %>
</p>
<p>
<a href="<%= @url %>"><%= dgettext "coherence", "Confirm my Account" %></a>
</p>
<p><%= dgettext "coherence", "Thank you!" %></p>
</div>

View File

@@ -0,0 +1,11 @@
<div>
<p><%= dgettext "coherence", "Hello %{name}!", name: @name %><p>
<p>
<%= dgettext "coherence", "You have been invited to create an Account. Use the link below to create an account." %>
</p>
<p>
<a href="<%= @url %>"><%= dgettext "coherence", "Create my Account" %></a>
</p>
<p><%= dgettext "coherence", "Thank you!" %></p>
</div>

View File

@@ -0,0 +1,16 @@
<div>
<p><%= dgettext "coherence", "Hello %{name}!", name: @name %><p>
<p>
<%= dgettext "coherence", "Someone has requested a link to change your password, and you can do this through the link below." %>
</p>
<p>
<a href="<%= @url %>"><%= dgettext "coherence", "Change my password" %></a>
</p>
<p>
<%= dgettext "coherence", "If you didn't request this, please ignore this email." %>
</p>
<p>
<%= dgettext "coherence", "Your password won't change until you access the link above and create a new one." %>
</p>
</div>

View File

@@ -0,0 +1,11 @@
<div>
<p><%= dgettext "coherence", "Hello %{name}!", name: @name %><p>
<p>
<%= dgettext "coherence", "You requested unlock instructions for your locked account. Please click the link below to unlock your account." %>
</p>
<p>
<a href="<%= @url %>"><%= dgettext "coherence", "Unlock my Account" %></a>
</p>
<p><%= dgettext "coherence", "Thank you!" %></p>
</div>

View File

@@ -0,0 +1,49 @@
<br \>
<%= form_for @changeset, invitation_path(@conn, :create_user), fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p><%= dgettext "coherence", "Oops, something went wrong! Please check the errors below." %></p>
</div>
<% end %>
<input type="hidden" name="token" value="<%= @token %>">
<div class="form-group">
<%= required_label f, dgettext("coherence", "Email"), class: "control-label" %>
<%= text_input f, :name, class: "form-control", required: "" %>
<%= error_tag f, :name %>
</div>
<%= unless (login_field = Coherence.Config.login_field) == :email do %>
<div class="form-group">
<%= required_label f, login_field, class: "control-label" %>
<%= text_input f, login_field, class: "form-control", required: "" %>
<%= error_tag f, login_field %>
</div>
<% end %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Email"), class: "control-label" %>
<%= text_input f, :email, class: "form-control", required: "" %>
<%= error_tag f, :email %>
</div>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password"), class: "control-label" %>
<%= password_input f, :password, class: "form-control", required: "" %>
<%= error_tag f, :password %>
</div>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password Confirmation"), class: "control-label" %>
<%= password_input f, :password_confirmation, class: "form-control", required: "" %>
<%= error_tag f, :password_confirmation %>
</div>
<div class="form-group">
<%= submit dgettext("coherence", "Create"), class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
</div>
<% end %>

View File

@@ -0,0 +1,26 @@
<%= form_for @changeset, invitation_path(@conn, :create), [as: :invitation], fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p><%= dgettext "coherence", "Oops, something went wrong! Please check the errors below." %></p>
</div>
<% end %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Name"), class: "control-label" %>
<%= text_input f, :name, class: "form-control", required: "" %>
<%= error_tag f, :name %>
</div>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Email"), class: "control-label" %>
<%= text_input f, :email, class: "form-control", required: "" %>
<%= error_tag f, :email %>
</div>
<div class="form-group">
<%= submit dgettext("coherence", "Send Invitation"), class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
<%= if invitation = @conn.assigns[:invitation] do %>
<%= link dgettext("coherence", "Resend Invitation!"), to: invitation_path(@conn, :resend, invitation.id), class: "btn" %>
<% end %>
</div>
<% end %>

View File

@@ -0,0 +1,8 @@
<html>
<head>
<title><%= @email.subject %></title>
</head>
<body>
<%= render @view_module, @view_template, assigns %>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<br \>
<h3><%= dgettext "coherence", "Create a New Password" %></h3>
<%= form_for @changeset, password_path(@conn, :update, @changeset.data), [as: :password], fn f -> %>
<%= hidden_input f, :reset_password_token %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password"), class: "control-label" %>
<%= password_input f, :password, class: "form-control", required: "" %>
<%= error_tag f, :password %>
</div>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password Confirmation"), class: "control-label" %>
<%= password_input f, :password_confirmation, class: "form-control", required: "" %>
<%= error_tag f, :password_confirmation %>
</div>
<div class="form-group">
<%= submit dgettext("coherence", "Update Password"), class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
</div>
<% end %>

View File

@@ -0,0 +1,17 @@
<br \>
<h3><%= dgettext "coherence", "Send reset password link" %></h3>
<%= form_for @changeset, password_path(@conn, :create), [as: :password], fn f -> %>
<div class="form-group">
<%= required_label f, :email, class: "control-label" %>
<%= text_input f, :email, class: "form-control", required: "" %>
<%= error_tag f, :email %>
</div>
<div class="form-group">
<%= submit dgettext("coherence", "Reset Password"), class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
</div>
<% end %>

View File

@@ -0,0 +1,5 @@
<h3><%= dgettext "coherence", "Edit Account" %></h3>
<%= render "form.html", changeset: @changeset,
label: dgettext("coherence", "Update"), required: [],
action: registration_path(@conn, :update) %>

View File

@@ -0,0 +1,58 @@
<%= form_for @changeset, @action, [as: :registration], fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p><%= dgettext "coherence", "Oops, something went wrong! Please check the errors below." %></p>
<ul>
<%= for error <- @changeset.errors do %>
<li><%= error %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Name"), class: "control-label" %>
<%= text_input f, :username, class: "form-control", required: "" %>
<%= error_tag f, :username %>
</div>
<%= unless (login_field = Coherence.Config.login_field) == :email do %>
<div class="form-group">
<%= required_label f, login_field, class: "control-label" %>
<%= text_input f, login_field, class: "form-control", required: "" %>
<%= error_tag f, login_field %>
</div>
<% end %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Email"), class: "control-label" %>
<%= text_input f, :email, class: "form-control", required: "" %>
<%= error_tag f, :email %>
</div>
<%= if Coherence.Config.require_current_password and not is_nil(@changeset.data.id) do %>
<div class="form-group">
<%= required_label f, :current_password, class: "control-label" %>
<%= password_input f, :current_password, [class: "form-control"] ++ @required %>
<%= error_tag f, :current_password %>
</div>
<% end %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password"), class: "control-label" %>
<%= password_input f, :password, [class: "form-control"] ++ @required %>
<%= error_tag f, :password %>
</div>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password Confirmation"), class: "control-label" %>
<%= password_input f, :password_confirmation, [class: "form-control"] ++ @required %>
<%= error_tag f, :password_confirmation %>
</div>
<div class="form-group">
<%= submit @label, class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
</div>
<% end %>

View File

@@ -0,0 +1,5 @@
<h3><%= dgettext "coherence", "Register Account" %></h3>
<%= render "form.html", changeset: @changeset,
label: dgettext("coherence", "Register"), required: [required: ""],
action: registration_path(@conn, :create) %>

View File

@@ -0,0 +1,25 @@
<h2><%= dgettext "coherence", "Show account" %></h2>
<ul>
<li>
<strong><%= dgettext "coherence", "Name:" %></strong>
<%= @user.username %>
</li>
<%= unless (login_field = Coherence.Config.login_field) == :email do %>
<li>
<strong><%= humanize login_field %></strong>
<%= Map.get(@user, login_field) %>
</li>
<% end %>
<li>
<strong><%= dgettext "coherence", "Email:" %></strong>
<%= @user.email %>
</li>
</ul>
<%= link dgettext("coherence", "Edit"), to: registration_path(@conn, :edit) %> |
<%= link dgettext("coherence", "Delete"),
to: registration_path(@conn, :delete),
method: :delete,
data: [confirm: dgettext("coherence", "Are you sure?")] %>

View File

@@ -0,0 +1,35 @@
<br \>
<%= form_for @conn, session_path(@conn, :create), [as: :session], fn f -> %>
<% login_field = Coherence.Config.login_field %>
<div class="form-group">
<%= required_label f, login_field, class: "control-label" %>
<%= text_input f, login_field, class: "form-control", required: "" %>
<%= error_tag f, login_field %>
</div>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password"), class: "control-label" %>
<%= password_input f, :password, class: "form-control", required: "" %>
<%= error_tag f, :password %>
</div>
<%= if @remember do %>
<div class="form-group">
<input type="checkbox" name="remember" id="remember">
<label for="remember"><%= dgettext "coherence", "Remember Me?" %></label>
</div>
<br />
<% end %>
<div class="form-group">
<%= submit dgettext("coherence", "Sign In"), class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
</div>
<div class="form-group">
<%= coherence_links(@conn, :new_session) %>
</div>
<% end %>

View File

@@ -0,0 +1,22 @@
<br \>
<%= form_for @conn, unlock_path(@conn, :create), [as: :unlock], fn f -> %>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Email"), class: "control-label" %>
<%= text_input f, :email, class: "form-control", required: "" %>
<%= error_tag f, :email %>
</div>
<div class="form-group">
<%= required_label f, dgettext("coherence", "Password"), class: "control-label" %>
<%= password_input f, :password, class: "form-control", required: "" %>
<%= error_tag f, :password %>
</div>
<div class="form-group">
<%= submit dgettext("coherence", "Send Instructions"), class: "btn btn-primary" %>
<%= link dgettext("coherence", "Cancel"), to: Coherence.Config.logged_out_url("/"), class: "btn" %>
</div>
<% end %>

View File

@@ -0,0 +1,5 @@
<h2>Edit Event</h2>
<%= render "form.html", Map.put(assigns, :action, event_path(@conn, :update, @event)) %>
<span><%= link "Back", to: event_path(@conn, :index) %></span>

View File

@@ -0,0 +1,35 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :title, class: "control-label" %>
<%= text_input f, :title, class: "form-control" %>
<%= error_tag f, :title %>
</div>
<div class="form-group">
<%= label f, :description, class: "control-label" %>
<%= text_input f, :description, class: "form-control" %>
<%= error_tag f, :description %>
</div>
<div class="form-group">
<%= label f, :begin_on, class: "control-label" %>
<%= datetime_select f, :begin_on, class: "form-control" %>
<%= error_tag f, :begin_on %>
</div>
<div class="form-group">
<%= label f, :ends_on, class: "control-label" %>
<%= datetime_select f, :ends_on, class: "form-control" %>
<%= error_tag f, :ends_on %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,32 @@
<h2>Listing Events</h2>
<table class="table">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Begin on</th>
<th>Ends on</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for event <- @events do %>
<tr>
<td><%= event.title %></td>
<td><%= event.description %></td>
<td><%= event.begin_on %></td>
<td><%= event.ends_on %></td>
<td class="text-right">
<span><%= link "Show", to: event_path(@conn, :show, event), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: event_path(@conn, :edit, event), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: event_path(@conn, :delete, event), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Event", to: event_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Event</h2>
<%= render "form.html", Map.put(assigns, :action, event_path(@conn, :create)) %>
<span><%= link "Back", to: event_path(@conn, :index) %></span>

View File

@@ -0,0 +1,28 @@
<h2>Show Event</h2>
<ul>
<li>
<strong>Title:</strong>
<%= @event.title %>
</li>
<li>
<strong>Description:</strong>
<%= @event.description %>
</li>
<li>
<strong>Begin on:</strong>
<%= @event.begin_on %>
</li>
<li>
<strong>Ends on:</strong>
<%= @event.ends_on %>
</li>
</ul>
<span><%= link "Edit", to: event_path(@conn, :edit, @event) %></span>
<span><%= link "Back", to: event_path(@conn, :index) %></span>

View File

@@ -0,0 +1,5 @@
<h2>Edit Event accounts</h2>
<%= render "form.html", Map.put(assigns, :action, event_accounts_path(@conn, :update, @event_accounts)) %>
<span><%= link "Back", to: event_accounts_path(@conn, :index) %></span>

View File

@@ -0,0 +1,17 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :roles, class: "control-label" %>
<%= number_input f, :roles, class: "form-control" %>
<%= error_tag f, :roles %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,26 @@
<h2>Listing Event accounts</h2>
<table class="table">
<thead>
<tr>
<th>Roles</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for event_accounts <- @event_accounts do %>
<tr>
<td><%= event_accounts.roles %></td>
<td class="text-right">
<span><%= link "Show", to: event_accounts_path(@conn, :show, event_accounts), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: event_accounts_path(@conn, :edit, event_accounts), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: event_accounts_path(@conn, :delete, event_accounts), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Event accounts", to: event_accounts_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Event accounts</h2>
<%= render "form.html", Map.put(assigns, :action, event_accounts_path(@conn, :create)) %>
<span><%= link "Back", to: event_accounts_path(@conn, :index) %></span>

View File

@@ -0,0 +1,13 @@
<h2>Show Event accounts</h2>
<ul>
<li>
<strong>Roles:</strong>
<%= @event_accounts.roles %>
</li>
</ul>
<span><%= link "Edit", to: event_accounts_path(@conn, :edit, @event_accounts) %></span>
<span><%= link "Back", to: event_accounts_path(@conn, :index) %></span>

View File

@@ -0,0 +1,5 @@
<h2>Edit Event request</h2>
<%= render "form.html", Map.put(assigns, :action, event_request_path(@conn, :update, @event_request)) %>
<span><%= link "Back", to: event_request_path(@conn, :index) %></span>

View File

@@ -0,0 +1,17 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :state, class: "control-label" %>
<%= number_input f, :state, class: "form-control" %>
<%= error_tag f, :state %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,26 @@
<h2>Listing Event requests</h2>
<table class="table">
<thead>
<tr>
<th>State</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for event_request <- @event_requests do %>
<tr>
<td><%= event_request.state %></td>
<td class="text-right">
<span><%= link "Show", to: event_request_path(@conn, :show, event_request), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: event_request_path(@conn, :edit, event_request), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: event_request_path(@conn, :delete, event_request), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Event request", to: event_request_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Event request</h2>
<%= render "form.html", Map.put(assigns, :action, event_request_path(@conn, :create)) %>
<span><%= link "Back", to: event_request_path(@conn, :index) %></span>

View File

@@ -0,0 +1,13 @@
<h2>Show Event request</h2>
<ul>
<li>
<strong>State:</strong>
<%= @event_request.state %>
</li>
</ul>
<span><%= link "Edit", to: event_request_path(@conn, :edit, @event_request) %></span>
<span><%= link "Back", to: event_request_path(@conn, :index) %></span>

View File

@@ -0,0 +1,5 @@
<h2>Edit Group</h2>
<%= render "form.html", Map.put(assigns, :action, group_path(@conn, :update, @group)) %>
<span><%= link "Back", to: group_path(@conn, :index) %></span>

View File

@@ -0,0 +1,41 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :title, class: "control-label" %>
<%= text_input f, :title, class: "form-control" %>
<%= error_tag f, :title %>
</div>
<div class="form-group">
<%= label f, :description, class: "control-label" %>
<%= text_input f, :description, class: "form-control" %>
<%= error_tag f, :description %>
</div>
<div class="form-group">
<%= label f, :suspended, class: "control-label" %>
<%= checkbox f, :suspended, class: "checkbox" %>
<%= error_tag f, :suspended %>
</div>
<div class="form-group">
<%= label f, :url, class: "control-label" %>
<%= text_input f, :url, class: "form-control" %>
<%= error_tag f, :url %>
</div>
<div class="form-group">
<%= label f, :uri, class: "control-label" %>
<%= text_input f, :uri, class: "form-control" %>
<%= error_tag f, :uri %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,34 @@
<h2>Listing Groups</h2>
<table class="table">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Suspended</th>
<th>Url</th>
<th>Uri</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for group <- @groups do %>
<tr>
<td><%= group.title %></td>
<td><%= group.description %></td>
<td><%= group.suspended %></td>
<td><%= group.url %></td>
<td><%= group.uri %></td>
<td class="text-right">
<span><%= link "Show", to: group_path(@conn, :show, group), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: group_path(@conn, :edit, group), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: group_path(@conn, :delete, group), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Group", to: group_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Group</h2>
<%= render "form.html", Map.put(assigns, :action, group_path(@conn, :create)) %>
<span><%= link "Back", to: group_path(@conn, :index) %></span>

View File

@@ -0,0 +1,33 @@
<h2>Show Group</h2>
<ul>
<li>
<strong>Title:</strong>
<%= @group.title %>
</li>
<li>
<strong>Description:</strong>
<%= @group.description %>
</li>
<li>
<strong>Suspended:</strong>
<%= @group.suspended %>
</li>
<li>
<strong>Url:</strong>
<%= @group.url %>
</li>
<li>
<strong>Uri:</strong>
<%= @group.uri %>
</li>
</ul>
<span><%= link "Edit", to: group_path(@conn, :edit, @group) %></span>
<span><%= link "Back", to: group_path(@conn, :index) %></span>

View File

@@ -0,0 +1,5 @@
<h2>Edit Group account</h2>
<%= render "form.html", Map.put(assigns, :action, group_account_path(@conn, :update, @group_account)) %>
<span><%= link "Back", to: group_account_path(@conn, :index) %></span>

View File

@@ -0,0 +1,17 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :role, class: "control-label" %>
<%= number_input f, :role, class: "form-control" %>
<%= error_tag f, :role %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,26 @@
<h2>Listing Group accounts</h2>
<table class="table">
<thead>
<tr>
<th>Role</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for group_account <- @group_accounts do %>
<tr>
<td><%= group_account.role %></td>
<td class="text-right">
<span><%= link "Show", to: group_account_path(@conn, :show, group_account), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: group_account_path(@conn, :edit, group_account), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: group_account_path(@conn, :delete, group_account), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Group account", to: group_account_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Group account</h2>
<%= render "form.html", Map.put(assigns, :action, group_account_path(@conn, :create)) %>
<span><%= link "Back", to: group_account_path(@conn, :index) %></span>

View File

@@ -0,0 +1,13 @@
<h2>Show Group account</h2>
<ul>
<li>
<strong>Role:</strong>
<%= @group_account.role %>
</li>
</ul>
<span><%= link "Edit", to: group_account_path(@conn, :edit, @group_account) %></span>
<span><%= link "Back", to: group_account_path(@conn, :index) %></span>

View File

@@ -0,0 +1,5 @@
<h2>Edit Group request</h2>
<%= render "form.html", Map.put(assigns, :action, group_request_path(@conn, :update, @group_request)) %>
<span><%= link "Back", to: group_request_path(@conn, :index) %></span>

View File

@@ -0,0 +1,17 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :state, class: "control-label" %>
<%= number_input f, :state, class: "form-control" %>
<%= error_tag f, :state %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,26 @@
<h2>Listing Group requests</h2>
<table class="table">
<thead>
<tr>
<th>State</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for group_request <- @group_request do %>
<tr>
<td><%= group_request.state %></td>
<td class="text-right">
<span><%= link "Show", to: group_request_path(@conn, :show, group_request), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: group_request_path(@conn, :edit, group_request), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: group_request_path(@conn, :delete, group_request), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Group request", to: group_request_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Group request</h2>
<%= render "form.html", Map.put(assigns, :action, group_request_path(@conn, :create)) %>
<span><%= link "Back", to: group_request_path(@conn, :index) %></span>

View File

@@ -0,0 +1,13 @@
<h2>Show Group request</h2>
<ul>
<li>
<strong>State:</strong>
<%= @group_request.state %>
</li>
</ul>
<span><%= link "Edit", to: group_request_path(@conn, :edit, @group_request) %></span>
<span><%= link "Back", to: group_request_path(@conn, :index) %></span>

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Hello Eventos!</title>
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
</head>
<body>
<div class="container">
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<main role="main">
<%= render @view_module, @view_template, assigns %>
</main>
</div> <!-- /container -->
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
</body>
</html>

View File

@@ -0,0 +1,4 @@
<div class="jumbotron">
<h2><%= gettext "Welcome to %{name}!", name: "Eventos" %></h2>
<p class="lead">A decentralized event management platform, currently rewritten with Elixir</p>
</div>

View File

@@ -0,0 +1,5 @@
<h2>Edit Tag</h2>
<%= render "form.html", Map.put(assigns, :action, tag_path(@conn, :update, @tag)) %>
<span><%= link "Back", to: tag_path(@conn, :index) %></span>

View File

@@ -0,0 +1,23 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :title, class: "control-label" %>
<%= text_input f, :title, class: "form-control" %>
<%= error_tag f, :title %>
</div>
<div class="form-group">
<%= label f, :slug, class: "control-label" %>
<%= text_input f, :slug, class: "form-control" %>
<%= error_tag f, :slug %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,28 @@
<h2>Listing Tags</h2>
<table class="table">
<thead>
<tr>
<th>Title</th>
<th>Slug</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for tag <- @tags do %>
<tr>
<td><%= tag.title %></td>
<td><%= tag.slug %></td>
<td class="text-right">
<span><%= link "Show", to: tag_path(@conn, :show, tag), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: tag_path(@conn, :edit, tag), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: tag_path(@conn, :delete, tag), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New Tag", to: tag_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New Tag</h2>
<%= render "form.html", Map.put(assigns, :action, tag_path(@conn, :create)) %>
<span><%= link "Back", to: tag_path(@conn, :index) %></span>

View File

@@ -0,0 +1,18 @@
<h2>Show Tag</h2>
<ul>
<li>
<strong>Title:</strong>
<%= @tag.title %>
</li>
<li>
<strong>Slug:</strong>
<%= @tag.slug %>
</li>
</ul>
<span><%= link "Edit", to: tag_path(@conn, :edit, @tag) %></span>
<span><%= link "Back", to: tag_path(@conn, :index) %></span>

View File

@@ -0,0 +1,5 @@
<h2>Edit User</h2>
<%= render "form.html", Map.put(assigns, :action, user_path(@conn, :update, @user)) %>
<span><%= link "Back", to: user_path(@conn, :index) %></span>

View File

@@ -0,0 +1,35 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group">
<%= label f, :username, class: "control-label" %>
<%= text_input f, :username, class: "form-control" %>
<%= error_tag f, :username %>
</div>
<div class="form-group">
<%= label f, :email, class: "control-label" %>
<%= text_input f, :email, class: "form-control" %>
<%= error_tag f, :email %>
</div>
<div class="form-group">
<%= label f, :password_hash, class: "control-label" %>
<%= text_input f, :password_hash, class: "form-control" %>
<%= error_tag f, :password_hash %>
</div>
<div class="form-group">
<%= label f, :role, class: "control-label" %>
<%= number_input f, :role, class: "form-control" %>
<%= error_tag f, :role %>
</div>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>

View File

@@ -0,0 +1,32 @@
<h2>Listing Users</h2>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Password hash</th>
<th>Role</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for user <- @users do %>
<tr>
<td><%= user.username %></td>
<td><%= user.email %></td>
<td><%= user.password_hash %></td>
<td><%= user.role %></td>
<td class="text-right">
<span><%= link "Show", to: user_path(@conn, :show, user), class: "btn btn-default btn-xs" %></span>
<span><%= link "Edit", to: user_path(@conn, :edit, user), class: "btn btn-default btn-xs" %></span>
<span><%= link "Delete", to: user_path(@conn, :delete, user), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "New User", to: user_path(@conn, :new) %></span>

View File

@@ -0,0 +1,5 @@
<h2>New User</h2>
<%= render "form.html", Map.put(assigns, :action, user_path(@conn, :create)) %>
<span><%= link "Back", to: user_path(@conn, :index) %></span>

View File

@@ -0,0 +1,28 @@
<h2>Show User</h2>
<ul>
<li>
<strong>Username:</strong>
<%= @user.username %>
</li>
<li>
<strong>Email:</strong>
<%= @user.email %>
</li>
<li>
<strong>Password hash:</strong>
<%= @user.password_hash %>
</li>
<li>
<strong>Role:</strong>
<%= @user.role %>
</li>
</ul>
<span><%= link "Edit", to: user_path(@conn, :edit, @user) %></span>
<span><%= link "Back", to: user_path(@conn, :index) %></span>

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.AccountView do
use EventosWeb, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.CategoryView do
use EventosWeb, :view
end

View File

@@ -0,0 +1,3 @@
defmodule Coherence.CoherenceView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,210 @@
defmodule EventosWeb.Coherence.ViewHelpers do
@moduledoc """
Helper functions for Coherence Views.
"""
use Phoenix.HTML
alias Coherence.Config
import EventosWeb.Gettext
@type conn :: Plug.Conn.t
@type schema :: Ecto.Schema.t
@seperator {:safe, "&nbsp; | &nbsp;"}
@helpers EventosWeb.Router.Helpers
@recover_link dgettext("coherence", "Forgot your password?")
@unlock_link dgettext("coherence", "Send an unlock email")
@register_link dgettext("coherence", "Need An Account?")
@invite_link dgettext("coherence", "Invite Someone")
@confirm_link dgettext("coherence", "Resend confirmation email")
@signin_link dgettext("coherence", "Sign In")
@signout_link dgettext("coherence", "Sign Out")
@doc """
Create coherence template links.
Generates links if the appropriate option is installed. This function
can be used to:
* create links for the new session page `:new_session`
* create links for your layout template `:layout`
Defaults are provided based on the options configured for Coherence.
However, the defaults can be overridden by passing the following options.
## Customize the links
### :new_session Options
* :recover - customize the recover link (#{@recover_link})
* :unlock - customize the unlock link (#{@unlock_link})
* :register - customize the register link (#{@register_link})
* :confirm - customize the confirm link (#{@confirm_link})
### :layout Options
* :list_tag - customize the list tag (:li)
* :signout_class - customize the class on the signout link ("navbar-form")
* :signin - customize the signin link text (#{@signin_link})
* :signout - customize the signout link text (#{@signout_link})
* :register - customize the register link text (#{@register_link})
### Disable links
If you set an option to false, the link will not be shown. For example, to
disable the register link on the layout, use the following in your layout template:
coherence_links(conn, :layout, register: false)
## Examples
coherence_links(conn, :new_session)
Generates: #{@recover_link} #{@unlock_link} #{@register_link} #{@confirm_link}
coherence_links(conn, :new_session, recover: "Password reset", register: false
Generates: Password reset #{@unlock_link}
coherence_links(conn, :layout) # when logged in
Generates: User's Name #{@signout_link}
coherence_links(conn, :layout) # when not logged in
Generates: #{@register_link} #{@signin_link}
"""
@spec coherence_links(conn, atom, Keyword.t) :: tuple
def coherence_links(conn, which, opts \\ [])
def coherence_links(conn, :new_session, opts) do
recover_link = Keyword.get opts, :recover, @recover_link
unlock_link = Keyword.get opts, :unlock, @unlock_link
register_link = Keyword.get opts, :register, @register_link
confirm_link = Keyword.get opts, :confirm, @confirm_link
user_schema = Coherence.Config.user_schema
[
recover_link(conn, user_schema, recover_link),
unlock_link(conn, user_schema, unlock_link),
register_link(conn, user_schema, register_link),
confirmation_link(conn, user_schema, confirm_link)
]
|> List.flatten
|> concat([])
end
def coherence_links(conn, :layout, opts) do
list_tag = Keyword.get opts, :list_tag, :li
signout_class = Keyword.get opts, :signout_class, "navbar-form"
signin = Keyword.get opts, :signin, @signin_link
signout = Keyword.get opts, :signout, @signout_link
register = Keyword.get opts, :register, @register_link
if Coherence.logged_in?(conn) do
current_user = Coherence.current_user(conn)
[
content_tag(list_tag, profile_link(current_user, conn)),
content_tag(list_tag, signout_link(conn, signout, signout_class))
]
else
signin_link = content_tag(list_tag, link(signin, to: coherence_path(@helpers, :session_path, conn, :new)))
if Config.has_option(:registerable) && register do
[content_tag(list_tag, link(register, to: coherence_path(@helpers, :registration_path, conn, :new))), signin_link]
else
signin_link
end
end
end
@doc """
Helper to avoid compile warnings when options are disabled.
"""
@spec coherence_path(module, atom, conn, atom) :: String.t
def coherence_path(module, route_name, conn, action) do
apply(module, route_name, [conn, action])
end
def coherence_path(module, route_name, conn, action, opts) do
apply(module, route_name, [conn, action, opts])
end
defp concat([], acc), do: Enum.reverse(acc)
defp concat([h|t], []), do: concat(t, [h])
defp concat([h|t], acc), do: concat(t, [h, @seperator | acc])
@spec recover_link(conn, module, false | String.t) :: [any] | []
def recover_link(_conn, _user_schema, false), do: []
def recover_link(conn, user_schema, text) do
if user_schema.recoverable?, do: [recover_link(conn, text)], else: []
end
@spec recover_link(conn, String.t) :: tuple
def recover_link(conn, text \\ @recover_link), do:
link(text, to: coherence_path(@helpers, :password_path, conn, :new))
@spec register_link(conn, module, false | String.t) :: [any] | []
def register_link(_conn, _user_schema, false), do: []
def register_link(conn, user_schema, text) do
if user_schema.registerable?, do: [register_link(conn, text)], else: []
end
@spec register_link(conn, String.t) :: tuple
def register_link(conn, text \\ @register_link), do:
link(text, to: coherence_path(@helpers, :registration_path, conn, :new))
@spec unlock_link(conn, module, false | String.t) :: [any] | []
def unlock_link(_conn, _user_schema, false), do: []
def unlock_link(conn, _user_schema, text) do
if conn.assigns[:locked], do: [unlock_link(conn, text)], else: []
end
@spec unlock_link(conn, String.t) :: tuple
def unlock_link(conn, text \\ @unlock_link), do:
link(text, to: coherence_path(@helpers, :unlock_path, conn, :new))
@spec invitation_link(conn, String.t) :: tuple
def invitation_link(conn, text \\ @invite_link) do
link text, to: coherence_path(@helpers, :invitation_path, conn, :new)
end
@spec signout_link(conn, String.t, String.t) :: tuple
def signout_link(conn, text \\ @signout_link, signout_class \\ "") do
link(text, to: coherence_path(@helpers, :session_path, conn, :delete), method: :delete, class: signout_class)
end
@spec confirmation_link(conn, module, false | String.t) :: [any] | []
def confirmation_link(_conn, _user_schema, false), do: []
def confirmation_link(conn, user_schema, text) do
if user_schema.confirmable?, do: [confirmation_link(conn, text)], else: []
end
@spec confirmation_link(conn, String.t) :: tuple
def confirmation_link(conn, text \\ @confirm_link) do
link(text, to: coherence_path(@helpers, :confirmation_path, conn, :new))
end
@spec required_label(atom, String.t | atom, Keyword.t) :: tuple
def required_label(f, name, opts \\ []) do
label f, name, opts do
[
"#{humanize(name)}\n",
content_tag(:abbr, "*", class: "required", title: "required")
]
end
end
@spec current_user(conn) :: schema
def current_user(conn) do
Coherence.current_user(conn)
end
@spec logged_in?(conn) :: boolean
def logged_in?(conn) do
Coherence.logged_in?(conn)
end
defp profile_link(current_user, conn) do
if Config.user_schema.registerable? do
link current_user.name, to: coherence_path(@helpers, :registration_path, conn, :show)
else
current_user.name
end
end
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.ConfirmationView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.EmailView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.InvitationView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.LayoutView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.PasswordView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.RegistrationView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.SessionView do
use EventosWeb.Coherence, :view
end

View File

@@ -0,0 +1,3 @@
defmodule EventosWeb.Coherence.UnlockView do
use EventosWeb.Coherence, :view
end

Some files were not shown because too many files have changed in this diff Show More