Class: PettanrCreativeCommonsV30Licenses::AttributesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/pettanr_creative_commons_v30_licenses/attributes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/pettanr_creative_commons_v30_licenses/attributes_controller.rb', line 19

def create
  @original_picture, @original_picture_license_group, @license_group = 
    PettanrCreativeCommonsV30Licenses::Attribute.remember_params params, @operators
  @attr = PettanrCreativeCommonsV30Licenses.new_attribute params[:creative_commons_license]
  @license = License.show @attr.license_id, @operators
  @resource_picture = @original_picture.resource_picture || ResourcePicture.new
  @resource_picture.attributes = @attr.resource_picture_attributes @original_picture, @license
  @resource_picture.overwrite @original_picture
  respond_to do |format|
    if @attr.valid?
      format.html { render main_app.new_resource_picture_path }
      format.json { render json: @resource_picture.to_json(ResourcePicture.show_json_opt), status: :created }
    else
      format.html { render action: "new" }
      format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
    end
  end
end

#newObject



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/pettanr_creative_commons_v30_licenses/attributes_controller.rb', line 8

def new
  @original_picture, @original_picture_license_group, @license_group = 
    PettanrCreativeCommonsV30Licenses::Attribute.remember_params params, @operators
  @attr = @license_group.my_engine.new_attribute {}
  @attr.supply_default @operators

  respond_to do |format|
    format.html
  end
end