ems 0.1.7 → 0.1.8

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.
@@ -6,9 +6,9 @@ module Ems
6
6
  check_authorization
7
7
 
8
8
  # # Global cancan failure recovery
9
- # rescue_from CanCan::AccessDenied do |exception|
10
- # redirect_to main_app.new_user_session_path, :alert => exception.message
11
- # end
9
+ rescue_from CanCan::AccessDenied do |exception|
10
+ redirect_to main_app.new_user_session_path, :alert => exception.message
11
+ end
12
12
 
13
13
  # We need to make sure that we are using the ems abilities in the EMS
14
14
  def current_ability
@@ -4,7 +4,7 @@ module Ems
4
4
 
5
5
  attr_accessible :category_id, :channel_ids, :tag_ids, :title, :publish_from,
6
6
  :status, :image, :standfirst, :content, :assets, :article_ids, :report_ids,
7
- :news_ids, :hot, :featured
7
+ :news_ids, :hot, :featured, :assets_attributes
8
8
 
9
9
  # use friendly_id to handle our slugs
10
10
  extend FriendlyId
@@ -95,10 +95,14 @@ module Ems
95
95
  Kramdown::Document.new(content, :input => "BeanKramdown").to_html
96
96
  end
97
97
 
98
+ def image_url
99
+ self.image.url
100
+ end
101
+
98
102
  #
99
103
  # @param options
100
104
  def as_json(options={})
101
- super( options.merge( :include => [ :category, :channels, :tags, :images ] ) )
105
+ super(options.merge(:include => [:category, :channels, :tags, :images], :methods => [:image_url]))
102
106
  end
103
107
 
104
108
  #
@@ -1,17 +1,21 @@
1
1
  module Ems
2
2
  class Asset < ActiveRecord::Base
3
-
3
+
4
+ attr_accessible :asset
5
+
4
6
  validates_attachment :asset, :presence => true,
5
7
  :content_type => { :content_type => ["image/jpg", "image/jpeg"] }
6
-
8
+
7
9
  belongs_to :assetable, :polymorphic => true
8
-
10
+ # accepts_nested_attributes_for :assets
11
+
9
12
  has_attached_file :asset, :styles => {:original => "564x252>"}
10
-
13
+
11
14
  # virtual alt text accessor - returns the title of the image otherwise the path
12
15
  def alt
13
- alt = self.title
16
+ alt = self.title
14
17
  alt ||= self.image.url
15
18
  end
19
+
16
20
  end
17
21
  end
@@ -6,7 +6,7 @@ module Ems
6
6
  def should_generate_new_friendly_id?
7
7
  not self.is_live?
8
8
  end
9
-
9
+
10
10
  # searchable do
11
11
  # text :title, :stored => true
12
12
  # text :standfirst, :stored => true
@@ -25,12 +25,12 @@ module Ems
25
25
  validates :channels, :presence => true, :if => :is_live?
26
26
  validates :publish_from, :presence => true, :if => :is_live?
27
27
  validates :status, :presence => true
28
-
28
+
29
29
  validates :image, :attachment_presence => true, :if => :is_live?
30
30
  validates :title, :presence => true, :if => :is_live?
31
31
  validates :standfirst, :presence => true, :if => :is_live?
32
32
  validates :content, :presence => true, :if => :is_live?
33
-
33
+
34
34
  validates_uniqueness_of :slug
35
35
  validates_inclusion_of :content_disposition, :in => [ :html, :markdown ], :message => "Value is not a valid content disposition"
36
36
  validates_inclusion_of :status, :in => [ :draft, :pending, :live ], :message => "Value is not a valid status"
@@ -49,9 +49,9 @@ module Ems
49
49
  accepts_nested_attributes_for :news
50
50
  has_and_belongs_to_many :reports, :join_table => 'ems_news_reports'
51
51
  accepts_nested_attributes_for :reports
52
-
52
+
53
53
  has_attached_file :image, :styles => { :image564x252 => "564x252#", :image312x189 => "312x189#", :image312x126 => "312x126", :image228x126 => "228x126"}
54
-
54
+
55
55
  has_many :assets, :as => :assetable
56
56
  accepts_nested_attributes_for :assets, :allow_destroy => true
57
57
 
@@ -60,7 +60,7 @@ module Ems
60
60
  self.status ||= :draft
61
61
  self.content_disposition ||= :markdown
62
62
  end
63
-
63
+
64
64
  # Custom getter for status attribute to emulate ENUMs
65
65
  # @return [Symbol] status currently assigned to the attribute
66
66
  def status
@@ -84,22 +84,22 @@ module Ems
84
84
  def content_disposition= (value)
85
85
  write_attribute(:content_disposition, value.to_s)
86
86
  end
87
-
87
+
88
88
  def content_as_html
89
89
  Kramdown::Document.new(content, :input => "BeanKramdown").to_html
90
90
  end
91
-
91
+
92
92
  #
93
93
  def is_live?
94
94
  self.status === :live
95
95
  end
96
-
96
+
97
97
  #
98
98
  # @param options
99
99
  def as_json(options={})
100
100
  super( options.merge( :include => [ :category, :channels, :tags ] ) )
101
101
  end
102
-
102
+
103
103
  # base queries
104
104
  class << self
105
105
  def base_query(category=nil)
@@ -107,6 +107,6 @@ module Ems
107
107
  q = q.where('ems_categories.id' => category.id) if category
108
108
  return q
109
109
  end
110
- end
110
+ end
111
111
  end
112
112
  end
@@ -1,3 +1,3 @@
1
1
  module Ems
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -0,0 +1 @@
1
+  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ems
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-17 00:00:00.000000000 Z
12
+ date: 2012-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -473,6 +473,7 @@ files:
473
473
  - test/dummy/config.ru
474
474
  - test/dummy/db/migrate/20120520002317_devise_create_users.rb
475
475
  - test/dummy/db/schema.rb
476
+ - test/dummy/log/development.log
476
477
  - test/dummy/public/404.html
477
478
  - test/dummy/public/422.html
478
479
  - test/dummy/public/500.html
@@ -552,7 +553,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
552
553
  version: '0'
553
554
  segments:
554
555
  - 0
555
- hash: 1341355416954403944
556
+ hash: -2125801159709775580
556
557
  required_rubygems_version: !ruby/object:Gem::Requirement
557
558
  none: false
558
559
  requirements:
@@ -561,10 +562,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
561
562
  version: '0'
562
563
  segments:
563
564
  - 0
564
- hash: 1341355416954403944
565
+ hash: -2125801159709775580
565
566
  requirements: []
566
567
  rubyforge_project:
567
- rubygems_version: 1.8.19
568
+ rubygems_version: 1.8.24
568
569
  signing_key:
569
570
  specification_version: 3
570
571
  summary: Editorial Management System
@@ -594,6 +595,7 @@ test_files:
594
595
  - test/dummy/config.ru
595
596
  - test/dummy/db/migrate/20120520002317_devise_create_users.rb
596
597
  - test/dummy/db/schema.rb
598
+ - test/dummy/log/development.log
597
599
  - test/dummy/public/404.html
598
600
  - test/dummy/public/422.html
599
601
  - test/dummy/public/500.html