-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
961ab31
commit 0517434
Showing
32 changed files
with
711 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
class PaperProfessorsController < ApplicationController | ||
authorize_resource | ||
|
||
active_scaffold :paper_professor do |config| | ||
config.create.label = :create_paper_professor_label | ||
config.columns = [:paper, :professor] | ||
config.columns[:professor].form_ui = :record_select | ||
|
||
config.actions.exclude :deleted_records | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
class PaperStudentsController < ApplicationController | ||
authorize_resource | ||
|
||
active_scaffold :paper_student do |config| | ||
config.create.label = :create_paper_student_label | ||
config.columns = [:paper, :student] | ||
config.columns[:student].form_ui = :record_select | ||
|
||
config.actions.exclude :deleted_records | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
class PapersController < ApplicationController | ||
authorize_resource | ||
|
||
active_scaffold :paper do |config| | ||
config.create.label = :create_paper_label | ||
config.actions.swap :search, :field_search | ||
config.list.sorting = { period: "DESC", owner: "ASC", order: "ASC" } | ||
|
||
config.columns.add :header | ||
config.columns.add :reason_group | ||
config.columns.add :reason_group_end | ||
form_columns = [ | ||
:header, | ||
:period, :owner, :reference, :order, :kind, :doi_issn_event, | ||
:paper_professors, :paper_students, :other_authors, | ||
:reason_group, | ||
:reason_impact_factor, | ||
:reason_international_list, | ||
:reason_citations, | ||
:reason_national_interest, | ||
:reason_international_interest, | ||
:reason_national_representativeness, | ||
:reason_scientific_contribution, | ||
:reason_tech_contribution, | ||
:reason_innovation_contribution, | ||
:reason_social_contribution, | ||
:reason_other, | ||
:reason_justify, | ||
:impact_factor, | ||
:reason_group_end, | ||
:other, | ||
] | ||
config.create.columns = form_columns | ||
config.update.columns = form_columns | ||
config.show.columns = [ | ||
:period, :owner, :reference, :kind, :doi_issn_event, | ||
:paper_professors, :paper_students, :other_authors, | ||
:reason_impact_factor, | ||
:reason_international_list, | ||
:reason_citations, | ||
:reason_national_interest, | ||
:reason_international_interest, | ||
:reason_national_representativeness, | ||
:reason_scientific_contribution, | ||
:reason_tech_contribution, | ||
:reason_innovation_contribution, | ||
:reason_social_contribution, | ||
:reason_other, | ||
:reason_justify, | ||
:impact_factor, | ||
:order, | ||
:other, | ||
] | ||
config.list.columns = [ | ||
:period, :owner, :order, :reference | ||
] | ||
|
||
config.columns[:owner].form_ui = :record_select | ||
config.columns[:kind].form_ui = :select | ||
config.columns[:kind].options = { | ||
options: Paper::KINDS, | ||
include_blank: I18n.t("active_scaffold._select_") | ||
} | ||
config.columns[:order].form_ui = :select | ||
config.columns[:order].options = { | ||
options: Paper::ORDERS, | ||
include_blank: I18n.t("active_scaffold._select_") | ||
} | ||
|
||
|
||
config.columns[:paper_students].show_blank_record = false | ||
config.columns[:paper_professors].show_blank_record = false | ||
|
||
config.actions.exclude :deleted_records | ||
end | ||
|
||
protected | ||
def do_new | ||
super | ||
@record.period = CustomVariable.quadrennial_period | ||
unless current_user.professor.blank? | ||
@record.owner = current_user.professor | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
module PaperProfessorsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
module PaperStudentsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
module PapersHelper | ||
def owner_form_column(record, options) | ||
if can?(:edit_professor, record) | ||
record_select_field :owner, record.owner || Professor.new, options | ||
else | ||
options[:value] = record.owner_id | ||
label( | ||
:record_value_1_params, record.id, record.owner.name | ||
) + hidden_field(:record, :owner, options) | ||
end | ||
end | ||
|
||
def period_form_column(record, options) | ||
if can?(:edit_professor, record) | ||
text_field :record, :period, options | ||
else | ||
label( | ||
:record_value_1_params, record.id, record.period | ||
) + hidden_field(:record, :period, options) | ||
end | ||
end | ||
|
||
def reason_group_form_column(record, options) | ||
"aaaa" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
class Paper < ApplicationRecord | ||
has_paper_trail | ||
|
||
attr_accessor :reason_group, :reason_group_end, :header | ||
|
||
belongs_to :owner, optional: false, class_name: "Professor" | ||
has_many :paper_professors, dependent: :destroy | ||
has_many :paper_students, dependent: :destroy | ||
has_many :professors, through: :paper_professors | ||
has_many :students, through: :paper_students | ||
|
||
JOURNAL = I18n.translate( | ||
"activerecord.attributes.paper.kinds.journal" | ||
) | ||
CONFERENCE = I18n.translate( | ||
"activerecord.attributes.paper.kinds.conference" | ||
) | ||
KINDS = [JOURNAL, CONFERENCE] | ||
|
||
ORDERS = [1, 2, 3, 4, 5, 6, 7, 8] | ||
|
||
validates :reference, presence: true | ||
validates :kind, presence: true, inclusion: { in: KINDS } | ||
validates :doi_issn_event, presence: true | ||
validates :reason_justify, presence: true | ||
validates :impact_factor, presence: true | ||
validates :order, presence: true, inclusion: { in: ORDERS }, uniqueness: { | ||
scope: [:period, :owner_id], message: :order_uniqueness | ||
} | ||
|
||
validate :that_professor_cannot_edit_other_papers, if: -> { cannot?(:edit_professor, self) } | ||
|
||
def that_professor_cannot_edit_other_papers | ||
current_professor = current_user&.professor | ||
return if current_professor.nil? | ||
if self.changes[:owner_id].present? && self.changes[:owner_id] != [nil, current_professor.id] | ||
self.errors.add(:owner, :cannot_edit_other_papers) | ||
end | ||
end | ||
|
||
def to_label | ||
"[#{self.owner.to_label}] #{self.reference}" | ||
end | ||
|
||
private | ||
delegate :can?, :cannot?, to: :ability | ||
|
||
def ability | ||
@ability ||= Ability.new(current_user) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
class PaperProfessor < ApplicationRecord | ||
has_paper_trail | ||
|
||
belongs_to :paper, optional: false | ||
belongs_to :professor, optional: false | ||
|
||
def to_label | ||
"#{self.professor.to_label} - #{self.paper.to_label}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class PaperStudent < ApplicationRecord | ||
has_paper_trail | ||
|
||
belongs_to :paper | ||
belongs_to :student | ||
|
||
def to_label | ||
"#{self.student.to_label} - #{self.paper.to_label}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Lembre que o relatório final é a coleção de artigos do programa. Assim: | ||
|
||
<ul> | ||
<li>Tente informar entre quatro e oito artigos. Mas não deixe de preencher se sua escolha for menor que essa.</li> | ||
<li>Caso tenha mais de um artigo de destaque por ano, informe também.</li> | ||
<li>Os artigos podem ser publicações em periódicos ou conferências.</li> | ||
</ul> | ||
|
||
<br> | ||
<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
</li> | ||
</div> | ||
|
||
<li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
</li> | ||
<style> | ||
.paper-reason-group { | ||
width: 35em; | ||
} | ||
.paper-reason-group li.checkbox dl { | ||
display: flex; | ||
flex-direction: row-reverse; | ||
flex-wrap: nowrap; | ||
} | ||
.paper-reason-group li.checkbox dl > dt { | ||
width: 100% !important; | ||
flex: 1 1 100%; | ||
padding: 10px 0; | ||
} | ||
.paper-reason-group li.checkbox dl > dd { | ||
flex: 0 1 23px; | ||
} | ||
</style> | ||
|
||
<% id ||= "group_#{SecureRandom.random_number(1_000_000)}" %> | ||
<h5> Motivos <a href="#" class="as-js-button visibility-toggle" data-toggable="<%= id %>" data-show="Mostrar" data-hide="Ocultar">Ocultar</a> </h5> | ||
<div id="<%= id %>" class="paper-reason-group"> | ||
Quais aspectos atribui ao artigo para que ele entre na sua lista? | ||
<li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.