comparison vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 684:cd7e10c4ab86 feature_36

Feature #238 - Edit Publication now showing the correct fields.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 16 Sep 2011 13:17:28 +0100
parents c3e6c51170fa
children 4481db876cdb
comparison
equal deleted inserted replaced
683:c3e6c51170fa 684:cd7e10c4ab86
61 parse_bibtex_list bibtex_entry 61 parse_bibtex_list bibtex_entry
62 end 62 end
63 end 63 end
64 64
65 def get_bibtex_required_fields 65 def get_bibtex_required_fields
66 all_fields = [ "editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "year", "type", "note", "number", "journal", "howpublished", "key", "school", "month" ] 66 all_fields = [ "editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "month", "year", "type", "note", "number", "journal", "howpublished", "key", "school" ]
67 67
68 fields = Hash.new 68 fields = Hash.new
69 fields[ 'article' ] = [ 'journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ] 69 fields[ 'article' ] = [ 'journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ]
70 fields[ 'book' ] = [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ] 70 fields[ 'book' ] = [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ]
71 fields[ 'booklet' ] = [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ] 71 fields[ 'booklet' ] = [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ]
110 110
111 def edit 111 def edit
112 find_project_by_project_id unless params[:project_id].nil? 112 find_project_by_project_id unless params[:project_id].nil?
113 113
114 @edit_view = true; 114 @edit_view = true;
115
116 @publication = Publication.find(params[:id]) 115 @publication = Publication.find(params[:id])
117 @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type 116 @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type
118 117
119 @author_options = [] 118 @author_options = []
119
120
121 fields = Hash.new
122 fields[ 'article' ] = [ 'journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ]
123 fields[ 'book' ] = [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ]
124 fields[ 'booklet' ] = [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ]
125 fields[ 'conference' ] = [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ]
126 fields[ 'inbook' ] = [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ]
127 fields[ 'incollection' ] = [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ]
128 fields[ 'inproceedings' ] = [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ]
129 fields[ 'manual' ] = [ 'organization', 'address', 'edition', 'month', 'year', 'note' ]
130 fields[ 'masterthesis' ] = [ 'school', 'year', 'address', 'month', 'note' ]
131 fields[ 'misc' ] = [ 'howpublished', 'month', 'year', 'note' ]
132 fields[ 'phdthesis' ] = [ 'school', 'year', 'address', 'month', 'note' ]
133 fields[ 'proceedings' ] = [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ]
134 fields[ 'techreport' ] = [ 'year', 'type', 'number', 'address', 'month', 'note' ]
135 fields[ 'unpublished' ] = [ 'note', 'month', 'year' ]
136
137 entrytype = BibtexEntryType.find(@selected_bibtex_entry_type_id).name
138
139 @bibtype_fields = fields[entrytype]
140
120 end 141 end
121 142
122 def update 143 def update
123 @publication = Publication.find(params[:id]) 144 @publication = Publication.find(params[:id])
124 145
139 end 160 end
140 end 161 end
141 162
142 def show 163 def show
143 find_project_by_project_id unless params[:project_id].nil? 164 find_project_by_project_id unless params[:project_id].nil?
144 165
145 if @publication.nil? 166 if @publication.nil?
146 @publications = Publication.all 167 @publications = Publication.all
147 render "index", :alert => 'The publication was not found!' 168 render "index", :alert => 'The publication was not found!'
148 else 169 else
149 @authors = @publication.authors 170 @authors = @publication.authors