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 +4 -4
- data/app/controllers/phcmemberspro/directory/listings_controller.rb +81 -58
- data/app/models/phcmemberspro/directory/listing.rb +15 -7
- data/app/views/phcmemberspro/directory/listings/index.html.erb +2 -2
- data/db/migrate/20160612010248_create_phcmemberspro_directory_listings.rb +4 -0
- data/lib/phcmemberspro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b32799629880dd328600644d2166eba85f9d7b5b
|
4
|
+
data.tar.gz: 2928945884f729b524f1d78c9cfdd422da4103bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class Directory::Listing < ActiveRecord::Base
|
3
|
+
|
4
|
+
# Add Paper Trail
|
5
5
|
has_paper_trail
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
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
|
33
|
-
<i class="fa fa-plus"></i> Create a New Directory
|
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>
|