typus 3.1.5 → 3.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,23 @@
1
- = 3.1.5 (2011-12-10)
1
+ CHANGELOG
2
+ =========
3
+
4
+ 3.1.6 (2012-01-02)
5
+ ------------------
6
+
7
+ * [FIXED] "Save and continue editing" button was shown even when the
8
+ user didn't have acess to it.
9
+
10
+ * [CHANGED] Improved MongoDB support.
11
+
12
+ * [NEW] We can now filter by integer.
13
+
14
+ * [FIXED] Independent paginators when showing associations.
15
+
16
+ Changes: <https://github.com/fesplugas/typus/compare/v3.1.5...v3.1.6>
17
+
18
+
19
+ 3.1.5 (2011-12-10)
20
+ ------------------
2
21
 
3
22
  * [CHANGED] Association tables now contain a "show" link.
4
23
 
@@ -10,11 +29,19 @@
10
29
 
11
30
  * [CHANGED] Repository moved again to http://github.com/fesplugas/typus
12
31
 
13
- = 3.1.4
32
+ Changes: <https://github.com/fesplugas/typus/compare/v3.1.4...v3.1.5>
33
+
34
+
35
+ 3.1.4
36
+ -----
14
37
 
15
38
  * [FIXED] Belongs to helper was not creating properly class ids.
16
39
 
17
- = 3.1.3
40
+ Changes: <https://github.com/fesplugas/typus/compare/v3.1.3...v3.1.4>
41
+
42
+
43
+ 3.1.3
44
+ -----
18
45
 
19
46
  * [CHANGED] Added `Typus.chosen` so we can disable "Chosen". This will
20
47
  be in Typus until "Chosen" supports remote data calls.
@@ -37,14 +64,20 @@
37
64
 
38
65
  * [FIXED] Detaching a Paperclip was not working.
39
66
 
40
- = 3.1.2
67
+ Changes: <https://github.com/fesplugas/typus/compare/v3.1.2...v3.1.3>
68
+
69
+
70
+ 3.1.2
71
+ -----
41
72
 
42
73
  * [CHANGED] Images, links and belongs_to associations do not have links
43
74
  when popup mode. This will avoid an "Inception" problem.
44
75
 
45
76
  * [FIXED] Problems on HABTM associations when generating association names.
46
77
 
47
- = 3.1.1
78
+
79
+ 3.1.1
80
+ -----
48
81
 
49
82
  * [CHANGED] Removed user guide. Docs can now be found at http://docs.typuscmf.com/
50
83
 
@@ -65,7 +98,9 @@
65
98
 
66
99
  * [CHANGED] Default development/test database is now **Postgresql**.
67
100
 
68
- = 3.1.0
101
+
102
+ 3.1.0
103
+ -----
69
104
 
70
105
  * [NEW] Filter with scopes.
71
106
 
@@ -146,27 +181,37 @@
146
181
 
147
182
  * [CHANGED] Configuration files are now generated by model not by groups.
148
183
 
149
- = 3.0.12
184
+
185
+ 3.0.12
186
+ ------
150
187
 
151
188
  * [FIXED] Use will_paginate 3.0.0.
152
189
 
153
- = 3.0.9
190
+
191
+ 3.0.9
192
+ -----
154
193
 
155
194
  * [NEW] Refactored and renamed `User` extensions to `AdminUserV1`.
156
195
 
157
196
  * [NEW] `AdminUserV2` which uses `bcrypt` and it's simpler. This will be the
158
197
  default authentication mechanism for my new apps.
159
198
 
160
- = 3.0.8 (unreleased)
199
+
200
+ 3.0.8
201
+ -----
161
202
 
162
203
  * [FIXED] Missing alias. (Commit 2af7d4cfd98bb0)
163
204
 
164
- = 3.0.7
165
205
 
166
- *[CHANGED] Updated assets. Please run the `typus:assets` generator in order
167
- to create the new files on the new location.
206
+ 3.0.7
207
+ -----
208
+
209
+ * [CHANGED] Updated assets. Please run the `typus:assets` generator in order
210
+ to create the new files on the new location.
168
211
 
169
- = 3.0.3
212
+
213
+ 3.0.3
214
+ -----
170
215
 
171
216
  * [NEW] Support for has many through relationships. [jmeiss]
172
217
 
@@ -247,7 +292,9 @@
247
292
 
248
293
  * [NEW] Better application templates.
249
294
 
250
- = 3.0.2
295
+
296
+ 3.0.2
297
+ -----
251
298
 
252
299
  * [FIXED] Use Arel to get the data on lists. After moving to will_paginate I
253
300
  broke the data method, on each list we where "selecting ALL on the table of
@@ -257,25 +304,31 @@
257
304
  to Rails caching mechanism this was not affecting to the performance. Now we
258
305
  only see the @current_user once. (As it should be.)
259
306
 
260
- = 3.0.1
307
+
308
+ 3.0.1
309
+ -----
261
310
 
262
311
  * [FIXED] After moving from a vendored paginator to will_paginate I removed
263
312
  some stuff which shouldn't be removed, so the 3.0.0 gem is totally broken.
264
313
 
265
314
  * [FIXED] Force query with postgresql adapter to not be case sensitive [jmeiss]
266
315
 
267
- = 3.0.0
316
+
317
+ 3.0.0
318
+ -----
268
319
 
269
320
  * [NEW] New gem version compatible with Rails 3.
270
321
 
271
- = Previously
322
+
323
+ Previously
324
+ ----------
272
325
 
273
326
  Why a 3.0.0 version? After considering the work done for the Rails 3 transition
274
327
  I though it would be a good idea to keep versions syncronized with Rails.
275
328
 
276
- Typus will have the same version numbers as Rails as I considered it's pretty
277
- tied to it. With each release of Rails, we will take the latest features into
278
- Typus.
329
+ **Typus** will have the same version numbers as Rails as I considered it's
330
+ pretty tied to it. With each release of Rails, we will take the latest features
331
+ into **Typus**.
279
332
 
280
333
  Pending stuff that someday will be done, donations and collaborations are
281
334
  accepted.
@@ -289,5 +342,3 @@ accepted.
289
342
  * Nested models.
290
343
 
291
344
  * Contextual content depending on the role logged.
292
-
293
- * Replace typus authentication by devise.
data/Gemfile CHANGED
@@ -8,9 +8,9 @@ gemspec
8
8
  # Gems used only for assets and not required
9
9
  # in production environments by default.
10
10
  group :assets do
11
- gem 'sass-rails', " ~> 3.1.0"
12
- gem 'coffee-rails', "~> 3.1.0"
13
- gem 'uglifier'
11
+ gem 'sass-rails', '~> 3.1.5'
12
+ gem 'coffee-rails', '~> 3.1.1'
13
+ gem 'uglifier', '>= 1.0.3'
14
14
  end
15
15
 
16
16
  # Database adapters
@@ -31,7 +31,7 @@ end
31
31
  # And this stuff needed for the demo application.
32
32
  gem "acts_as_list"
33
33
  gem "acts_as_tree"
34
- gem "factory_girl_rails", "~> 1.1.0"
34
+ gem "factory_girl_rails", "~> 1.4.0"
35
35
  gem "rails-permalink", "~> 1.0.0"
36
36
  gem "rails-trash", "~> 1.1.2"
37
37
 
@@ -42,14 +42,14 @@ gem "jquery-rails"
42
42
  gem "ckeditor-rails", "0.0.2"
43
43
 
44
44
  # Alternative authentication
45
- gem "devise", "~> 1.4.7"
45
+ gem "devise", "~> 1.5.2"
46
46
 
47
47
  # Asset Management with Dragonfly
48
48
  gem "dragonfly", "~> 0.9.8"
49
49
  gem "rack-cache", :require => "rack/cache"
50
50
 
51
51
  # Asset Management with Paperclip
52
- gem "paperclip", "~> 2.4.2"
52
+ gem "paperclip", "~> 2.4.5"
53
53
 
54
54
  # MongoDB
55
55
  gem "mongoid", "~> 2.3.4"
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Typus: Admin Panel for Ruby on Rails applications
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/typus/typus.png)](http://travis-ci.org/typus/typus)
3
+ [![Build Status](https://secure.travis-ci.org/fesplugas/typus.png)](http://travis-ci.org/fesplugas/typus)
4
4
 
5
5
  **Typus** is a control panel for [Ruby on Rails][rails] applications to
6
6
  allow trusted users edit structured content.
@@ -149,7 +149,7 @@ class Admin::ResourcesController < Admin::BaseController
149
149
  set_wheres
150
150
  set_joins
151
151
  check_resources_ownership if @resource.typus_options_for(:only_user_items)
152
- set_order
152
+ set_order if @resource.respond_to?(:order)
153
153
  set_eager_loading
154
154
  end
155
155
 
@@ -0,0 +1,10 @@
1
+ module Admin::Resources::DataTypes::IntegerHelper
2
+
3
+ def integer_filter(filter)
4
+ values = set_context.send(filter.to_s.pluralize).to_a
5
+ items = [[Typus::I18n.t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase), ""]]
6
+ array = values.first.is_a?(Array) ? values : values.map { |i| [i, i] }
7
+ items += array
8
+ end
9
+
10
+ end
@@ -10,7 +10,7 @@ module Admin::Resources::DataTypes::PositionHelper
10
10
 
11
11
  unless first_item || last_item
12
12
  options = { :controller => "/admin/#{item.class.to_resource}", :action => "position", :id => item.id, :go => key }
13
- locals[:html_position] << link_to(Typus::I18n.t(value), params.merge(options))
13
+ locals[:html_position] << link_to(Typus::I18n.t(value), params.merge(options), { :class => Typus::I18n.t(value).downcase })
14
14
  end
15
15
  end
16
16
 
@@ -5,7 +5,8 @@ module Admin::Resources::FiltersHelper
5
5
  locals = {}
6
6
 
7
7
  locals[:filters] = typus_filters.map do |key, value|
8
- { :key => set_filter(key, value), :value => send("#{value}_filter", key) }
8
+ { :key => set_filter(key, value),
9
+ :value => send("#{value}_filter", key) }
9
10
  end
10
11
 
11
12
  rejections = %w(controller action locale utf8 sort_order order_by) + locals[:filters].map { |f| f[:key] }
@@ -59,9 +59,13 @@ module Admin::Resources::FormHelper
59
59
  end
60
60
 
61
61
  def save_options
62
- { "_addanother" => "Save and add another",
63
- "_continue" => "Save and continue editing",
64
- "_save" => "Save" }
62
+ options = {}
63
+ options["_addanother"] = "Save and add another"
64
+ if admin_user.can?('edit', @resource.model_name)
65
+ options["_continue"] = "Save and continue editing"
66
+ end
67
+ options["_save"] = "Save"
68
+ options
65
69
  end
66
70
 
67
71
  def save_options_for_headless_mode
@@ -11,7 +11,8 @@ module Admin::Resources::RelationshipsHelper
11
11
  def build_pagination
12
12
  items_per_page = @model_to_relate.typus_options_for(:per_page)
13
13
  data = @item.send(@field).order(@model_to_relate.typus_order_by).where(set_conditions)
14
- @items = data.page(params[:page]).per(items_per_page)
14
+ page = params["#{@association_name}_page"]
15
+ @items = data.page(page).per(items_per_page)
15
16
  end
16
17
 
17
18
  def build_relationship_table
@@ -1,3 +1,7 @@
1
+ <%
2
+ param_name = "#{association_name}_page"
3
+ %>
4
+
1
5
  <div class="box_relationships" id="<%= association_name %>">
2
6
 
3
7
  <h2>
@@ -7,7 +11,7 @@
7
11
 
8
12
  <% if @items.any? -%>
9
13
  <%= table %>
10
- <%= paginate(@items, Typus.pagination.merge(:anchor => association_name)) %>
14
+ <%= paginate(@items, Typus.pagination.merge(:anchor => association_name, :param_name => param_name)) %>
11
15
  <% else %>
12
16
  <p><%= Typus::I18n.t("No %{resources} found.", :resources => association_name.humanize.downcase.pluralize) %></p>
13
17
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= item.position %>
2
2
 
3
- <div class="actions">
3
+ <div class="actions position">
4
4
  <%= html_position.join(connector).html_safe %>
5
5
  </div>
@@ -21,13 +21,9 @@ Rails.application.routes.draw do
21
21
  end
22
22
  end
23
23
 
24
- Typus.models.map(&:to_resource).each do |resource|
25
- match "#{resource}(/:action(/:id))(.:format)", :controller => resource
26
- end
24
+ controllers = Typus.models.map(&:to_resource) + Typus.resources.map(&:underscore)
25
+ controllers.each { |c| match "#{c}(/:action(/:id))(.:format)", :controller => c }
27
26
 
28
- Typus.resources.map(&:underscore).each do |resource|
29
- match "#{resource}(/:action(/:id))(.:format)", :controller => resource
30
- end
31
27
  end
32
28
 
33
29
  if Typus.subdomain
@@ -37,4 +33,5 @@ Rails.application.routes.draw do
37
33
  else
38
34
  scope "admin", {:module => :admin, :as => "admin"}, &routes_block
39
35
  end
36
+
40
37
  end
@@ -4,11 +4,14 @@ require "support/object"
4
4
  require "support/string"
5
5
 
6
6
  require "typus/engine"
7
- require "typus/orm/base"
8
- require "typus/orm/active_record"
9
7
  require "typus/regex"
10
8
  require "typus/version"
11
9
 
10
+ require "typus/orm/base/class_methods"
11
+ require "typus/orm/base/search"
12
+ require "typus/orm/active_record"
13
+ require "typus/orm/mongoid"
14
+
12
15
  require "kaminari"
13
16
 
14
17
  autoload :FakeUser, "support/fake_user"
@@ -27,7 +27,7 @@ module Typus
27
27
  options = { :conditions => @conditions, :batch_size => 1000 }
28
28
 
29
29
  ::CSV.open(filename, 'w') do |csv|
30
- csv << fields.keys
30
+ csv << fields.keys.map { |k| @resource.human_attribute_name(k) }
31
31
  @resource.find_in_batches(options) do |records|
32
32
  records.each do |record|
33
33
  csv << fields.map do |key, value|
@@ -3,7 +3,7 @@ module Typus
3
3
  module ActiveRecord
4
4
  module ClassMethods
5
5
 
6
- include Typus::Orm::Base
6
+ include Typus::Orm::Base::ClassMethods
7
7
 
8
8
  # Model fields as an <tt>ActiveSupport::OrderedHash</tt>.
9
9
  def model_fields
@@ -51,10 +51,6 @@ module Typus
51
51
  filter.to_sym.eql?(:index) ? ['id'] : model_fields.keys
52
52
  end
53
53
 
54
- def virtual_fields
55
- instance_methods.map(&:to_s) - model_fields.keys.map(&:to_s)
56
- end
57
-
58
54
  def virtual_attribute?(field)
59
55
  :virtual if virtual_fields.include?(field.to_s)
60
56
  end
@@ -79,15 +75,6 @@ module Typus
79
75
  reflect_on_association(field).macro if reflect_on_association(field)
80
76
  end
81
77
 
82
- def custom_attribute?(field)
83
- case field.to_s
84
- when 'parent', 'parent_id' then :tree
85
- when /password/ then :password
86
- when 'position' then :position
87
- when /\./ then :transversal
88
- end
89
- end
90
-
91
78
  def typus_filters
92
79
  ActiveSupport::OrderedHash.new.tap do |fields_with_type|
93
80
  get_typus_filters.each do |field|
@@ -101,6 +88,10 @@ module Typus
101
88
  data.extract_settings.map(&:to_sym)
102
89
  end
103
90
 
91
+ def typus_user_id?
92
+ columns.map(&:name).include?(Typus.user_foreign_key)
93
+ end
94
+
104
95
  end
105
96
  end
106
97
  end
@@ -3,6 +3,8 @@ module Typus
3
3
  module ActiveRecord
4
4
  module Search
5
5
 
6
+ include Typus::Orm::Base::Search
7
+
6
8
  def build_search_conditions(key, value)
7
9
  Array.new.tap do |search|
8
10
  query = ::ActiveRecord::Base.connection.quote_string(value.downcase)
@@ -25,76 +27,10 @@ module Typus
25
27
  end.join(" OR ")
26
28
  end
27
29
 
28
- def build_boolean_conditions(key, value)
29
- { key => (value == 'true') ? true : false }
30
- end
31
-
32
- def build_datetime_conditions(key, value)
33
- tomorrow = Time.zone.now.beginning_of_day.tomorrow
34
-
35
- interval = case value
36
- when 'today' then 0.days.ago.beginning_of_day..tomorrow
37
- when 'last_few_days' then 3.days.ago.beginning_of_day..tomorrow
38
- when 'last_7_days' then 6.days.ago.beginning_of_day..tomorrow
39
- when 'last_30_days' then 30.days.ago.beginning_of_day..tomorrow
40
- end
41
-
42
- build_filter_interval(interval, key)
43
- end
44
-
45
- def build_date_conditions(key, value)
46
- tomorrow = 0.days.ago.tomorrow.to_date
47
-
48
- interval = case value
49
- when 'today' then 0.days.ago.to_date..tomorrow
50
- when 'last_few_days' then 3.days.ago.to_date..tomorrow
51
- when 'last_7_days' then 6.days.ago.to_date..tomorrow
52
- when 'last_30_days' then 30.days.ago.to_date..tomorrow
53
- end
54
-
55
- build_filter_interval(interval, key)
56
- end
57
-
58
30
  def build_filter_interval(interval, key)
59
31
  ["#{table_name}.#{key} BETWEEN ? AND ?", interval.first.to_s(:db), interval.last.to_s(:db)]
60
32
  end
61
33
 
62
- def build_string_conditions(key, value)
63
- { key => value }
64
- end
65
-
66
- alias_method :build_integer_conditions, :build_string_conditions
67
- alias_method :build_belongs_to_conditions, :build_string_conditions
68
-
69
- # TODO: Detect the primary_key for this object.
70
- def build_has_many_conditions(key, value)
71
- ["#{key}.id = ?", value]
72
- end
73
-
74
- ##
75
- # To build conditions we reject all those params which are not model
76
- # fields.
77
- #
78
- # Note: We still want to be able to search so the search param is not
79
- # rejected.
80
- #
81
- def build_conditions(params)
82
- Array.new.tap do |conditions|
83
- query_params = params.dup
84
-
85
- query_params.reject! do |k, v|
86
- !model_fields.keys.include?(k.to_sym) &&
87
- !model_relationships.keys.include?(k.to_sym) &&
88
- !(k.to_sym == :search)
89
- end
90
-
91
- query_params.compact.each do |key, value|
92
- filter_type = model_fields[key.to_sym] || model_relationships[key.to_sym] || key
93
- conditions << send("build_#{filter_type}_conditions", key, value)
94
- end
95
- end
96
- end
97
-
98
34
  def build_my_joins(params)
99
35
  query_params = params.dup
100
36
  query_params.reject! { |k, v| !model_relationships.keys.include?(k.to_sym) }