Skip to content

Commit

Permalink
Merge branch 'release/v1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
sadikay committed Jul 21, 2017
2 parents bf497e7 + 0b54396 commit 7908ff7
Show file tree
Hide file tree
Showing 56 changed files with 663 additions and 691 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0
2.3.3
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ sudo docker-compose build
sudo docker-compose run web rake db:migrate
sudo docker-compose up -d
```
### Configure Sendgrid
If you are using sendgrid as email provider, you will be able to
get status of sent emails.


Go to: https://app.sendgrid.com/settings/mail_settings ->
Event Notification -> `<yourhost.com>`/campaigns/event_receiver

## Tests
We used the tool very day, so we test on production :)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require bootstrap-sprockets
//= require editable/bootstrap-editable
//= require editable/rails
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@

.btn-info { background-color: #2b9cbd; }

.large-data-table {
display: block;
overflow-x: auto;
}
12 changes: 12 additions & 0 deletions app/controllers/api/v1/api_base_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Api::V1::ApiBaseController < ActionController::API
include ActionController::HttpAuthentication::Token::ControllerMethods

before_filter :authenticate

protected
def authenticate
authenticate_or_request_with_http_token do |token, _options|
@api_account = Account.find_by(authentication_token: token)
end
end
end
33 changes: 33 additions & 0 deletions app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Api::V1::UsersController < Api::V1::ApiBaseController
# Creates User.
# Create a user for authenticated account.
# == Example Request
# curl -i -H "Authorization: Token token=7LGWItoVYJmjCAMbdRHTSAtt" -X POST -d "user[name]=API User" -d "user[email]=email@api.com" -d "user[tag_list]= tester, new user" -d "attributes[phone]=+123456456" -d "attributes[custom_key]=custom_value" http://localhost:3000/api/v1/users
# == Request Type:
# POST
# == Parameters:
# [String] user[email] User's email (required)
# [String] user[name] User's name (optional)
# [String] user[tag_list] User's tags (optional)
# [String] attributes[key] User's attributes (optional)
def create
user = @api_account.users.new(user_params)
if user.save
if params[:attributes].present?
params[:attributes].keys.each do |key|
user.user_attributes.create(key: key, value: params[:attributes][key])
end
end
render json: {
user: user.attributes.merge(tags: user.tag_list, atributes: user.user_attributes.pluck(:key, :value) )
}, status: 200
else
render json: { errors: user.errors.messages }, status: 422
end
end

# Requiered Paramaters for create a User
def user_params
params.require(:user).permit(:name, :email, :tag_list)
end
end
1 change: 0 additions & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ class HomeController < ApplicationController

def index; end

def documentation; end
end
8 changes: 4 additions & 4 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class NotesController < ApplicationController

# GET /notes
def index
@notes = Note.all
@notes = current_account.notes.all
end

# GET /notes/1
Expand All @@ -12,7 +12,7 @@ def show

# GET /notes/new
def new
@note = Note.new
@note = current_account.notes.new
end

# GET /notes/1/edit
Expand All @@ -21,7 +21,7 @@ def edit

# POST /notes
def create
@note = Note.new(note_params)
@note = current_account.notes.new(note_params)

respond_to do |format|
if @note.save
Expand Down Expand Up @@ -54,7 +54,7 @@ def destroy
private
# Use callbacks to share common setup or constraints between actions.
def set_note
@note = Note.find(params[:id])
@note = current_account.notes.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/user_attributes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ class UserAttributesController < ApplicationController
helper_method :xeditable?
before_action :set_user

def index; end

def create
@attribute = @user.user_attributes.create(attribute_params)
end
Expand Down
12 changes: 11 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,35 @@ class UsersController < ApplicationController

def index
@q = current_account.users.includes(:user_attributes, :campaigns, :campaign_users, :tags)
.ransack(params[:q])
.ransack(params[:q])
@q.build_grouping unless @q.groupings.any?
@q.sorts = 'created_at DESC' if @q.sorts.empty?

@users = ransack_results_with_limit
@associations = [:tags, :user_attributes, :campaign_users, :campaign_users_tags, :campaigns, :campaigns_tags]
@total_user_count = @users.total_count

@user_attribute_keys = UserAttribute.joins(:user).where('users.account_id = ?', current_account.id).select('DISTINCT key').order('key ASC').map(&:key)

respond_to do |format|
format.html
format.xlsx { render xlsx: 'download', filename: "Users-#{Time.now.strftime("%Y%m%d%H%M")}.xlsx", locals: { users: users_to_export } }
format.csv { send_data users_to_export.to_csv_file, filename: "Users-#{Time.now.strftime("%Y%m%d%H%M")}.csv" }
end
end

def detailed_list
index
end

def new; end

def import; end

def show
@user = current_account.users.find(params[:id])
end

def create
if params[:file].present? && params[:tags].present?

Expand Down
10 changes: 10 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ def link_to_add_fields(name, f, type)
end
link_to(name, '#', class: 'add_fields', data: { id: id, fields: fields.delete("\n") })
end

def xeditable?(arg)
true
end

def page_title(title)
content_for :page_title do
title
end
end
end
16 changes: 16 additions & 0 deletions app/helpers/campaigns_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
module CampaignsHelper
def status_card(display_text, count, status_percent)
content_tag :div, class: 'col-md-2 col-sm-4 col-xs-6 tile_stats_count' do
(content_tag :span, class: 'count_top' do
concat (display_text)
end) +

(content_tag :div, class: 'count' do
count.to_s
end) +

(content_tag :span, class: 'count_bottom' do
content_tag :i, class: 'content'
"#{status_percent} %"
end)
end
end
end
7 changes: 7 additions & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ class Account < ApplicationRecord
has_many :smtp_settings
has_many :imap_settings
has_many :notes

before_create :set_authentication_token

private
def set_authentication_token
self.authentication_token = Devise.friendly_token
end
end
15 changes: 15 additions & 0 deletions app/views/campaign_users/_index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%table.table.table-bordered
%thead
%tr
%th Campaign
%th Status
%th Tags

%tbody
- user.campaign_users.each do |cu|
%tr
%td= link_to cu.campaign.name, cu.campaign
%td= cu.status
%td
%div{id: "CampaignUserTags-#{cu.id}"}
= render partial: 'tags/item_tags', locals: { item: cu }
90 changes: 10 additions & 80 deletions app/views/campaigns/_stats.html.haml
Original file line number Diff line number Diff line change
@@ -1,94 +1,24 @@
.row.tile_count
.col-md-1
.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Draft Emails
.count= @stats['draft'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['draft'], @total_users_count).to_i} %"
= status_card('Draft', (@stats['draft'] || 0), Campaign.calculate_percent(@stats['draft'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Processed Emails
.count.green= @stats['processed'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['processed'] , @total_users_count).to_i} %"
= status_card('Processed', (@stats['processed'] || 0), Campaign.calculate_percent(@stats['processed'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Dropped Emails
.count= @stats['dropped'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['dropped'] , @total_users_count).to_i} %"
= status_card('Dropped', (@stats['dropped'] || 0), Campaign.calculate_percent(@stats['dropped'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Delivered Emails
.count= @stats['delivered'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['delivered'] , @total_users_count).to_i} %"
= status_card('Delivered', (@stats['delivered'] || 0), Campaign.calculate_percent(@stats['delivered'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Deferred Emails
.count= @stats['deferred'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['deferred'] , @total_users_count).to_i} %"
= status_card('Deferred', (@stats['deferred'] || 0), Campaign.calculate_percent(@stats['deferred'], @total_users_count).to_i)

.row.tile_count
.col-md-1
.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Bounced Emails
.count= @stats['bounce'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['bounce'], @total_users_count).to_i} %"
= status_card('Bounced', (@stats['bounce'] || 0), Campaign.calculate_percent(@stats['bounce'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Opened Emails
.count.green= @stats['open'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['open'] , @total_users_count).to_i} %"
= status_card('Opened', (@stats['open'] || 0), Campaign.calculate_percent(@stats['open'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Clicked Emails
.count= @stats['click'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['click'] , @total_users_count).to_i} %"
= status_card('Clicked', (@stats['click'] || 0), Campaign.calculate_percent(@stats['click'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Spamreport Emails
.count= @stats['spamreport'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['spamreport'] , @total_users_count).to_i} %"
= status_card('Spam', (@stats['spamreport'] || 0), Campaign.calculate_percent(@stats['spamreport'], @total_users_count).to_i)

.col-md-2.col-sm-4.col-xs-6.tile_stats_count
%span.count_top
%i.fa.fa-user
Unsubscribed Emails
.count= @stats['unsubscribe'] || 0
%span.count_bottom
%i.green
= "#{Campaign.calculate_percent(@stats['unsubscribe'] , @total_users_count).to_i} %"
= status_card('Unsubscribed', (@stats['unsubscribe'] || 0), Campaign.calculate_percent(@stats['unsubscribe'], @total_users_count).to_i)
.col-md-1
20 changes: 0 additions & 20 deletions app/views/campaigns/_template_form.html.haml

This file was deleted.

Loading

0 comments on commit 7908ff7

Please sign in to comment.