before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
else
before_filter :authenticate_resource_reader, :only => [
- :index, :show, :credit, :by_original_picture, :by_license, :by_artist, :count, :count_by_license, :count_by_artist
+ :index, :show, :credit, :by_license_group, :by_license, :by_artist, :count, :count_by_license_group, :count_by_license, :count_by_artist
]
before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
end
-
- def self.model
- ResourcePicture
- end
def index
filer_list
end
- def by_original_picture
+ def by_license_group
filer_list
end
def show_html_format format
format.html {
- @resource_picture = @item
+ @item.boosts 'post'
}
end
def credit
@resource_picture = ResourcePicture.show(params[:id], @operators)
-
+
respond_to do |format|
format.html { render :layout => false } # show.html.erb
- format.json { render :json => @resource_picture.to_json(ResourcePicture.show_json_opt)}
end
end
list_count
end
+ def count_by_license_group
+ list_count
+ end
+
def count_by_license
list_count
end
end
def new
- @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
- @imager = PettanImager.load @original_picture.restore
- @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
- @license_group = LicenseGroup.show @original_picture_license_group.license_group_id
- @resource_picture = @original_picture.resource_picture
- unless @resource_picture
- @resource_picture = ResourcePicture.new
- @resource_picture.supply_default
- end
- @resource_picture.attributes = params[:resource_picture]
- @resource_picture.overwrite @original_picture
- @license = @resource_picture.license
-
+ # use @item, @original_picture
respond_to do |format|
- format.html # new.html.erb
- format.js
+ format.html
end
end
def create
@original_picture = OriginalPicture.edit params[:original_picture_id], @operators
@imager = PettanImager.load @original_picture.restore
- @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
- @license_group = LicenseGroup.show @original_picture_license_group.license_group_id, @operators
- @resource_picture = @original_picture.resource_picture
- unless @resource_picture
- @resource_picture = ResourcePicture.new
- @resource_picture.supply_default
+ jsn = nil
+ if params[:json]
+ jsn = JSON.parse_no_except(params[:json])
end
- @resource_picture.attributes = params[:resource_picture]
- @resource_picture.overwrite @original_picture
- @license = @resource_picture.license
-
+ @prm = if params[:resource_picture] == nil or params[:resource_picture].empty?
+ jsn
+ else
+ params[:resource_picture]
+ end
+ @item = @original_picture.resource_picture || ResourcePicture.new
+ @item.attributes = @prm
+ @item.overwrite @original_picture
+ @item.boosts 'post'
+
respond_to do |format|
- if @resource_picture.store(@imager)
- format.html { redirect_to @resource_picture }
- format.json { render json: @resource_picture.to_json(ResourcePicture.show_json_opt), status: :created, location: @resource_picture }
+ if @item.store(@imager)
+ format.html { redirect_to @item }
+ format.json { render json: @item.to_json, status: :created, location: @item }
else
format.html { render action: "new" }
- format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
+ format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end