diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1f296767e0..69e2fcef46 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,15 +14,15 @@ def set_sidebar(type = :generic, data = :all, args = {}) args[:note_count] ||= 8 if type == :tags # accepts data of array of tag names as strings if params[:controller] == 'questions' - @notes = @notes || DrupalTag.find_nodes_by_type(data, 'note', args[:note_count]) + @notes = @notes || Tag.find_nodes_by_type(data, 'note', args[:note_count]) else - @notes = @notes || DrupalTag.find_research_notes(data, args[:note_count]) + @notes = @notes || Tag.find_research_notes(data, args[:note_count]) end @notes = @notes.where('node.nid != (?)', @node.nid) if @node - @wikis = DrupalTag.find_pages(data,10) - @videos = DrupalTag.find_nodes_by_type_with_all_tags(['video']+data,'note',8) if args[:videos] && data.length > 1 - @maps = DrupalTag.find_nodes_by_type(data,'map',20) + @wikis = Tag.find_pages(data,10) + @videos = Tag.find_nodes_by_type_with_all_tags(['video']+data,'note',8) if args[:videos] && data.length > 1 + @maps = Tag.find_nodes_by_type(data,'map',20) else # type is generic # remove "classroom" postings; also switch to an EXCEPT operator in sql, see https://github.com/publiclab/plots2/issues/375 hidden_nids = DrupalNode.joins(:drupal_node_community_tag) @@ -192,7 +192,7 @@ def sort_question_by_tags @session_tags = session[:tags] qids = @questions.collect(&:nid) @questions = DrupalNode.where(status: 1, type: 'note') - .joins(:drupal_tag) + .joins(:tag) .where('term_data.name IN (?)', @session_tags.values) .where('node.nid IN (?)', qids) .group('node.nid') diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 6ec7e9ef85..584b28b76e 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -48,7 +48,7 @@ def dashboard @wiki_count = DrupalNodeRevision.select(:timestamp) .where(timestamp: Time.now.to_i - 1.weeks.to_i..Time.now.to_i) .count - @blog = DrupalTag.find_nodes_by_type('blog', 'note', 1).first + @blog = Tag.find_nodes_by_type('blog', 'note', 1).first # remove "classroom" postings; also switch to an EXCEPT operator in sql, see https://github.com/publiclab/plots2/issues/375 hidden_nids = DrupalNode.joins(:drupal_node_community_tag) .joins("LEFT OUTER JOIN term_data ON term_data.tid = community_tags.tid") diff --git a/app/controllers/map_controller.rb b/app/controllers/map_controller.rb index 6ef5424822..95acd6d086 100644 --- a/app/controllers/map_controller.rb +++ b/app/controllers/map_controller.rb @@ -6,13 +6,13 @@ def index .order("nid DESC") .where(type: 'map', status: 1) - # I'm not sure if this is actually eager loading the drupal_tags... - @maps = DrupalNode.joins(:drupal_tag) + # I'm not sure if this is actually eager loading the tags... + @maps = DrupalNode.joins(:tag) .where('type = "map" AND status = 1 AND (term_data.name LIKE ? OR term_data.name LIKE ?)', 'lat:%', 'lon:%') .uniq # This is supposed to eager load the url_aliases, and seems to run, but doesn't actually eager load them...? - #@maps = DrupalNode.select("node.*,url_alias.dst AS dst").joins(:drupal_tag).where('type = "map" AND status = 1 AND (term_data.name LIKE ? OR term_data.name LIKE ?)', 'lat:%', 'lon:%').joins("INNER JOIN url_alias ON url_alias.src = CONCAT('node/',node.nid)") + #@maps = DrupalNode.select("node.*,url_alias.dst AS dst").joins(:tag).where('type = "map" AND status = 1 AND (term_data.name LIKE ? OR term_data.name LIKE ?)', 'lat:%', 'lon:%').joins("INNER JOIN url_alias ON url_alias.src = CONCAT('node/',node.nid)") end def show @@ -206,7 +206,7 @@ def tag set_sidebar :tags, [params[:id]], {:note_count => 20} @tagnames = params[:id].split(',') - nids = DrupalTag.find_nodes_by_type(params[:id],'map',20).collect(&:nid) + nids = Tag.find_nodes_by_type(params[:id],'map',20).collect(&:nid) @notes = DrupalNode.paginate(page: params[:page]) .where('nid in (?)', nids) .order("nid DESC") diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index bc7150156f..c7a9f70e68 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -11,7 +11,7 @@ def index def methods @title = "Methods" @notes = DrupalNode.where(status: 1, type: ['page','tool']) - .includes(:drupal_node_revision, :drupal_tag) + .includes(:drupal_node_revision, :tag) .where('term_data.name = ?','tool') .page(params[:page]) .order("node_revisions.timestamp DESC") @@ -29,7 +29,7 @@ def techniques def places @title = "Places" @notes = DrupalNode.where(status: 1, type: ['page','place']) - .includes(:drupal_node_revision, :drupal_tag) + .includes(:drupal_node_revision, :tag) .where('term_data.name = ?','chapter') .page(params[:page]) .order("node_revisions.timestamp DESC") diff --git a/app/controllers/questions_search_controller.rb b/app/controllers/questions_search_controller.rb index 7bbf0b82d8..cbc4c9ae6c 100644 --- a/app/controllers/questions_search_controller.rb +++ b/app/controllers/questions_search_controller.rb @@ -13,7 +13,7 @@ def index 'type = "note" AND node.status = 1 AND title LIKE ?', "%" + params[:id] + "%" ) - .joins(:drupal_tag) + .joins(:tag) .where('term_data.name LIKE ?', 'question:%') .order('node.nid DESC') .page(params[:page]) @@ -32,7 +32,7 @@ def typeahead 'type = "note" AND node.status = 1 AND title LIKE ?', "%" + params[:id] + "%" ) - .joins(:drupal_tag) + .joins(:tag) .where('term_data.name LIKE ?', 'question:%') .order('node.nid DESC') .limit(25) diff --git a/app/controllers/subscription_controller.rb b/app/controllers/subscription_controller.rb index be969ba25a..8c54a3084f 100644 --- a/app/controllers/subscription_controller.rb +++ b/app/controllers/subscription_controller.rb @@ -34,11 +34,11 @@ def add if current_user # assume tag, for now if params[:type] == "tag" - tag = DrupalTag.find_by_name(params[:name]) + tag = Tag.find_by_name(params[:name]) if tag.nil? # if the tag doesn't exist, we should create it! # this could fail validations; error out if so... - tag = DrupalTag.new({ + tag = Tag.new({ :vid => 3, # vocabulary id :name => params[:name], :description => "", @@ -86,7 +86,7 @@ def add def delete # assume tag, for now if params[:type] == "tag" - id = DrupalTag.find_by_name(params[:name]).tid + id = Tag.find_by_name(params[:name]).tid end if id.nil? flash[:error] = "You are not subscribed to '#{params[:name]}'" @@ -114,7 +114,7 @@ def delete def set_following(value,type,id) # add swtich statement for different types: tag, node, user - if type == 'tag' && DrupalTag.find_by_tid(id) + if type == 'tag' && Tag.find_by_tid(id) # Create the entry if it isn't already created. # assume tag, for now: subscription = TagSelection.where(:user_id => current_user.uid, @@ -123,7 +123,7 @@ def set_following(value,type,id) # Check if the value changed. if subscription.following_changed? - #tag = DrupalTag.find(id) + #tag = Tag.find(id) # we have to implement caching for tags if we want to adapt this code: #if subscription.following # node.cached_likes = node.cached_likes + 1 diff --git a/app/controllers/tag_controller.rb b/app/controllers/tag_controller.rb index c0eac8e907..45a51cd920 100644 --- a/app/controllers/tag_controller.rb +++ b/app/controllers/tag_controller.rb @@ -6,7 +6,7 @@ class TagController < ApplicationController def index @title = I18n.t('tag_controller.tags') @paginated = true - @tags = DrupalTag.joins(:drupal_node_community_tag, :drupal_node) + @tags = Tag.joins(:drupal_node_community_tag, :drupal_node) .where('node.status = ?', 1) .paginate(:page => params[:page]) .order('count DESC') @@ -27,16 +27,16 @@ def show qids = DrupalNode.questions.where(status: 1).collect(&:nid) if params[:id][-1..-1] == "*" # wildcard tags @wildcard = true - @tags = DrupalTag.where('name LIKE (?)', params[:id][0..-2] + '%') + @tags = Tag.where('name LIKE (?)', params[:id][0..-2] + '%') nodes = DrupalNode.where(status: 1, type: node_type) - .includes(:drupal_node_revision, :drupal_tag) + .includes(:drupal_node_revision, :tag) .where('term_data.name LIKE (?) OR term_data.parent LIKE (?)', params[:id][0..-2] + '%', params[:id][0..-2] + '%') .page(params[:page]) .order("node_revisions.timestamp DESC") else - @tags = DrupalTag.find_all_by_name params[:id] + @tags = Tag.find_all_by_name params[:id] nodes = DrupalNode.where(status: 1, type: node_type) - .includes(:drupal_node_revision, :drupal_tag) + .includes(:drupal_node_revision, :tag) .where('term_data.name = ? OR term_data.parent = ?', params[:id], params[:id]) .page(params[:page]) .order("node_revisions.timestamp DESC") @@ -67,7 +67,7 @@ def show def widget num = params[:n] || 4 - nids = DrupalTag.find_nodes_by_type(params[:id],'note',num).collect(&:nid) + nids = Tag.find_nodes_by_type(params[:id],'note',num).collect(&:nid) @notes = DrupalNode.page(params[:page]) .where('status = 1 AND nid in (?)', nids) .order("nid DESC") @@ -75,11 +75,11 @@ def widget end def blog - nids = DrupalTag.find_nodes_by_type(params[:id],'note',20).collect(&:nid) + nids = Tag.find_nodes_by_type(params[:id],'note',20).collect(&:nid) @notes = DrupalNode.paginate(:page => params[:page], :per_page => 6) .where('status = 1 AND nid in (?)', nids) .order("nid DESC") - @tags = DrupalTag.find_all_by_name params[:id] + @tags = Tag.find_all_by_name params[:id] @tagnames = @tags.collect(&:name).uniq! || [] @title = @tagnames.join(',') + " Blog" if @tagnames end @@ -91,7 +91,7 @@ def author def barnstar node = DrupalNode.find params[:nid] tagname = "barnstar:"+params[:star] - if DrupalTag.exists?(tagname,params[:nid]) + if Tag.exists?(tagname,params[:nid]) flash[:error] = I18n.t('tag_controller.tag_already_exists') elsif !node.add_barnstar(tagname.strip,current_user) flash[:error] = I18n.t('tag_controller.barnstar_not_created') @@ -122,7 +122,7 @@ def create # this should all be done in the model: - if DrupalTag.exists?(tagname, params[:nid]) + if Tag.exists?(tagname, params[:nid]) @output[:errors] << I18n.t('tag_controller.tag_already_exists') elsif node.can_tag(tagname, current_user) === true || current_user.role == "admin"# || current_user.role == "moderator" saved, tag = node.add_tag(tagname.strip, current_user) @@ -178,7 +178,7 @@ def suggested if params[:id].length > 2 @suggestions = [] # filtering out tag spam by requiring tags attached to a published node - DrupalTag.where('name LIKE ?', "%" + params[:id] + "%") + Tag.where('name LIKE ?', "%" + params[:id] + "%") .includes(:drupal_node) .where('node.status = 1') .limit(10).each do |tag| @@ -193,12 +193,12 @@ def suggested def rss if params[:tagname][-1..-1] == "*" @notes = DrupalNode.where(:status => 1, :type => 'note') - .includes(:drupal_node_revision,:drupal_tag) + .includes(:drupal_node_revision,:tag) .where('term_data.name LIKE (?)', params[:tagname][0..-2]+'%') .limit(20) .order("node_revisions.timestamp DESC") else - @notes = DrupalTag.find_nodes_by_type([params[:tagname]],'note',20) + @notes = Tag.find_nodes_by_type([params[:tagname]],'note',20) end respond_to do |format| format.rss { @@ -217,9 +217,9 @@ def rss def contributors set_sidebar :tags, [params[:id]], {:note_count => 20} @tagnames = [params[:id]] - @tag = DrupalTag.find_by_name params[:id] + @tag = Tag.find_by_name params[:id] @notes = DrupalNode.where(:status => 1, :type => 'note') - .includes(:drupal_node_revision,:drupal_tag) + .includes(:drupal_node_revision,:tag) .where('term_data.name = ?', params[:id]) .order("node_revisions.timestamp DESC") @users = @notes.collect(&:author).uniq @@ -232,10 +232,10 @@ def contributors_index @tags = [] @tagnames.each do |tagname| - tag = DrupalTag.find_by_name(tagname) + tag = Tag.find_by_name(tagname) @tags << tag if tag @tagdata[tagname] = {} - t = DrupalTag.find :all, :conditions => {:name => tagname} + t = Tag.find :all, :conditions => {:name => tagname} nct = DrupalNodeCommunityTag.find :all, :conditions => ['tid in (?)',t.collect(&:tid)] @tagdata[tagname][:users] = DrupalNode.find(:all, :conditions => ['nid IN (?)',(nct).collect(&:nid)]).collect(&:author).uniq.length @tagdata[tagname][:wikis] = DrupalNode.count :all, :conditions => ["nid IN (?) AND (type = 'page' OR type = 'tool' OR type = 'place')", (nct).collect(&:nid)] @@ -252,7 +252,7 @@ def add_tag end tagnames = params[:name].split(',') tagnames.each do |tagname| - tag = DrupalTag.find_by_name(tagname) + tag = Tag.find_by_name(tagname) if tag session[:tags][tag.tid.to_s] = tagname else diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 28806563c6..633248481d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -143,7 +143,7 @@ def profile def likes @user = DrupalUsers.find_by_name(params[:id]) @title = "Liked by "+@user.name - @notes = @user.liked_notes.includes([:drupal_tag, :comments]) + @notes = @user.liked_notes.includes([:tag, :comments]) .paginate(page: params[:page], per_page: 20) @wikis = @user.liked_pages @tagnames = [] diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 05865bd362..9834398111 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -43,7 +43,7 @@ def show return if check_and_redirect_node(@node) if !@node.nil? # it's a place page! @tags = @node.tags - @tags += [DrupalTag.find_by_name(params[:id])] if DrupalTag.find_by_name(params[:id]) + @tags += [Tag.find_by_name(params[:id])] if Tag.find_by_name(params[:id]) else # it's a new wiki page! @title = I18n.t('wiki_controller.new_wiki_page') if current_user @@ -61,7 +61,7 @@ def show end @tagnames = @tags.collect(&:name) set_sidebar :tags, @tagnames, {:videos => true} - @wikis = DrupalTag.find_pages(@node.slug_from_path,30) if @node.has_tag('chapter') || @node.has_tag('tabbed:wikis') + @wikis = Tag.find_pages(@node.slug_from_path,30) if @node.has_tag('chapter') || @node.has_tag('tabbed:wikis') impressionist(@node.drupal_node_counter) @revision = @node.latest @@ -111,9 +111,9 @@ def new .order("node.nid DESC") .where('type = "page" AND node.status = 1 AND (node.title LIKE ? OR node_revisions.body LIKE ?)', "%" + title + "%","%" + title + "%") .includes(:drupal_node_revision) - tag = DrupalTag.find_by_name(params[:id]) # add page name as a tag, too + tag = Tag.find_by_name(params[:id]) # add page name as a tag, too @tags << tag if tag - @related += DrupalTag.find_nodes_by_type(@tags.collect(&:name),'page',10) + @related += Tag.find_nodes_by_type(@tags.collect(&:name),'page',10) end render :template => 'wiki/edit' end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fb6e0cbd48..826bccc47a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -40,7 +40,7 @@ def insert_extras(body) output += '
Here you can ask a question to the Public Lab community to help you in your environmental exploration. This is a great space to ask whether a method exists for identifying a possible pollutant, or ask about details of a specific technique for identifying a pollutant.
You can add more tags in the tags section below to further relate your question. You can also change the main tag of the question by renaming the part after question: tag
diff --git a/app/views/editor/question.html.erb b/app/views/editor/question.html.erb index 9deb888d89..5dc804ad4d 100644 --- a/app/views/editor/question.html.erb +++ b/app/views/editor/question.html.erb @@ -15,8 +15,8 @@Here you can ask a question to the Public Lab community to help you in your environmental exploration. This is a great space to ask whether a method exists for identifying a possible pollutant, or ask about details of a specific technique for identifying a pollutant.
You can add more tags in the tags section below to further relate your question. You can also change the main tag of the question by renaming the part after question: tag
diff --git a/app/views/home/subscriptions.html.erb b/app/views/home/subscriptions.html.erb index c49feaad3e..b0457f40fb 100644 --- a/app/views/home/subscriptions.html.erb +++ b/app/views/home/subscriptions.html.erb @@ -32,7 +32,7 @@More "<%= tagname %>" research »
diff --git a/db/migrate/20130402232059_create_like_and_follow.rb b/db/migrate/20130402232059_create_like_and_follow.rb index 3698e4ffe8..8f4cbc373b 100644 --- a/db/migrate/20130402232059_create_like_and_follow.rb +++ b/db/migrate/20130402232059_create_like_and_follow.rb @@ -1,8 +1,8 @@ class CreateLikeAndFollow < ActiveRecord::Migration def up - # dictionary of (user.id, drupal_tag.id) mapping to (following) + # dictionary of (user.id, tag.id) mapping to (following) # no need for wasteful primary key when the unique index recreates a - # composite PK using (user.id, drupal_tag.id). + # composite PK using (user.id, tag.id). # In English: track user follow tag unless table_exists? "tagselections" create_table :tagselections, :id => false do |t| diff --git a/db/migrate/20140429190219_consolidate_tags.rb b/db/migrate/20140429190219_consolidate_tags.rb index f0d35d102c..e6c4ad80e6 100644 --- a/db/migrate/20140429190219_consolidate_tags.rb +++ b/db/migrate/20140429190219_consolidate_tags.rb @@ -27,21 +27,21 @@ def up # do some tallies to check success: summ = "\n======= BEGIN TAG CONSOLIDATION ========" - drupaltags = DrupalTag.count(:all) + drupaltags = Tag.count(:all) summ += "\nTags: "+drupaltags.to_s drupalnodetags = ActiveRecord::Base.connection.execute('select COUNT(*) from term_node;') summ += "\nNodeTags: "+drupalnodetags.first[0].to_s drupalnodecommunitytags = DrupalNodeCommunityTag.count(:all) summ += "\nCommunityNodeTags: "+drupalnodecommunitytags.to_s summ += "\n========================================" - tags = DrupalTag.find(:all,:select => [:name]) + tags = Tag.find(:all,:select => [:name]) utags = tags.uniq.length summ += "\nDuplicate tags: "+(tags.length-utags).to_s summ += "\n========================================" puts summ # remove spaces - DrupalTag.find(:all).each do |tag| + Tag.find(:all).each do |tag| tag.name = tag.name.downcase.gsub(' ','-') tag.save end @@ -55,7 +55,7 @@ def up node = DrupalNode.find(nt[0]) if nt[2].nil? || nt[0].nil? || (node && node.status == 0) # nt - [nid, vid, tid] - tag = DrupalTag.find(nt[2]) + tag = Tag.find(nt[2]) deleted << tag.name ActiveRecord::Base.connection.execute("delete from term_node where vid = #{nt[1]};") end @@ -80,7 +80,7 @@ def up if DrupalNodeCommunityTag.find_all_by_nid(ntag[0], :conditions => {:tid => ntag[2]}).length > 0 dupes += 1 elsif ctag.save - tag = DrupalTag.find(ntag[2]) + tag = Tag.find(ntag[2]) deleted << tag.name unless tag.nil? ActiveRecord::Base.connection.execute("delete from term_node where vid = #{ntag[1]};") else @@ -96,15 +96,15 @@ def up puts "deleted after migrating:" puts deleted.join(',') - # get rid of DrupalTag duplicates, ensure no new dupes are created + # get rid of Tag duplicates, ensure no new dupes are created failed = [] dupes = 0 - uniqtags = DrupalTag.find(:all).collect(&:name).uniq + uniqtags = Tag.find(:all).collect(&:name).uniq uniqtags.each do |uniqtag| # find the version with the earliest tid - origtag = DrupalTag.find_by_name uniqtag, :order => "tid" - DrupalTag.find_all_by_name(uniqtag).each do |tag_clone| - # re-assign all TagSelections to newly consolidated DrupalTag tids + origtag = Tag.find_by_name uniqtag, :order => "tid" + Tag.find_all_by_name(uniqtag).each do |tag_clone| + # re-assign all TagSelections to newly consolidated Tag tids TagSelection.find_all_by_tid(tag_clone.tid).each do |tsel| # ensure unique unless TagSelection.find(:first, :conditions => {:tid => origtag.tid, :user_id => tsel.user_id}) @@ -143,7 +143,7 @@ def up # now find all orphaned tags and delete them: deleted = [] - DrupalTag.find(:all).each do |tag| + Tag.find(:all).each do |tag| # delete orphans related_drupal_node_tags = ActiveRecord::Base.connection.execute("select * from term_node where tid = #{tag.id};") if related_drupal_node_tags.size == 0 && tag.drupal_node_community_tag.length == 0 && tag.subscriptions.length == 0 @@ -159,7 +159,7 @@ def up puts summ # new stats: summ = "\n======= END TAG CONSOLIDATION ========" - drupaltags2 = DrupalTag.count(:all) + drupaltags2 = Tag.count(:all) summ += "\nTags: "+drupaltags2.to_s drupalnodetags2 = ActiveRecord::Base.connection.execute('select COUNT(*) from term_node;') summ += "\nNodeTags: "+drupalnodetags2.first[0].to_s @@ -170,7 +170,7 @@ def up summ += "\nFewer NodeTags: "+(drupalnodetags.first[0]-drupalnodetags2.first[0]).to_s summ += "\nMore CommunityNodeTags: "+(drupalnodecommunitytags2-drupalnodecommunitytags).to_s summ += "\n========================================" - tags = DrupalTag.find(:all,:select => [:name]) + tags = Tag.find(:all,:select => [:name]) utags = tags.uniq.length summ += "\nDuplicate tags: "+(tags.length-utags).to_s summ += "\n========================================" diff --git a/db/migrate/20141115214749_add_tag_count.rb b/db/migrate/20141115214749_add_tag_count.rb index 6b840752c0..dc642130da 100644 --- a/db/migrate/20141115214749_add_tag_count.rb +++ b/db/migrate/20141115214749_add_tag_count.rb @@ -1,7 +1,7 @@ class AddTagCount < ActiveRecord::Migration def up add_column :term_data, :count, :integer - DrupalTag.all.each do |tag| + Tag.all.each do |tag| tag.run_count end end diff --git a/db/seeds.rb b/db/seeds.rb index 305d3ad706..7b2a84df5c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,7 +7,7 @@ # Mayor.create(name: 'Emanuel', city: cities.first) # set up a tag for all_notes subscription -everything_tag = DrupalTag.create! "name"=>"everything", "description"=>"", "weight"=>0 +everything_tag = Tag.create! "name"=>"everything", "description"=>"", "weight"=>0 # set up 3 basic users: admin, mod, and user admin = User.create! "username"=>"admin", "email"=>"admin@example.com", @@ -43,7 +43,7 @@ blog_post_revisions = DrupalNodeRevision.create! "nid"=>blog_post.nid, "uid"=>admin.uid, "title"=>"Blog Post", "body"=>"Blog post body", "teaser"=>"", "log"=>"", "format"=>1 -blog_post_tag = DrupalTag.create! "name"=>"blog", "description"=>"", "weight"=>0 +blog_post_tag = Tag.create! "name"=>"blog", "description"=>"", "weight"=>0 blog_post_community_tag = DrupalNodeCommunityTag.create! "tid"=>blog_post_tag.id, "nid"=>blog_post.id, "uid"=>admin.id blog_post_comment = Comment.create! "nid"=>blog_post.id, "uid"=>admin.id, @@ -57,10 +57,10 @@ DrupalNodeRevision.attr_accessible :nid, :vid map_node_revision = DrupalNodeRevision.create! "nid" => map_node.nid, "vid" => map_node.nid, "uid"=>1, "title"=>"Test Map #{t}", "body"=>"Body of revision #{t}" - drupal_tag_lat = DrupalTag.create! name: "lat:#{rand * 80}", description: "Desc #{t}", weight: 5 - drupal_tag_lon = DrupalTag.create! name: "lon:#{rand * 80}", description: "Desc #{t}", weight: 5 - drupal_comm_tag_lat = DrupalNodeCommunityTag.create! nid: map_node.nid, tid: drupal_tag_lat.tid, uid: 1 - drupal_comm_tag_lon = DrupalNodeCommunityTag.create! nid: map_node.nid, tid: drupal_tag_lon.tid, uid: 1 + tag_lat = Tag.create! name: "lat:#{rand * 80}", description: "Desc #{t}", weight: 5 + tag_lon = Tag.create! name: "lon:#{rand * 80}", description: "Desc #{t}", weight: 5 + drupal_comm_tag_lat = DrupalNodeCommunityTag.create! nid: map_node.nid, tid: tag_lat.tid, uid: 1 + drupal_comm_tag_lon = DrupalNodeCommunityTag.create! nid: map_node.nid, tid: tag_lon.tid, uid: 1 DrupalContentTypeMap.attr_accessible :nid, :vid, :field_publication_date_value, :field_capture_date_value, :field_tms_url_value, :field_license_value, :field_raw_images_value, :field_cartographer_notes_value, :field_notes_value, :field_zoom_min_value, :field_zoom_max_value, :authorship content_type_mape = DrupalContentTypeMap.create! "vid"=>map_node.nid, "nid"=>map_node.nid, "field_publication_date_value"=>Time.now.to_s(:short), diff --git a/doc/DATA_MODEL.md b/doc/DATA_MODEL.md index 590c8d78a8..160bdde900 100644 --- a/doc/DATA_MODEL.md +++ b/doc/DATA_MODEL.md @@ -67,6 +67,6 @@ User `role` can be: ## Tagging -Tags (`DrupalTag`) are unique tag names with primary key `tid`, which may be linked to Nodes via join table CommunityTag (`DrupalNodeCommunityTag`) via the latter's `nid` and `tid` fields. +Tags (`Tag`) are unique tag names with primary key `tid`, which may be linked to Nodes via join table CommunityTag (`DrupalNodeCommunityTag`) via the latter's `nid` and `tid` fields. diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index 27e733c41f..64ce8cede2 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -97,7 +97,7 @@ def teardown test "show note with Browse other activities link" do note = DrupalNode.where(type: 'note', status: 1).first note.add_tag('activity:spectrometer', note.author) # testing responses display - assert DrupalTag.where(name: 'activities:' + note.power_tag('activity')).length > 0 + assert Tag.where(name: 'activities:' + note.power_tag('activity')).length > 0 get :show, author: note.author.name, diff --git a/test/functional/tag_controller_test.rb b/test/functional/tag_controller_test.rb index 66e774f0ab..5d82fef5f8 100644 --- a/test/functional/tag_controller_test.rb +++ b/test/functional/tag_controller_test.rb @@ -30,7 +30,7 @@ def setup xhr :post, :create, name: 'myfourthtag,myfifthtag', nid: node(:one).nid, uid: rusers(:bob).id assert_response :success - assert_equal [["myfourthtag", DrupalTag.find_by_name("myfourthtag").tid], ["myfifthtag", DrupalTag.find_by_name("myfifthtag").tid]], JSON.parse(response.body)['saved'] + assert_equal [["myfourthtag", Tag.find_by_name("myfourthtag").tid], ["myfifthtag", Tag.find_by_name("myfifthtag").tid]], JSON.parse(response.body)['saved'] end test "validate unused tag" do @@ -175,14 +175,14 @@ def setup end test "tag widget" do - get :widget, id: DrupalTag.last.name + get :widget, id: Tag.last.name assert :success assert_not_nil :notes end test "tag blog" do - get :blog, id: DrupalTag.last.name + get :blog, id: Tag.last.name assert :success assert_not_nil :notes @@ -198,7 +198,7 @@ def setup test "tag rss" do - get :rss, tagname: DrupalTag.last.name + get :rss, tagname: Tag.last.name assert :success assert_not_nil :notes @@ -206,7 +206,7 @@ def setup test "tag contributors" do - get :contributors, id: DrupalTag.last.name + get :contributors, id: Tag.last.name assert :success assert_not_nil :notes diff --git a/test/test_helper.rb b/test/test_helper.rb index 97b9dabee9..0962c0ac10 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,7 +17,7 @@ class ActiveSupport::TestCase set_fixture_class :node_counter => DrupalNodeCounter set_fixture_class :node_revisions => DrupalNodeRevision set_fixture_class :tag_selection => TagSelection - set_fixture_class :tags => DrupalTag + set_fixture_class :tags => Tag set_fixture_class :community_tags => DrupalNodeCommunityTag set_fixture_class :comments => Comment set_fixture_class :searches => SearchRecord diff --git a/test/unit/drupal_node_revision_test.rb b/test/unit/drupal_node_revision_test.rb index f25cf4cfd9..a59ef6c217 100644 --- a/test/unit/drupal_node_revision_test.rb +++ b/test/unit/drupal_node_revision_test.rb @@ -106,7 +106,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should add tags for hashtags" do revision = node_revisions(:hashtag_one) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_includes tag_names, 'hashtag' end @@ -114,7 +114,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should ignore hashtags in markdown" do revision = node_revisions(:hashtag_one) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_false tag_names.include?('heading') end @@ -122,7 +122,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should ignore commas, exclamation, and periods in hashtags" do revision = node_revisions(:hashtag_with_punctuation) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} expected_tags = ['hashtag1', 'hashtag2', 'hashtag3'] ignore_tags = ['hashtag1,', 'hashtag2!', 'hashtag3.'] @@ -133,7 +133,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should tag hashtags in headers" do revision = node_revisions(:hashtag_in_header) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_includes tag_names, 'hashtags' end @@ -141,7 +141,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should ignore subheaders" do revision = node_revisions(:subheader) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_false tag_names.include?('subheader') or tag_names.include?('#subheader') end @@ -149,7 +149,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should ignore hashtags in links" do revision = node_revisions(:hashtag_in_link) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_false tag_names.include?('hashtag') end @@ -157,7 +157,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should ignore hashtags in URLs" do revision = node_revisions(:hashtag_in_url) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_false tag_names.include?('hashtag') end @@ -165,7 +165,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should not add duplicate tags" do revision = node_revisions(:hashtag_three) revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_false tag_names.count('hashtag') > 1 assert_false tag_names.include?('heading') @@ -174,7 +174,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase test "should make the author the tag author" do revision = node_revisions(:hashtag_three) revision.save - author = revision.parent.drupal_tag.last.drupal_node_community_tag.first.drupal_users + author = revision.parent.tag.last.drupal_node_community_tag.first.drupal_users assert_equal revision.author, author end @@ -183,7 +183,7 @@ class DrupalNodeRevisionsTest < ActiveSupport::TestCase revision.save revision.body = "another #hashtag" revision.save - associated_tags = revision.parent.drupal_tag + associated_tags = revision.parent.tag tag_names = associated_tags.map{|x| x.name} assert_true tag_names.count('hashtag') == 1 end diff --git a/test/unit/drupal_node_tag_test.rb b/test/unit/drupal_node_tag_test.rb index a076fcb21c..240a5902cc 100644 --- a/test/unit/drupal_node_tag_test.rb +++ b/test/unit/drupal_node_tag_test.rb @@ -8,18 +8,18 @@ class DrupalNodeTagTest < ActiveSupport::TestCase assert node.has_tag('activi*') assert node.normal_tags.length < node.tags.length assert_equal node.tagnames, node.tags.collect(&:name) - assert DrupalTag.find_nodes_by_type('spectrometer').to_a.include?(node) - assert DrupalTag.find_nodes_by_type_with_all_tags(['spectrometer']).to_a.include?(node) - assert_not_nil DrupalTag.follower_count('spectrometer') - assert_not_nil DrupalTag.followers('spectrometer') + assert Tag.find_nodes_by_type('spectrometer').to_a.include?(node) + assert Tag.find_nodes_by_type_with_all_tags(['spectrometer']).to_a.include?(node) + assert_not_nil Tag.follower_count('spectrometer') + assert_not_nil Tag.followers('spectrometer') assert_not_nil tags(:spectrometer).weekly_tallies - assert_not_nil DrupalTag.subscribers([tags(:spectrometer)]) + assert_not_nil Tag.subscribers([tags(:spectrometer)]) end # as we eliminate legacy Drupal naming schemes, these can be removed: test "tag method aliases" do node = node(:one) - assert_equal node.tags, node.drupal_tag + assert_equal node.tags, node.tag assert_equal node.community_tags, node.drupal_node_community_tag end @@ -36,7 +36,7 @@ class DrupalNodeTagTest < ActiveSupport::TestCase # in unit tests: # 1. if a post is tagged with child tag like "balloon-mapping", # does it appear in a notes/activities/questions grid for its parent tag, like "aerial-photography"? Yes. - # So, application_helper's insert_extras(body) should use a model method like DrupalTag.find_nodes_by_type + # So, application_helper's insert_extras(body) should use a model method like Tag.find_nodes_by_type # 2. has_tag will return parent tags, but not child tags, for now. Not used a lot. # 3. create an 'aliases = true' param for some of these @@ -55,10 +55,10 @@ class DrupalNodeTagTest < ActiveSupport::TestCase assert_false node.has_tag_without_aliasing('spectrometry') assert_equal node.get_matching_tags_without_aliasing('spectrometer').length, 1 assert_equal node.get_matching_tags_without_aliasing('spectrometry').length, 0 - assert_false DrupalTag.find_nodes_by_type('spectrometry').to_a.include?(node) - assert_false DrupalTag.find_nodes_by_type_with_all_tags(['spectrometry']).to_a.include?(node) - assert DrupalTag.find_nodes_by_type('spectrometer').to_a.include?(node) - assert DrupalTag.find_nodes_by_type_with_all_tags(['spectrometer']).to_a.include?(node) + assert_false Tag.find_nodes_by_type('spectrometry').to_a.include?(node) + assert_false Tag.find_nodes_by_type_with_all_tags(['spectrometry']).to_a.include?(node) + assert Tag.find_nodes_by_type('spectrometer').to_a.include?(node) + assert Tag.find_nodes_by_type_with_all_tags(['spectrometer']).to_a.include?(node) # test node.add_tag, which uses has_tag saved, tag = node.add_tag('spectrometry', rusers(:bob)) @@ -76,10 +76,10 @@ class DrupalNodeTagTest < ActiveSupport::TestCase tag2.save assert node.has_tag('spectrometer') # this is directly true assert_false node.has_tag('spectrometry') # should return false;