Skip to content

Commit

Permalink
Merge branch 'release/v1.1.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
sadikay committed Jul 4, 2017
2 parents caefee4 + 74aae6c commit 0768b44
Show file tree
Hide file tree
Showing 57 changed files with 808 additions and 273 deletions.
Binary file modified app/assets/images/campaigns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/assets/images/email-template.png
Binary file not shown.
Binary file added app/assets/images/filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/inbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/assets/images/mj.png
Binary file not shown.
Binary file removed app/assets/images/ss-users.png
Binary file not shown.
Binary file added app/assets/images/template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/users.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ $( document ).ready(function() {
});

function reply_template_select(){
$('#body').text($('#reply_email_template').val());
$('#body').val($('#reply_email_template').val());
}
7 changes: 1 addition & 6 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,5 @@
height: 500px;
}

.jumbotron {
padding-top: 0;
background-color: #2A3F54;
color: #ffffff;
}
.btn-info { background-color: #2b9cbd; }

.btn-info { background-color: #2b9cbd; }
155 changes: 155 additions & 0 deletions app/assets/stylesheets/landing.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
@import "bootstrap-sprockets";
@import "bootstrap";

.jumbotron {
padding-top: 0;
background-color: #2A3F54;
color: #ffffff;
}

// Landing Page CSS
.topnav {
font-size: 14px;
}

.lead {
font-size: 18px;
font-weight: 400;
}

.intro-header {
text-align: center;
color: #f8f8f8;
background-color: #2A3F54;
background-size: cover;
}

.intro-message {
position: relative;
padding-top: 10%;
padding-bottom: 10%;
}

.intro-message > h1 {
margin: 0;
text-shadow: 2px 2px 3px rgba(0,0,0,0.6);
font-size: 5em;
}

.intro-divider {
width: 400px;
border-top: 1px solid #f8f8f8;
border-bottom: 1px solid rgba(0,0,0,0.2);
}

.intro-message > h3 {
text-shadow: 2px 2px 3px rgba(0,0,0,0.6);
}

@media(max-width:767px) {
.intro-message {
padding-bottom: 15%;
}

.intro-message > h1 {
font-size: 3em;
}

ul.intro-social-buttons > li {
display: block;
margin-bottom: 20px;
padding: 0;
}

ul.intro-social-buttons > li:last-child {
margin-bottom: 0;
}

.intro-divider {
width: 100%;
}
}

.network-name {
text-transform: uppercase;
font-size: 14px;
font-weight: 400;
letter-spacing: 2px;
}

.content-section-a {
padding: 50px 0;
background-color: #f8f8f8;
}

.content-section-b {
padding: 50px 0;
border-top: 1px solid #e7e7e7;
border-bottom: 1px solid #e7e7e7;
}

.section-heading {
margin-bottom: 30px;
}

.section-heading-spacer {
float: left;
width: 200px;
border-top: 3px solid #e7e7e7;
}

.banner {
padding: 100px 0;
color: #f8f8f8;
background: url(../img/banner-bg.jpg) no-repeat center center;
background-size: cover;
}

.banner h2 {
margin: 0;
text-shadow: 2px 2px 3px rgba(0,0,0,0.6);
font-size: 3em;
}

.banner ul {
margin-bottom: 0;
}

.banner-social-buttons {
float: right;
margin-top: 0;
}

@media(max-width:1199px) {
ul.banner-social-buttons {
float: left;
margin-top: 15px;
}
}

@media(max-width:767px) {
.banner h2 {
margin: 0;
text-shadow: 2px 2px 3px rgba(0,0,0,0.6);
font-size: 3em;
}

ul.banner-social-buttons > li {
display: block;
margin-bottom: 20px;
padding: 0;
}

ul.banner-social-buttons > li:last-child {
margin-bottom: 0;
}
}

footer {
padding: 50px 0;
background-color: #f8f8f8;
}

p.copyright {
margin: 15px 0 0;
}
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

before_action :authenticate_account!

def set_all_tags
@all_tags = ActsAsTaggableOn::Tag.all.pluck(:name)
end
Expand Down
12 changes: 7 additions & 5 deletions app/controllers/campaigns_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class CampaignsController < ApplicationController
before_action :authenticate_account!, except: :event_receiver
skip_before_action :authenticate_account!, only: :event_receiver
skip_before_action :verify_authenticity_token, only: :event_receiver

before_action :set_campaign, only: [:show, :destroy, :send_emails]
before_action :check_new_campaign_avaibility, :set_all_tags, only: :new
skip_before_action :verify_authenticity_token, only: :event_receiver

def index
@associations = [:users, :tags, :email_template, :campaign_users]
Expand Down Expand Up @@ -57,13 +58,14 @@ def destroy

def send_emails
# Redirect to settings path if account doesn't have settings.
unless current_account.mail_setting.try(:all_present?)
redirect_to settings_path, notice: 'Your settings information are required!'
smtp_settings = current_account.smtp_settings.find_by(id: params[:smtp_id]) || current_account.smtp_settings.default_for_campaigns
if !smtp_settings.present? || !smtp_settings.try(:all_present?)
redirect_to smtp_settings_path, notice: 'Your SMTP settings are required!'
return
end

# Send campaign emails in bg job
SendCampaignEmailsJob.perform_later(@campaign.id)
SendCampaignEmailsJob.perform_later(@campaign.id, smtp_settings.id)

redirect_to campaign_path(@campaign), notice: 'Emails sending in background!'
end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/email_templates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class EmailTemplatesController < ApplicationController
before_action :authenticate_account!
before_action :set_email_template, only: [:show, :edit, :update, :destroy]

def index
Expand Down
23 changes: 4 additions & 19 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
class HomeController < ApplicationController
before_action :authenticate_account!, only: :settings
def index; end

def settings
@settings = current_account.mail_setting
end
layout 'welcome'
skip_before_action :authenticate_account!

def update_settings
if current_account.mail_setting.update(settings_params)
redirect_to settings_path, notice: 'Settings updated successfully!'
else
redirect_to settings_path, notice: 'Error! Settings not updated!'
end
end

private
def index; end

def settings_params
params.require(:settings).permit(:from_email, :reply_to, :address, :port, :domain, :user_name, :password, :provider,
:imap_password, :imap_port, :imap_address, :imap_username)
end
def documentation; end
end
62 changes: 62 additions & 0 deletions app/controllers/imap_settings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
class ImapSettingsController < ApplicationController
before_action :set_imap_setting, only: [:edit, :update, :destroy]

# GET /imap_settings
def index
@imap_settings = current_account.imap_settings.all
end

# GET /imap_settings/new
def new
unless current_account.smtp_settings.present?
redirect_to smtp_settings_path, notice: 'Please define at least one smtp settings to read reply emails of it.'
return
end
@imap_setting = current_account.imap_settings.new
end

# GET /imap_settings/1/edit
def edit
end

# POST /imap_settings
def create
@imap_setting = current_account.imap_settings.new(imap_setting_params)

respond_to do |format|
if @imap_setting.save
format.html { redirect_to imap_settings_path, notice: 'IMAP setting was successfully created.' }
else
format.html { render :new }
end
end
end

# PATCH/PUT /imap_settings/1
def update
respond_to do |format|
if @imap_setting.update(imap_setting_params)
format.html { redirect_to imap_settings_path, notice: 'IMAP setting was successfully updated.' }
else
format.html { render :edit }
end
end
end

# DELETE /imap_settings/1
def destroy
@imap_setting.destroy
respond_to do |format|
format.html { redirect_to imap_settings_url, notice: 'IMAP setting was successfully destroyed.' }
end
end

private
def set_imap_setting
@imap_setting = current_account.imap_settings.find(params[:id])
end

def imap_setting_params
params.require(:imap_setting).permit(:address, :port, :email, :password)
end
end
46 changes: 11 additions & 35 deletions app/controllers/inbox_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
class InboxController < ApplicationController
before_action :authenticate_account!
before_action :set_imap_settings, only: :index
before_action :set_smtp_settings, only: :reply_email

def index
if params[:from].present? && params[:to].present?
Expand All @@ -17,6 +15,7 @@ def detail
@message = params[:message]
@subject = params[:subject]
@email = params[:email]
@has_attach = params[:has_attachments]
@user = current_account.users.find_by(email: @email)

if @user.present?
Expand All @@ -35,53 +34,30 @@ def reply_email
mail_to = params[:mail_to]
mail_body = Tilt::ERBTemplate.new { params[:body] }
content = mail_body.render(current_account.users.find_by(email: params[:mail_to]))
mail_from = current_account.mail_setting.imap_username
smtp_id = current_account.smtp_settings.find_by(id: params[:smtp_id]).try(:id) ||
current_account.smtp_settings.where(is_default_for_campaigns: true).first.try(:id)

Mail.deliver do
from mail_from
to mail_to
subject subject
html_part do
content_type 'text/html; charset=UTF-8'
body content
end
end
UserMailer.reply_email(mail_to, subject, content, smtp_id).deliver_now
end

private

# To read emails
def set_imap_settings
settings = current_account.mail_setting
settings = current_account.imap_settings.find_by(id: params[:imap_id]) || current_account.imap_settings.first

if !settings.imap_address.present? || !settings.imap_port.present? || !settings.imap_password.present? || !settings.imap_username.present?
redirect_to settings_path, notice: 'Please! Add your IMAP Settings to read the messages.'
if !settings.present? || !settings.address.present? || !settings.port.present? || !settings.password.present? || !settings.email.present?
redirect_to imap_settings_path, notice: 'Please! Add your IMAP Settings to read the messages.'
return
end

Mail.defaults do
retriever_method :imap,
:address => settings.imap_address,
:port => settings.imap_port,
:user_name => settings.imap_username,
:password => settings.imap_password,
:address => settings.address,
:port => settings.port,
:user_name => settings.email,
:password => settings.password,
:enable_ssl => true
end
end

# To send email
def set_smtp_settings
settings = current_account.mail_setting

Mail.defaults do
delivery_method :smtp,
user_name: settings.user_name,
password: settings.password,
address: settings.address,
port: settings.port,
domain: settings.domain,
authentication: 'plain',
enable_starttls_auto: true
end
end
end
Loading

0 comments on commit 0768b44

Please sign in to comment.