class ResourcePicturesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show, :credit, :new, :create, :update, :destroy]
- before_filter :authenticate_author, :only => [:index, :show, :credit, :new, :create, :update, :destroy]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
+ before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
+ else
+ before_filter :authenticate_resource_reader, :only => [:index, :show, :credit]
+ before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
+ before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
- before_filter :authenticate_artist, :only => [:new, :create, :destroy]
- # GET /resource_pictures
- # GET /resource_pictures.json
def index
@page = ResourcePicture.page params[:page]
@page_size = ResourcePicture.page_size params[:page_size]
@resource_pictures = ResourcePicture.list(@page, @page_size)
respond_to do |format|
- format.html # index.html.erb
+ format.html {
+ @paginate = ResourcePicture.list_paginate(@page, @page_size)
+ }
format.json { render :json => @resource_pictures.to_json(ResourcePicture.list_json_opt) }
end
end
- # GET /resource_pictures/1
- # GET /resource_pictures/1.json
def show
- @resource_picture = ResourcePicture.show(params[:id], @author)
+ @resource_picture = ResourcePicture.show(params[:id], [@user, @admin, @demand_user])
respond_to do |format|
opt = {:type => @resource_picture.mime_type, :disposition=>"inline"}
end
def credit
- @resource_picture = ResourcePicture.show(params[:id], @author)
+ @resource_picture = ResourcePicture.show(params[:id], [@user, @admin, @demand_user])
respond_to do |format|
format.html { render :layout => false } # show.html.erb
respond_to do |format|
if @resource_picture.unpublish
- format.html { redirect_to resource_pictures_path }
+ format.html { redirect_to :controller => '/home', :action => :resource_picture }
format.json { head :ok }
else
- format.html { render resource_picture_path(@resource_picture) }
+ format.html { redirect_to resource_picture_path(@resource_picture) }
format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
end
end