phcmembers 6.3.4 → 6.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,77 +1,77 @@
1
1
  require_dependency "phcmembers/application_controller"
2
2
 
3
3
  module Phcmembers
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
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
- 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
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
- # Dashboard (Engine Root)
4
- get 'dashboard/mains/index', :path => "dashboard"
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
- # Application API
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
- "ActiveRecord::ConnectionAdapters::MysqlAdapter",
9
- "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
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
- 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
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
- opt = { null: false }
50
- opt[:limit] = 191 if mysql?
51
- opt
49
+ opt = { null: false }
50
+ opt[:limit] = 191 if mysql?
51
+ opt
52
52
  end
53
-
53
+
54
54
  def mysql?
55
- MYSQL_ADAPTERS.include?(connection.class.name)
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
- else
76
+ else
77
77
  {}
78
78
  end
79
79
  end
80
80
  end
81
+
82
+