phcmembers 6.3.4 → 6.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +6 -6
- data/Rakefile +12 -12
- data/app/controllers/phcmembers/api/directories_controller.rb +14 -14
- data/app/controllers/phcmembers/application_controller.rb +15 -15
- data/app/controllers/phcmembers/dashboard/mains_controller.rb +14 -15
- data/app/controllers/phcmembers/directory/categories_controller.rb +65 -63
- data/app/controllers/phcmembers/directory/categorylistings_controller.rb +16 -16
- data/app/controllers/phcmembers/member/addresses_controller.rb +71 -71
- data/app/controllers/phcmembers/member/listings_controller.rb +73 -73
- data/app/controllers/phcmembers/member/profiles_controller.rb +64 -64
- data/config/routes.rb +33 -37
- data/db/migrate/20160707154842_create_versions.rb +38 -36
- data/db/migrate/20160724220339_create_phcmembers_member_profiles.rb +19 -16
- data/db/migrate/20160725153306_create_phcmembers_member_addresses.rb +22 -19
- data/db/migrate/20160725182257_create_phcmembers_directory_categories.rb +14 -11
- data/db/migrate/20160727024006_create_phcmembers_member_listings.rb +26 -23
- data/db/migrate/20160727042756_create_phcmembers_directory_categorylistings.rb +14 -11
- data/lib/phcmembers/engine.rb +47 -47
- data/lib/phcmembers/version.rb +1 -1
- metadata +19 -37
@@ -1,77 +1,77 @@
|
|
1
1
|
require_dependency "phcmembers/application_controller"
|
2
2
|
|
3
3
|
module Phcmembers
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
4
|
+
class Member::ListingsController < ApplicationController
|
5
|
+
|
6
|
+
# Security & Action Filters
|
7
|
+
before_action :set_paper_trail_whodunnit
|
8
|
+
before_action :get_member_profile_info
|
9
|
+
before_action :set_member_listing, only: [:show, :edit, :update, :destroy]
|
10
|
+
|
11
|
+
# INDEX - Directory Listings
|
12
|
+
def index
|
13
|
+
profile = Member::Profile.find(params[:profile_id])
|
14
|
+
@member_listings = profile.listings
|
15
|
+
end
|
16
|
+
|
17
|
+
# LISTINGS DETAILS - Directory Listings
|
18
|
+
def show
|
19
|
+
profile = Member::Profile.find(params[:profile_id])
|
20
|
+
@meber_listing = profile.listings.find(params[:id])
|
21
|
+
@versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcmembers::Member::Listing')
|
22
|
+
end
|
23
|
+
|
24
|
+
# NEW - Directory Listings
|
25
|
+
def new
|
26
|
+
profile = Member::Profile.find(params[:profile_id])
|
27
|
+
@member_listing = profile.listings.build
|
28
|
+
end
|
29
|
+
|
30
|
+
# EDIT - Directory Listings
|
31
|
+
def edit
|
32
|
+
end
|
33
|
+
|
34
|
+
# POST - Directory Listings
|
35
|
+
def create
|
36
|
+
@profile = Member::Profile.find(params[:profile_id])
|
37
|
+
@member_listing = @profile.listings.create(member_listing_params)
|
38
|
+
if @member_listing.save
|
39
|
+
@member_listing.categorylistings.build
|
40
|
+
redirect_to member_profile_listings_url, notice: 'Listing was successfully created.'
|
41
|
+
else
|
42
|
+
render :new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# PATCH/PUT - Directory Listings
|
47
|
+
def update
|
48
|
+
if @member_listing.update(member_listing_params)
|
49
|
+
@member_listing.categorylistings.build
|
50
|
+
redirect_to member_profile_listings_url, notice: 'Listing was successfully updated.'
|
51
|
+
else
|
52
|
+
render :edit
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# DELETE - Directory Listings
|
57
|
+
def destroy
|
58
|
+
@profile = Member::Profile.find(params[:profile_id])
|
59
|
+
@member_listing = @profile.listings.find(params[:id])
|
60
|
+
@member_listing.destroy
|
61
|
+
redirect_to member_profile_listings_url, notice: 'Listing was successfully destroyed.'
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# Common Callbacks
|
67
|
+
def set_member_listing
|
68
|
+
@member_listing = Member::Listing.find(params[:id])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Whitelist
|
72
|
+
def member_listing_params
|
73
|
+
params.require(:member_listing).permit(:mbcompanyname, :mbcontactname, :mbaddressl1, :mbaddressl2, :mbcity, :mbcountry, :mbprovince, :mbpostalcode, :mbphone, :mbcontactemail, :mbwebsite, :profile_id, category_ids: [])
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
77
|
end
|
@@ -1,68 +1,68 @@
|
|
1
1
|
require_dependency "phcmembers/application_controller"
|
2
2
|
|
3
3
|
module Phcmembers
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
4
|
+
class Member::ProfilesController < ApplicationController
|
5
|
+
|
6
|
+
# Security & Action Filters
|
7
|
+
before_action :set_paper_trail_whodunnit
|
8
|
+
before_action :set_member_profile, only: [:show, :edit, :update, :destroy]
|
9
|
+
|
10
|
+
# INDEX - Member Profile
|
11
|
+
def index
|
12
|
+
@member_profiles = Member::Profile.all
|
13
|
+
end
|
14
|
+
|
15
|
+
# DETAILED PROFILE - Member Profile
|
16
|
+
def show
|
17
|
+
@member_profile = Member::Profile.find(params[:id])
|
18
|
+
@versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcmembers::Member::Profile')
|
19
|
+
end
|
20
|
+
|
21
|
+
# NEW FORM - Member Profile
|
22
|
+
def new
|
23
|
+
@member_profile = Member::Profile.new
|
24
|
+
end
|
25
|
+
|
26
|
+
# EDIT FORM - Member Profile
|
27
|
+
def edit
|
28
|
+
end
|
29
|
+
|
30
|
+
# POST - Member Profile
|
31
|
+
def create
|
32
|
+
@member_profile = Member::Profile.new(member_profile_params)
|
33
|
+
if @member_profile.save
|
34
|
+
redirect_to member_profiles_url, notice: 'Profile was successfully created.'
|
35
|
+
else
|
36
|
+
render :new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# PATCH/PUT - Member Profile
|
41
|
+
def update
|
42
|
+
if @member_profile.update(member_profile_params)
|
43
|
+
redirect_to member_profiles_url, notice: 'Profile was successfully updated.'
|
44
|
+
else
|
45
|
+
render :edit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# DELETE - Member Profile
|
50
|
+
def destroy
|
51
|
+
@member_profile.destroy
|
52
|
+
redirect_to member_profiles_url, notice: 'Profile was successfully destroyed.'
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Common Callbacks
|
58
|
+
def set_member_profile
|
59
|
+
@member_profile = Member::Profile.find(params[:id])
|
60
|
+
end
|
61
|
+
|
62
|
+
# Whitelist
|
63
|
+
def member_profile_params
|
64
|
+
params.require(:member_profile).permit(:mfirstname, :mlastname, :mtitle, :memail, :mphone, :mnotes)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
68
|
end
|
data/config/routes.rb
CHANGED
@@ -1,42 +1,38 @@
|
|
1
1
|
Phcmembers::Engine.routes.draw do
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# Dashboard (Engine Root)
|
4
|
+
get 'dashboard/mains/index', :path => "dashboard"
|
5
|
+
|
6
|
+
# Application API
|
7
|
+
namespace :api do
|
8
|
+
# Routes for API
|
9
|
+
resources :catsapi, defaults: {format: 'json'} do
|
10
|
+
resources :listapi
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Application Client Backend
|
15
|
+
|
16
|
+
# Members Section
|
17
|
+
namespace :member do
|
18
|
+
# Members Main Index
|
19
|
+
root 'profiles#index'
|
20
|
+
|
21
|
+
# Member Routes
|
22
|
+
resources :profiles, class_name: 'Phcmembers::Member::Profile' do
|
23
|
+
resources :listings, class_name: 'Phcmembers::Member::Listing'
|
24
|
+
resources :addresses, class_name: 'Phcmembers::Member::Address'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Directory Section
|
29
|
+
namespace :directory do
|
30
|
+
# Members Main Index
|
31
|
+
root 'categories#index'
|
32
|
+
resources :categories, class_name: 'Phcmembers::Directory::Category'
|
33
|
+
resources :categorylistings, class_name: 'Phcmembers::Directory::Categorylisting'
|
34
|
+
end
|
5
35
|
|
6
|
-
|
7
|
-
namespace :api do
|
8
|
-
|
9
|
-
# Routes for API
|
10
|
-
resources :catsapi, defaults: {format: 'json'} do
|
11
|
-
resources :listapi
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# Application Client Backend
|
17
|
-
|
18
|
-
# Members Section
|
19
|
-
namespace :member do
|
20
|
-
|
21
|
-
# Members Main Index
|
22
|
-
root 'profiles#index'
|
23
|
-
|
24
|
-
# Member Routes
|
25
|
-
resources :profiles, class_name: 'Phcmembers::Member::Profile' do
|
26
|
-
resources :listings, class_name: 'Phcmembers::Member::Listing'
|
27
|
-
resources :addresses, class_name: 'Phcmembers::Member::Address'
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
# Directory Section
|
33
|
-
namespace :directory do
|
34
|
-
|
35
|
-
# Members Main Index
|
36
|
-
root 'categories#index'
|
36
|
+
end
|
37
37
|
|
38
|
-
resources :categories, class_name: 'Phcmembers::Directory::Category'
|
39
|
-
resources :categorylistings, class_name: 'Phcmembers::Directory::Categorylisting'
|
40
|
-
end
|
41
38
|
|
42
|
-
end
|
@@ -5,56 +5,56 @@ class CreateVersions < ActiveRecord::Migration
|
|
5
5
|
# - `MysqlAdapter` - Used by gems: `mysql`, `activerecord-jdbcmysql-adapter`.
|
6
6
|
# - `Mysql2Adapter` - Used by `mysql2` gem.
|
7
7
|
MYSQL_ADAPTERS = [
|
8
|
-
|
9
|
-
|
8
|
+
"ActiveRecord::ConnectionAdapters::MysqlAdapter",
|
9
|
+
"ActiveRecord::ConnectionAdapters::Mysql2Adapter"
|
10
10
|
].freeze
|
11
|
-
|
11
|
+
|
12
12
|
# The largest text column available in all supported RDBMS is
|
13
13
|
# 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
|
14
14
|
# so that MySQL will use `longtext` instead of `text`. Otherwise,
|
15
15
|
# when serializing very large objects, `text` might not be big enough.
|
16
16
|
TEXT_BYTES = 1_073_741_823
|
17
|
-
|
17
|
+
|
18
18
|
def change
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
add_index :versions, [:item_type, :item_id]
|
19
|
+
create_table :versions, versions_table_options do |t|
|
20
|
+
t.string :item_type, item_type_options
|
21
|
+
t.integer :item_id, null: false
|
22
|
+
t.string :event, null: false
|
23
|
+
t.string :whodunnit
|
24
|
+
t.text :object, limit: TEXT_BYTES
|
25
|
+
|
26
|
+
# Known issue in MySQL: fractional second precision
|
27
|
+
# -------------------------------------------------
|
28
|
+
#
|
29
|
+
# MySQL timestamp columns do not support fractional seconds unless
|
30
|
+
# defined with "fractional seconds precision". MySQL users should manually
|
31
|
+
# add fractional seconds precision to this migration, specifically, to
|
32
|
+
# the `created_at` column.
|
33
|
+
# (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)
|
34
|
+
#
|
35
|
+
# MySQL users should also upgrade to rails 4.2, which is the first
|
36
|
+
# version of ActiveRecord with support for fractional seconds in MySQL.
|
37
|
+
# (https://github.com/rails/rails/pull/14359)
|
38
|
+
#
|
39
|
+
t.datetime :created_at
|
42
40
|
end
|
43
|
-
|
41
|
+
add_index :versions, [:item_type, :item_id]
|
42
|
+
end
|
43
|
+
|
44
44
|
private
|
45
|
-
|
45
|
+
|
46
46
|
# MySQL 5.6 utf8mb4 limit is 191 chars for keys used in indexes.
|
47
47
|
# See https://github.com/airblade/paper_trail/issues/651
|
48
48
|
def item_type_options
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
opt = { null: false }
|
50
|
+
opt[:limit] = 191 if mysql?
|
51
|
+
opt
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def mysql?
|
55
|
-
|
55
|
+
MYSQL_ADAPTERS.include?(connection.class.name)
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
# Even modern versions of MySQL still use `latin1` as the default character
|
59
59
|
# encoding. Many users are not aware of this, and run into trouble when they
|
60
60
|
# try to use PaperTrail in apps that otherwise tend to use UTF-8. Postgres, by
|
@@ -73,8 +73,10 @@ class CreateVersions < ActiveRecord::Migration
|
|
73
73
|
def versions_table_options
|
74
74
|
if mysql?
|
75
75
|
{ options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }
|
76
|
-
|
76
|
+
else
|
77
77
|
{}
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
|