Skip to content
Permalink
Browse files

Adding ability to display retraction on site

  • Loading branch information...
arfon committed Aug 17, 2019
1 parent a43a23d commit 56cbe49ba0fe0a16ae280d790b749bb7722a4276
@@ -223,6 +223,10 @@ TODO
&.under-review {
background-color: #fff3cd;
}

&.retracted {
background-color: #ff3333;
}
}

.badge-lang {
@@ -233,7 +237,7 @@ TODO
color: #2E294E;
font-weight: 400;
display: inline-block;

a {
transition: color .3s;
color: #2E294E;
@@ -21,6 +21,7 @@ class Paper < ActiveRecord::Base
state :superceded
state :accepted
state :rejected
state :retracted
state :withdrawn

event :reject do
@@ -46,7 +47,8 @@ class Paper < ActiveRecord::Base

VISIBLE_STATES = [
"accepted",
"superceded"
"superceded",
"retracted"
].freeze

IN_PROGRESS_STATES = [
@@ -127,23 +129,27 @@ def self.popular
recent
end

def published?
accepted? || retracted?
end

def scholar_title
return nil unless accepted?
return nil unless published?
metadata['paper']['title']
end

def scholar_authors
return nil unless accepted?
return nil unless published?
metadata['paper']['authors'].collect {|a| "#{a['given_name']} #{a['last_name']}"}.join(', ')
end

def language_tags
return [] unless accepted?
return [] unless published?
metadata['paper']['languages'] - IGNORED_LANGUAGES
end

def author_tags
return [] unless accepted?
return [] unless published?
if metadata['paper']['tags']
return metadata['paper']['tags'] - language_tags
else
@@ -152,37 +158,37 @@ def author_tags
end

def metadata_reviewers
return [] unless accepted?
return [] unless published?
metadata['paper']['reviewers']
end

def metadata_editor
return nil unless accepted?
return nil unless published?
metadata['paper']['editor']
end

def metadata_authors
return nil unless accepted?
return nil unless published?
metadata['paper']['authors']
end

def issue
return nil unless accepted?
return nil unless published?
metadata['paper']['issue']
end

def volume
return nil unless accepted?
return nil unless published?
metadata['paper']['volume']
end

def year
return nil unless accepted?
return nil unless published?
metadata['paper']['year']
end

def page
return nil unless accepted?
return nil unless published?
metadata['paper']['page']
end

@@ -87,6 +87,8 @@

<div class="container paper-show">
<% if @paper.doi? %>
<%= render partial: "shared/retraction_notice" if @paper.retracted? %>

<div class="paper-title">
<span class="__dimensions_badge_embed__" data-doi="<%= @paper.doi %>" data-hide-zero-citations="true"></span>
<div class="paper-meta">
@@ -0,0 +1,3 @@
<div class="alert alert-danger">
<%= @paper.retraction_notice.html_safe %>
</div>
@@ -0,0 +1,5 @@
class AddRetractionNoticeToPaper < ActiveRecord::Migration[5.2]
def change
add_column :papers, :retraction_notice, :text
end
end
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_08_02_131034) do
ActiveRecord::Schema.define(version: 2019_08_17_111418) do

# These are extensions that must be enabled in order to support this database
enable_extension "hstore"
@@ -57,17 +57,14 @@
t.string "reviewers", default: [], array: true
t.text "activities"
t.datetime "last_activity"
t.string "tags", default: [], array: true
t.string "languages", default: [], array: true
t.jsonb "labels", default: {}, null: false
t.text "metadata"
t.text "retraction_notice"
t.index ["editor_id"], name: "index_papers_on_editor_id"
t.index ["labels"], name: "index_papers_on_labels", using: :gin
t.index ["languages"], name: "index_papers_on_languages", using: :gin
t.index ["last_activity"], name: "index_papers_on_last_activity"
t.index ["reviewers"], name: "index_papers_on_reviewers", using: :gin
t.index ["sha"], name: "index_papers_on_sha"
t.index ["tags"], name: "index_papers_on_tags", using: :gin
t.index ["user_id"], name: "index_papers_on_user_id"
end

@@ -32,6 +32,14 @@
state 'submitted'
end

factory :retracted_paper do
metadata paper_metadata
state 'retracted'
accepted_at { Time.now }
review_issue_id 0
doi '10.21105/joss.00000'
end

factory :submitted_paper_with_sha do
sha '48d24b0158528e85ac7706aecd8cddc4'
state 'submitted'
@@ -124,5 +124,16 @@

expect(rendered).to have_content "View review issue"
end

it "shows the takedown notice for a retracted paper" do
user = create(:user)
allow(view).to receive_message_chain(:current_user).and_return(user)

paper = create(:retracted_paper, :retraction_notice => "Reasons for retraction")
assign(:paper, paper)

render :template => "papers/show.html.erb"
expect(rendered).to have_content("Reasons for retraction")
end
end
end

0 comments on commit 56cbe49

Please sign in to comment.
You can’t perform that action at this time.