phcmemberspro 6.8.2 → 6.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fc6e65782266f40ef4693057004af216d6dcbf7
4
- data.tar.gz: bf69e63cbb475b6343c0634fd6907d8576f74999
3
+ metadata.gz: b32799629880dd328600644d2166eba85f9d7b5b
4
+ data.tar.gz: 2928945884f729b524f1d78c9cfdd422da4103bf
5
5
  SHA512:
6
- metadata.gz: 628ed5632cff4ea5aad1809659672b24d6d7c801500c035c0e1268d7c559c095f079e8d5978bf9f83bd578f04150ad9970ca314bb6be021b888ffcb49bdc6449
7
- data.tar.gz: fe34e4490431e981736953dc70094e021a9ee6441a55f9fb087aff008cc8d46bbd888df83be5ed42666e252c401d96efa7edb86b1ffe0d23b48470007ef455a4
6
+ metadata.gz: 83f3f6b5c82eff12d98c4df98d998a9c53826e62c70878d9c5381724af6d4c94d0b2f1f038aeddb73b4c9f3077d8efdd82cee0d1ed2fac7bfea77314abb020ea
7
+ data.tar.gz: b92bf7d8035497379fbf5e2d3868c4cc9f8a4b7684564795a3c2673af77d433d1c8d9d0165b5bdcee201399773f91651d4fc47215853ca7c3c9cdbb9aab7a768
@@ -1,62 +1,85 @@
1
1
  require_dependency "phcmemberspro/application_controller"
2
2
 
3
3
  module Phcmemberspro
4
- class Directory::ListingsController < ApplicationController
5
- before_action :set_directory_listing, only: [:show, :edit, :update, :destroy]
6
-
7
- # GET /directory/listings
8
- def index
9
- @directory_listings = Directory::Listing.all
10
- end
11
-
12
- # GET /directory/listings/1
13
- def show
14
- end
15
-
16
- # GET /directory/listings/new
17
- def new
18
- @directory_listing = Directory::Listing.new
19
- end
20
-
21
- # GET /directory/listings/1/edit
22
- def edit
23
- end
24
-
25
- # POST /directory/listings
26
- def create
27
- @directory_listing = Directory::Listing.new(directory_listing_params)
28
-
29
- if @directory_listing.save
30
- redirect_to @directory_listing, notice: 'Listing was successfully created.'
31
- else
32
- render :new
33
- end
34
- end
35
-
36
- # PATCH/PUT /directory/listings/1
37
- def update
38
- if @directory_listing.update(directory_listing_params)
39
- redirect_to @directory_listing, notice: 'Listing was successfully updated.'
40
- else
41
- render :edit
42
- end
43
- end
44
-
45
- # DELETE /directory/listings/1
46
- def destroy
47
- @directory_listing.destroy
48
- redirect_to directory_listings_url, notice: 'Listing was successfully destroyed.'
49
- end
50
-
51
- private
52
- # Use callbacks to share common setup or constraints between actions.
53
- def set_directory_listing
54
- @directory_listing = Directory::Listing.find(params[:id])
55
- end
56
-
57
- # Only allow a trusted parameter "white list" through.
58
- def directory_listing_params
59
- params[:directory_listing]
60
- end
61
- end
4
+ class Directory::ListingsController < ApplicationController
5
+
6
+ # Security & Action Filters
7
+ before_action :require_user
8
+ before_action :set_paper_trail_whodunnit
9
+ before_action :directorycategory
10
+ before_action :set_directory_listing, only: [:show, :edit, :update, :destroy]
11
+ layout 'layouts/phcmemberspro/directory/directory_all.html.erb'
12
+
13
+ # Directory Listing Index
14
+ def index
15
+ @directory_listings = Directory::Listing.where(oganization_id: membership_info.org_id)
16
+ end
17
+
18
+ # Show Directory Listing
19
+ def show
20
+ end
21
+
22
+ # New Directory Listing
23
+ def new
24
+ @directory_listing = Directory::Listing.new
25
+ end
26
+
27
+ # Edit Directory Listing Action
28
+ def edit
29
+ end
30
+
31
+ # Create Directory Listing Action
32
+ def create
33
+ @directory_listing = Directory::Listing.new(directory_listing_params)
34
+ @directory_listing.user_id = current_user.id
35
+ @directory_listing.membership_id = membership_info.id
36
+ @directory_listing.oganization_id = membership_info.org_id
37
+ if @directory_listing.save
38
+ redirect_to @directory_listing, notice: 'Listing was successfully created.'
39
+ else
40
+ render :new
41
+ end
42
+ end
43
+
44
+ # Update Directory Listing Action
45
+ def update
46
+ @directory_listing.user_id = current_user.id
47
+ @directory_listing.membership_id = membership_info.id
48
+ @directory_listing.oganization_id = membership_info.org_id
49
+ if @directory_listing.update(directory_listing_params)
50
+ redirect_to @directory_listing, notice: 'Listing was successfully updated.'
51
+ else
52
+ render :edit
53
+ end
54
+ end
55
+
56
+ # Delete Directory Listing
57
+ def destroy
58
+ @directory_listing.destroy
59
+ redirect_to directory_listings_url, notice: 'Listing was successfully destroyed.'
60
+ end
61
+
62
+ private
63
+
64
+ # Grab User Session Key (For ID)
65
+ def current_user
66
+ @_current_user ||= AuthRocket::Session.from_token(session[:ar_token]).try(:user)
67
+ end
68
+
69
+ # Get Current User from Above and Get Membership Info
70
+ def membership_info
71
+ AuthRocket::Membership.all(user_id: current_user.id).first
72
+ end
73
+
74
+ # Common Callbacks
75
+ def set_directory_listing
76
+ @directory_listing = Directory::Listing.find(params[:id])
77
+ end
78
+
79
+ # Whitelists
80
+ def directory_listing_params
81
+ params.require(:directory_listing).permit(:business_id, :category_id, :main_id, :user_id, :membership_id, :oganization_id)
82
+ end
83
+
84
+ end
62
85
  end
@@ -1,12 +1,20 @@
1
1
  module Phcmemberspro
2
- class Directory::Listing < ActiveRecord::Base
3
-
4
- # Add Paper Trail
2
+ class Directory::Listing < ActiveRecord::Base
3
+
4
+ # Add Paper Trail
5
5
  has_paper_trail
6
6
 
7
- # Model Relationship
8
- belongs_to :business, class_name: 'Members::Business'
9
- belongs_to :category, class_name: 'Directory::Category'
7
+ # Model Relationship
8
+ belongs_to :business, class_name: 'Members::Business'
9
+ belongs_to :category, class_name: 'Directory::Category'
10
+
11
+ # Validation for Form Fields
12
+ validates :business_id,
13
+ presence: true
14
+
15
+ # Validation for Form Fields
16
+ validates :category_id,
17
+ presence: true
10
18
 
11
- end
19
+ end
12
20
  end
@@ -29,8 +29,8 @@
29
29
  <span class="caption-subject bold uppercase"><%= yield(:phc_title_tagline) %></span>
30
30
  </div>
31
31
  <div class="actions">
32
- <%= link_to new_directory_category_path, class: "btn blue-chambray btn-circle" do %>
33
- <i class="fa fa-plus"></i> Create a New Directory Category
32
+ <%= link_to new_directory_listing_path, class: "btn blue-chambray btn-circle" do %>
33
+ <i class="fa fa-plus"></i> Create a New Directory Listing
34
34
  <% end %>
35
35
  </div>
36
36
  </div>
@@ -5,6 +5,10 @@ class CreatePhcmembersproDirectoryListings < ActiveRecord::Migration
5
5
  t.references :business, index: true
6
6
  t.references :category, index: true
7
7
 
8
+ t.string :user_id
9
+ t.string :membership_id
10
+ t.string :oganization_id
11
+
8
12
  t.timestamps null: false
9
13
 
10
14
  end
@@ -1,3 +1,3 @@
1
1
  module Phcmemberspro
2
- VERSION = "6.8.2"
2
+ VERSION = "6.8.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phcmemberspro
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.8.2
4
+ version: 6.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BradPotts