| 
									
										
										
										
											2011-12-23 10:34:21 +00:00
										 |  |  | class Admin::RolesController < ApplicationController | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2012-11-22 10:20:11 +00:00
										 |  |  |   layout "new_admin" | 
					
						
							| 
									
										
										
										
											2011-12-23 10:34:21 +00:00
										 |  |  |   before_filter :authenticate_user! | 
					
						
							|  |  |  |   before_filter :is_admin? | 
					
						
							|  |  |  |   before_filter :set_attribute, :only => [:index, :show, :new, :edit] | 
					
						
							| 
									
										
										
										
											2012-11-22 10:20:11 +00:00
										 |  |  |   helper Admin::AttributeValuesViewHelper | 
					
						
							| 
									
										
										
										
											2012-11-26 02:08:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-23 10:34:21 +00:00
										 |  |  |   def index | 
					
						
							|  |  |  |     @attributes = Role.all.entries | 
					
						
							|  |  |  |     render :template => 'admin/attributes/index' | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def show | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def new | 
					
						
							|  |  |  |     @attribute = Role.new | 
					
						
							|  |  |  |     render :template => 'admin/attributes/new' | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def edit | 
					
						
							|  |  |  |     @attribute = Role.find(params[:id]) | 
					
						
							| 
									
										
										
										
											2012-11-26 02:08:06 +00:00
										 |  |  |     @attribute_fields_upper_object = @attribute.sub_roles | 
					
						
							| 
									
										
										
										
											2011-12-23 10:34:21 +00:00
										 |  |  |     render :template => 'admin/attributes/edit' | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def create | 
					
						
							|  |  |  |     @attribute = Role.new(params[:role]) | 
					
						
							|  |  |  |     @attribute.save | 
					
						
							|  |  |  |     redirect_to :action => :index | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def update | 
					
						
							|  |  |  |     @attribute = Role.find(params[:id]) | 
					
						
							|  |  |  |     @attribute.update_attributes(params[:role]) | 
					
						
							|  |  |  |     respond_to do |format| | 
					
						
							|  |  |  |       format.html { redirect_to :action => :index } | 
					
						
							|  |  |  |       format.js  { render 'admin/attributes/toggle_enable' } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def destroy | 
					
						
							|  |  |  |     @attribute = Role.find(params[:id]) | 
					
						
							|  |  |  |     @attribute.destroy | 
					
						
							|  |  |  |     redirect_to :action => :index | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   protected | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def set_attribute | 
					
						
							|  |  |  |     @attribute_type = 'role' | 
					
						
							|  |  |  |     @class = 'roles' | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | end |