ish_manager 0.1.8.36 → 0.1.8.37

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: 612f4af3c46b7d22677a10ee633faef6855978b9
4
- data.tar.gz: 22aace4640e3e92d5a4ab15c88a950a16914c77d
3
+ metadata.gz: a622f2fe5deaa768db66c2050f042f7f6858f0e6
4
+ data.tar.gz: 3b56657b81f037d6276914ac85863ffd10d5999b
5
5
  SHA512:
6
- metadata.gz: daa6fdfc439c55ae8c7480cd51a172f739a012056948dd3d1fd7aeca4a0b5628cf2cccd21ac27a718ef8a921b791b5251c855ad7119471b8188351259137b492
7
- data.tar.gz: a94357491b7164dd0989677cac130fabc3a7723bec846f95a295aac60f9632ef9938f8a71602b6b404fc8b5cd1de06c91504aec70b93429e45164deb70b58797
6
+ metadata.gz: 5e0ac390eb79caf399a629cfe793e1ede81a9a26b7dc42839cde59ae31a42bbcab782944d8aca28bc67cda41edf407df5018c0a52337970393c5b04fc0497dba
7
+ data.tar.gz: 459f48e84910830234b1561d590d53cda99c34523fa2e0038c4186c7a954ceb9a1bd549c788eb79df58f97f767f13f9d981a70a33bdef17f5e121d5ba5fca644
@@ -18,32 +18,19 @@ class IshManager::NewsitemsController < IshManager::ApplicationController
18
18
 
19
19
  def create
20
20
  n = Newsitem.new params[:newsitem].permit!
21
- authorize! :create, n
21
+ @resource = City.find params[:city_id] if params[:city_id]
22
+ @resource = Site.find params[:site_id] if params[:site_id]
23
+ authorize! :create_newsitem, @resource
22
24
 
23
- if params[:city_id]
24
- @city = City.find params[:city_id]
25
- @city.newsitems << n
26
- flag = @city.save
27
- if flag
28
- @city.touch
29
- url = edit_city_path( @city.id )
30
- else
31
- error = 'No Luck. ' + @city.errors.inspect
32
- end
25
+ @resource.newsitems << n
26
+ flag = @resource.save
27
+ if flag
28
+ @resource.touch
29
+ else
30
+ error = 'No Luck. ' + @resource.errors.inspect
33
31
  end
32
+ url = params[:city_id] ? edit_city_path( @resource.id ) : edit_site_path( @resource.id )
34
33
 
35
- if params[:site_id]
36
- @site = Site.find params[:site_id]
37
- @site.newsitems << n
38
- flag = @site.save
39
- if flag
40
- @site.touch
41
- url = edit_site_path( @site.id )
42
- else
43
- error = 'No Luck. ' + @site.errors.inspect
44
- end
45
- end
46
-
47
34
  if flag
48
35
  flash[:notice] = 'Success'
49
36
  redirect_to url
@@ -82,6 +82,13 @@ class IshManager::ReportsController < IshManager::ApplicationController
82
82
  @site = Site.where( :id => params[:report][:site_id] ).first
83
83
  @site ||= Site.find_by :domain => 'piousbox.com', :lang => :en
84
84
 
85
+ if @site
86
+ redirect_path = site_reports_path( @site.id )
87
+ end
88
+ if params[:report][:city_id]
89
+ redirect_path = city_path( params[:report][:city_id] )
90
+ end
91
+
85
92
  # @report.user = @current_user || User.where( :username => 'anon' ).first
86
93
  # @report.username = @report.user.username
87
94
  @report[:lang] = @locale
@@ -127,7 +134,7 @@ class IshManager::ReportsController < IshManager::ApplicationController
127
134
  end
128
135
 
129
136
  format.html do
130
- redirect_to reports_path, :notice => 'Report was successfully created (but newsitem, no information).'
137
+ redirect_to redirect_path, :notice => 'Report was successfully created (but newsitem, no information).'
131
138
  end
132
139
  format.json { render :json => @report, :status => :created, :location => @report }
133
140
  else
@@ -1,8 +1,8 @@
1
1
  class IshManager::SitesController < IshManager::ApplicationController
2
2
 
3
3
  def index
4
- authorize! :index, @site
5
- @sites = Site.all.order_by( :domainname => :desc, :lang => :desc )
4
+ authorize! :sites_index, ::Manager
5
+ @sites = Site.where( :is_trash => false ).order_by( :domainname => :desc, :lang => :desc )
6
6
  end
7
7
 
8
8
  # not trash
@@ -12,7 +12,7 @@ class IshManager::SitesController < IshManager::ApplicationController
12
12
  end
13
13
 
14
14
  def show
15
- @site = Site.find params[:id]
15
+ @site = Site.unscoped.find params[:id]
16
16
  authorize! :show, @site
17
17
  @galleries = @site.galleries.unscoped.where({ :is_trash => false }).page( params[:galleries_page] ).per( 10 )
18
18
  @reports = @site.reports.unscoped.where({ :is_trash => false }).page( params[:reports_page] ).per( 10 )
@@ -40,11 +40,11 @@ class IshManager::SitesController < IshManager::ApplicationController
40
40
  else
41
41
  flash[:error] = 'No Luck. ' + @site.errors.inspect
42
42
  end
43
- redirect_to manager_sites_path
43
+ redirect_to sites_path
44
44
  end
45
45
 
46
46
  def update
47
- @site = Site.find params[:id]
47
+ @site = Site.unscoped.find params[:id]
48
48
  authorize! :update, @site
49
49
 
50
50
  if @site.update_attributes params[:site].permit!
@@ -52,7 +52,7 @@ class IshManager::SitesController < IshManager::ApplicationController
52
52
  else
53
53
  flash[:error] = 'No Luck'
54
54
  end
55
- redirect_to manager_sites_path
55
+ redirect_to sites_path
56
56
  end
57
57
 
58
58
  def newsitem_delete
@@ -62,7 +62,7 @@ class IshManager::SitesController < IshManager::ApplicationController
62
62
  n.delete
63
63
  @site.save
64
64
  flash[:notice] = 'Probably successfully deleted a newsitem.'
65
- redirect_to manager_site_path( @site.id )
65
+ redirect_to site_path( @site.id )
66
66
  end
67
67
 
68
68
  end
@@ -11,5 +11,22 @@ class IshManager::UserProfilesController < IshManager::ApplicationController
11
11
  authorize! :show, @user_profile
12
12
  end
13
13
 
14
+ def edit
15
+ @profile = IshModels::UserProfile.find params[:id]
16
+ authorize! :edit, @profile
17
+ end
18
+
19
+ def update
20
+ @profile = IshModels::UserProfile.find params[:id]
21
+ authorize! :update, @profile
22
+ flag = @profile.update_attributes params[:ish_models_user_profile].permit!
23
+ if flag
24
+ flash[:notice] = "Updated profile #{@profile.email}"
25
+ else
26
+ flash[:alert] = "Cannot update profile: #{pp_errors @profile.errors.messages}"
27
+ end
28
+ redirect_to :action => :index
29
+ end
30
+
14
31
  end
15
32
 
@@ -4,7 +4,7 @@ class IshManager::VenuesController < IshManager::ApplicationController
4
4
  before_action :set_lists
5
5
 
6
6
  def index
7
- authorize! :index, Venue
7
+ authorize! :venues_index, ::Manager
8
8
  @venues = Venue.all
9
9
  end
10
10
 
@@ -5,5 +5,9 @@ module IshManager
5
5
  return input.strftime("%Y-%m-%d")
6
6
  end
7
7
 
8
+ def pp_errors errors
9
+ return errors
10
+ end
11
+
8
12
  end
9
13
  end
@@ -9,7 +9,24 @@ class IshManager::Ability
9
9
  #
10
10
  unless user.blank?
11
11
 
12
- if user.profile && user.profile.manager?
12
+ # role manager
13
+ if user.profile && user.profile.role_name == :manager
14
+
15
+ can [ :create_newsitem, :show ], ::City
16
+
17
+ can [ :cities_index, :home, :sites_index, :venues_index ], ::Manager
18
+
19
+ can [ :new ], Newsitem
20
+
21
+ can [ :new, :create ], Report
22
+
23
+ can [ :show, :edit, :update, :create_newsitem ], ::Site do |site|
24
+ !site.is_private && !site.is_trash
25
+ end
26
+
27
+ end
28
+
29
+ if user.profile && user.profile.sudoer?
13
30
  can :manage, :all
14
31
  can [ :home ], ::Manager
15
32
  can :destroy, ::Photo
@@ -2,15 +2,16 @@
2
2
  .container
3
3
  %br
4
4
  .row
5
- .col-sm-6
5
+ .col-sm-5
6
6
  - if defined?( current_user ) && current_user
7
- >[ #{current_user.email} ]<
8
- = button_to '[x]', main_app.destroy_user_session_path, :method => :delete
7
+ %ul
8
+ %li >[ #{current_user.email} ]<
9
+ %li >[ #{current_user.profile.role_name} ]<
9
10
  - else
10
11
  Please log in
11
12
  = link_to '[+]', main_app.new_user_session_path
12
13
 
13
- .col-sm-6
14
+ .col-sm-5
14
15
  %br
15
16
  \~__^
16
17
  %br
@@ -18,3 +19,5 @@
18
19
  %br
19
20
  %br
20
21
  %br
22
+ .col-sm.2
23
+ = button_to 'Logout', main_app.destroy_user_session_path, :method => :delete
@@ -1,3 +1,3 @@
1
1
 
2
- Welcome home! (ish manager)
2
+ Welcome home! Your role is #{current_user.profile.role_name}.
3
3
 
@@ -15,9 +15,9 @@
15
15
  .col-sm-12
16
16
  %h2 Newsitems (#{newsitems.count}) #{link_to '[+]', new_newsitem }
17
17
  = paginate newsitems, :param_name => 'newsitems_page'
18
- %ol
19
- - newsitems.each do |n|
20
- %li
18
+ - newsitems.each do |n|
19
+ .panel
20
+ .panel-body
21
21
  %ul
22
22
  %li
23
23
  = link_to '[~]', edit_url.call( n )
@@ -36,14 +36,14 @@
36
36
 
37
37
  .row
38
38
  .small-4.columns
39
- = f.label :is_trash
40
39
  = f.check_box :is_trash
40
+ = f.label :is_trash
41
41
  .small-4.columns
42
- = f.label :is_private
43
42
  = f.check_box :is_private
43
+ = f.label :is_private
44
44
  .small-4.columns
45
- = f.label :is_ads_enabled
46
45
  = f.check_box :is_ads_enabled
46
+ = f.label :is_ads_enabled
47
47
 
48
48
  .row
49
49
  .large-12.columns
@@ -3,11 +3,11 @@
3
3
  %h3 Sites
4
4
  .row
5
5
  - @sites.each do |site|
6
- .col-xs-6
6
+ .col-xs-12.col-md-6.col-lg-4
7
7
  .panel.panel-primary
8
8
  .panel-body
9
- %h4
10
- = link_to "http://#{site.domain}/#{site.lang}", site_path( site )
9
+ %h5
10
+ = link_to "#{site.domain}/#{site.lang}", site_path( site )
11
11
  = link_to '[~]', edit_site_path( site )
12
12
  .title Title: #{site.title}
13
13
  .subhead Subhead: #{site.subhead}
@@ -0,0 +1,12 @@
1
+
2
+ .a
3
+ = form_for @profile do |f|
4
+ .field
5
+ = f.label :email
6
+ = f.text_field :email, :disabled => true
7
+ .field
8
+ = f.label :role_name
9
+ = f.select :role_name, ::IshModels::UserProfile::ROLES
10
+ .action
11
+ = f.submit 'Submit', :class => %w(button)
12
+
@@ -1,12 +1,14 @@
1
1
 
2
- %h1 User Profiles (#{@user_profiles.count})
2
+ %h1
3
+ User Profiles (#{@user_profiles.count})
4
+ = link_to '[+]', new_user_profile_path
3
5
 
4
6
  %ul
5
7
  - @user_profiles.each do |profile|
6
- %li
7
- &nbsp;
8
+ .panel
8
9
  %ul
9
- %li= profile.email
10
- %li= profile.name
11
- %li= profile.fb_access_token
10
+ %li= link_to '[edit]', edit_user_profile_path( profile )
11
+ %li Email: #{profile.email}
12
+ %li Name: #{profile.name}
13
+ %li Role: #{profile.role_name}
12
14
  %br
data/config/routes.rb CHANGED
@@ -36,6 +36,7 @@ IshManager::Engine.routes.draw do
36
36
  resources :tags
37
37
 
38
38
  resources :user_profiles
39
+ resources :user_profiles, :as => :ish_models_user_profiles
39
40
 
40
41
  resources :venues
41
42
  resources :videos
@@ -1,4 +1,16 @@
1
- # desc "Explaining what the task does"
2
- # task :ish_manager do
3
- # # Task goes here
4
- # end
1
+
2
+ namespace :ish do
3
+
4
+ desc "every user needs a user_profile"
5
+ task :generate_user_profiles => :environment do
6
+ User.all.map do |u|
7
+ unless u.profile
8
+ p = ::IshModels::UserProfile.new :email => u.email, :user => u, :role_name => :guy
9
+ u.profile = p
10
+ u.save && p.save && print('.')
11
+ end
12
+ end
13
+ puts 'OK'
14
+ end
15
+
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.36
4
+ version: 0.1.8.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -262,6 +262,8 @@ files:
262
262
  - app/views/ish_manager/tags/index.haml
263
263
  - app/views/ish_manager/tags/new.haml
264
264
  - app/views/ish_manager/tags/show.haml
265
+ - app/views/ish_manager/user_profiles/edit.haml
266
+ - app/views/ish_manager/user_profiles/edit.haml~
265
267
  - app/views/ish_manager/user_profiles/index.haml
266
268
  - app/views/ish_manager/user_profiles/index.haml~
267
269
  - app/views/ish_manager/users/_index.haml