From 13549cd59ac3723d30a1f7cb0f8be169e0810568 Mon Sep 17 00:00:00 2001 From: Gabriel Porto Oliveira Date: Wed, 29 Aug 2018 11:03:01 -0300 Subject: [PATCH 1/4] Created ground-work for email implementation --- Gemfile | 2 +- Gemfile.lock | 80 ++++++++++++++-------------- app/mailers/application_mailer.rb | 4 ++ app/mailers/user_mailer.rb | 9 ++++ app/views/layouts/mailer.html.slim | 3 ++ app/views/layouts/mailer.text.slim | 1 + app/views/user_mailer/email.text.erb | 9 ++++ db/schema.rb | 14 ----- 8 files changed, 67 insertions(+), 55 deletions(-) create mode 100644 app/mailers/application_mailer.rb create mode 100644 app/mailers/user_mailer.rb create mode 100644 app/views/layouts/mailer.html.slim create mode 100644 app/views/layouts/mailer.text.slim create mode 100644 app/views/user_mailer/email.text.erb diff --git a/Gemfile b/Gemfile index ad4fc0b..4383e62 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ ruby '2.3.6' gem 'rails', '4.2.7' # Use PostgreSQL as the database for Active Record -gem 'pg' +gem 'pg','~> 0.18' # Nested Forms gem 'cocoon' diff --git a/Gemfile.lock b/Gemfile.lock index 3e5a926..af5435f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,10 +38,10 @@ GEM tzinfo (~> 1.1) arel (6.0.4) ast (2.4.0) - autoprefixer-rails (7.2.5) + autoprefixer-rails (9.1.3) execjs - bcrypt (3.1.11) - better_errors (2.4.0) + bcrypt (3.1.12) + better_errors (2.5.0) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -55,8 +55,8 @@ GEM bootswatch-rails (3.3.5) railties (>= 3.1) builder (3.2.3) - byebug (10.0.0) - cancancan (2.1.3) + byebug (10.0.2) + cancancan (2.2.0) cocoon (1.2.11) coderay (1.1.2) coffee-rails (4.1.1) @@ -67,36 +67,36 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.0.5) - crass (1.0.3) + crass (1.0.4) daemons (1.2.6) debug_inspector (0.0.3) - devise (4.4.1) + devise (4.5.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) - erubi (1.7.0) + erubi (1.7.1) erubis (2.7.0) eventmachine (1.0.9.1) execjs (2.7.0) - faker (1.8.7) + faker (1.9.1) i18n (>= 0.7) - ffi (1.9.18) + ffi (1.9.25) globalid (0.4.1) activesupport (>= 4.2.0) - i18n (0.9.3) + i18n (0.9.5) concurrent-ruby (~> 1.0) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) - jquery-rails (4.3.1) + jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.6) - kgio (2.11.1) - loofah (2.1.1) + kgio (2.11.2) + loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.0) @@ -109,28 +109,28 @@ GEM skinny (~> 0.2.3) sqlite3 (~> 1.3) thin (~> 1.5.0) - mini_mime (1.0.0) + mini_mime (1.0.1) mini_portile2 (2.3.0) minitest (5.11.3) - momentjs-rails (2.17.1) + momentjs-rails (2.20.1) railties (>= 3.1) multi_json (1.13.1) - nokogiri (1.8.2) + nokogiri (1.8.4) mini_portile2 (~> 2.3.0) orm_adapter (0.5.0) parallel (1.12.1) - parser (2.4.0.2) - ast (~> 2.3) + parser (2.5.1.2) + ast (~> 2.4.0) pdf-core (0.7.0) - pg (1.0.0) - powerpack (0.1.1) + pg (0.21.0) + powerpack (0.1.2) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - rack (1.6.8) - rack-protection (1.5.3) + rack (1.6.10) + rack-protection (1.5.5) rack rack-test (0.6.3) rack (>= 1.0) @@ -151,8 +151,8 @@ GEM activesupport (>= 4.2.0, < 5.0) nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging @@ -166,8 +166,8 @@ GEM rainbow (2.2.2) rake raindrops (0.19.0) - rake (12.3.0) - rb-fsevent (0.10.2) + rake (12.3.1) + rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) rdoc (4.3.0) @@ -182,8 +182,8 @@ GEM rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) - sass (3.5.5) + ruby-progressbar (1.10.0) + sass (3.5.7) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -213,7 +213,7 @@ GEM slim (~> 3.0) spring (2.0.2) activesupport (>= 4.2) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) @@ -230,15 +230,15 @@ GEM thread_safe (0.3.6) tilt (2.0.8) ttfunk (1.5.1) - turbolinks (5.1.0) - turbolinks-source (~> 5.1) - turbolinks-source (5.1.0) - tzinfo (1.2.4) + turbolinks (5.2.0) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.5) + uglifier (4.1.18) execjs (>= 0.3.0, < 3) - unicode-display_width (1.3.0) - unicorn (5.4.0) + unicode-display_width (1.4.0) + unicorn (5.4.1) kgio (~> 2.6) raindrops (~> 0.7) unicorn-rails (2.2.1) @@ -272,7 +272,7 @@ DEPENDENCIES json mailcatcher momentjs-rails (>= 2.9.0) - pg + pg (~> 0.18) prawn prawn-table rails (= 4.2.7) @@ -296,4 +296,4 @@ RUBY VERSION ruby 2.3.6p384 BUNDLED WITH - 1.16.1 + 1.16.2 diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000..d25d889 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout 'mailer' +end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb new file mode 100644 index 0000000..bef4841 --- /dev/null +++ b/app/mailers/user_mailer.rb @@ -0,0 +1,9 @@ +class UserMailer < ApplicationMailer + default from: 'faltas@cjr.org.br' + + def welcome_email + @user = params[:user] + @url = 'http://example.com/login' + mail(to: email do diogo, subject: 'Falta ou Atraso') + end +end diff --git a/app/views/layouts/mailer.html.slim b/app/views/layouts/mailer.html.slim new file mode 100644 index 0000000..e17dcf6 --- /dev/null +++ b/app/views/layouts/mailer.html.slim @@ -0,0 +1,3 @@ +html + body + = yield diff --git a/app/views/layouts/mailer.text.slim b/app/views/layouts/mailer.text.slim new file mode 100644 index 0000000..0a90f09 --- /dev/null +++ b/app/views/layouts/mailer.text.slim @@ -0,0 +1 @@ += yield diff --git a/app/views/user_mailer/email.text.erb b/app/views/user_mailer/email.text.erb new file mode 100644 index 0000000..35bbb50 --- /dev/null +++ b/app/views/user_mailer/email.text.erb @@ -0,0 +1,9 @@ +Olá Diogo +<% require 'date' %> + + +O membro: <%= @user.name %>. + +Chegou <%= %>. + +Thanks for joining and have a great day! diff --git a/db/schema.rb b/db/schema.rb index 9ebd04f..c8e00f1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -16,20 +16,6 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "bootsy_image_galleries", force: :cascade do |t| - t.integer "bootsy_resource_id" - t.string "bootsy_resource_type" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "bootsy_images", force: :cascade do |t| - t.string "image_file" - t.integer "image_gallery_id" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "discussions", force: :cascade do |t| t.text "content" t.integer "record_id" From 17dd9965d58415248d701805dcf25979960dc09a Mon Sep 17 00:00:00 2001 From: Gabriel Porto Oliveira Date: Wed, 29 Aug 2018 12:32:56 -0300 Subject: [PATCH 2/4] Just to make sure email is being sent --- app/controllers/records_controller.rb | 153 +++++++++++++------------- app/mailers/user_mailer.rb | 5 +- app/views/user_mailer/email.html.erb | 11 ++ app/views/user_mailer/email.text.erb | 12 +- 4 files changed, 99 insertions(+), 82 deletions(-) create mode 100644 app/views/user_mailer/email.html.erb diff --git a/app/controllers/records_controller.rb b/app/controllers/records_controller.rb index 3d230a4..aa2a899 100644 --- a/app/controllers/records_controller.rb +++ b/app/controllers/records_controller.rb @@ -1,90 +1,95 @@ class RecordsController < ApplicationController + require 'date' + load_and_authorize_resource - load_and_authorize_resource + respond_to :html, :js, :json + before_action :set_record, only: [:show, :edit, + :update, :destroy, + :download, :print_view] - respond_to :html, :js, :json - before_action :set_record, only: [:show, :edit, - :update, :destroy, - :download, :print_view] - - # GET /records - def index - @records = Record.all.order(:updated_at) - end + # GET /records + def index + @records = Record.all.order(:updated_at) + end - # GET /records/1/download - def download - send_file view_context.download_record(@record) - end + # GET /records/1/download + def download + send_file view_context.download_record(@record) + end - # GET /records/1/print_view - def print_view - end + # GET /records/1/print_view + def print_view + end - # GET /records/1 - # GET /records/1.json - def show - end + # GET /records/1 + # GET /records/1.json + def show + end - # GET /records/new - def new - respond_modal_with @record = Record.new - end + # GET /records/new + def new + respond_modal_with @record = Record.new + end - # GET /records/1/edit - def edit - end + # GET /records/1/edit + def edit + end - # POST /records - # POST /records.json - def create - @record = Record.new(record_params) + # POST /records + # POST /records.json + def create + @record = Record.new(record_params) - respond_to do |format| - if @record.save - presente_id = Status.find_by(name: 'Presente').id - @record.sector.users.each do |user| - RecordsUser.create(user_id: user.id, record_id: @record.id, status_id: presente_id) + respond_to do |format| + if @record.save + presente_id = Status.find_by(name: 'Presente').id + faltou_id = Status.find_by(name:'Falta').id + atrasou_id = Status.find_by(name:'Atraso').id + if faltou_id!=nil || atrasou_id !=nil + UserMailer.with(user: @user).welcome_email.deliver_now + end + @record.sector.users.each do |user| + RecordsUser.create(user_id: user.id, record_id: @record.id, status_id: presente_id) + end + format.html { redirect_to edit_record_path(@record), notice: 'A ata foi criada com sucesso!' } + end + end end - format.html { redirect_to edit_record_path(@record), notice: 'A ata foi criada com sucesso!' } - end - end - end - # PATCH/PUT /records/1 - # PATCH/PUT /records/1.json - def update - respond_to do |format| - if @record.update_attributes(record_params) - @record.update_attribute(:updated_at, Time.now) - format.html { redirect_to record_path(@record), notice: 'A ata foi atualizada com sucesso!' } - end - end - end + # PATCH/PUT /records/1 + # PATCH/PUT /records/1.json + def update + respond_to do |format| + if @record.update_attributes(record_params) + @record.update_attribute(:updated_at, Time.now) + format.html { redirect_to record_path(@record), notice: 'A ata foi atualizada com sucesso!' } + end + end + end - # DELETE /records/1 - # DELETE /records/1.json - def destroy - respond_to do |format| - if @record.destroy - format.html { redirect_to records_path, notice: 'A ata foi excluída com sucesso!' } - end - end - end + # DELETE /records/1 + # DELETE /records/1.json + def destroy + respond_to do |format| + if @record.destroy + format.html { redirect_to records_path, notice: 'A ata foi excluída com sucesso!' } + end + end + end - private - # Use callbacks to share common setup or constraints between actions. - def set_record - @record = Record.find(params[:id]) - end + private + # Use callbacks to share common setup or constraints between actions. + def set_record + @record = Record.find(params[:id]) + end - # Never trust parameters from the scary internet, only allow the white list through. - def record_params - params.require(:record).permit(:date, - :sector_id, - :number, - :discussion, - records_users_attributes: [:id, :user_id, :status_id, :_destroy]) - end + # Never trust parameters from the scary internet, only allow the white list through. + def record_params + params.require(:record).permit(:date, + :sector_id, + :number, + :discussion, + records_users_attributes: [:id, :user_id, :status_id, :_destroy]) + end -end + end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index bef4841..7e0752d 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -2,8 +2,7 @@ class UserMailer < ApplicationMailer default from: 'faltas@cjr.org.br' def welcome_email - @user = params[:user] - @url = 'http://example.com/login' - mail(to: email do diogo, subject: 'Falta ou Atraso') + + mail(to: 'gabrielporto@cjr.org.br', subject: 'Falta ou Atraso') end end diff --git a/app/views/user_mailer/email.html.erb b/app/views/user_mailer/email.html.erb new file mode 100644 index 0000000..1ef7e51 --- /dev/null +++ b/app/views/user_mailer/email.html.erb @@ -0,0 +1,11 @@ +Olá Diogo + + + O membro: <%= @user.name %> + + <% if faltou_id== nil && atrasou_id!=nil + status="Chegou atrasado" + end if faltou_id!= nil && atrasou_id==nil + status = "Faltou" + end%> + <%=status%>. diff --git a/app/views/user_mailer/email.text.erb b/app/views/user_mailer/email.text.erb index 35bbb50..1ef7e51 100644 --- a/app/views/user_mailer/email.text.erb +++ b/app/views/user_mailer/email.text.erb @@ -1,9 +1,11 @@ Olá Diogo -<% require 'date' %> -O membro: <%= @user.name %>. + O membro: <%= @user.name %> -Chegou <%= %>. - -Thanks for joining and have a great day! + <% if faltou_id== nil && atrasou_id!=nil + status="Chegou atrasado" + end if faltou_id!= nil && atrasou_id==nil + status = "Faltou" + end%> + <%=status%>. From 61d79b682b64c89b523d6efddfa985fb0d885f5b Mon Sep 17 00:00:00 2001 From: Gabriel Porto Oliveira Date: Mon, 17 Sep 2018 18:19:53 -0300 Subject: [PATCH 3/4] =?UTF-8?q?Ultimas=20mudan=C3=A7as?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 3 + app/controllers/records_controller.rb | 38 ++++++++++-- app/jobs/email_job.rb | 8 +++ app/mailers/user_mailer.rb | 58 +++++++++++++++-- app/views/user_mailer/email.html.erb | 12 +--- app/views/user_mailer/email.text.erb | 12 +--- config/environments/development.rb | 89 +++++++++++++++------------ config/environments/production.rb | 5 +- db/seeds.rb | 5 +- 9 files changed, 157 insertions(+), 73 deletions(-) create mode 100644 app/jobs/email_job.rb diff --git a/Gemfile b/Gemfile index 4383e62..a65750d 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,9 @@ gem 'pg','~> 0.18' # Nested Forms gem 'cocoon' +#Heroku +gem 'figaro' + # Geração de PDF gem 'prawn' gem 'prawn-table' diff --git a/app/controllers/records_controller.rb b/app/controllers/records_controller.rb index aa2a899..7b7a625 100644 --- a/app/controllers/records_controller.rb +++ b/app/controllers/records_controller.rb @@ -43,13 +43,13 @@ def create respond_to do |format| if @record.save presente_id = Status.find_by(name: 'Presente').id - faltou_id = Status.find_by(name:'Falta').id - atrasou_id = Status.find_by(name:'Atraso').id - if faltou_id!=nil || atrasou_id !=nil - UserMailer.with(user: @user).welcome_email.deliver_now - end + + @record.sector.users.each do |user| + + RecordsUser.create(user_id: user.id, record_id: @record.id, status_id: presente_id) + end format.html { redirect_to edit_record_path(@record), notice: 'A ata foi criada com sucesso!' } end @@ -61,6 +61,34 @@ def create def update respond_to do |format| if @record.update_attributes(record_params) + + falta_id = Status.find_by(name: 'Falta').id + atraso_id = Status.find_by(name: 'Atraso').id + @records_user = RecordsUser.where(record_id: @record.id) + admin = User.all + + teste=0 + + @records_user.each do |record_user| + + + + if record_user.status_id === falta_id || record_user.status_id === atraso_id + + admin.each do |admin| + + if admin.role_id ===1 + + EmailJob.perform_later(record_user.id,record_user.user_id,admin.email) + + end + + end + + end + + + end @record.update_attribute(:updated_at, Time.now) format.html { redirect_to record_path(@record), notice: 'A ata foi atualizada com sucesso!' } end diff --git a/app/jobs/email_job.rb b/app/jobs/email_job.rb new file mode 100644 index 0000000..df9f054 --- /dev/null +++ b/app/jobs/email_job.rb @@ -0,0 +1,8 @@ +class EmailJob < ActiveJob::Base + queue_as :default + + def perform(id,record_user,admin) + UserMailer.email(id,record_user,admin).deliver_now + + end +end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 7e0752d..3f45d8c 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,8 +1,56 @@ class UserMailer < ApplicationMailer - default from: 'faltas@cjr.org.br' + default from: ENV["GMAIL_USERNAME"] - def welcome_email - - mail(to: 'gabrielporto@cjr.org.br', subject: 'Falta ou Atraso') - end + def email(id,user_id,email) + + falta_id = Status.find_by(name: 'Falta').id + atraso_id = Status.find_by(name: 'Atraso').id + noe_id = Sector.find_by(short_name: 'NOE').id + ndp_id = Sector.find_by(short_name: 'NDP').id + nam_id = Sector.find_by(short_name: 'NAM').id + nut_id = Sector.find_by(short_name: 'NUT').id + pc_id = Sector.find_by(short_name: 'PC').id + cjr_id = Sector.find_by(short_name: 'CJR').id + + @records_user = RecordsUser.all.find(id) + puts record_id = @records_user.record_id + @records = Record.all.find(record_id) + @date= Time.now + + + + @user = User.all.find(user_id) + status = @records_user.status_id + case @records.sector_id + when noe_id + @sector = "NOE" + when ndp_id + @sector = "NDP" + when nam_id + @sector = "NAM" + when nut_id + @sector= "NUT" + when pc_id + @sector= "PC" + when cjr_id + @sector = "CJR" + end + + + + if status === falta_id + @msg = "faltou" + elsif status === atraso_id + @msg = "atrasou" + end + + assunto = @user.name + " "+@msg +" a reunião da/do "+ @sector + + + + + mail(to: email , subject: assunto,charset:'UTF-8') + + + end end diff --git a/app/views/user_mailer/email.html.erb b/app/views/user_mailer/email.html.erb index 1ef7e51..dfa306d 100644 --- a/app/views/user_mailer/email.html.erb +++ b/app/views/user_mailer/email.html.erb @@ -1,11 +1,3 @@ -Olá Diogo +Olá, - - O membro: <%= @user.name %> - - <% if faltou_id== nil && atrasou_id!=nil - status="Chegou atrasado" - end if faltou_id!= nil && atrasou_id==nil - status = "Faltou" - end%> - <%=status%>. +O membro: <%= @user.name %> <%= @msg%> para a reunião da <%=@sector %> no dia e hora <%=@date%> diff --git a/app/views/user_mailer/email.text.erb b/app/views/user_mailer/email.text.erb index 1ef7e51..05b8d72 100644 --- a/app/views/user_mailer/email.text.erb +++ b/app/views/user_mailer/email.text.erb @@ -1,11 +1,3 @@ -Olá Diogo +Olá - - O membro: <%= @user.name %> - - <% if faltou_id== nil && atrasou_id!=nil - status="Chegou atrasado" - end if faltou_id!= nil && atrasou_id==nil - status = "Faltou" - end%> - <%=status%>. +O membro: <%= @user.name %> <%= @msg%> para a reunião da <%=@sector%> no dia e hora <%=@date%> diff --git a/config/environments/development.rb b/config/environments/development.rb index 91dc197..afb5279 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,42 +1,53 @@ Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.cache_classes = false - - # Do not eager load code on boot. - config.eager_load = false - - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - - # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false - - # Print deprecation notices to the Rails logger. - config.active_support.deprecation = :log - - # Raise an error on page load if there are pending migrations. - config.active_record.migration_error = :page_load - - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true - - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true - - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + config.action_mailer.delivery_method = :smtp + # SMTP settings for gmail + config.action_mailer.smtp_settings = { + :address => "smtp.gmail.com", + :port => 587, + :domain => 'cjr.org.br', + :user_name => ENV["GMAIL_USERNAME"], + :password => ENV["GMAIL_PASSWORD"], + :authentication => :plain, + :enable_starttls_auto => true + } end diff --git a/config/environments/production.rb b/config/environments/production.rb index 3987d57..e19e432 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -87,9 +87,10 @@ address: "smtp.gmail.com", port: 587, authentication: :plain, - domain: 'gmail.com', + domain: 'cjr.org.br', user_name: ENV["GMAIL_USERNAME"], - password: ENV["GMAIL_PASSWORD"] + password: ENV["GMAIL_PASSWORD"], + :enable_starttls_auto => true } end diff --git a/db/seeds.rb b/db/seeds.rb index 2b633d3..71d5c6c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -12,7 +12,7 @@ { name: 'Núcleo de Talentos', short_name: 'NUT'}, { name: 'Pequeno Conselho', short_name: 'PC'}, { name: 'Empresa Júnior de Computação', short_name: 'CJR'}] - + Sector.create(nucleos) status = [{ name: 'Presente' }, { name: 'Falta' }, { name: 'Falta Justificada' }, { name: 'Atraso' } ] @@ -22,4 +22,5 @@ admin = Role.create(name: 'Administrador') usuario_comum = Role.create(name: 'Usuário Comum') -User.create(name: 'Administrador', email: 'admin@cjr.org.br', password: 'admincjr', role_id: admin.id) +User.create(name: 'Administrador', email: 'admincjr@cjr.org.br', password: 'admincjr', role_id: admin.id) +User.create(name: 'Usuário Comum', email: 'comum@comum.com',password:'teste123',role_id: usuario_comum.id) From b28c8eeb3a27a51632dd5b33b885932c2c46d66d Mon Sep 17 00:00:00 2001 From: Gabriel Porto Oliveira Date: Wed, 10 Oct 2018 17:13:11 -0300 Subject: [PATCH 4/4] gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5b61ab0..7fc858d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ /log/* !/log/.keep /tmp + +config/application\.yml