Skip to content

Commit

Permalink
Remove redundancy of 'new_contributor' code (#3903)
Browse files Browse the repository at this point in the history
* Add range buttons to /tag/____ page #3298

Update the file app/views/tag/show.html.erb in the plots2 repository (press the little pen Icon) and edit the line as shown below.

* Update the file app/models/node_tag.rb

#3864

* a href='/tag/first-time-poster'

#3864

* a href='/tag/first-time-poster'

#3864

* Remove unrelated issues

* remove redundancy of 'new_contributor' code

drupal_user

* remove redundancy of 'new_contributor' code

node_tag

* fix

* Update node_tag.rb

* Update node_tag.rb

* Update drupal_user.rb

* Update node_tag.rb

* Update node_tag.rb

* Update node_tag.rb

* Update tag_test.rb
  • Loading branch information
leanyanko authored and jywarren committed Dec 1, 2018
1 parent f084697 commit 4e87036
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 2 additions & 4 deletions app/models/drupal_user.rb
Expand Up @@ -88,13 +88,11 @@ def first_time_poster
end

def new_author_contributor
@uid = uid
return "<a href='/tag/first-time-poster' class='label label-success'><i>new contributor</i></a>".html_safe if Node.where(:uid => @uid).length === 1 && Node.where(:uid => @uid).first.created_at > Date.today - 1.month
user.new_contributor
end

def new_contributor
@uid = id
return "<a href='/tag/first-time-poster' class='label label-success'><i>new contributor</i></a>".html_safe if Node.where(:uid => @uid).length === 1 && Node.where(:uid => @uid).first.created_at > Date.today - 1.month
user.new_contributor
end

def likes
Expand Down
11 changes: 5 additions & 6 deletions app/models/node_tag.rb
Expand Up @@ -15,17 +15,16 @@ def increment_count
tag.save
end

def user
User.find(uid)
end

def author
user
end

def new_author_contributor
@uid = uid
return "<a href='/tag/first-time-poster' class='label label-success'><i>new contributor</i></a>".html_safe if Node.where(:uid => @uid).length === 1 && Node.where(:uid => @uid).first.created_at > Date.today - 1.month
end

def user
DrupalUser.find_by(uid: uid).try(:user)
user.new_contributor
end

def drupal_user
Expand Down
4 changes: 3 additions & 1 deletion test/unit/tag_test.rb
Expand Up @@ -28,7 +28,9 @@ class TagTest < ActiveSupport::TestCase
tid: tags(:awesome).tid,
nid: nodes(:one).nid)
assert node_tag.save!
assert_nil node_tag.author
assert_raises(ActiveRecord::RecordNotFound) do
node_tag.author
end
end

test 'tag weekly tallies' do
Expand Down

0 comments on commit 4e87036

Please sign in to comment.