cartoonist-twitter 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,11 @@ class Admin::TweetsController < AdminCartoonistController
22
22
 
23
23
  private
24
24
  def send_tweet_if_requested
25
- @tweet.manual_tweet! if params[:tweet_now].present?
25
+ if params[:tweet_now].present?
26
+ @tweet.manual_tweet!
27
+ elsif params[:resend_tweet].present?
28
+ @tweet.resend_tweet!
29
+ end
26
30
  end
27
31
 
28
32
  def tweet_or_entity_redirect
data/app/models/tweet.rb CHANGED
@@ -5,13 +5,19 @@ class Tweet < ActiveRecord::Base
5
5
  attr_accessible :entity_id, :entity_type, :tweet, :tweeted_at
6
6
 
7
7
  def allow_tweet_now?
8
+ allow_save? && !disabled? && entity_posted?
9
+ end
10
+
11
+ def allow_resend_tweet?
12
+ tweeted? && !disabled? && entity_posted?
13
+ end
14
+
15
+ def entity_posted?
8
16
  if entity.kind_of? Postable
9
17
  posted = entity.posted?
10
18
  else
11
19
  posted = true
12
20
  end
13
-
14
- allow_save? && !disabled? && posted
15
21
  end
16
22
 
17
23
  def allow_save?
@@ -34,6 +40,13 @@ class Tweet < ActiveRecord::Base
34
40
  send_tweet!
35
41
  end
36
42
 
43
+ def resend_tweet!
44
+ raise "Tweeting is not allowed!" unless allow_resend_tweet?
45
+ return unless tweeted?
46
+ return if disabled?
47
+ send_tweet!
48
+ end
49
+
37
50
  def auto_tweet!
38
51
  return if tweeted?
39
52
  return unless expected_tweet_time
@@ -119,6 +132,7 @@ class Tweet < ActiveRecord::Base
119
132
  class << self
120
133
  def update_tweet(params)
121
134
  tweet = find params[:id].to_i
135
+ return tweet if params[:resend_tweet].present?
122
136
  raise "Saving is not allowed!" unless tweet.allow_save?
123
137
  tweet.tweet = params[:tweet]
124
138
  tweet.save!
@@ -18,5 +18,11 @@
18
18
  <p>
19
19
  <input type="submit" name="tweet_now" value="<%= t "admin.tweets.entity_tweet.tweet_now" %>" <%= 'disabled="disabled"'.html_safe unless tweet.allow_tweet_now? %> />
20
20
  </p>
21
+
22
+ <% if tweet.allow_resend_tweet? %>
23
+ <p>
24
+ <input type="submit" name="resend_tweet" value="<%= t "admin.tweets.entity_tweet.resend_tweet" %>" onclick="return confirm('Are you sure?')" />
25
+ </p>
26
+ <% end %>
21
27
  <% end %>
22
28
  <% end %>
@@ -2,4 +2,4 @@
2
2
  <%= @tweet.description %>
3
3
  </p>
4
4
 
5
- <%= render :partial => "admin/tweets/entity_tweet", :locals => { :entity => @tweet.entity, :destination => :tweet } %>
5
+ <%= partial "admin/tweets/entity_tweet", :entity => @tweet.entity, :destination => :tweet %>
@@ -8,6 +8,7 @@ en:
8
8
  save: Save
9
9
  tweet: "Tweet:"
10
10
  tweet_now: Tweet Now
11
+ resend_tweet: Resend Tweet
11
12
  index:
12
13
  not_tweeted: Not yet tweeted
13
14
  tweeted: Tweeted
@@ -2,7 +2,7 @@ module CartoonistTwitter
2
2
  class Version
3
3
  class << self
4
4
  def to_s
5
- "0.0.16"
5
+ "0.0.17"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,48 +1,54 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cartoonist-twitter
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.17
4
5
  prerelease:
5
- version: 0.0.16
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Mike Virata-Stone
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-12-15 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: cartoonist
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - "="
22
- - !ruby/object:Gem::Version
23
- version: 0.0.16
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.17
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: twitter
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.17
30
+ - !ruby/object:Gem::Dependency
31
+ name: twitter
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
- requirements:
34
+ requirements:
32
35
  - - ~>
33
- - !ruby/object:Gem::Version
36
+ - !ruby/object:Gem::Version
34
37
  version: 4.4.1
35
38
  type: :runtime
36
- version_requirements: *id002
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 4.4.1
37
46
  description: Plugin to allow tweeting of cartoonist entities.
38
47
  email: reasonnumber@gmail.com
39
48
  executables: []
40
-
41
49
  extensions: []
42
-
43
50
  extra_rdoc_files: []
44
-
45
- files:
51
+ files:
46
52
  - app/controllers/admin/tweets_controller.rb
47
53
  - app/models/tweet.rb
48
54
  - app/views/admin/tweets/_entity_tweet.html.erb
@@ -57,30 +63,26 @@ files:
57
63
  - lib/cartoonist-twitter/version.rb
58
64
  homepage: http://reasonnumber.com/cartoonist
59
65
  licenses: []
60
-
61
66
  post_install_message:
62
67
  rdoc_options: []
63
-
64
- require_paths:
68
+ require_paths:
65
69
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
70
+ required_ruby_version: !ruby/object:Gem::Requirement
67
71
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: "0"
72
- required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
77
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
78
82
  requirements: []
79
-
80
83
  rubyforge_project:
81
84
  rubygems_version: 1.8.24
82
85
  signing_key:
83
86
  specification_version: 3
84
87
  summary: Cartoonist Twitter
85
88
  test_files: []
86
-