Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ DATABASE_USER=postgres
DATABASE_PASSWORD=postgres
DATABASE_HOST=localhost
DATABASE_PORT=5432

GMAIL_SMTP_USER_NAME=
GMAIL_SMTP_APP_PASSWORD=
1 change: 1 addition & 0 deletions app/controllers/rents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def create

respond_to do |format|
if @rent.save
RentMailer.with(rent: @rent).create_email.deliver_later
format.html { redirect_to users_rents_url, notice: "Sikeres kölcsönzés." }
format.json { render :show, status: :created, location: @rent }
else
Expand Down
6 changes: 6 additions & 0 deletions app/mailers/previews/rent_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RentMailerPreview < ActionMailer::Preview
def create_email
@rent = params[:rent]
mail(to: User.first.mail, subject: 'Schörpong mail')
end
end
6 changes: 6 additions & 0 deletions app/mailers/rent_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RentMailer < ApplicationMailer
def create_email
@rent = params[:rent]
mail(to:'sepsi.laszlo99@gmail.com', subject: 'Schörpong mail')
end
end
44 changes: 44 additions & 0 deletions app/views/rent_mailer/create_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.5.0/dist/semantic.min.css">
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.5.0/dist/semantic.min.js"></script>
</head>
<body>


<div class="container" style="max-width: 1000px; margin: auto; padding: 2rem">
<div class="ui center aligned grid">
<div class="row black">
<div class="red sixteen wide column inv">
<h1>Új feldolgozatlan eszközigénylés</h1>
</div>
</div>
<div class="black row">
<div class="column">
<h2>Eszköz: <%= @rent.item.name %></h2>
</div>
</div>
<div class="black row">
<div class="eight wide column">
<h3>Kölcsönzés kezdete:</h3>
</div>
<div class="eight wide column">
<h3>Kölcsönzés vége:</h3>
</div>
</div>
<div class="black row">
<div class="eight wide column">
<h3><%= @rent.begin.strftime("%Y-%m-%d %H:%M") %></h3>
</div>
<div class="eight wide column">
<h3><%= @rent.end.strftime("%Y-%m-%d %H:%M") %></h3>
</div>
</div>
<div class="black row">
<div class="column">
<%= link_to "Részletek", rents_url, class:"ui red huge button" %>
</div>
</div>
</div>
</div>
</body>

12 changes: 12 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.i18n.default_locale = :hu
routes.default_url_options[:host] = 'localhost:3001'
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: ENV['GMAIL_SMTP_USER_NAME'],
password: ENV['GMAIL_SMTP_APP_PASSWORD'],
authentication: 'plain',
enable_starttls_auto: true,
open_timeout: 5,
read_timeout: 5 }

# Configuration for the application, engines, and railties goes here.
#
Expand Down
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
routes.default_url_options[:host] = 'https://schorpong.sch.bme.hu/'

# Code is not reloaded between requests.
config.cache_classes = true
Expand Down
7 changes: 7 additions & 0 deletions test/mailers/previews/rent_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Preview all emails at http://localhost:3000/rails/mailers/rent_mailer
class RentMailerPreview < ActionMailer::Preview
def create_email
@rent = Rent.last
RentMailer.with(rent: @rent).create_email
end
end
7 changes: 7 additions & 0 deletions test/mailers/rent_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class RentMailerTest < ActionMailer::TestCase
# test "the truth" do
# assert true
# end
end