initial commit
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
commit
90ceb4f6fe
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# App artifacts
|
||||||
|
/_build
|
||||||
|
/db
|
||||||
|
/deps
|
||||||
|
/*.ez
|
||||||
|
|
||||||
|
# Generated on crash by the VM
|
||||||
|
erl_crash.dump
|
||||||
|
|
||||||
|
# Files matching config/*.secret.exs pattern contain sensitive
|
||||||
|
# data and you should not commit them into version control.
|
||||||
|
#
|
||||||
|
# Alternatively, you may comment the line below and commit the
|
||||||
|
# secrets files as long as you replace their contents by environment
|
||||||
|
# variables.
|
||||||
|
/config/*.secret.exs
|
19
README.md
Normal file
19
README.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Eventos
|
||||||
|
|
||||||
|
To start your Phoenix server:
|
||||||
|
|
||||||
|
* Install dependencies with `mix deps.get`
|
||||||
|
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
|
||||||
|
* Start Phoenix endpoint with `mix phx.server`
|
||||||
|
|
||||||
|
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
|
||||||
|
|
||||||
|
Ready to run in production? Please [check our deployment guides](http://www.phoenixframework.org/docs/deployment).
|
||||||
|
|
||||||
|
## Learn more
|
||||||
|
|
||||||
|
* Official website: http://www.phoenixframework.org/
|
||||||
|
* Guides: http://phoenixframework.org/docs/overview
|
||||||
|
* Docs: https://hexdocs.pm/phoenix
|
||||||
|
* Mailing list: http://groups.google.com/group/phoenix-talk
|
||||||
|
* Source: https://github.com/phoenixframework/phoenix
|
46
config/config.exs
Normal file
46
config/config.exs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# This file is responsible for configuring your application
|
||||||
|
# and its dependencies with the aid of the Mix.Config module.
|
||||||
|
#
|
||||||
|
# This configuration file is loaded before any dependency and
|
||||||
|
# is restricted to this project.
|
||||||
|
use Mix.Config
|
||||||
|
|
||||||
|
# General application configuration
|
||||||
|
config :eventos,
|
||||||
|
ecto_repos: [Eventos.Repo]
|
||||||
|
|
||||||
|
# Configures the endpoint
|
||||||
|
config :eventos, EventosWeb.Endpoint,
|
||||||
|
url: [host: "localhost"],
|
||||||
|
secret_key_base: "1yOazsoE0Wqu4kXk3uC5gu3jDbShOimTCzyFL3OjCdBmOXMyHX87Qmf3+Tu9s0iM",
|
||||||
|
render_errors: [view: EventosWeb.ErrorView, accepts: ~w(html json)],
|
||||||
|
pubsub: [name: Eventos.PubSub,
|
||||||
|
adapter: Phoenix.PubSub.PG2]
|
||||||
|
|
||||||
|
# Configures Elixir's Logger
|
||||||
|
config :logger, :console,
|
||||||
|
format: "$time $metadata[$level] $message\n",
|
||||||
|
metadata: [:request_id]
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
# %% Coherence Configuration %% Don't remove this line
|
||||||
|
config :coherence,
|
||||||
|
user_schema: Eventos.Accounts.User,
|
||||||
|
repo: Eventos.Repo,
|
||||||
|
module: Eventos,
|
||||||
|
web_module: EventosWeb,
|
||||||
|
router: EventosWeb.Router,
|
||||||
|
messages_backend: EventosWeb.Coherence.Messages,
|
||||||
|
logged_out_url: "/",
|
||||||
|
user_active_field: true,
|
||||||
|
email_from_name: "Your Name",
|
||||||
|
email_from_email: "yourname@example.com",
|
||||||
|
opts: [:invitable, :confirmable, :rememberable, :authenticatable, :recoverable, :lockable, :trackable, :unlockable_with_token, :registerable]
|
||||||
|
|
||||||
|
config :coherence, EventosWeb.Coherence.Mailer,
|
||||||
|
adapter: Swoosh.Adapters.Sendgrid,
|
||||||
|
api_key: "your api key here"
|
||||||
|
# %% End Coherence Configuration %%
|
57
config/dev.exs
Normal file
57
config/dev.exs
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
use Mix.Config
|
||||||
|
|
||||||
|
# For development, we disable any cache and enable
|
||||||
|
# debugging and code reloading.
|
||||||
|
#
|
||||||
|
# The watchers configuration can be used to run external
|
||||||
|
# watchers to your application. For example, we use it
|
||||||
|
# with brunch.io to recompile .js and .css sources.
|
||||||
|
config :eventos, EventosWeb.Endpoint,
|
||||||
|
http: [port: 4000],
|
||||||
|
debug_errors: true,
|
||||||
|
code_reloader: true,
|
||||||
|
check_origin: false,
|
||||||
|
watchers: []
|
||||||
|
|
||||||
|
# ## SSL Support
|
||||||
|
#
|
||||||
|
# In order to use HTTPS in development, a self-signed
|
||||||
|
# certificate can be generated by running the following
|
||||||
|
# command from your terminal:
|
||||||
|
#
|
||||||
|
# openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem
|
||||||
|
#
|
||||||
|
# The `http:` config above can be replaced with:
|
||||||
|
#
|
||||||
|
# https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"],
|
||||||
|
#
|
||||||
|
# If desired, both `http:` and `https:` keys can be
|
||||||
|
# configured to run both http and https servers on
|
||||||
|
# different ports.
|
||||||
|
|
||||||
|
# Watch static and templates for browser reloading.
|
||||||
|
config :eventos, EventosWeb.Endpoint,
|
||||||
|
live_reload: [
|
||||||
|
patterns: [
|
||||||
|
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
|
||||||
|
~r{priv/gettext/.*(po)$},
|
||||||
|
~r{lib/eventos_web/views/.*(ex)$},
|
||||||
|
~r{lib/eventos_web/templates/.*(eex)$}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
# Do not include metadata nor timestamps in development logs
|
||||||
|
config :logger, :console, format: "[$level] $message\n", level: :debug
|
||||||
|
|
||||||
|
# Set a higher stacktrace during development. Avoid configuring such
|
||||||
|
# in production as building large stacktraces may be expensive.
|
||||||
|
config :phoenix, :stacktrace_depth, 20
|
||||||
|
|
||||||
|
# Configure your database
|
||||||
|
config :eventos, Eventos.Repo,
|
||||||
|
adapter: Ecto.Adapters.Postgres,
|
||||||
|
username: "elixir",
|
||||||
|
password: "elixir",
|
||||||
|
database: "eventos_dev",
|
||||||
|
hostname: "localhost",
|
||||||
|
pool_size: 10
|
64
config/prod.exs
Normal file
64
config/prod.exs
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
use Mix.Config
|
||||||
|
|
||||||
|
# For production, we often load configuration from external
|
||||||
|
# sources, such as your system environment. For this reason,
|
||||||
|
# you won't find the :http configuration below, but set inside
|
||||||
|
# EventosWeb.Endpoint.init/2 when load_from_system_env is
|
||||||
|
# true. Any dynamic configuration should be done there.
|
||||||
|
#
|
||||||
|
# Don't forget to configure the url host to something meaningful,
|
||||||
|
# Phoenix uses this information when generating URLs.
|
||||||
|
#
|
||||||
|
# Finally, we also include the path to a cache manifest
|
||||||
|
# containing the digested version of static files. This
|
||||||
|
# manifest is generated by the mix phx.digest task
|
||||||
|
# which you typically run after static files are built.
|
||||||
|
config :eventos, EventosWeb.Endpoint,
|
||||||
|
load_from_system_env: true,
|
||||||
|
url: [host: "example.com", port: 80],
|
||||||
|
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||||
|
|
||||||
|
# Do not print debug messages in production
|
||||||
|
config :logger, level: :info
|
||||||
|
|
||||||
|
# ## SSL Support
|
||||||
|
#
|
||||||
|
# To get SSL working, you will need to add the `https` key
|
||||||
|
# to the previous section and set your `:url` port to 443:
|
||||||
|
#
|
||||||
|
# config :eventos, EventosWeb.Endpoint,
|
||||||
|
# ...
|
||||||
|
# url: [host: "example.com", port: 443],
|
||||||
|
# https: [:inet6,
|
||||||
|
# port: 443,
|
||||||
|
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
|
||||||
|
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
|
||||||
|
#
|
||||||
|
# Where those two env variables return an absolute path to
|
||||||
|
# the key and cert in disk or a relative path inside priv,
|
||||||
|
# for example "priv/ssl/server.key".
|
||||||
|
#
|
||||||
|
# We also recommend setting `force_ssl`, ensuring no data is
|
||||||
|
# ever sent via http, always redirecting to https:
|
||||||
|
#
|
||||||
|
# config :eventos, EventosWeb.Endpoint,
|
||||||
|
# force_ssl: [hsts: true]
|
||||||
|
#
|
||||||
|
# Check `Plug.SSL` for all available options in `force_ssl`.
|
||||||
|
|
||||||
|
# ## Using releases
|
||||||
|
#
|
||||||
|
# If you are doing OTP releases, you need to instruct Phoenix
|
||||||
|
# to start the server for all endpoints:
|
||||||
|
#
|
||||||
|
# config :phoenix, :serve_endpoints, true
|
||||||
|
#
|
||||||
|
# Alternatively, you can configure exactly which server to
|
||||||
|
# start per endpoint:
|
||||||
|
#
|
||||||
|
# config :eventos, EventosWeb.Endpoint, server: true
|
||||||
|
#
|
||||||
|
|
||||||
|
# Finally import the config/prod.secret.exs
|
||||||
|
# which should be versioned separately.
|
||||||
|
import_config "prod.secret.exs"
|
19
config/test.exs
Normal file
19
config/test.exs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use Mix.Config
|
||||||
|
|
||||||
|
# We don't run a server during test. If one is required,
|
||||||
|
# you can enable the server option below.
|
||||||
|
config :eventos, EventosWeb.Endpoint,
|
||||||
|
http: [port: 4001],
|
||||||
|
server: false
|
||||||
|
|
||||||
|
# Print only warnings and errors during test
|
||||||
|
config :logger, level: :warn
|
||||||
|
|
||||||
|
# Configure your database
|
||||||
|
config :eventos, Eventos.Repo,
|
||||||
|
adapter: Ecto.Adapters.Postgres,
|
||||||
|
username: "postgres",
|
||||||
|
password: "postgres",
|
||||||
|
database: "eventos_test",
|
||||||
|
hostname: "localhost",
|
||||||
|
pool: Ecto.Adapters.SQL.Sandbox
|
9
lib/eventos.ex
Normal file
9
lib/eventos.ex
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
defmodule Eventos do
|
||||||
|
@moduledoc """
|
||||||
|
Eventos keeps the contexts that define your domain
|
||||||
|
and business logic.
|
||||||
|
|
||||||
|
Contexts are also responsible for managing your data, regardless
|
||||||
|
if it comes from the database, an external API or others.
|
||||||
|
"""
|
||||||
|
end
|
32
lib/eventos/accounts/account.ex
Normal file
32
lib/eventos/accounts/account.ex
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
defmodule Eventos.Accounts.Account do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Accounts.{Account, GroupAccount, GroupRequest, Group, User}
|
||||||
|
alias Eventos.Events.Event
|
||||||
|
|
||||||
|
|
||||||
|
schema "accounts" do
|
||||||
|
field :description, :string
|
||||||
|
field :display_name, :string
|
||||||
|
field :domain, :string
|
||||||
|
field :private_key, :string
|
||||||
|
field :public_key, :string
|
||||||
|
field :suspended, :boolean, default: false
|
||||||
|
field :uri, :string
|
||||||
|
field :url, :string
|
||||||
|
field :username, :string
|
||||||
|
has_many :organized_events, Event
|
||||||
|
many_to_many :groups, Group, join_through: GroupAccount
|
||||||
|
has_many :group_request, GroupRequest
|
||||||
|
has_one :user_id, User
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%Account{} = account, attrs) do
|
||||||
|
account
|
||||||
|
|> cast(attrs, [:username, :domain, :display_name, :description, :private_key, :public_key, :suspended, :uri, :url])
|
||||||
|
|> validate_required([:username, :domain, :display_name, :description, :private_key, :public_key, :suspended, :uri, :url])
|
||||||
|
end
|
||||||
|
end
|
488
lib/eventos/accounts/accounts.ex
Normal file
488
lib/eventos/accounts/accounts.ex
Normal file
|
@ -0,0 +1,488 @@
|
||||||
|
defmodule Eventos.Accounts do
|
||||||
|
@moduledoc """
|
||||||
|
The Accounts context.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import Ecto.Query, warn: false
|
||||||
|
alias Eventos.Repo
|
||||||
|
|
||||||
|
alias Eventos.Accounts.User
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of users.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_users()
|
||||||
|
[%User{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_users do
|
||||||
|
Repo.all(User)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single user.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the User does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_user!(123)
|
||||||
|
%User{}
|
||||||
|
|
||||||
|
iex> get_user!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_user!(id), do: Repo.get!(User, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a user.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_user(%{field: value})
|
||||||
|
{:ok, %User{}}
|
||||||
|
|
||||||
|
iex> create_user(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_user(attrs \\ %{}) do
|
||||||
|
%User{}
|
||||||
|
|> User.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a user.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_user(user, %{field: new_value})
|
||||||
|
{:ok, %User{}}
|
||||||
|
|
||||||
|
iex> update_user(user, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_user(%User{} = user, attrs) do
|
||||||
|
user
|
||||||
|
|> User.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a User.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_user(user)
|
||||||
|
{:ok, %User{}}
|
||||||
|
|
||||||
|
iex> delete_user(user)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_user(%User{} = user) do
|
||||||
|
Repo.delete(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking user changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_user(user)
|
||||||
|
%Ecto.Changeset{source: %User{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_user(%User{} = user) do
|
||||||
|
User.changeset(user, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Accounts.Account
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of accounts.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_accounts()
|
||||||
|
[%Account{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_accounts do
|
||||||
|
Repo.all(Account)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single account.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Account does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_account!(123)
|
||||||
|
%Account{}
|
||||||
|
|
||||||
|
iex> get_account!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_account!(id), do: Repo.get!(Account, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a account.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_account(%{field: value})
|
||||||
|
{:ok, %Account{}}
|
||||||
|
|
||||||
|
iex> create_account(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_account(attrs \\ %{}) do
|
||||||
|
%Account{}
|
||||||
|
|> Account.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a account.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_account(account, %{field: new_value})
|
||||||
|
{:ok, %Account{}}
|
||||||
|
|
||||||
|
iex> update_account(account, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_account(%Account{} = account, attrs) do
|
||||||
|
account
|
||||||
|
|> Account.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a Account.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_account(account)
|
||||||
|
{:ok, %Account{}}
|
||||||
|
|
||||||
|
iex> delete_account(account)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_account(%Account{} = account) do
|
||||||
|
Repo.delete(account)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking account changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_account(account)
|
||||||
|
%Ecto.Changeset{source: %Account{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_account(%Account{} = account) do
|
||||||
|
Account.changeset(account, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Accounts.Group
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of groups.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_groups()
|
||||||
|
[%Group{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_groups do
|
||||||
|
Repo.all(Group)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single group.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Group does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_group!(123)
|
||||||
|
%Group{}
|
||||||
|
|
||||||
|
iex> get_group!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_group!(id), do: Repo.get!(Group, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a group.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_group(%{field: value})
|
||||||
|
{:ok, %Group{}}
|
||||||
|
|
||||||
|
iex> create_group(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_group(attrs \\ %{}) do
|
||||||
|
%Group{}
|
||||||
|
|> Group.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a group.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_group(group, %{field: new_value})
|
||||||
|
{:ok, %Group{}}
|
||||||
|
|
||||||
|
iex> update_group(group, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_group(%Group{} = group, attrs) do
|
||||||
|
group
|
||||||
|
|> Group.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a Group.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_group(group)
|
||||||
|
{:ok, %Group{}}
|
||||||
|
|
||||||
|
iex> delete_group(group)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_group(%Group{} = group) do
|
||||||
|
Repo.delete(group)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking group changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_group(group)
|
||||||
|
%Ecto.Changeset{source: %Group{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_group(%Group{} = group) do
|
||||||
|
Group.changeset(group, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Accounts.GroupAccount
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of group_accounts.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_group_accounts()
|
||||||
|
[%GroupAccount{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_group_accounts do
|
||||||
|
Repo.all(GroupAccount)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single group_account.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Group account does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_group_account!(123)
|
||||||
|
%GroupAccount{}
|
||||||
|
|
||||||
|
iex> get_group_account!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_group_account!(id), do: Repo.get!(GroupAccount, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a group_account.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_group_account(%{field: value})
|
||||||
|
{:ok, %GroupAccount{}}
|
||||||
|
|
||||||
|
iex> create_group_account(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_group_account(attrs \\ %{}) do
|
||||||
|
%GroupAccount{}
|
||||||
|
|> GroupAccount.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a group_account.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_group_account(group_account, %{field: new_value})
|
||||||
|
{:ok, %GroupAccount{}}
|
||||||
|
|
||||||
|
iex> update_group_account(group_account, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_group_account(%GroupAccount{} = group_account, attrs) do
|
||||||
|
group_account
|
||||||
|
|> GroupAccount.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a GroupAccount.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_group_account(group_account)
|
||||||
|
{:ok, %GroupAccount{}}
|
||||||
|
|
||||||
|
iex> delete_group_account(group_account)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_group_account(%GroupAccount{} = group_account) do
|
||||||
|
Repo.delete(group_account)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking group_account changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_group_account(group_account)
|
||||||
|
%Ecto.Changeset{source: %GroupAccount{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_group_account(%GroupAccount{} = group_account) do
|
||||||
|
GroupAccount.changeset(group_account, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Accounts.GroupRequest
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of group_request.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_group_requests()
|
||||||
|
[%GroupRequest{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_group_requests do
|
||||||
|
Repo.all(GroupRequest)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single group_request.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Group request does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_group_request!(123)
|
||||||
|
%GroupRequest{}
|
||||||
|
|
||||||
|
iex> get_group_request!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_group_request!(id), do: Repo.get!(GroupRequest, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a group_request.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_group_request(%{field: value})
|
||||||
|
{:ok, %GroupRequest{}}
|
||||||
|
|
||||||
|
iex> create_group_request(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_group_request(attrs \\ %{}) do
|
||||||
|
%GroupRequest{}
|
||||||
|
|> GroupRequest.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a group_request.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_group_request(group_request, %{field: new_value})
|
||||||
|
{:ok, %GroupRequest{}}
|
||||||
|
|
||||||
|
iex> update_group_request(group_request, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_group_request(%GroupRequest{} = group_request, attrs) do
|
||||||
|
group_request
|
||||||
|
|> GroupRequest.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a GroupRequest.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_group_request(group_request)
|
||||||
|
{:ok, %GroupRequest{}}
|
||||||
|
|
||||||
|
iex> delete_group_request(group_request)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_group_request(%GroupRequest{} = group_request) do
|
||||||
|
Repo.delete(group_request)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking group_request changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_group_request(group_request)
|
||||||
|
%Ecto.Changeset{source: %GroupRequest{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_group_request(%GroupRequest{} = group_request) do
|
||||||
|
GroupRequest.changeset(group_request, %{})
|
||||||
|
end
|
||||||
|
end
|
25
lib/eventos/accounts/group.ex
Normal file
25
lib/eventos/accounts/group.ex
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
defmodule Eventos.Accounts.Group do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Accounts.{Group, Account, GroupAccount, GroupRequest}
|
||||||
|
|
||||||
|
|
||||||
|
schema "groups" do
|
||||||
|
field :description, :string
|
||||||
|
field :suspended, :boolean, default: false
|
||||||
|
field :title, :string
|
||||||
|
field :uri, :string
|
||||||
|
field :url, :string
|
||||||
|
many_to_many :accounts, Account, join_through: GroupAccount
|
||||||
|
has_many :requests, GroupRequest
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%Group{} = group, attrs) do
|
||||||
|
group
|
||||||
|
|> cast(attrs, [:title, :description, :suspended, :url, :uri])
|
||||||
|
|> validate_required([:title, :description, :suspended, :url, :uri])
|
||||||
|
end
|
||||||
|
end
|
21
lib/eventos/accounts/group_account.ex
Normal file
21
lib/eventos/accounts/group_account.ex
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
defmodule Eventos.Accounts.GroupAccount do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Accounts.{GroupAccount, Account, Group}
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
schema "group_accounts" do
|
||||||
|
field :role, :integer
|
||||||
|
belongs_to :group, Group
|
||||||
|
belongs_to :account, Account
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%GroupAccount{} = group_account, attrs) do
|
||||||
|
group_account
|
||||||
|
|> cast(attrs, [:role])
|
||||||
|
|> validate_required([:role])
|
||||||
|
end
|
||||||
|
end
|
20
lib/eventos/accounts/group_request.ex
Normal file
20
lib/eventos/accounts/group_request.ex
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
defmodule Eventos.Accounts.GroupRequest do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Accounts.{GroupRequest}
|
||||||
|
|
||||||
|
schema "group_requests" do
|
||||||
|
field :state, :integer
|
||||||
|
field :group_id, :integer
|
||||||
|
field :account_id, :integer
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%GroupRequest{} = group_request, attrs) do
|
||||||
|
group_request
|
||||||
|
|> cast(attrs, [:state])
|
||||||
|
|> validate_required([:state])
|
||||||
|
end
|
||||||
|
end
|
43
lib/eventos/accounts/user.ex
Normal file
43
lib/eventos/accounts/user.ex
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
defmodule Eventos.Accounts.User do
|
||||||
|
use Ecto.Schema
|
||||||
|
use Coherence.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Accounts.{User}
|
||||||
|
|
||||||
|
|
||||||
|
schema "users" do
|
||||||
|
field :email, :string
|
||||||
|
field :role, :integer, default: 0
|
||||||
|
field :username, :string
|
||||||
|
field :account_id, :integer
|
||||||
|
|
||||||
|
coherence_schema()
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(user, attrs, :password) do
|
||||||
|
user
|
||||||
|
|> cast(attrs, ~w(password password_confirmation reset_password_token reset_password_sent_at))
|
||||||
|
|> validate_coherence_password_reset(attrs)
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(user, attrs, :registration) do
|
||||||
|
user
|
||||||
|
|> cast(attrs, [:username, :email] ++ coherence_fields())
|
||||||
|
|> validate_required([:username, :email])
|
||||||
|
|> validate_format(:email, ~r/@/)
|
||||||
|
|> unique_constraint(:username)
|
||||||
|
|> validate_coherence(attrs)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%User{} = user, attrs) do
|
||||||
|
user
|
||||||
|
|> cast(attrs, [:username, :email, :password_hash, :role] ++ coherence_fields())
|
||||||
|
|> validate_required([:username, :email])
|
||||||
|
|> unique_constraint(:username)
|
||||||
|
|> validate_format(:email, ~r/@/)
|
||||||
|
|> validate_coherence(attrs)
|
||||||
|
end
|
||||||
|
end
|
31
lib/eventos/application.ex
Normal file
31
lib/eventos/application.ex
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
defmodule Eventos.Application do
|
||||||
|
use Application
|
||||||
|
|
||||||
|
# See https://hexdocs.pm/elixir/Application.html
|
||||||
|
# for more information on OTP Applications
|
||||||
|
def start(_type, _args) do
|
||||||
|
import Supervisor.Spec
|
||||||
|
|
||||||
|
# Define workers and child supervisors to be supervised
|
||||||
|
children = [
|
||||||
|
# Start the Ecto repository
|
||||||
|
supervisor(Eventos.Repo, []),
|
||||||
|
# Start the endpoint when the application starts
|
||||||
|
supervisor(EventosWeb.Endpoint, []),
|
||||||
|
# Start your own worker by calling: Eventos.Worker.start_link(arg1, arg2, arg3)
|
||||||
|
# worker(Eventos.Worker, [arg1, arg2, arg3]),
|
||||||
|
]
|
||||||
|
|
||||||
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||||
|
# for other strategies and supported options
|
||||||
|
opts = [strategy: :one_for_one, name: Eventos.Supervisor]
|
||||||
|
Supervisor.start_link(children, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Tell Phoenix to update the endpoint configuration
|
||||||
|
# whenever the application is updated.
|
||||||
|
def config_change(changed, _new, removed) do
|
||||||
|
EventosWeb.Endpoint.config_change(changed, removed)
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
40
lib/eventos/coherence/invitation.ex
Normal file
40
lib/eventos/coherence/invitation.ex
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
defmodule Eventos.Coherence.Invitation do
|
||||||
|
@moduledoc """
|
||||||
|
Schema to support inviting a someone to create an account.
|
||||||
|
"""
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
schema "invitations" do
|
||||||
|
field :name, :string
|
||||||
|
field :email, :string
|
||||||
|
field :token, :string
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a changeset based on the `model` and `params`.
|
||||||
|
|
||||||
|
If no params are provided, an invalid changeset is returned
|
||||||
|
with no validation performed.
|
||||||
|
"""
|
||||||
|
@spec changeset(Ecto.Schema.t, Map.t) :: Ecto.Changeset.t
|
||||||
|
def changeset(model, params \\ %{}) do
|
||||||
|
model
|
||||||
|
|> cast(params, ~w(name email token))
|
||||||
|
|> validate_required([:name, :email])
|
||||||
|
|> unique_constraint(:email)
|
||||||
|
|> validate_format(:email, ~r/@/)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a changeset for a new schema
|
||||||
|
"""
|
||||||
|
@spec new_changeset(Map.t) :: Ecto.Changeset.t
|
||||||
|
def new_changeset(params \\ %{}) do
|
||||||
|
changeset %__MODULE__{}, params
|
||||||
|
end
|
||||||
|
end
|
44
lib/eventos/coherence/rememberable.ex
Normal file
44
lib/eventos/coherence/rememberable.ex
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
defmodule Eventos.Coherence.Rememberable do
|
||||||
|
@moduledoc false
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
import Ecto.Query
|
||||||
|
|
||||||
|
alias Coherence.Config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
schema "rememberables" do
|
||||||
|
field :series_hash, :string
|
||||||
|
field :token_hash, :string
|
||||||
|
field :token_created_at, Timex.Ecto.DateTime
|
||||||
|
belongs_to :user, Module.concat(Config.module, Config.user_schema)
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
use Coherence.Rememberable
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a changeset based on the `model` and `params`.
|
||||||
|
|
||||||
|
If no params are provided, an invalid changeset is returned
|
||||||
|
with no validation performed.
|
||||||
|
"""
|
||||||
|
@spec changeset(Ecto.Schema.t, Map.t) :: Ecto.Changeset.t
|
||||||
|
def changeset(model, params \\ %{}) do
|
||||||
|
model
|
||||||
|
|> cast(params, ~w(series_hash token_hash token_created_at user_id))
|
||||||
|
|> validate_required(~w(series_hash token_hash token_created_at user_id)a)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a changeset for a new schema
|
||||||
|
"""
|
||||||
|
@spec new_changeset(Map.t) :: Ecto.Changeset.t
|
||||||
|
def new_changeset(params \\ %{}) do
|
||||||
|
changeset %Rememberable{}, params
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
141
lib/eventos/coherence/schemas.ex
Normal file
141
lib/eventos/coherence/schemas.ex
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
defmodule Eventos.Coherence.Schemas do
|
||||||
|
|
||||||
|
use Coherence.Config
|
||||||
|
|
||||||
|
import Ecto.Query
|
||||||
|
|
||||||
|
@user_schema Config.user_schema
|
||||||
|
@repo Config.repo
|
||||||
|
|
||||||
|
def list_user do
|
||||||
|
@repo.all @user_schema
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_by_user(opts) do
|
||||||
|
@repo.get_by @user_schema, opts
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_user(id) do
|
||||||
|
@repo.get @user_schema, id
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_user!(id) do
|
||||||
|
@repo.get! @user_schema, id
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_user_by_email(email) do
|
||||||
|
@repo.get_by @user_schema, email: email
|
||||||
|
end
|
||||||
|
|
||||||
|
def change_user(struct, params) do
|
||||||
|
@user_schema.changeset struct, params
|
||||||
|
end
|
||||||
|
|
||||||
|
def change_user(params) do
|
||||||
|
@user_schema.changeset @user_schema.__struct__, params
|
||||||
|
end
|
||||||
|
|
||||||
|
def change_user do
|
||||||
|
@user_schema.changeset @user_schema.__struct__, %{}
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_user(user, params) do
|
||||||
|
@repo.update change_user(user, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_user(params) do
|
||||||
|
@repo.insert change_user(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
Enum.each [Eventos.Coherence.Invitation, Eventos.Coherence.Rememberable], fn module ->
|
||||||
|
|
||||||
|
name =
|
||||||
|
module
|
||||||
|
|> Module.split
|
||||||
|
|> List.last
|
||||||
|
|> String.downcase
|
||||||
|
|
||||||
|
def unquote(String.to_atom("list_#{name}"))() do
|
||||||
|
@repo.all unquote(module)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("list_#{name}"))(%Ecto.Query{} = query) do
|
||||||
|
@repo.all query
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("get_#{name}"))(id) do
|
||||||
|
@repo.get unquote(module), id
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("get_#{name}!"))(id) do
|
||||||
|
@repo.get! unquote(module), id
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("get_by_#{name}"))(opts) do
|
||||||
|
@repo.get_by unquote(module), opts
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("change_#{name}"))(struct, params) do
|
||||||
|
unquote(module).changeset(struct, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("change_#{name}"))(params) do
|
||||||
|
unquote(module).new_changeset(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("change_#{name}"))() do
|
||||||
|
unquote(module).new_changeset(%{})
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("create_#{name}"))(params) do
|
||||||
|
@repo.insert unquote(module).new_changeset(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("update_#{name}"))(struct, params) do
|
||||||
|
@repo.update unquote(module).changeset(struct, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unquote(String.to_atom("delete_#{name}"))(struct) do
|
||||||
|
@repo.delete struct
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def query_by(schema, opts) do
|
||||||
|
Enum.reduce opts, schema, fn {k, v}, query ->
|
||||||
|
where(query, [b], field(b, ^k) == ^v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_all(%Ecto.Query{} = query) do
|
||||||
|
@repo.delete_all query
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_all(module) when is_atom(module) do
|
||||||
|
@repo.delete_all module
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(%Ecto.Changeset{} = changeset) do
|
||||||
|
@repo.insert changeset
|
||||||
|
end
|
||||||
|
|
||||||
|
def create!(%Ecto.Changeset{} = changeset) do
|
||||||
|
@repo.insert! changeset
|
||||||
|
end
|
||||||
|
|
||||||
|
def update(%Ecto.Changeset{} = changeset) do
|
||||||
|
@repo.update changeset
|
||||||
|
end
|
||||||
|
|
||||||
|
def update!(%Ecto.Changeset{} = changeset) do
|
||||||
|
@repo.update! changeset
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete(schema) do
|
||||||
|
@repo.delete schema
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete!(schema) do
|
||||||
|
@repo.delete! schema
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
21
lib/eventos/events/category.ex
Normal file
21
lib/eventos/events/category.ex
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
defmodule Eventos.Events.Category do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Events.Category
|
||||||
|
|
||||||
|
|
||||||
|
schema "categories" do
|
||||||
|
field :picture, :string
|
||||||
|
field :title, :string
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%Category{} = category, attrs) do
|
||||||
|
category
|
||||||
|
|> cast(attrs, [:title, :picture])
|
||||||
|
|> validate_required([:title, :picture])
|
||||||
|
|> unique_constraint(:title)
|
||||||
|
end
|
||||||
|
end
|
26
lib/eventos/events/event.ex
Normal file
26
lib/eventos/events/event.ex
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
defmodule Eventos.Events.Event do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Events.{Event, EventAccount, EventRequest}
|
||||||
|
alias Eventos.Accounts.Account
|
||||||
|
|
||||||
|
|
||||||
|
schema "events" do
|
||||||
|
field :begin_on, :utc_datetime
|
||||||
|
field :description, :string
|
||||||
|
field :ends_on, :utc_datetime
|
||||||
|
field :title, :string
|
||||||
|
has_one :organizer_id, Account
|
||||||
|
many_to_many :participants, Account, join_through: EventAccount
|
||||||
|
has_many :event_request, EventRequest
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%Event{} = event, attrs) do
|
||||||
|
event
|
||||||
|
|> cast(attrs, [:title, :description, :begin_on, :ends_on])
|
||||||
|
|> validate_required([:title, :description, :begin_on, :ends_on, :organizer_id])
|
||||||
|
end
|
||||||
|
end
|
22
lib/eventos/events/event_accounts.ex
Normal file
22
lib/eventos/events/event_accounts.ex
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
defmodule Eventos.Events.EventAccounts do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Events.{EventAccounts, Event}
|
||||||
|
alias Eventos.Accounts.Account
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
schema "event_accounts" do
|
||||||
|
field :roles, :integer
|
||||||
|
belongs_to :event, Event
|
||||||
|
belongs_to :account, Account
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%EventAccounts{} = event_accounts, attrs) do
|
||||||
|
event_accounts
|
||||||
|
|> cast(attrs, [:roles])
|
||||||
|
|> validate_required([:roles])
|
||||||
|
end
|
||||||
|
end
|
22
lib/eventos/events/event_request.ex
Normal file
22
lib/eventos/events/event_request.ex
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
defmodule Eventos.Events.EventRequest do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Events.{EventRequest, Event}
|
||||||
|
alias Eventos.Accounts.Account
|
||||||
|
|
||||||
|
|
||||||
|
schema "event_requests" do
|
||||||
|
field :state, :integer
|
||||||
|
has_one :event_id, Event
|
||||||
|
has_one :account_id, Account
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%EventRequest{} = event_request, attrs) do
|
||||||
|
event_request
|
||||||
|
|> cast(attrs, [:state])
|
||||||
|
|> validate_required([:state])
|
||||||
|
end
|
||||||
|
end
|
488
lib/eventos/events/events.ex
Normal file
488
lib/eventos/events/events.ex
Normal file
|
@ -0,0 +1,488 @@
|
||||||
|
defmodule Eventos.Events do
|
||||||
|
@moduledoc """
|
||||||
|
The Events context.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import Ecto.Query, warn: false
|
||||||
|
alias Eventos.Repo
|
||||||
|
|
||||||
|
alias Eventos.Events.Event
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of events.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_events()
|
||||||
|
[%Event{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_events do
|
||||||
|
Repo.all(Event)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single event.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Event does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_event!(123)
|
||||||
|
%Event{}
|
||||||
|
|
||||||
|
iex> get_event!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_event!(id), do: Repo.get!(Event, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a event.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_event(%{field: value})
|
||||||
|
{:ok, %Event{}}
|
||||||
|
|
||||||
|
iex> create_event(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_event(attrs \\ %{}) do
|
||||||
|
%Event{}
|
||||||
|
|> Event.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a event.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_event(event, %{field: new_value})
|
||||||
|
{:ok, %Event{}}
|
||||||
|
|
||||||
|
iex> update_event(event, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_event(%Event{} = event, attrs) do
|
||||||
|
event
|
||||||
|
|> Event.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a Event.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_event(event)
|
||||||
|
{:ok, %Event{}}
|
||||||
|
|
||||||
|
iex> delete_event(event)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_event(%Event{} = event) do
|
||||||
|
Repo.delete(event)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking event changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_event(event)
|
||||||
|
%Ecto.Changeset{source: %Event{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_event(%Event{} = event) do
|
||||||
|
Event.changeset(event, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Events.Category
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of categories.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_categories()
|
||||||
|
[%Category{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_categories do
|
||||||
|
Repo.all(Category)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single category.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Category does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_category!(123)
|
||||||
|
%Category{}
|
||||||
|
|
||||||
|
iex> get_category!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_category!(id), do: Repo.get!(Category, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a category.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_category(%{field: value})
|
||||||
|
{:ok, %Category{}}
|
||||||
|
|
||||||
|
iex> create_category(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_category(attrs \\ %{}) do
|
||||||
|
%Category{}
|
||||||
|
|> Category.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a category.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_category(category, %{field: new_value})
|
||||||
|
{:ok, %Category{}}
|
||||||
|
|
||||||
|
iex> update_category(category, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_category(%Category{} = category, attrs) do
|
||||||
|
category
|
||||||
|
|> Category.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a Category.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_category(category)
|
||||||
|
{:ok, %Category{}}
|
||||||
|
|
||||||
|
iex> delete_category(category)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_category(%Category{} = category) do
|
||||||
|
Repo.delete(category)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking category changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_category(category)
|
||||||
|
%Ecto.Changeset{source: %Category{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_category(%Category{} = category) do
|
||||||
|
Category.changeset(category, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Events.Tag
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of tags.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_tags()
|
||||||
|
[%Tag{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_tags do
|
||||||
|
Repo.all(Tag)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single tag.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Tag does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_tag!(123)
|
||||||
|
%Tag{}
|
||||||
|
|
||||||
|
iex> get_tag!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_tag!(id), do: Repo.get!(Tag, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a tag.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_tag(%{field: value})
|
||||||
|
{:ok, %Tag{}}
|
||||||
|
|
||||||
|
iex> create_tag(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_tag(attrs \\ %{}) do
|
||||||
|
%Tag{}
|
||||||
|
|> Tag.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a tag.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_tag(tag, %{field: new_value})
|
||||||
|
{:ok, %Tag{}}
|
||||||
|
|
||||||
|
iex> update_tag(tag, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_tag(%Tag{} = tag, attrs) do
|
||||||
|
tag
|
||||||
|
|> Tag.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a Tag.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_tag(tag)
|
||||||
|
{:ok, %Tag{}}
|
||||||
|
|
||||||
|
iex> delete_tag(tag)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_tag(%Tag{} = tag) do
|
||||||
|
Repo.delete(tag)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking tag changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_tag(tag)
|
||||||
|
%Ecto.Changeset{source: %Tag{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_tag(%Tag{} = tag) do
|
||||||
|
Tag.changeset(tag, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Events.EventAccounts
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of event_accounts.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_event_accounts()
|
||||||
|
[%EventAccounts{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_event_accounts do
|
||||||
|
Repo.all(EventAccounts)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single event_accounts.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Event accounts does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_event_accounts!(123)
|
||||||
|
%EventAccounts{}
|
||||||
|
|
||||||
|
iex> get_event_accounts!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_event_accounts!(id), do: Repo.get!(EventAccounts, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a event_accounts.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_event_accounts(%{field: value})
|
||||||
|
{:ok, %EventAccounts{}}
|
||||||
|
|
||||||
|
iex> create_event_accounts(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_event_accounts(attrs \\ %{}) do
|
||||||
|
%EventAccounts{}
|
||||||
|
|> EventAccounts.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a event_accounts.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_event_accounts(event_accounts, %{field: new_value})
|
||||||
|
{:ok, %EventAccounts{}}
|
||||||
|
|
||||||
|
iex> update_event_accounts(event_accounts, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_event_accounts(%EventAccounts{} = event_accounts, attrs) do
|
||||||
|
event_accounts
|
||||||
|
|> EventAccounts.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a EventAccounts.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_event_accounts(event_accounts)
|
||||||
|
{:ok, %EventAccounts{}}
|
||||||
|
|
||||||
|
iex> delete_event_accounts(event_accounts)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_event_accounts(%EventAccounts{} = event_accounts) do
|
||||||
|
Repo.delete(event_accounts)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking event_accounts changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_event_accounts(event_accounts)
|
||||||
|
%Ecto.Changeset{source: %EventAccounts{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_event_accounts(%EventAccounts{} = event_accounts) do
|
||||||
|
EventAccounts.changeset(event_accounts, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Events.EventRequest
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the list of event_requests.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> list_event_requests()
|
||||||
|
[%EventRequest{}, ...]
|
||||||
|
|
||||||
|
"""
|
||||||
|
def list_event_requests do
|
||||||
|
Repo.all(EventRequest)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Gets a single event_request.
|
||||||
|
|
||||||
|
Raises `Ecto.NoResultsError` if the Event request does not exist.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> get_event_request!(123)
|
||||||
|
%EventRequest{}
|
||||||
|
|
||||||
|
iex> get_event_request!(456)
|
||||||
|
** (Ecto.NoResultsError)
|
||||||
|
|
||||||
|
"""
|
||||||
|
def get_event_request!(id), do: Repo.get!(EventRequest, id)
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a event_request.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_event_request(%{field: value})
|
||||||
|
{:ok, %EventRequest{}}
|
||||||
|
|
||||||
|
iex> create_event_request(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_event_request(attrs \\ %{}) do
|
||||||
|
%EventRequest{}
|
||||||
|
|> EventRequest.changeset(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates a event_request.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> update_event_request(event_request, %{field: new_value})
|
||||||
|
{:ok, %EventRequest{}}
|
||||||
|
|
||||||
|
iex> update_event_request(event_request, %{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def update_event_request(%EventRequest{} = event_request, attrs) do
|
||||||
|
event_request
|
||||||
|
|> EventRequest.changeset(attrs)
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Deletes a EventRequest.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_event_request(event_request)
|
||||||
|
{:ok, %EventRequest{}}
|
||||||
|
|
||||||
|
iex> delete_event_request(event_request)
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_event_request(%EventRequest{} = event_request) do
|
||||||
|
Repo.delete(event_request)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns an `%Ecto.Changeset{}` for tracking event_request changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> change_event_request(event_request)
|
||||||
|
%Ecto.Changeset{source: %EventRequest{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def change_event_request(%EventRequest{} = event_request) do
|
||||||
|
EventRequest.changeset(event_request, %{})
|
||||||
|
end
|
||||||
|
end
|
21
lib/eventos/events/tag.ex
Normal file
21
lib/eventos/events/tag.ex
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
defmodule Eventos.Events.Tag do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
alias Eventos.Events.Tag
|
||||||
|
|
||||||
|
|
||||||
|
schema "tags" do
|
||||||
|
field :slug, :string
|
||||||
|
field :title, :string
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(%Tag{} = tag, attrs) do
|
||||||
|
tag
|
||||||
|
|> cast(attrs, [:title, :slug])
|
||||||
|
|> validate_required([:title, :slug])
|
||||||
|
|> unique_constraint(:slug)
|
||||||
|
end
|
||||||
|
end
|
11
lib/eventos/repo.ex
Normal file
11
lib/eventos/repo.ex
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
defmodule Eventos.Repo do
|
||||||
|
use Ecto.Repo, otp_app: :eventos
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Dynamically loads the repository url from the
|
||||||
|
DATABASE_URL environment variable.
|
||||||
|
"""
|
||||||
|
def init(_, opts) do
|
||||||
|
{:ok, Keyword.put(opts, :url, System.get_env("DATABASE_URL"))}
|
||||||
|
end
|
||||||
|
end
|
67
lib/eventos_web.ex
Normal file
67
lib/eventos_web.ex
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
defmodule EventosWeb do
|
||||||
|
@moduledoc """
|
||||||
|
The entrypoint for defining your web interface, such
|
||||||
|
as controllers, views, channels and so on.
|
||||||
|
|
||||||
|
This can be used in your application as:
|
||||||
|
|
||||||
|
use EventosWeb, :controller
|
||||||
|
use EventosWeb, :view
|
||||||
|
|
||||||
|
The definitions below will be executed for every view,
|
||||||
|
controller, etc, so keep them short and clean, focused
|
||||||
|
on imports, uses and aliases.
|
||||||
|
|
||||||
|
Do NOT define functions inside the quoted expressions
|
||||||
|
below. Instead, define any helper function in modules
|
||||||
|
and import those modules here.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def controller do
|
||||||
|
quote do
|
||||||
|
use Phoenix.Controller, namespace: EventosWeb
|
||||||
|
import Plug.Conn
|
||||||
|
import EventosWeb.Router.Helpers
|
||||||
|
import EventosWeb.Gettext
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def view do
|
||||||
|
quote do
|
||||||
|
use Phoenix.View, root: "lib/eventos_web/templates",
|
||||||
|
namespace: EventosWeb
|
||||||
|
|
||||||
|
# Import convenience functions from controllers
|
||||||
|
import Phoenix.Controller, only: [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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def router do
|
||||||
|
quote do
|
||||||
|
use Phoenix.Router
|
||||||
|
import Plug.Conn
|
||||||
|
import Phoenix.Controller
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def channel do
|
||||||
|
quote do
|
||||||
|
use Phoenix.Channel
|
||||||
|
import EventosWeb.Gettext
|
||||||
|
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
|
37
lib/eventos_web/channels/user_socket.ex
Normal file
37
lib/eventos_web/channels/user_socket.ex
Normal 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
|
79
lib/eventos_web/coherence_messages.ex
Normal file
79
lib/eventos_web/coherence_messages.ex
Normal 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
|
47
lib/eventos_web/coherence_web.ex
Normal file
47
lib/eventos_web/coherence_web.ex
Normal 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
|
60
lib/eventos_web/controllers/account_controller.ex
Normal file
60
lib/eventos_web/controllers/account_controller.ex
Normal 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
|
60
lib/eventos_web/controllers/category_controller.ex
Normal file
60
lib/eventos_web/controllers/category_controller.ex
Normal 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
|
54
lib/eventos_web/controllers/coherence/redirects.ex
Normal file
54
lib/eventos_web/controllers/coherence/redirects.ex
Normal 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
|
60
lib/eventos_web/controllers/event_accounts_controller.ex
Normal file
60
lib/eventos_web/controllers/event_accounts_controller.ex
Normal 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
|
60
lib/eventos_web/controllers/event_controller.ex
Normal file
60
lib/eventos_web/controllers/event_controller.ex
Normal 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
|
60
lib/eventos_web/controllers/event_request_controller.ex
Normal file
60
lib/eventos_web/controllers/event_request_controller.ex
Normal 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
|
60
lib/eventos_web/controllers/group_account_controller.ex
Normal file
60
lib/eventos_web/controllers/group_account_controller.ex
Normal 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
|
60
lib/eventos_web/controllers/group_controller.ex
Normal file
60
lib/eventos_web/controllers/group_controller.ex
Normal 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
|
60
lib/eventos_web/controllers/group_request_controller.ex
Normal file
60
lib/eventos_web/controllers/group_request_controller.ex
Normal 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
|
7
lib/eventos_web/controllers/page_controller.ex
Normal file
7
lib/eventos_web/controllers/page_controller.ex
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
defmodule EventosWeb.PageController do
|
||||||
|
use EventosWeb, :controller
|
||||||
|
|
||||||
|
def index(conn, _params) do
|
||||||
|
render conn, "index.html"
|
||||||
|
end
|
||||||
|
end
|
60
lib/eventos_web/controllers/tag_controller.ex
Normal file
60
lib/eventos_web/controllers/tag_controller.ex
Normal 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
|
60
lib/eventos_web/controllers/user_controller.ex
Normal file
60
lib/eventos_web/controllers/user_controller.ex
Normal 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
|
6
lib/eventos_web/emails/coherence/coherence_mailer.ex
Normal file
6
lib/eventos_web/emails/coherence/coherence_mailer.ex
Normal 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
|
82
lib/eventos_web/emails/coherence/user_email.ex
Normal file
82
lib/eventos_web/emails/coherence/user_email.ex
Normal 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
|
57
lib/eventos_web/endpoint.ex
Normal file
57
lib/eventos_web/endpoint.ex
Normal 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
|
24
lib/eventos_web/gettext.ex
Normal file
24
lib/eventos_web/gettext.ex
Normal 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
63
lib/eventos_web/router.ex
Normal 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
|
5
lib/eventos_web/templates/account/edit.html.eex
Normal file
5
lib/eventos_web/templates/account/edit.html.eex
Normal 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>
|
65
lib/eventos_web/templates/account/form.html.eex
Normal file
65
lib/eventos_web/templates/account/form.html.eex
Normal 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 %>
|
42
lib/eventos_web/templates/account/index.html.eex
Normal file
42
lib/eventos_web/templates/account/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/account/new.html.eex
Normal file
5
lib/eventos_web/templates/account/new.html.eex
Normal 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>
|
53
lib/eventos_web/templates/account/show.html.eex
Normal file
53
lib/eventos_web/templates/account/show.html.eex
Normal 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>
|
5
lib/eventos_web/templates/category/edit.html.eex
Normal file
5
lib/eventos_web/templates/category/edit.html.eex
Normal 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>
|
23
lib/eventos_web/templates/category/form.html.eex
Normal file
23
lib/eventos_web/templates/category/form.html.eex
Normal 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 %>
|
28
lib/eventos_web/templates/category/index.html.eex
Normal file
28
lib/eventos_web/templates/category/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/category/new.html.eex
Normal file
5
lib/eventos_web/templates/category/new.html.eex
Normal 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>
|
18
lib/eventos_web/templates/category/show.html.eex
Normal file
18
lib/eventos_web/templates/category/show.html.eex
Normal 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>
|
|
@ -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 %>
|
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
16
lib/eventos_web/templates/coherence/email/password.html.eex
Normal file
16
lib/eventos_web/templates/coherence/email/password.html.eex
Normal 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>
|
||||||
|
|
11
lib/eventos_web/templates/coherence/email/unlock.html.eex
Normal file
11
lib/eventos_web/templates/coherence/email/unlock.html.eex
Normal 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>
|
||||||
|
|
49
lib/eventos_web/templates/coherence/invitation/edit.html.eex
Normal file
49
lib/eventos_web/templates/coherence/invitation/edit.html.eex
Normal 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 %>
|
26
lib/eventos_web/templates/coherence/invitation/new.html.eex
Normal file
26
lib/eventos_web/templates/coherence/invitation/new.html.eex
Normal 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 %>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title><%= @email.subject %></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%= render @view_module, @view_template, assigns %>
|
||||||
|
</body>
|
||||||
|
</html>
|
25
lib/eventos_web/templates/coherence/password/edit.html.eex
Normal file
25
lib/eventos_web/templates/coherence/password/edit.html.eex
Normal 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 %>
|
17
lib/eventos_web/templates/coherence/password/new.html.eex
Normal file
17
lib/eventos_web/templates/coherence/password/new.html.eex
Normal 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 %>
|
|
@ -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) %>
|
|
@ -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 %>
|
|
@ -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) %>
|
|
@ -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?")] %>
|
35
lib/eventos_web/templates/coherence/session/new.html.eex
Normal file
35
lib/eventos_web/templates/coherence/session/new.html.eex
Normal 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 %>
|
22
lib/eventos_web/templates/coherence/unlock/new.html.eex
Normal file
22
lib/eventos_web/templates/coherence/unlock/new.html.eex
Normal 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 %>
|
5
lib/eventos_web/templates/event/edit.html.eex
Normal file
5
lib/eventos_web/templates/event/edit.html.eex
Normal 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>
|
35
lib/eventos_web/templates/event/form.html.eex
Normal file
35
lib/eventos_web/templates/event/form.html.eex
Normal 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 %>
|
32
lib/eventos_web/templates/event/index.html.eex
Normal file
32
lib/eventos_web/templates/event/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/event/new.html.eex
Normal file
5
lib/eventos_web/templates/event/new.html.eex
Normal 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>
|
28
lib/eventos_web/templates/event/show.html.eex
Normal file
28
lib/eventos_web/templates/event/show.html.eex
Normal 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>
|
5
lib/eventos_web/templates/event_accounts/edit.html.eex
Normal file
5
lib/eventos_web/templates/event_accounts/edit.html.eex
Normal 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>
|
17
lib/eventos_web/templates/event_accounts/form.html.eex
Normal file
17
lib/eventos_web/templates/event_accounts/form.html.eex
Normal 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 %>
|
26
lib/eventos_web/templates/event_accounts/index.html.eex
Normal file
26
lib/eventos_web/templates/event_accounts/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/event_accounts/new.html.eex
Normal file
5
lib/eventos_web/templates/event_accounts/new.html.eex
Normal 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>
|
13
lib/eventos_web/templates/event_accounts/show.html.eex
Normal file
13
lib/eventos_web/templates/event_accounts/show.html.eex
Normal 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>
|
5
lib/eventos_web/templates/event_request/edit.html.eex
Normal file
5
lib/eventos_web/templates/event_request/edit.html.eex
Normal 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>
|
17
lib/eventos_web/templates/event_request/form.html.eex
Normal file
17
lib/eventos_web/templates/event_request/form.html.eex
Normal 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 %>
|
26
lib/eventos_web/templates/event_request/index.html.eex
Normal file
26
lib/eventos_web/templates/event_request/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/event_request/new.html.eex
Normal file
5
lib/eventos_web/templates/event_request/new.html.eex
Normal 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>
|
13
lib/eventos_web/templates/event_request/show.html.eex
Normal file
13
lib/eventos_web/templates/event_request/show.html.eex
Normal 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>
|
5
lib/eventos_web/templates/group/edit.html.eex
Normal file
5
lib/eventos_web/templates/group/edit.html.eex
Normal 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>
|
41
lib/eventos_web/templates/group/form.html.eex
Normal file
41
lib/eventos_web/templates/group/form.html.eex
Normal 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 %>
|
34
lib/eventos_web/templates/group/index.html.eex
Normal file
34
lib/eventos_web/templates/group/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/group/new.html.eex
Normal file
5
lib/eventos_web/templates/group/new.html.eex
Normal 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>
|
33
lib/eventos_web/templates/group/show.html.eex
Normal file
33
lib/eventos_web/templates/group/show.html.eex
Normal 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>
|
5
lib/eventos_web/templates/group_account/edit.html.eex
Normal file
5
lib/eventos_web/templates/group_account/edit.html.eex
Normal 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>
|
17
lib/eventos_web/templates/group_account/form.html.eex
Normal file
17
lib/eventos_web/templates/group_account/form.html.eex
Normal 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 %>
|
26
lib/eventos_web/templates/group_account/index.html.eex
Normal file
26
lib/eventos_web/templates/group_account/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/group_account/new.html.eex
Normal file
5
lib/eventos_web/templates/group_account/new.html.eex
Normal 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>
|
13
lib/eventos_web/templates/group_account/show.html.eex
Normal file
13
lib/eventos_web/templates/group_account/show.html.eex
Normal 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>
|
5
lib/eventos_web/templates/group_request/edit.html.eex
Normal file
5
lib/eventos_web/templates/group_request/edit.html.eex
Normal 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>
|
17
lib/eventos_web/templates/group_request/form.html.eex
Normal file
17
lib/eventos_web/templates/group_request/form.html.eex
Normal 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 %>
|
26
lib/eventos_web/templates/group_request/index.html.eex
Normal file
26
lib/eventos_web/templates/group_request/index.html.eex
Normal 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>
|
5
lib/eventos_web/templates/group_request/new.html.eex
Normal file
5
lib/eventos_web/templates/group_request/new.html.eex
Normal 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>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue