diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 1eebfdd..3e05b51 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -40,7 +40,7 @@ def get_options(settings) address: settings.address, port: settings.port, domain: settings.domain, - authentication: 'plain', + authentication: 'login', enable_starttls_auto: true } end diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb new file mode 100644 index 0000000..5ad93f8 --- /dev/null +++ b/app/models/admin_user.rb @@ -0,0 +1,5 @@ +class AdminUser < ApplicationRecord + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable +end diff --git a/app/models/mail_setting.rb b/app/models/mail_setting.rb deleted file mode 100644 index dfea94f..0000000 --- a/app/models/mail_setting.rb +++ /dev/null @@ -1,8 +0,0 @@ -class MailSetting < ApplicationRecord - belongs_to :account - - def all_present? - from_email.present? && address.present? && port.present? && - domain.present? && address.present? && user_name.present? - end -end diff --git a/app/views/home/documentation.html.erb b/app/views/home/documentation.html.erb index e69de29..588b2b8 100644 --- a/app/views/home/documentation.html.erb +++ b/app/views/home/documentation.html.erb @@ -0,0 +1,83 @@ +
+
+

Smart Email Marketing

+

A simple dockerized rails app to manage your emails and campaigns with taggings.

+

Code Climate

+ +

Installation

+

Install Docker

+

Install the most recent version of the Docker Engine for your platform using the official Docker releases, which can also be installed using:

+
wget -qO- https://get.docker.com/ | sh
+  
+

Install Docker Compose

+

Install docker compose from the official page.

+
curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
+  chmod +x /usr/local/bin/docker-compose
+  
+

Database Settings

+

You can use sqlite, postgresql, mysql and sql server.

+

Create a database.yml and link it in the docker-compose.yml

+

Create data folders

+
mkdir -p /datadrive/csv-files && mkdir -p /datadrive/data/db && mkdir -p /datadrive/data/redis && mkdir -p /datadrive/data/nginx && mkdir -p /datadrive/working-dir
+  
+

Create a database.yml

+ +
cd /datadrive && wget https://raw.githubusercontent.com/mojilala/smart-emailing/master/config/database.yml
+  
+ +
cd /datadrive && wget https://raw.githubusercontent.com/mojilala/smart-emailing/master/config/database_mysql.example.yml
+  
+ +
cd /datadrive && wget https://raw.githubusercontent.com/mojilala/smart-emailing/master/config/database_postgresql.example.yml
+  
+ +
cd /datadrive && wget https://raw.githubusercontent.com/mojilala/smart-emailing/master/config/database_azure_sql.example.yml
+  
+

Create nginx settings

+
cd /datadrive/data/nginx && wget https://raw.githubusercontent.com/mojilala/smart-emailing/master/nginx/my_proxy.conf
+  
+

Get docker-compose.yml

+ +
cd /datadrive/working-dir && wget https://raw.githubusercontent.com/mojilala/smart-emailing/master/docker-compose.yml
+  
+ +

Run

+
sudo docker-compose build
+  sudo docker-compose run web rake db:migrate
+  sudo docker-compose up -d
+  
+

Tests

+

We used the tool very day, so we test on production :)
+ There are no tests. any test contrubtions are verywelcome.

+

Contributing

+
    +
  1. Fork it
  2. +
  3. Create your feature branch (git checkout -b my-new-feature)
  4. +
  5. Commit your changes (git commit -am 'Add some feature')
  6. +
  7. Push to the branch (git push origin my-new-feature)
  8. +
  9. Create new Pull Request
  10. +
+

Created by

+ +

Developed by

+ +
+
+ diff --git a/app/views/imap_settings/_form.html.haml b/app/views/imap_settings/_form.html.haml index 63ff0cd..541f549 100644 --- a/app/views/imap_settings/_form.html.haml +++ b/app/views/imap_settings/_form.html.haml @@ -10,10 +10,10 @@ .field = f.label 'IMAP address' - = f.text_field :address, class: 'form-control' + = f.text_field :address, class: 'form-control', placeholder: 'outlook.office365.com' .field = f.label :port - = f.text_field :port, class: 'form-control', required: true + = f.text_field :port, class: 'form-control', required: true, placeholder: '993' .field = f.label :email = f.select :email, options_for_select(current_account.smtp_settings.pluck(:reply_to).uniq), { include_blank: false }, { class: 'form-control' } diff --git a/app/views/inbox/_detail.html.haml b/app/views/inbox/_detail.html.haml index f28c541..85cfb3d 100644 --- a/app/views/inbox/_detail.html.haml +++ b/app/views/inbox/_detail.html.haml @@ -28,22 +28,22 @@ = render partial: 'tags/item_tags', locals: { item: campaign_user } - if campaign_users.count < 1 %p.text-center.text-danger Campaign User Not Found! - - .row - .panel.panel-default - .panel-heading - User Attributes - .panel-body - %table.table-bordered.table-condensed - %thead - %tr - %td Attribute - %td Value - %tbody - - user.user_attributes.each do |attr| + - if user.user_attributes.present? + .row + .panel.panel-default + .panel-heading + User Attributes + .panel-body + %table.table-bordered.table-condensed + %thead %tr - %td= attr.key - %td= attr.value + %td Attribute + %td Value + %tbody + - user.user_attributes.each do |attr| + %tr + %td= attr.key + %td= attr.value diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 6881b11..adc102d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -74,7 +74,7 @@ Sidekiq %li %a{:href => 'https://github.com/svtek/smart-emailing', :target => '_blank'} - %img{:alt => "Known Vulnerabilities", "data-canonical-src" => "https://snyk.io/test/github/svtek/smart-emailing", :src => "http://github-release-version.herokuapp.com/github/svtek/smart-emailing/release.svg?style=flat", :style => "max-width:100%;"}/ + %img{:alt => "Known Vulnerabilities", :src => "https://img.shields.io/github/release/svtek/smart-emailing.svg?maxAge=2592000", :style => "max-width:100%;"}/ / top navigation .top_nav diff --git a/app/views/layouts/welcome.html.haml b/app/views/layouts/welcome.html.haml index 6997a0c..b219373 100644 --- a/app/views/layouts/welcome.html.haml +++ b/app/views/layouts/welcome.html.haml @@ -36,6 +36,6 @@ .row .col-lg-12 .col-md-6.text-left - %img{:alt => "Known Vulnerabilities", "data-canonical-src" => "https://snyk.io/test/github/svtek/smart-emailing", :src => "http://github-release-version.herokuapp.com/github/svtek/smart-emailing/release.svg?style=flat", :style => "max-width:100%;"}/ + %img{:alt => "Known Vulnerabilities", :src => "https://img.shields.io/github/release/svtek/smart-emailing.svg?maxAge=2592000", :style => "max-width:100%;"}/ .col-md-6.text-right %p.copyright.text-muted.small Copyright © 2017. All Rights Reserved diff --git a/app/views/smtp_settings/_form.html.haml b/app/views/smtp_settings/_form.html.haml index 55a582a..8e78fa6 100644 --- a/app/views/smtp_settings/_form.html.haml +++ b/app/views/smtp_settings/_form.html.haml @@ -14,22 +14,22 @@ .field = f.label :from_email - = f.text_field :from_email, class: 'form-control', required: true + = f.text_field :from_email, class: 'form-control', required: true, placeholder: 'email@example.com' .field = f.label :reply_to - = f.text_field :reply_to, class: 'form-control', required: true + = f.text_field :reply_to, class: 'form-control', required: true, placeholder: 'support@example.com' .field = f.label :provider - = f.text_field :provider, class: 'form-control', required: true + = f.text_field :provider, class: 'form-control', required: true, placeholder: 'sendgrid, google, outlook etc...' .field = f.label :address - = f.text_field :address, class: 'form-control', required: true + = f.text_field :address, class: 'form-control', required: true, placeholder: 'smtp.sendgrid.net' .field = f.label :port - = f.text_field :port, class: 'form-control', required: true + = f.text_field :port, class: 'form-control', required: true, placeholder: '587' .field = f.label :domain - = f.text_field :domain, class: 'form-control', required: true + = f.text_field :domain, class: 'form-control', required: true, placeholder: 'email-domain.com' .field = f.label :username = f.text_field :username, class: 'form-control', required: true diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index 7a34bf8..3469ce9 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -3,9 +3,9 @@ ## == Devise == config.authenticate_with do - warden.authenticate! scope: :account + warden.authenticate! scope: :admin_user end - config.current_user_method(&:current_account) + config.current_user_method(&:current_admin_user) ## == Cancan == # config.authorize_with :cancan diff --git a/config/routes.rb b/config/routes.rb index b9a6480..bae5a65 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,8 @@ Rails.application.routes.draw do + + devise_for :admin_users mount RailsAdmin::Engine => '/admin', as: 'rails_admin' + devise_for :accounts authenticated :account do diff --git a/db/migrate/20170704205043_devise_create_admin_users.rb b/db/migrate/20170704205043_devise_create_admin_users.rb new file mode 100644 index 0000000..d36d4b0 --- /dev/null +++ b/db/migrate/20170704205043_devise_create_admin_users.rb @@ -0,0 +1,42 @@ +class DeviseCreateAdminUsers < ActiveRecord::Migration[5.0] + def change + create_table :admin_users do |t| + ## Database authenticatable + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, default: 0, null: false + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + + t.timestamps null: false + end + + add_index :admin_users, :email, unique: true + add_index :admin_users, :reset_password_token, unique: true + # add_index :admin_users, :confirmation_token, unique: true + # add_index :admin_users, :unlock_token, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index b8c25ea..576fd88 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170703122535) do +ActiveRecord::Schema.define(version: 20170704205043) do create_table "accounts", force: :cascade do |t| t.string "email", default: "", null: false @@ -32,6 +32,23 @@ t.index ["email"], name: "index_accounts_on_email", unique: true end + create_table "admin_users", force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", default: 0, null: false + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["email"], name: "index_admin_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true + end + create_table "campaign_users", force: :cascade do |t| t.integer "campaign_id" t.integer "user_id"