Skip to content

Commit 12fccdb

Browse files
committed
DrupalNodeRevision => Revision
1 parent c08dc35 commit 12fccdb

32 files changed

+152
-129
lines changed

app/assets/javascripts/post.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jQuery(document).ready(function() {
1414
$('.side-dropzone').css('background','#fcc')
1515
alert_notice('Click <b>Publish</b> again to publish without a main image, but it is recommended that you add one.', {'scroll': true})
1616
} else {
17-
$('#new_drupal_node_revision#new_drupal_node_revision,#edit_drupal_node_revision').submit()
17+
$('#new_revision#new_revision,#edit_revision').submit()
1818
}
1919
}
2020
$(".publish").bind("click",publish)

app/controllers/admin_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def spam
7373

7474
def spam_revisions
7575
if current_user && (current_user.role == 'moderator' || current_user.role == 'admin')
76-
@revisions = DrupalNodeRevision.paginate(page: params[:page])
77-
.order('timestamp DESC')
78-
.where(status: 0)
76+
@revisions = Revision.paginate(page: params[:page])
77+
.order('timestamp DESC')
78+
.where(status: 0)
7979
render template: 'admin/spam'
8080
else
8181
flash[:error] = 'Only moderators can moderate revisions.'
@@ -140,7 +140,7 @@ def publish
140140
end
141141

142142
def mark_spam_revision
143-
@revision = DrupalNodeRevision.find_by_vid params[:vid]
143+
@revision = Revision.find_by_vid params[:vid]
144144
if current_user && (current_user.role == 'moderator' || current_user.role == 'admin')
145145
if @revision.status == 1
146146
@revision.spam
@@ -163,7 +163,7 @@ def mark_spam_revision
163163

164164
def publish_revision
165165
if current_user && (current_user.role == 'moderator' || current_user.role == 'admin')
166-
@revision = DrupalNodeRevision.find params[:vid]
166+
@revision = Revision.find params[:vid]
167167
@revision.publish
168168
@revision.author.unban
169169
flash[:notice] = 'Item published.'

app/controllers/application_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def set_sidebar(type = :generic, data = :all, args = {})
3333
.collect(&:nid)
3434
@notes = if params[:controller] == 'questions'
3535
Node.questions
36-
.joins(:drupal_node_revision)
36+
.joins(:revision)
3737
else
3838
Node.research_notes
39-
.joins(:drupal_node_revision)
39+
.joins(:revision)
4040
.order('node.nid DESC')
4141
.paginate(page: params[:page])
4242
end
@@ -52,7 +52,7 @@ def set_sidebar(type = :generic, data = :all, args = {})
5252
end
5353

5454
@wikis = Node.order('changed DESC')
55-
.joins(:drupal_node_revision)
55+
.joins(:revision)
5656
.where('node_revisions.status = 1 AND node.status = 1 AND type = "page"')
5757
.limit(10)
5858
.group('node_revisions.nid')

app/controllers/home_controller.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def dashboard
4444
@note_count = Node.select(%i[created type status])
4545
.where(type: 'note', status: 1, created: Time.now.to_i - 1.weeks.to_i..Time.now.to_i)
4646
.count
47-
@wiki_count = DrupalNodeRevision.select(:timestamp)
48-
.where(timestamp: Time.now.to_i - 1.weeks.to_i..Time.now.to_i)
49-
.count
47+
@wiki_count = Revision.select(:timestamp)
48+
.where(timestamp: Time.now.to_i - 1.weeks.to_i..Time.now.to_i)
49+
.count
5050
@blog = Tag.find_nodes_by_type('blog', 'note', 1).first
5151
# remove "classroom" postings; also switch to an EXCEPT operator in sql, see https://github.com/publiclab/plots2/issues/375
5252
hidden_nids = Node.joins(:node_tag)
@@ -73,14 +73,14 @@ def dashboard
7373
@wikis = Node.where(type: 'page', status: 1)
7474
.order('nid DESC')
7575
.limit(10)
76-
revisions = DrupalNodeRevision.joins(:node)
77-
.order('timestamp DESC')
78-
.where('type = (?)', 'page')
79-
.where('node.status = 1')
80-
.where('node_revisions.status = 1')
81-
.where('timestamp - node.created > ?', 300) # don't report edits within 5 mins of page creation
82-
.limit(10)
83-
.group('node.title')
76+
revisions = Revision.joins(:node)
77+
.order('timestamp DESC')
78+
.where('type = (?)', 'page')
79+
.where('node.status = 1')
80+
.where('node_revisions.status = 1')
81+
.where('timestamp - node.created > ?', 300) # don't report edits within 5 mins of page creation
82+
.limit(10)
83+
.group('node.title')
8484
# group by day: http://stackoverflow.com/questions/5970938/group-by-day-from-timestamp
8585
revisions = revisions.group('DATE(FROM_UNIXTIME(timestamp))') if Rails.env == 'production'
8686
@wikis += revisions

app/controllers/notes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def tools
1414
def places
1515
@title = 'Places'
1616
@notes = Node.where(status: 1, type: %w[page place])
17-
.includes(:drupal_node_revision, :tag)
17+
.includes(:revision, :tag)
1818
.where('term_data.name = ?', 'chapter')
1919
.page(params[:page])
2020
.order('node_revisions.timestamp DESC')

app/controllers/stats_controller.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def range
1414
@notes = Node.select(%i[created type status])
1515
.where(type: 'note', status: 1, created: @start.to_i..@end.to_i)
1616
.count
17-
@wikis = DrupalNodeRevision.select(:timestamp)
18-
.where(timestamp: @start.to_i..@end.to_i)
19-
.count - @notes # because notes each have one revision
17+
@wikis = Revision.select(:timestamp)
18+
.where(timestamp: @start.to_i..@end.to_i)
19+
.count - @notes # because notes each have one revision
2020
@people = User.where(created_at: @start..@end)
2121
.joins('INNER JOIN users ON users.uid = rusers.id')
2222
.where('users.status = 1')
@@ -33,19 +33,19 @@ def index
3333
@weekly_notes = Node.select(%i[created type status])
3434
.where(type: 'note', status: 1, created: @time.to_i - 1.weeks.to_i..@time.to_i)
3535
.count
36-
@weekly_wikis = DrupalNodeRevision.select(:timestamp)
37-
.where(timestamp: @time.to_i - 1.weeks.to_i..@time.to_i)
38-
.count
36+
@weekly_wikis = Revision.select(:timestamp)
37+
.where(timestamp: @time.to_i - 1.weeks.to_i..@time.to_i)
38+
.count
3939
@weekly_members = User.where(created_at: @time - 1.weeks..@time)
4040
.joins('INNER JOIN users ON users.uid = rusers.id')
4141
.where('users.status = 1')
4242
.count
4343
@monthly_notes = Node.select(%i[created type status])
4444
.where(type: 'note', status: 1, created: @time.to_i - 1.months.to_i..@time.to_i)
4545
.count
46-
@monthly_wikis = DrupalNodeRevision.select(:timestamp)
47-
.where(timestamp: @time.to_i - 1.months.to_i..@time.to_i)
48-
.count
46+
@monthly_wikis = Revision.select(:timestamp)
47+
.where(timestamp: @time.to_i - 1.months.to_i..@time.to_i)
48+
.count
4949
@monthly_members = User.where(created_at: @time - 1.months..@time)
5050
.joins('INNER JOIN users ON users.uid = rusers.id')
5151
.where('users.status = 1')
@@ -54,9 +54,9 @@ def index
5454
@notes_per_week_past_year = Node.select(%i[created type status])
5555
.where(type: 'note', status: 1, created: @time.to_i - 1.years.to_i..@time.to_i)
5656
.count / 52.0
57-
@edits_per_week_past_year = DrupalNodeRevision.select(:timestamp)
58-
.where(timestamp: @time.to_i - 1.years.to_i..@time.to_i)
59-
.count / 52.0
57+
@edits_per_week_past_year = Revision.select(:timestamp)
58+
.where(timestamp: @time.to_i - 1.years.to_i..@time.to_i)
59+
.count / 52.0
6060

6161
@graph_notes = Node.weekly_tallies('note', 52, @time).to_a.sort.to_json
6262
@graph_wikis = Node.weekly_tallies('page', 52, @time).to_a.sort.to_json

app/controllers/tag_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ def show
3333
@wildcard = true
3434
@tags = Tag.where('name LIKE (?)', params[:id][0..-2] + '%')
3535
nodes = Node.where(status: 1, type: node_type)
36-
.includes(:drupal_node_revision, :tag)
36+
.includes(:revision, :tag)
3737
.where('term_data.name LIKE (?) OR term_data.parent LIKE (?)', params[:id][0..-2] + '%', params[:id][0..-2] + '%')
3838
.page(params[:page])
3939
.order('node_revisions.timestamp DESC')
4040
else
4141
@tags = Tag.find_all_by_name params[:id]
4242
nodes = Node.where(status: 1, type: node_type)
43-
.includes(:drupal_node_revision, :tag)
43+
.includes(:revision, :tag)
4444
.where('term_data.name = ? OR term_data.parent = ?', params[:id], params[:id])
4545
.page(params[:page])
4646
.order('node_revisions.timestamp DESC')
@@ -197,7 +197,7 @@ def suggested
197197
def rss
198198
if params[:tagname][-1..-1] == '*'
199199
@notes = Node.where(status: 1, type: 'note')
200-
.includes(:drupal_node_revision, :tag)
200+
.includes(:revision, :tag)
201201
.where('term_data.name LIKE (?)', params[:tagname][0..-2] + '%')
202202
.limit(20)
203203
.order('node_revisions.timestamp DESC')
@@ -223,7 +223,7 @@ def contributors
223223
@tagnames = [params[:id]]
224224
@tag = Tag.find_by_name params[:id]
225225
@notes = Node.where(status: 1, type: 'note')
226-
.includes(:drupal_node_revision, :tag)
226+
.includes(:revision, :tag)
227227
.where('term_data.name = ?', params[:id])
228228
.order('node_revisions.timestamp DESC')
229229
@users = @notes.collect(&:author).uniq

app/controllers/users_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ def profile
117117
.where(status: 1)
118118
.order('node.nid DESC')
119119
@answered_questions = questions.select{|q| q.answers.collect(&:author).include?(@user)}
120-
wikis = DrupalNodeRevision.order("nid DESC")
121-
.where('node.type' => 'page', 'node.status' => 1, uid: @user.uid)
122-
.joins(:node)
123-
.limit(20)
120+
wikis = Revision.order("nid DESC")
121+
.where('node.type' => 'page', 'node.status' => 1, uid: @user.uid)
122+
.joins(:node)
123+
.limit(20)
124124
@wikis = wikis.collect(&:parent).uniq
125125
if @user.status == 0
126126
if current_user && (current_user.role == "admin" || current_user.role == "moderator")

app/controllers/wiki_controller.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def show
8484
# display a revision, raw
8585
def raw
8686
response.headers['Content-Type'] = 'text/plain; charset=utf-8'
87-
render text: DrupalNodeRevision.find(params[:id]).body
87+
render text: Revision.find(params[:id]).body
8888
end
8989

9090
def edit
@@ -121,7 +121,7 @@ def new
121121
@related = Node.limit(10)
122122
.order('node.nid DESC')
123123
.where('type = "page" AND node.status = 1 AND (node.title LIKE ? OR node_revisions.body LIKE ?)', '%' + title + '%', '%' + title + '%')
124-
.includes(:drupal_node_revision)
124+
.includes(:revision)
125125
tag = Tag.find_by_name(params[:id]) # add page name as a tag, too
126126
@tags << tag if tag
127127
@related += Tag.find_nodes_by_type(@tags.collect(&:name), 'page', 10)
@@ -213,7 +213,7 @@ def delete
213213
end
214214

215215
def revert
216-
revision = DrupalNodeRevision.find params[:id]
216+
revision = Revision.find params[:id]
217217
node = revision.parent
218218
if current_user && (current_user.role == 'moderator' || current_user.role == 'admin')
219219
new_rev = revision.dup
@@ -263,7 +263,7 @@ def revision
263263
@unpaginated = true
264264
@is_revision = true
265265
set_sidebar :tags, @tagnames, videos: true
266-
@revision = DrupalNodeRevision.find_by_nid_and_vid(@node.id, params[:vid])
266+
@revision = Revision.find_by_nid_and_vid(@node.id, params[:vid])
267267
if @revision.nil?
268268
flash[:error] = I18n.t('wiki_controller.revision_not_found')
269269
redirect_to action: 'revisions'
@@ -277,8 +277,8 @@ def revision
277277
end
278278

279279
def diff
280-
@a = DrupalNodeRevision.find_by_vid(params[:a])
281-
@b = DrupalNodeRevision.find_by_vid(params[:b])
280+
@a = Revision.find_by_vid(params[:a])
281+
@b = Revision.find_by_vid(params[:b])
282282
if @a.body == @b.body
283283
render text: I18n.t('wiki_controller.lead_image_or_title_change').html_safe
284284
else
@@ -295,7 +295,7 @@ def index
295295
'node_revisions.timestamp DESC'
296296
end
297297

298-
@wikis = Node.includes(:drupal_node_revision)
298+
@wikis = Node.includes(:revision)
299299
.group('node_revisions.nid')
300300
.order(order_string)
301301
.where("node_revisions.status = 1 AND node.status = 1 AND (type = 'page' OR type = 'tool' OR type = 'place')")
@@ -308,7 +308,7 @@ def popular
308308
@title = I18n.t('wiki_controller.popular_wiki_pages')
309309
@wikis = Node.limit(40)
310310
.order('views DESC')
311-
.joins(:drupal_node_revision)
311+
.joins(:revision)
312312
.group('node_revisions.nid')
313313
.order('node_revisions.timestamp DESC')
314314
.where("node.status = 1 AND node_revisions.status = 1 AND node.nid != 259 AND (type = 'page' OR type = 'tool' OR type = 'place')")
@@ -349,7 +349,7 @@ def techniques
349349
def methods
350350
@nodes = Node.where(status: 1, type: ['page'])
351351
.where('term_data.name = ?', 'tool')
352-
.includes(:drupal_node_revision, :tag)
352+
.includes(:revision, :tag)
353353
.order('node_revisions.timestamp DESC')
354354
# deprecating the following in favor of javascript implementation in /app/assets/javascripts/methods.js
355355
if params[:topic]
@@ -361,7 +361,7 @@ def methods
361361
'%' + params[:topic] + '%',
362362
'%' + params[:topic] + '%',
363363
params[:topic])
364-
.includes(:drupal_node_revision, :tag)
364+
.includes(:revision, :tag)
365365
.order('node_revisions.timestamp DESC')
366366
end
367367
if params[:topic]
@@ -373,7 +373,7 @@ def methods
373373
'%' + params[:topic] + '%',
374374
'%' + params[:topic] + '%',
375375
params[:topic])
376-
.includes(:drupal_node_revision, :tag)
376+
.includes(:revision, :tag)
377377
.order('node_revisions.timestamp DESC')
378378
end
379379

app/models/concerns/node_shared.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def self.notes_grid(body, _page = 1)
1414
body.gsub(/[^\>`](\<p\>)?\[notes\:(\S+)\]/) do |_tagname|
1515
tagname = Regexp.last_match(2).parameterize
1616
nodes = Node.where(status: 1, type: 'note')
17-
.includes(:drupal_node_revision, :tag)
17+
.includes(:revision, :tag)
1818
.where('term_data.name = ?', tagname)
1919
.order('node_revisions.timestamp DESC')
2020
output = ''
@@ -38,7 +38,7 @@ def self.questions_grid(body, _page = 1)
3838
body.gsub(/[^\>`](\<p\>)?\[questions\:(\S+)\]/) do |_tagname|
3939
tagname = Regexp.last_match(2).parameterize
4040
nodes = Node.where(status: 1, type: 'note')
41-
.includes(:drupal_node_revision, :tag)
41+
.includes(:revision, :tag)
4242
.where('term_data.name = ?', "question:#{tagname}")
4343
.order('node_revisions.timestamp DESC')
4444
output = ''

app/models/drupal_users.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def note_count
144144
end
145145

146146
def node_count
147-
Node.count(:all, conditions: { status: 1, uid: uid }) + DrupalNodeRevision.count(:all, conditions: { uid: uid })
147+
Node.count(:all, conditions: { status: 1, uid: uid }) + Revision.count(:all, conditions: { uid: uid })
148148
end
149149

150150
# accepts array of tag names (strings)

0 commit comments

Comments
 (0)