Class: Alchemy::Admin::EssencePicturesController

Inherits:
BaseController show all
Defined in:
app/controllers/alchemy/admin/essence_pictures_controller.rb

Constant Summary collapse

FLOAT_REGEX =
/\A\d+(\.\d+)?\z/

Instance Method Summary collapse

Methods inherited from BaseController

#leave

Methods included from Modules

included, #module_definition_for, register_module

Methods included from Alchemy::AbilityHelper

#current_ability

Methods included from ConfigurationMethods

#configuration, #multi_language?, #multi_site?, #prefix_locale?

Instance Method Details

#assignObject

Assigns picture, but does not save it.

When the user saves the element the content gets updated as well.


43
44
45
46
47
48
49
50
51
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 43

def assign
  @picture = Picture.find_by(id: params[:picture_id])
  @content.essence.picture = @picture
  @element = @content.element

  # We need to update timestamp here because we don't save yet,
  # but the cache needs to be get invalid.
  @content.touch
end

#cropObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 19

def crop
  if @picture = @essence_picture.picture
    @content = @essence_picture.content
    options_from_params[:format] ||= (configuration(:image_store_format) || 'png')

    @min_size = sizes_from_essence_or_params
    @ratio = ratio_from_size_or_params
    infer_width_or_height_from_ratio

    @default_box = @essence_picture.default_mask(@min_size)
    @initial_box = @essence_picture.cropping_mask || @default_box
  else
    @no_image_notice = Alchemy.t(:no_image_for_cropper_found)
  end
end

#destroyObject


53
54
55
56
57
58
59
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 53

def destroy
  @content = Content.find_by(id: params[:id])
  @element = @content.element
  @content_id = @content.id
  @content.destroy
  @essence_pictures = @element.contents.essence_pictures
end

#editObject


16
17
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 16

def edit
end

#updateObject


35
36
37
# File 'app/controllers/alchemy/admin/essence_pictures_controller.rb', line 35

def update
  @essence_picture.update(essence_picture_params)
end