Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change history for Fork PR process

  • Loading branch information...
commit acd45317f13c4148e3737d5914cac561bbe5d9d8 1 parent afdb092
@RajRoR authored
View
16 app/helpers/admin/changelogs_helper.rb
@@ -1,6 +1,6 @@
module Admin::ChangelogsHelper
CHARACTERS_AROUND_DIFF = 40
-
+
def changelogged_link_for(changelog)
link_text = "#{I18n.t('activerecord.models.'+changelog.changelogged_type.downcase)} ##{changelog.changelogged_id}"
if changelog.changelogged.class == Comment
@@ -10,26 +10,32 @@ def changelogged_link_for(changelog)
elsif comment.commentable.class == Article
link_to link_text, article_path(comment.commentable, anchor: "comments")
end
+ elsif changelog.changelogged.class == TranslatedIdea
+ translated_idea = changelog.changelogged
+ link_to link_text, idea_translated_idea_path(translated_idea.idea, translated_idea)
+ elsif changelog.changelogged.class == ForkedIdea
+ translated_idea = changelog.changelogged.class.find(changelog.changelogged_id).translated_idea
+ link_to link_text, idea_translated_idea_forked_idea_path(translated_idea.idea, translated_idea, changelog.changelogged)
else
link_to link_text, changelog.changelogged
end
end
-
+
def short_diff(change)
if change.first.present? && change.last.present?
diffed = Differ.diff(change.last.to_s, change.first.to_s, '').to_s
-
+
# location of the actual diff
diff_start = diffed.index("<del class=\"differ\">")
diff_start ||= diffed.index("<ins class=\"differ\">")
diff_end = diffed.rindex("</ins>") && (diffed.rindex("</ins>") + "</ins>".length - 1) || nil
diff_end ||= diffed.rindex("</del>") + "</del>".length - 1
-
+
# take along some extra chars around the diff
from = [0, diff_start - CHARACTERS_AROUND_DIFF].max
to = [diffed.to_s.length, diff_end + CHARACTERS_AROUND_DIFF].min
diff = diffed[from..to]
-
+
# add "&hellip;"s to indicate there is more text out there
diff.insert(0, '&hellip; ') if from > 0
diff << ' &hellip;' if to < diffed.length
View
2  app/models/forked_idea.rb
@@ -1,4 +1,6 @@
class ForkedIdea < ActiveRecord::Base
+ include Changelogger
+
attr_accessible :author_id, :body, :summary, :title, :translated_idea_id, :pull_request_at, :is_closed
belongs_to :translated_idea
View
28 app/models/translated_idea.rb
@@ -1,37 +1,39 @@
class TranslatedIdea < ActiveRecord::Base
+ include Changelogger
+
belongs_to :idea
belongs_to :author, class_name: "Citizen", foreign_key: "author_id"
-
+
has_many :forked_ideas, :dependent => :destroy
attr_accessible :author_id, :body, :idea_id, :language, :summary, :title
-
+
validates_uniqueness_of :idea_id, :scope => [:language]
-
+
def collecting_ended
self.idea.collecting_ended
end
-
+
def signatures
self.idea.signatures
end
-
+
def additional_signatures_count
- self.idea.additional_signatures_count
+ self.idea.additional_signatures_count
end
-
+
def vote_counts
self.idea.vote_counts
end
-
+
def comments
- self.idea.comments
+ self.idea.comments
end
-
+
def collecting_start_date
- self.idea.collecting_start_date
+ self.idea.collecting_start_date
end
-
+
def collecting_end_date
- self.idea.collecting_end_date
+ self.idea.collecting_end_date
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.