changeset 428:9cfd7a1d848e feature_36

Created the Edit View (still not changing the DB) Small changes to Publications model.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 01 Jun 2011 17:27:52 +0100
parents de7c31d4cf9a
children 27930c9b424d
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb
diffstat 3 files changed, 56 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Jun 01 17:25:50 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Jun 01 17:27:52 2011 +0100
@@ -53,7 +53,8 @@
   end
 
   def edit
-    logger.error "AAAA edit"
+    @publication = Publication.find(params[:id])
+
 
   end
 
@@ -64,7 +65,7 @@
   end
 
   def show
-    @publication = Publication.find_by_id(params[:id])
+    @publication = Publication.find(params[:id])
 
     if @publication.nil?
         @publications = Publication.all
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb	Wed Jun 01 17:25:50 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb	Wed Jun 01 17:27:52 2011 +0100
@@ -1,12 +1,17 @@
 # vendor/plugins/redmine_bibliography/app/models/publication.rb
 
 class Publication < ActiveRecord::Base
+  unloadable
+
+
   has_many :authorships
   has_many :authors, :through => :authorships
   has_one :bibtex_entry
 
   validates_presence_of :title
   
+  accepts_nested_attributes_for :authors, :bibtex_entry
+  
   attr_writer :current_step
 
   def current_step
--- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Wed Jun 01 17:25:50 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Wed Jun 01 17:27:52 2011 +0100
@@ -1,1 +1,49 @@
 <h2>Publications#edit</h2>
+
+<% form_for @publication, :url => {:action => :edit} do |f| -%>
+  <%= f.error_messages %>
+  <p>
+    <%= f.label :title, l(:title) %>  <%= f.text_field :title %>  
+  </p>
+  
+
+  <h3><%= l(:authors) -%></h3>
+  
+  <% f.fields_for :authors do |author| %>
+    <p>
+      <%= author.label :name, l("name") %> <%= author.text_field :name %>            
+    </p>
+    
+  <% end %>
+  
+  
+  <% f.fields_for @publication.bibtex_entry do |b| -%>
+    <p> 
+      <%= b.label :year, l(:year) %>  <%= b.text_field :year %>  
+    </p>
+    <p> 
+      <%= b.label :chapter, l(:chapter) %>  <%= b.text_field :chapter %>  
+    </p>
+    <p>  
+      <%= b.label :editor, l(:editor) %>  <%= b.text_field :editor %>  
+    </p>
+    <p> 
+      <%= b.label :booktitle, l(:booktitle) %>  <%= b.text_field :booktitle %>  
+    </p>
+    <p> 
+      <%= b.label :publisher, l(:publisher) %>  <%= b.text_field :publisher %>  
+    </p>
+    <p> 
+      <%= b.label :pages, l(:pages) %>  <%= b.text_field :pages %>  
+    </p>
+  <% end -%>
+
+
+
+  <%= f.submit "Submit" %>
+
+
+
+
+
+<% end -%>
\ No newline at end of file