Sha256: 741c9ccc52f6dcbb679d9b3322490f717127e68e02d1cbcb07c1211324ee94f7

Contents?: true

Size: 1.88 KB

Versions: 15

Compression:

Stored size: 1.88 KB

Contents

class DataEntriesController < ApplicationController
  before_filter :find_data_entry, :except => [:create]
  before_filter :check_can_edit
  layout :admin_layout

  def show
  end

  def new
    # TODO
  end

  def create
    @data_entry = secure!(Node) { DataEntry.create_data_entry(params['data_entry']) }

    respond_to do |format|
      if @data_entry.errors.empty?
        flash.now[:notice] = _('Data entry was successfully created.')
        format.html { redirect_to data_entry_url(@data_entry) }
        format.js
        format.xml  { head :created, :location => data_entry_url(@data_entry) }
      else
        format.html { render :action => "new" }
        format.js
        format.xml  { render :xml => @data_entry.errors.to_xml }
      end
    end
  end

  def zafu
    respond_to do |format|
      format.js { render :action => 'show' }
    end
  end

  # modifications of the node itself (dates, groups, revert editions, etc)
  def edit
    respond_to do |format|
      format.js do
        # zafu edit
        render :template => 'data_entries/edit.rjs' # FIXME: this should not be needed. Rails bug ?
      end
    end
  end

  def update
    @data_entry.update_attributes_with_transformation(params[:data_entry])

    respond_to do |format|
      format.html # TODO
      format.js
    end
  end

  def destroy
    @data_entry.destroy

    respond_to do |format|
      format.html { redirect_to zen_path(@node) }
      format.js
      format.xml  { head :ok }
    end
  end

  private
    def find_data_entry
      return false unless @data_entry = secure(DataEntry) { DataEntry.find_by_id(params[:id]) }
      @node = @data_entry.node_a
    end

    def check_can_edit
      if @data_entry
        @data_entry.can_write?
      else
        unless @node = secure_write(Node) { Node.find_by_zip(params['data_entry']['node_a_id']) }
          return false
        end
      end
      return true
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
zena-1.2.8 app/controllers/data_entries_controller.rb
zena-1.2.7 app/controllers/data_entries_controller.rb
zena-1.2.6 app/controllers/data_entries_controller.rb
zena-1.2.5 app/controllers/data_entries_controller.rb
zena-1.2.4 app/controllers/data_entries_controller.rb
zena-1.2.3 app/controllers/data_entries_controller.rb
zena-1.2.2 app/controllers/data_entries_controller.rb
zena-1.2.1 app/controllers/data_entries_controller.rb
zena-1.2.0 app/controllers/data_entries_controller.rb
zena-1.1.3 app/controllers/data_entries_controller.rb
zena-1.1.2 app/controllers/data_entries_controller.rb
zena-1.1.1 app/controllers/data_entries_controller.rb
zena-1.1.0 app/controllers/data_entries_controller.rb
zena-1.0.0 app/controllers/data_entries_controller.rb
zena-1.0.0.rc3 app/controllers/data_entries_controller.rb