ish_lib_engine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/ish_lib_engine/application.js +13 -0
  6. data/app/assets/javascripts/ish_lib_engine/articles.js +2 -0
  7. data/app/assets/stylesheets/ish_lib_engine/application.css +15 -0
  8. data/app/assets/stylesheets/ish_lib_engine/articles.css +4 -0
  9. data/app/assets/stylesheets/scaffold.css +56 -0
  10. data/app/controllers/ish_lib_engine/application_controller.rb +4 -0
  11. data/app/controllers/ish_lib_engine/articles_controller.rb +62 -0
  12. data/app/controllers/ish_lib_engine/manager/cities_controller.rb +95 -0
  13. data/app/controllers/ish_lib_engine/manager/cities_controller.rb~ +95 -0
  14. data/app/controllers/ish_lib_engine/manager/features_controller.rb +122 -0
  15. data/app/controllers/ish_lib_engine/manager/features_controller.rb~ +122 -0
  16. data/app/controllers/ish_lib_engine/manager/galleries_controller.rb +78 -0
  17. data/app/controllers/ish_lib_engine/manager/galleries_controller.rb~ +78 -0
  18. data/app/controllers/ish_lib_engine/manager/manager_controller.rb +31 -0
  19. data/app/controllers/ish_lib_engine/manager/manager_controller.rb~ +31 -0
  20. data/app/controllers/ish_lib_engine/manager/newsitems_controller.rb +47 -0
  21. data/app/controllers/ish_lib_engine/manager/newsitems_controller.rb~ +47 -0
  22. data/app/controllers/ish_lib_engine/manager/photos_controller.rb +20 -0
  23. data/app/controllers/ish_lib_engine/manager/photos_controller.rb~ +20 -0
  24. data/app/controllers/ish_lib_engine/manager/reports_controller.rb +62 -0
  25. data/app/controllers/ish_lib_engine/manager/reports_controller.rb~ +62 -0
  26. data/app/controllers/ish_lib_engine/manager/sites_controller.rb +72 -0
  27. data/app/controllers/ish_lib_engine/manager/sites_controller.rb~ +72 -0
  28. data/app/controllers/ish_lib_engine/manager/tags_controller.rb +54 -0
  29. data/app/controllers/ish_lib_engine/manager/tags_controller.rb~ +54 -0
  30. data/app/controllers/ish_lib_engine/manager/users_controller.rb +13 -0
  31. data/app/controllers/ish_lib_engine/manager/users_controller.rb~ +13 -0
  32. data/app/controllers/ish_lib_engine/manager/welcome_controller.rb +8 -0
  33. data/app/controllers/ish_lib_engine/manager/welcome_controller.rb~ +9 -0
  34. data/app/helpers/ish_lib_engine/application_helper.rb +4 -0
  35. data/app/helpers/ish_lib_engine/articles_helper.rb +4 -0
  36. data/app/models/ability.rb +152 -0
  37. data/app/models/ability.rb~ +151 -0
  38. data/app/models/admin_user.rb +113 -0
  39. data/app/models/app_model2.rb +33 -0
  40. data/app/models/auth_token.rb +17 -0
  41. data/app/models/aux_model.rb +22 -0
  42. data/app/models/cities_user.rb +17 -0
  43. data/app/models/city.rb +117 -0
  44. data/app/models/country.rb +13 -0
  45. data/app/models/day.rb +21 -0
  46. data/app/models/decoded_auth_token.rb +6 -0
  47. data/app/models/event.rb +21 -0
  48. data/app/models/feature.rb +38 -0
  49. data/app/models/gallery.rb +59 -0
  50. data/app/models/ish_lib_engine/article.rb +4 -0
  51. data/app/models/ish_lib_engine/comment.rb +4 -0
  52. data/app/models/manager.rb +10 -0
  53. data/app/models/manager_city.rb +4 -0
  54. data/app/models/manager_feature.rb +4 -0
  55. data/app/models/manager_gallery.rb +3 -0
  56. data/app/models/manager_newsitem.rb +5 -0
  57. data/app/models/manager_photo.rb +3 -0
  58. data/app/models/manager_report.rb +4 -0
  59. data/app/models/manager_site.rb +4 -0
  60. data/app/models/manager_tag.rb +6 -0
  61. data/app/models/manager_user.rb +3 -0
  62. data/app/models/manager_venue.rb +4 -0
  63. data/app/models/message.rb +14 -0
  64. data/app/models/newsitem.rb +50 -0
  65. data/app/models/nodeitem.rb +18 -0
  66. data/app/models/photo.rb +68 -0
  67. data/app/models/rate_me.rb +13 -0
  68. data/app/models/report.rb +144 -0
  69. data/app/models/review.rb +4 -0
  70. data/app/models/site.rb +83 -0
  71. data/app/models/tag.rb +78 -0
  72. data/app/models/user.rb +122 -0
  73. data/app/models/user_profile.rb +20 -0
  74. data/app/models/venue.rb +69 -0
  75. data/app/models/video.rb +48 -0
  76. data/app/models/welcome.rb +6 -0
  77. data/app/models/wikitravel_page.rb +19 -0
  78. data/app/views/application/_flash_messages.haml +24 -0
  79. data/app/views/application/_flash_messages.haml~ +24 -0
  80. data/app/views/ish_lib_engine/articles/_form.html.erb +25 -0
  81. data/app/views/ish_lib_engine/articles/edit.html.erb +6 -0
  82. data/app/views/ish_lib_engine/articles/index.html.erb +29 -0
  83. data/app/views/ish_lib_engine/articles/new.html.erb +5 -0
  84. data/app/views/ish_lib_engine/articles/show.html.erb +14 -0
  85. data/app/views/layouts/ish_lib_engine/application.html.erb +14 -0
  86. data/config/routes.rb +3 -0
  87. data/db/migrate/20160501041837_create_ish_lib_engine_articles.rb +10 -0
  88. data/db/migrate/20160501041940_create_ish_lib_engine_comments.rb +10 -0
  89. data/lib/addressbookitems_tasks.rb +33 -0
  90. data/lib/cities_tasks.rb +143 -0
  91. data/lib/core_extensions.rb +21 -0
  92. data/lib/features_tasks.rb +17 -0
  93. data/lib/float.rb +14 -0
  94. data/lib/galleries_tasks.rb +91 -0
  95. data/lib/ish_lib_engine.rb +4 -0
  96. data/lib/ish_lib_engine/engine.rb +5 -0
  97. data/lib/ish_lib_engine/version.rb +3 -0
  98. data/lib/reports_tasks.rb +53 -0
  99. data/lib/sitemaps_tasks.rb +108 -0
  100. data/lib/sites_tasks.rb +31 -0
  101. data/lib/string.rb +15 -0
  102. data/lib/tags_tasks.rb +104 -0
  103. data/lib/tasks/cities.rake +29 -0
  104. data/lib/tasks/galleries.rake +19 -0
  105. data/lib/tasks/ish_lib_engine_tasks.rake +4 -0
  106. data/lib/tasks/reports.rake +37 -0
  107. data/lib/tasks/resque.rake +8 -0
  108. data/lib/tasks/sitemaps.rake +12 -0
  109. data/lib/tasks/sites.rake +12 -0
  110. data/lib/tasks/tags.rake +17 -0
  111. data/lib/tasks/users.rake +14 -0
  112. data/lib/tasks/venues.rake +13 -0
  113. data/lib/tasks/videos.rake +18 -0
  114. data/lib/tasks/wikitravel_pages.rake +40 -0
  115. data/lib/test_extensions.rb +9 -0
  116. data/lib/u.rb +34 -0
  117. data/lib/users_tasks.rb +88 -0
  118. data/lib/venues_tasks.rb +15 -0
  119. data/lib/videos_tasks.rb +71 -0
  120. data/lib/wikitravel_tasks.rb +139 -0
  121. data/spec/factories/cities.rb +89 -0
  122. data/spec/factories/galleries.rb +133 -0
  123. data/spec/factories/photo.rb +20 -0
  124. data/spec/factories/reports.rb +379 -0
  125. data/spec/factories/site.rb +26 -0
  126. data/spec/factories/tag.rb +42 -0
  127. data/spec/factories/user.rb +87 -0
  128. data/spec/factories/user_profiles.rb +33 -0
  129. data/spec/factories/venues.rb +25 -0
  130. data/spec/factories/videos.rb +38 -0
  131. data/test/controllers/ish_lib_engine/articles_controller_test.rb +52 -0
  132. data/test/dummy/README.rdoc +28 -0
  133. data/test/dummy/Rakefile +6 -0
  134. data/test/dummy/app/assets/javascripts/application.js +13 -0
  135. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  136. data/test/dummy/app/controllers/application_controller.rb +5 -0
  137. data/test/dummy/app/helpers/application_helper.rb +2 -0
  138. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  139. data/test/dummy/bin/bundle +3 -0
  140. data/test/dummy/bin/rails +4 -0
  141. data/test/dummy/bin/rake +4 -0
  142. data/test/dummy/bin/setup +29 -0
  143. data/test/dummy/config.ru +4 -0
  144. data/test/dummy/config/application.rb +26 -0
  145. data/test/dummy/config/boot.rb +5 -0
  146. data/test/dummy/config/database.yml +25 -0
  147. data/test/dummy/config/environment.rb +5 -0
  148. data/test/dummy/config/environments/development.rb +41 -0
  149. data/test/dummy/config/environments/production.rb +79 -0
  150. data/test/dummy/config/environments/test.rb +42 -0
  151. data/test/dummy/config/initializers/assets.rb +11 -0
  152. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  153. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  154. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  155. data/test/dummy/config/initializers/inflections.rb +16 -0
  156. data/test/dummy/config/initializers/mime_types.rb +4 -0
  157. data/test/dummy/config/initializers/session_store.rb +3 -0
  158. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  159. data/test/dummy/config/locales/en.yml +23 -0
  160. data/test/dummy/config/routes.rb +4 -0
  161. data/test/dummy/config/secrets.yml +22 -0
  162. data/test/dummy/db/development.sqlite3 +0 -0
  163. data/test/dummy/db/schema.rb +30 -0
  164. data/test/dummy/log/development.log +15 -0
  165. data/test/dummy/public/404.html +67 -0
  166. data/test/dummy/public/422.html +67 -0
  167. data/test/dummy/public/500.html +66 -0
  168. data/test/dummy/public/favicon.ico +0 -0
  169. data/test/fixtures/ish_lib_engine/articles.yml +9 -0
  170. data/test/fixtures/ish_lib_engine/comments.yml +9 -0
  171. data/test/integration/navigation_test.rb +8 -0
  172. data/test/ish_lib_engine_test.rb +7 -0
  173. data/test/models/ish_lib_engine/article_test.rb +9 -0
  174. data/test/models/ish_lib_engine/comment_test.rb +9 -0
  175. data/test/test_helper.rb +21 -0
  176. metadata +361 -0
@@ -0,0 +1,122 @@
1
+
2
+ class Manager::FeaturesController < Manager::ManagerController
3
+
4
+ before_filter :set_lists
5
+
6
+ def new
7
+ authorize! :new, ManagerFeature.new
8
+ @city = City.find params[:city_id] unless params[:city_id].blank?
9
+ @site = Site.find params[:site_id] unless params[:site_id].blank?
10
+ @tag = Tag.find params[:tag_id] unless params[:tag_id].blank?
11
+ @feature = Feature.new
12
+ end
13
+
14
+ def create
15
+ authorize! :create, ManagerFeature.new
16
+
17
+ @feature = Feature.new params[:feature].permit( :name, :subhead, :image_path, :link_path, :partial_name, :photo, :weight,
18
+ :report, :report_id, :gallery, :gallery_id, :video, :video_id
19
+ )
20
+ if params[:city_id]
21
+ @city = City.find params[:city_id]
22
+ @city.features << @feature
23
+ redirect_path = manager_cities_path
24
+ end
25
+ if params[:site_id]
26
+ @site = Site.find params[:site_id]
27
+ @site.features << @feature
28
+ redirect_path = manager_sites_path
29
+ end
30
+ if params[:tag_id]
31
+ @tag = Tag.find params[:tag_id]
32
+ @tag.features << @feature
33
+ redirect_path = manager_tags_path
34
+ end
35
+
36
+ if (@city && @city.save) || (@site && @site.save) || (@tag && @tag.save)
37
+ flash[:notice] = 'Success.'
38
+ redirect_to redirect_path
39
+ else
40
+ flash[:error] = 'No Luck. ' + ( @city || @site || @tag ).errors.inspect
41
+ render :action => :new
42
+ end
43
+ end
44
+
45
+ def edit
46
+ authorize! :edit, ManagerCity.new
47
+
48
+ if params[:city_id]
49
+ @city = City.find params[:city_id]
50
+ @feature = @city.features.find params[:id]
51
+ end
52
+
53
+ if params[:site_id]
54
+ @site = Site.find params[:site_id]
55
+ @feature = @site.features.find params[:id]
56
+ end
57
+
58
+ if params[:tag_id]
59
+ @tag = Tag.find params[:tag_id]
60
+ @feature = @tag.features.find params[:id]
61
+ end
62
+
63
+ if params[:venue_id]
64
+ @venue = Tag.find params[:venue_id]
65
+ @feature = @venue.features.find params[:id]
66
+ end
67
+
68
+ end
69
+
70
+ def update
71
+ unless params[:city_id].blank?
72
+ @city = City.find params[:city_id]
73
+ authorize! :update, ManagerCity.new
74
+ @feature = @city.features.find params[:id]
75
+ redirect_path = manager_city_path( @city )
76
+ end
77
+ unless params[:site_id].blank?
78
+ @site = Site.find params[:site_id]
79
+ authorize! :update, ManagerSite.new
80
+ @feature = @site.features.find params[:id]
81
+ redirect_path = manager_site_path( @site )
82
+ end
83
+ unless params[:tag_id].blank?
84
+ @tag = Tag.find params[:tag_id]
85
+ authorize! :update, ManagerTag.new
86
+ @feature = @tag.features.find params[:id]
87
+ redirect_path = manager_tag_path( @tag )
88
+ end
89
+
90
+ if @feature.update_attributes params[:feature].permit( :name, :subhead, :image_path, :link_path, :partial_name, :weight,
91
+ :photo_id, :photo, :report_id, :gallery_id, :video_id )
92
+ flash[:notice] = 'Success'
93
+ redirect_to redirect_path
94
+ else
95
+ flash[:error] = 'No Luck. ' + @feature.errors.inspect
96
+ puts! @feature.errors, 'Errors updating feature'
97
+ render :action => :edit_feature
98
+ end
99
+ end
100
+
101
+ def index
102
+ if params[:tag_id]
103
+ @resource = Tag.find params[:tag_id]
104
+ end
105
+
106
+ end
107
+
108
+ def destroy
109
+ if params[:tag_id]
110
+ @resource = Tag.find params[:tag_id]
111
+ end
112
+ @feature = @resource.features.find params[:id]
113
+ if @feature.destroy
114
+ flash[:notice] = :'Success.'
115
+ else
116
+ flash[:error] = :'No luck.'
117
+ end
118
+ redirect_to request.referrer
119
+ end
120
+
121
+ end
122
+
@@ -0,0 +1,78 @@
1
+
2
+ class IshLibEngine::Manager::GalleriesController < Manager::ManagerController
3
+
4
+ before_filter :set_lists
5
+
6
+ def index
7
+ redirect_to manager_galleries_thumb_path
8
+ end
9
+
10
+ def index_title
11
+ @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc )
12
+ end
13
+
14
+ def index_thumb
15
+ @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc ).page( params[:galleries_page] ).per( 10 )
16
+ end
17
+
18
+ def index_mini
19
+ @galleries = Gallery.all
20
+ end
21
+
22
+ def new
23
+ @gallery = Gallery.new
24
+ @cities_list = City.list
25
+ @tags_list = Tag.list
26
+ end
27
+
28
+ def create
29
+ @gallery = Gallery.new(params[:gallery].permit(:name, :city, :tag, :is_public, :is_done, :is_feature))
30
+ @gallery.user = current_user
31
+ @gallery.site = @site
32
+ authorize! :create, @gallery
33
+
34
+ if @gallery.save
35
+ # expire_page :controller => 'galleries', :action => 'index', :domainname => @site.domain
36
+ # expire_page :controller => 'sites', :action => 'show', :domainname => @site.domain
37
+ flash[:notice] = 'Success'
38
+ redirect_to manager_galleries_path
39
+ else
40
+ flash[:error] = 'No Luck. ' + @gallery.errors.inspect
41
+ @cities_list = City.list
42
+ @tags_list = Tag.list
43
+ render :action => 'new'
44
+ end
45
+ end
46
+
47
+ def edit
48
+ @gallery = Gallery.unscoped.find params[:id]
49
+ end
50
+
51
+ def update
52
+ @gallery = Gallery.unscoped.find params[:id]
53
+ if @gallery.update_attributes( params[:gallery].permit( :username, :name, :galleryname, :subhead, :descr, :lang,
54
+ :is_trash, :is_public, :is_done, :is_feature,
55
+ :tag_id, :city_id, :venue_id, :site_id, :user_id, :site_id ) )
56
+ flash[:notice] = 'Success.'
57
+ redirect_to manager_galleries_path
58
+ else
59
+ flash[:error] = 'No Luck. ' + @gallery.errors
60
+ render :action => :edit
61
+ end
62
+ end
63
+
64
+ def show
65
+ @gallery = Gallery.unscoped.find params[:id]
66
+ @photos = @gallery.photos.unscoped.where({ :is_trash => false })
67
+ end
68
+
69
+ def destroy
70
+ @gallery = Gallery.unscoped.find params[:id]
71
+ @gallery.is_trash = true
72
+ @gallery.save
73
+ flash[:notice] = 'Logically deleted gallery.'
74
+ redirect_to manager_galleries_title_path
75
+ end
76
+
77
+ end
78
+
@@ -0,0 +1,78 @@
1
+
2
+ class Manager::GalleriesController < Manager::ManagerController
3
+
4
+ before_filter :set_lists
5
+
6
+ def index
7
+ redirect_to manager_galleries_thumb_path
8
+ end
9
+
10
+ def index_title
11
+ @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc )
12
+ end
13
+
14
+ def index_thumb
15
+ @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc ).page( params[:galleries_page] ).per( 10 )
16
+ end
17
+
18
+ def index_mini
19
+ @galleries = Gallery.all
20
+ end
21
+
22
+ def new
23
+ @gallery = Gallery.new
24
+ @cities_list = City.list
25
+ @tags_list = Tag.list
26
+ end
27
+
28
+ def create
29
+ @gallery = Gallery.new(params[:gallery].permit(:name, :city, :tag, :is_public, :is_done, :is_feature))
30
+ @gallery.user = current_user
31
+ @gallery.site = @site
32
+ authorize! :create, @gallery
33
+
34
+ if @gallery.save
35
+ # expire_page :controller => 'galleries', :action => 'index', :domainname => @site.domain
36
+ # expire_page :controller => 'sites', :action => 'show', :domainname => @site.domain
37
+ flash[:notice] = 'Success'
38
+ redirect_to manager_galleries_path
39
+ else
40
+ flash[:error] = 'No Luck. ' + @gallery.errors.inspect
41
+ @cities_list = City.list
42
+ @tags_list = Tag.list
43
+ render :action => 'new'
44
+ end
45
+ end
46
+
47
+ def edit
48
+ @gallery = Gallery.unscoped.find params[:id]
49
+ end
50
+
51
+ def update
52
+ @gallery = Gallery.unscoped.find params[:id]
53
+ if @gallery.update_attributes( params[:gallery].permit( :username, :name, :galleryname, :subhead, :descr, :lang,
54
+ :is_trash, :is_public, :is_done, :is_feature,
55
+ :tag_id, :city_id, :venue_id, :site_id, :user_id, :site_id ) )
56
+ flash[:notice] = 'Success.'
57
+ redirect_to manager_galleries_path
58
+ else
59
+ flash[:error] = 'No Luck. ' + @gallery.errors
60
+ render :action => :edit
61
+ end
62
+ end
63
+
64
+ def show
65
+ @gallery = Gallery.unscoped.find params[:id]
66
+ @photos = @gallery.photos.unscoped.where({ :is_trash => false })
67
+ end
68
+
69
+ def destroy
70
+ @gallery = Gallery.unscoped.find params[:id]
71
+ @gallery.is_trash = true
72
+ @gallery.save
73
+ flash[:notice] = 'Logically deleted gallery.'
74
+ redirect_to manager_galleries_title_path
75
+ end
76
+
77
+ end
78
+
@@ -0,0 +1,31 @@
1
+
2
+ class IshLibEngine::Manager::ManagerController < ApplicationController
3
+
4
+ layout 'manager'
5
+
6
+ prepend_before_filter :authenticate_user!
7
+ before_filter :validate_manager
8
+
9
+ private
10
+
11
+ def validate_manager
12
+ if 'piousbox' == current_user['username'] || 'manager' == current_user['username']
13
+ return true
14
+ else
15
+ redirect_to root_path
16
+ end
17
+ end
18
+
19
+ def set_lists
20
+ @tags_list = Tag.all.list
21
+ @sites_list = Site.all.list
22
+ @cities_list = City.all.list
23
+ @venues_list = Venue.all.list
24
+ @users_list = User.all.list
25
+
26
+ @reports_list = Report.all.list
27
+ @galleries_list = Gallery.all.list
28
+ @videos_list = Video.all.list
29
+ end
30
+
31
+ end
@@ -0,0 +1,31 @@
1
+
2
+ class Manager::ManagerController < ApplicationController
3
+
4
+ layout 'manager'
5
+
6
+ prepend_before_filter :authenticate_user!
7
+ before_filter :validate_manager
8
+
9
+ private
10
+
11
+ def validate_manager
12
+ if 'piousbox' == current_user['username'] || 'manager' == current_user['username']
13
+ return true
14
+ else
15
+ redirect_to root_path
16
+ end
17
+ end
18
+
19
+ def set_lists
20
+ @tags_list = Tag.all.list
21
+ @sites_list = Site.all.list
22
+ @cities_list = City.all.list
23
+ @venues_list = Venue.all.list
24
+ @users_list = User.all.list
25
+
26
+ @reports_list = Report.all.list
27
+ @galleries_list = Gallery.all.list
28
+ @videos_list = Video.all.list
29
+ end
30
+
31
+ end
@@ -0,0 +1,47 @@
1
+
2
+ class IshLibEngine::Manager::NewsitemsController < Manager::ManagerController
3
+
4
+ def new
5
+ authorize! :new, ManagerNewsitem.new
6
+
7
+ @newsitem = Newsitem.new
8
+ @city = City.find params[:city_id]
9
+
10
+ end
11
+
12
+ def create
13
+ authorize! :create, ManagerNewsitem.new
14
+
15
+ n = Newsitem.new params[:newsitem]
16
+ n.report = Report.find params[:newsitem][:report_id] unless params[:newsitem][:report_id].blank?
17
+ n.gallery = Gallery.find params[:newsitem][:gallery_id] unless params[:newsitem][:gallery_id].blank?
18
+ n.photo = Photo.find params[:newsitem][:photo_id] unless params[:newsitem][:photo_id].blank?
19
+ n.descr = params[:newsitem][:descr]
20
+
21
+ @city = City.find params[:city_id]
22
+ @city.newsitems << n
23
+
24
+ if @city.save
25
+ flash[:notice] = 'Success'
26
+ redirect_to edit_manager_city_path( @city.id )
27
+ else
28
+ flash[:error] = 'No Luck. ' + @city.errors.inspect
29
+ render :action => :new_newsitem
30
+
31
+ end
32
+ end
33
+
34
+ def show
35
+ end
36
+
37
+ def index
38
+ end
39
+
40
+ def destroy
41
+ end
42
+
43
+ def update
44
+ end
45
+
46
+ end
47
+
@@ -0,0 +1,47 @@
1
+
2
+ class Manager::NewsitemsController < Manager::ManagerController
3
+
4
+ def new
5
+ authorize! :new, ManagerNewsitem.new
6
+
7
+ @newsitem = Newsitem.new
8
+ @city = City.find params[:city_id]
9
+
10
+ end
11
+
12
+ def create
13
+ authorize! :create, ManagerNewsitem.new
14
+
15
+ n = Newsitem.new params[:newsitem]
16
+ n.report = Report.find params[:newsitem][:report_id] unless params[:newsitem][:report_id].blank?
17
+ n.gallery = Gallery.find params[:newsitem][:gallery_id] unless params[:newsitem][:gallery_id].blank?
18
+ n.photo = Photo.find params[:newsitem][:photo_id] unless params[:newsitem][:photo_id].blank?
19
+ n.descr = params[:newsitem][:descr]
20
+
21
+ @city = City.find params[:city_id]
22
+ @city.newsitems << n
23
+
24
+ if @city.save
25
+ flash[:notice] = 'Success'
26
+ redirect_to edit_manager_city_path( @city.id )
27
+ else
28
+ flash[:error] = 'No Luck. ' + @city.errors.inspect
29
+ render :action => :new_newsitem
30
+
31
+ end
32
+ end
33
+
34
+ def show
35
+ end
36
+
37
+ def index
38
+ end
39
+
40
+ def destroy
41
+ end
42
+
43
+ def update
44
+ end
45
+
46
+ end
47
+
@@ -0,0 +1,20 @@
1
+
2
+ class IshLibEngine::Manager::PhotosController < Manager::ManagerController
3
+
4
+ def without_gallery
5
+ @photos = Photo.unscoped.where( :gallery => nil, :is_trash => false )
6
+ end
7
+
8
+ def destroy
9
+ @photo = Photo.unscoped.find params[:id]
10
+ @photo.is_trash = true
11
+ @photo.save
12
+ redirect_to request.referrer
13
+ end
14
+
15
+ def show
16
+ @photo = Photo.unscoped.find params[:id]
17
+ end
18
+
19
+ end
20
+