Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

68-rola-autora #361

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,3 @@ DEPENDENCIES
twitter-bootstrap-rails
uglifier (>= 1.3.0)
web-console (~> 2.0)

BUNDLED WITH
1.11.2
2 changes: 1 addition & 1 deletion app/controllers/authorships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def sign

private
def authorship_params
params.require(:authorship).permit(:person_id,:corresponding,:position)
params.require(:authorship).permit(:person_id,:corresponding,:position,:role)
end

def create_password(len=8)
Expand Down
10 changes: 9 additions & 1 deletion app/models/authorship.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Authorship < ActiveRecord::Base
validates :person, presence: true, uniqueness: { scope: :submission_id }

belongs_to :person
accepts_nested_attributes_for :person

Expand All @@ -24,10 +23,19 @@ def mail
end
end

def author_role
if !self.role.blank?
self.role
else
"[BRAK ZDEFINIOWANEJ ROLI]"
end
end

def title
self.submission.title
end


def date
self.submission.received
end
Expand Down
3 changes: 2 additions & 1 deletion app/views/authorships/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
= f.association :person, label: "Autor", label_method: :reverse_full_name, include_blank: false, collection: Person.authors.order([:surname,:name]).all
= f.input :corresponding, label: "Korespondujący?"
= f.input :position, label: "Liczba porządkowa"
= f.submit "Dodaj", class: %w{btn btn-primary btn-outline}
= f.input :role, label: "Rola"
= f.submit "Dodaj", class: %w{btn btn-primary btn-outline}
2 changes: 2 additions & 0 deletions app/views/submissions/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
%th Korespondujący
%th Liczba porządkowa
%th Podpisana umowa
%th Rola
%th Zmiana 'signed'
%th
%tbody
Expand All @@ -69,6 +70,7 @@
%td= authorship.corresponding? ? raw("&#10004;") : ""
%td= authorship.position
%td= authorship.signed? ? icon('check') : icon('times')
%td= authorship.author_role
%th= authorship.signed? ? "" : (link_to "podpisz", sign_authorship_path(authorship), method: :post)
%td.text-right
= destroy_button(authorship,"Czy na pewno chcesz usunąć tego autora?")
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20160303191441_add_role_to_authorship.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddRoleToAuthorship < ActiveRecord::Migration
def change
add_column :authorships, :role, :string
end
end
18 changes: 11 additions & 7 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160302164859) do
ActiveRecord::Schema.define(version: 20160303191853) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -63,13 +63,16 @@
create_table "authorships", force: :cascade do |t|
t.integer "person_id"
t.integer "submission_id"
t.boolean "corresponding", default: true
t.integer "position", default: 0
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "signed", default: false
t.boolean "corresponding", default: true
t.integer "position", default: 0
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "signed", default: false
t.integer "author_role_id"
t.string "role"
end

add_index "authorships", ["author_role_id"], name: "index_authorships_on_author_role_id", using: :btree
add_index "authorships", ["person_id", "submission_id"], name: "index_authorships_on_person_id_and_submission_id", unique: true, using: :btree
add_index "authorships", ["person_id"], name: "index_authorships_on_person_id", using: :btree
add_index "authorships", ["submission_id"], name: "index_authorships_on_submission_id", using: :btree
Expand Down Expand Up @@ -158,8 +161,8 @@
t.string "sex"
t.string "photo"
t.text "competence"
t.text "discipline", default: [], null: false, array: true
t.string "reviewer_status"
t.text "discipline", default: [], null: false, array: true
end

add_index "people", ["email"], name: "index_people_on_email", using: :btree
Expand Down Expand Up @@ -366,6 +369,7 @@
t.datetime "updated_at", null: false
t.integer "person_id"
t.integer "issue_id"
t.string "author_role"
t.integer "follow_up_id"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/features/certificate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
english_abstract: 'Tak po prostu', english_keywords: 'knowledge',
issue: issue_1, person:person1, language: 'polski', received: '28-01-2016',
status: 'przyjęty')
Authorship.create!(person:person1, submission: submission1)
Authorship.create!(person:person1, submission: submission1, role: "autor")
Article.create!(submission: submission1, issue: issue_1, status: 'opublikowany',
DOI: 40000, external_link:'http://bulka', pages:'300')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/public_articles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
english_abstract: 'Tak po prostu', english_keywords: 'knowledge',
issue: issue_1, person:person1, language: 'polski', received: '28-01-2016',
status: 'przyjęty')
Authorship.create!(person:person1, submission: submission1)
Authorship.create!(person:person1, submission: submission1, role: "autor")
Article.create!(submission: submission1, issue: issue_1, status: 'opublikowany', DOI: 40000,
external_link:'http://bulka', pages:'300')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/public_issues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
english_abstract: 'Tak po prostu', english_keywords: 'knowledge',
issue: issue_1, person:person1, language: 'polski', received: '28-01-2016',
status: 'przyjęty')
Authorship.create!(person:person1, submission: submission1)
Authorship.create!(person:person1, submission: submission1, role: "autor")
Article.create!(submission: submission1, issue: issue_1, status: 'opublikowany', DOI: 40000,
external_link:'http://bulka', pages:'300')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/revisions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
article_file = Rails.root.join("spec/features/files/plik.pdf").open
ArticleRevision.create!(submission: submission, received: '19-01-2016',
version: "1", pages: "3", pictures: "0", article: article_file,)
Authorship.create!(person: author, submission: submission, corresponding: "true", position: "0")
Authorship.create!(person: author, submission: submission, corresponding: "true", role: "autor", position: "0")
end

scenario "Dodawanie recenzenta o takiej samej afiliacji jak autor" do
Expand Down
9 changes: 5 additions & 4 deletions spec/features/submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
test", received: "2015-02-17")
Person.create!(name: "Andrzej", surname: "Kapusta", email: "[email protected]", sex:
"mężczyzna", roles: ['autor', 'redaktor'], discipline:["psychologia"])
Person.create!(name: "Damian", surname: "Papryka", email: "[email protected]", sex:
"mężczyzna", roles: ['autor', 'redaktor'], discipline:["psychologia"])
Authorship.create!(person: Person.last, submission: Submission.first,
corresponding: false, position: 1)
corresponding: false, position: 1, role: "autor")
Authorship.create!(person: Person.last, submission: Submission.last,
corresponding: false, position: 1, signed: true)
corresponding: false, position: 1, role: "autor", signed: true)
end

scenario "podpisana umowa" do
Expand All @@ -61,8 +63,7 @@

expect(page).to have_css("i[class*='fa fa-check']")
end
end

end
context "nawiązanie do innego arytułu" do
before do
Person.create!(name: "Maciej", surname: "Fasola", email: "[email protected]", sex:
Expand Down
2 changes: 1 addition & 1 deletion spec/features/user_submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Submission.create!(person: Person.first, status: "odrzucony", polish_title: "Alicja w krainie czarów",
english_title: "Alice in Wonderland", english_abstract: "Little about that story",
english_keywords: "alice", received: "19-01-2016", language: "polski", issue: Issue.first)
Authorship.create!(person: Person.last, submission: Submission.first, corresponding: true, position: 1)
Authorship.create!(person: Person.last, submission: Submission.first, corresponding: true, position: 1, role: "autor")
end

scenario "wyświetlanie zgłoszeń dla autora korespondującego" do
Expand Down