ish_lib_engine 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e20f00594ea69bb0afd040450bfd308c1165d761
4
+ data.tar.gz: d9b35d6006851aac7cacb9df0fcfe99a34c481b6
5
+ SHA512:
6
+ metadata.gz: 9db0d223fde7177bb0ab0d8463c82f6024cc1ce0c7b7600258c80b990e66dd6a5e7fa8880e712e0dc9777ba47dac3de411400cc81c51a6594a18a0c007301651
7
+ data.tar.gz: 941c4ea19342e5498da52082ab1c95ce4ca931407882fe2f3a51e3121b0f770e7f2bf5998637ae2768a4c97460e8d99b8f6c0bee559cacac994e1e9e6ecd3b9b
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Victor Piousbox
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = IshLibEngine
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'IshLibEngine'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ module IshLibEngine
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,62 @@
1
+ require_dependency "ish_lib_engine/application_controller"
2
+
3
+ module IshLibEngine
4
+ class ArticlesController < ApplicationController
5
+ before_action :set_article, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /articles
8
+ def index
9
+ @articles = Article.all
10
+ end
11
+
12
+ # GET /articles/1
13
+ def show
14
+ end
15
+
16
+ # GET /articles/new
17
+ def new
18
+ @article = Article.new
19
+ end
20
+
21
+ # GET /articles/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /articles
26
+ def create
27
+ @article = Article.new(article_params)
28
+
29
+ if @article.save
30
+ redirect_to @article, notice: 'Article was successfully created.'
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /articles/1
37
+ def update
38
+ if @article.update(article_params)
39
+ redirect_to @article, notice: 'Article was successfully updated.'
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ # DELETE /articles/1
46
+ def destroy
47
+ @article.destroy
48
+ redirect_to articles_url, notice: 'Article was successfully destroyed.'
49
+ end
50
+
51
+ private
52
+ # Use callbacks to share common setup or constraints between actions.
53
+ def set_article
54
+ @article = Article.find(params[:id])
55
+ end
56
+
57
+ # Only allow a trusted parameter "white list" through.
58
+ def article_params
59
+ params.require(:article).permit(:title, :body)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,95 @@
1
+
2
+ class IshLibEngine::Manager::CitiesController < Manager::ManagerController
3
+
4
+ before_filter :set_lists, :only => [ :new_newsitem, :create_newsitem ]
5
+ before_filter :sett_city, :only => [ :show, :edit ]
6
+
7
+ def index
8
+ authorize! :index, ManagerCity.new
9
+ @cities = City.all
10
+ @city = City.new
11
+ @photo = Photo.new
12
+ end
13
+
14
+ def show
15
+ authorize! :show, @city
16
+ end
17
+
18
+ def new
19
+ authorize! :new, ManagerCity.new
20
+ @city = City.new
21
+ @photo = Photo.new
22
+ end
23
+
24
+ def create
25
+ authorize! :create, ManagerCity.new
26
+ @city = City.new params[:city].permit( :n_features, :n_newsitems, :x, :y, :is_feature, :cityname,
27
+ :name_pt, :name_en, :name_ru, :name )
28
+
29
+ if @city.save
30
+ flash[:notice] = 'Success'
31
+ redirect_to manager_cities_path
32
+ else
33
+ flash[:error] = 'No Luck'
34
+ render :action => :new
35
+ end
36
+ end
37
+
38
+ def edit
39
+ authorize! :edit, @city
40
+ end
41
+
42
+ def update
43
+ authorize! :update, ManagerCity.new
44
+
45
+ @city = City.find( params[:id] )
46
+
47
+ @city.update_attributes params[:city]
48
+
49
+ if @city.save
50
+ flash[:notice] = 'Success'
51
+ redirect_to edit_manager_city_path @city.id
52
+ else
53
+ flash[:error] = 'No Luck. ' + @city.errors.inspect
54
+ @newsitems = @city.newsitems.all.page( params[:newsitems_page] )
55
+ @features = @city.features.all.page( params[:features_page] )
56
+ @photo = Photo.new
57
+ render :action => :edit
58
+ end
59
+ end
60
+
61
+ def change_profile_pic
62
+ authorize! :change_profile_pic, ManagerCity.new
63
+
64
+ @city = City.find params[:id]
65
+
66
+ @photo = Photo.new params[:photo]
67
+ @photo.user = @current_user
68
+ flag = @photo.save
69
+ @city.profile_photo = @photo
70
+ flagg = @city.save
71
+ if flag && flagg
72
+ flash[:notice] = 'Success'
73
+ else
74
+ flash[:error] = "No Luck. #{@photo.errors.inspect} #{@city.errors.inspect}"
75
+ # puts! @photo.errors.inspect
76
+ # puts! @city.errors.inspect
77
+ end
78
+
79
+ redirect_to manager_cities_path
80
+ end
81
+
82
+ private
83
+
84
+ def sett_city
85
+ @city = City.find params[:id]
86
+ @photo = Photo.new
87
+ end
88
+
89
+ def set_lists
90
+ @list_reports = Report.all.list
91
+ @list_galleries = Gallery.all.list
92
+ @list_users = [['', nil]] + User.all.order_by( :name => :asc ).map { |u| [u.username, u.username] }
93
+ end
94
+
95
+ end
@@ -0,0 +1,95 @@
1
+
2
+ class Manager::CitiesController < Manager::ManagerController
3
+
4
+ before_filter :set_lists, :only => [ :new_newsitem, :create_newsitem ]
5
+ before_filter :sett_city, :only => [ :show, :edit ]
6
+
7
+ def index
8
+ authorize! :index, ManagerCity.new
9
+ @cities = City.all
10
+ @city = City.new
11
+ @photo = Photo.new
12
+ end
13
+
14
+ def show
15
+ authorize! :show, @city
16
+ end
17
+
18
+ def new
19
+ authorize! :new, ManagerCity.new
20
+ @city = City.new
21
+ @photo = Photo.new
22
+ end
23
+
24
+ def create
25
+ authorize! :create, ManagerCity.new
26
+ @city = City.new params[:city].permit( :n_features, :n_newsitems, :x, :y, :is_feature, :cityname,
27
+ :name_pt, :name_en, :name_ru, :name )
28
+
29
+ if @city.save
30
+ flash[:notice] = 'Success'
31
+ redirect_to manager_cities_path
32
+ else
33
+ flash[:error] = 'No Luck'
34
+ render :action => :new
35
+ end
36
+ end
37
+
38
+ def edit
39
+ authorize! :edit, @city
40
+ end
41
+
42
+ def update
43
+ authorize! :update, ManagerCity.new
44
+
45
+ @city = City.find( params[:id] )
46
+
47
+ @city.update_attributes params[:city]
48
+
49
+ if @city.save
50
+ flash[:notice] = 'Success'
51
+ redirect_to edit_manager_city_path @city.id
52
+ else
53
+ flash[:error] = 'No Luck. ' + @city.errors.inspect
54
+ @newsitems = @city.newsitems.all.page( params[:newsitems_page] )
55
+ @features = @city.features.all.page( params[:features_page] )
56
+ @photo = Photo.new
57
+ render :action => :edit
58
+ end
59
+ end
60
+
61
+ def change_profile_pic
62
+ authorize! :change_profile_pic, ManagerCity.new
63
+
64
+ @city = City.find params[:id]
65
+
66
+ @photo = Photo.new params[:photo]
67
+ @photo.user = @current_user
68
+ flag = @photo.save
69
+ @city.profile_photo = @photo
70
+ flagg = @city.save
71
+ if flag && flagg
72
+ flash[:notice] = 'Success'
73
+ else
74
+ flash[:error] = "No Luck. #{@photo.errors.inspect} #{@city.errors.inspect}"
75
+ # puts! @photo.errors.inspect
76
+ # puts! @city.errors.inspect
77
+ end
78
+
79
+ redirect_to manager_cities_path
80
+ end
81
+
82
+ private
83
+
84
+ def sett_city
85
+ @city = City.find params[:id]
86
+ @photo = Photo.new
87
+ end
88
+
89
+ def set_lists
90
+ @list_reports = Report.all.list
91
+ @list_galleries = Gallery.all.list
92
+ @list_users = [['', nil]] + User.all.order_by( :name => :asc ).map { |u| [u.username, u.username] }
93
+ end
94
+
95
+ end
@@ -0,0 +1,122 @@
1
+
2
+ class IshLibEngine::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
+