changeset 686:b1debf464389 feature_36

Validates the presence of at least one author
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 16 Sep 2011 15:14:23 +0100
parents 4481db876cdb
children cdddec376920 1f488f375d64
files vendor/plugins/redmine_bibliography/app/models/authorship.rb vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/config/locales/en.yml
diffstat 3 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb	Fri Sep 16 14:37:24 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb	Fri Sep 16 15:14:23 2011 +0100
@@ -6,6 +6,8 @@
   
   accepts_nested_attributes_for :author
   accepts_nested_attributes_for :publication
+
+  validates_presence_of :name_on_paper
   
   attr_accessor :is_user, :author_user_id, :search_name, :identify_author, :search_results
   before_save :associate_author_user
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb	Fri Sep 16 14:37:24 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb	Fri Sep 16 15:14:23 2011 +0100
@@ -9,6 +9,7 @@
   has_one :bibtex_entry, :dependent => :destroy
 
   validates_presence_of :title
+  validates_length_of :authorships, :minimum => 1, :message => l("error_no_authors")
 
   accepts_nested_attributes_for :authorships
   accepts_nested_attributes_for :authors, :allow_destroy => true
--- a/vendor/plugins/redmine_bibliography/config/locales/en.yml	Fri Sep 16 14:37:24 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml	Fri Sep 16 15:14:23 2011 +0100
@@ -16,6 +16,8 @@
   identify_author_correct: "Yes, but I need to correct some details below"
   identify_author_no: "No, the author was not found in the search"
 
+  error_no_authors: "Please add at least one author to this publication."
+
   label_all_publications: All Publications
   label_all_publications_for_project: Publications associated with %{project}
   label_authors_show: "Authorships by this author"