Skip to content

Mailer #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'devise'
gem 'hamlit-rails'
gem 'iex-ruby-client'

group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
70 changes: 69 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
bcrypt (3.1.16)
bcrypt (3.1.16-java)
bindex (0.8.1)
bootsnap (1.7.3)
msgpack (~> 1.0)
Expand All @@ -83,21 +84,53 @@ GEM
factory_bot_rails (6.1.0)
factory_bot (~> 6.1.0)
railties (>= 5.0.0)
faraday (1.5.1)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday_middleware (1.0.0)
faraday (~> 1.0)
ffi (1.15.0)
ffi (1.15.0-java)
ffi (1.15.0-x64-mingw32)
ffi (1.15.0-x86-mingw32)
globalid (0.4.2)
activesupport (>= 4.2.0)
hamlit (2.15.0)
temple (>= 0.8.2)
thor
tilt
hamlit (2.15.0-java)
temple (>= 0.8.2)
thor
tilt
hamlit-rails (0.2.3)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
hamlit (>= 1.2.0)
railties (>= 4.0.1)
hashdiff (1.0.1)
hashie (4.1.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
iex-ruby-client (1.4.1)
faraday (>= 0.17)
faraday_middleware
hashie
money_helper
jbuilder (2.11.2)
activesupport (>= 5.0.0)
listen (3.5.1)
Expand All @@ -111,10 +144,26 @@ GEM
marcel (1.0.1)
method_source (1.0.0)
mini_mime (1.1.0)
mini_portile2 (2.5.3)
minitest (5.14.4)
money (6.16.0)
i18n (>= 0.6.4, <= 2)
money_helper (1.0.2)
activesupport
money (~> 6.5)
msgpack (1.4.2)
msgpack (1.4.2-java)
multipart-post (2.1.1)
nio4r (2.5.7)
nokogiri (1.11.3-x86_64-darwin)
nio4r (2.5.7-java)
nokogiri (1.11.3)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
nokogiri (1.11.3-java)
racc (~> 1.4)
nokogiri (1.11.3-x64-mingw32)
racc (~> 1.4)
nokogiri (1.11.3-x86-mingw32)
racc (~> 1.4)
nokogiri (1.11.3-x86_64-linux)
racc (~> 1.4)
Expand All @@ -123,10 +172,15 @@ GEM
parser (3.0.1.0)
ast (~> 2.4.1)
pg (1.2.3)
pg (1.2.3-x64-mingw32)
pg (1.2.3-x86-mingw32)
public_suffix (4.0.6)
puma (4.3.7)
nio4r (~> 2.0)
puma (4.3.7-java)
nio4r (~> 2.0)
racc (1.5.2)
racc (1.5.2-java)
rack (2.2.3)
rack-proxy (0.6.5)
rack
Expand Down Expand Up @@ -204,10 +258,13 @@ GEM
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
ffi (~> 1.9)
sassc (2.4.0-x64-mingw32)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
Expand All @@ -230,12 +287,15 @@ GEM
temple (0.8.2)
thor (1.1.0)
thread_safe (0.3.6)
thread_safe (0.3.6-java)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo-data (1.2021.1)
tzinfo (>= 1.0.0)
unicode-display_width (2.0.0)
vcr (6.0.0)
warden (1.2.9)
Expand All @@ -255,10 +315,17 @@ GEM
railties (>= 4.2)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-driver (0.7.3-java)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.2)

PLATFORMS
java
ruby
x64-mingw32
x86-mingw32
x86-mswin32
x86_64-linux

DEPENDENCIES
Expand All @@ -268,6 +335,7 @@ DEPENDENCIES
devise
factory_bot_rails
hamlit-rails
iex-ruby-client
jbuilder (~> 2.7)
listen (~> 3.2)
pg
Expand Down
50 changes: 50 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,53 @@
*= require_tree .
*= require_self
*/

*, ::before, ::after{
box-sizing: border-box;
padding: 0;
margin: 0;
}

html, body{
font-size: 1em;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #111111;
}

.container{
max-width: 700px;
margin: 0 auto;
}

header{
padding: 5px 15px;
background-color: #111111;
color: #ffffff;
}

nav{
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}

.title-container h1 a{
color: #ffffff;
text-decoration: none;
}

.menu-item a{
margin-left: 10px;
color: #ffffff;
text-decoration: none;
}

.yield-container{
max-width: 700px;
margin: 0 auto;
}




32 changes: 32 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Place all the styles related to the Users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
.container-sign-up{
color: #111111;
max-width: 700px;
margin: 0 auto;
padding: 10px 15px;
}

.container-sign-up h2{
font-size: 2em;
}

.container-sign-up input{
width: 100%;
padding: 5px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin-bottom: 3px;
border: 3px solid #111111;
}

.container-sign-up input[type="submit"]{
padding: 8px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 1em;
margin-top: 5px;
color: #ffffff;
background-color: #111111;
border: none;
width: 50%;
}
67 changes: 67 additions & 0 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# frozen_string_literal: true

class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]

# GET /resource/sign_up
# def new
# super
# end

# POST /resource
def create
super
if @user.save
UserMailer.signup_confirmation(@user).deliver
else
render :new
end
end

# GET /resource/edit
# def edit
# super
# end

# PUT /resource
# def update
# super
# end

# DELETE /resource
# def destroy
# super
# end

# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end

# protected

# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
end

# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end

# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end

# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
3 changes: 1 addition & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'

end
12 changes: 12 additions & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class UserMailer < ApplicationMailer
default from: "[email protected]"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.user_mailer.signup_confirmation.subject
#
def signup_confirmation(user)
@user = user
mail to: @user.email, subject: "Account approval pending.."
end
end
19 changes: 19 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable

def active_for_authentication?
super && approved?
end

def inactive_message
approved? ? super : :not_approved
end

# after_create :send_email_approval
# def send_email_approval
# UserMailer.signup_confirmation(email).deliver
# end
end
18 changes: 17 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
</head>

<body>
<%= yield %>
<div class="container">
<header>
<nav>
<div class="title-container"><h1><%= link_to "Aviontrade", users_path() %></h1></div>
<div class="menu-container">
<span class=menu-item><%= link_to "Login", new_user_session_path() %></span>
<span class=menu-item><%= link_to "Register", new_user_registration_path() %></span>
</div>
</nav>
</header>
</div>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<div class="yield-container">
<%= yield %>
</div>

</body>
</html>
3 changes: 3 additions & 0 deletions app/views/layouts/mailer.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%hmtl
%body
= yield
1 change: 1 addition & 0 deletions app/views/layouts/mailer.text.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= yield
Loading