Changeset 2049
- Timestamp:
- 11/16/07 17:18:01 (1 year ago)
- Files:
-
- branches/2007.1/app/controllers/application_controller.rb (modified) (1 diff)
- branches/2007.1/app/controllers/cast_controller.rb (moved) (moved from branches/2007.1/app/controllers/casts_controller.rb) (6 diffs)
- branches/2007.1/app/controllers/movies_controller.rb (modified) (2 diffs)
- branches/2007.1/app/helpers/cast_helper.rb (moved) (moved from branches/2007.1/app/helpers/casts_helper.rb) (1 diff)
- branches/2007.1/app/models/job/department.rb (modified) (2 diffs)
- branches/2007.1/app/views/cast (moved) (moved from branches/2007.1/app/views/casts)
- branches/2007.1/app/views/cast/_actor.rhtml (copied) (copied from branches/2007.1/app/views/casts/_actor.rhtml)
- branches/2007.1/app/views/cast/_cast.rhtml (copied) (copied from branches/2007.1/app/views/casts/_cast.rhtml)
- branches/2007.1/app/views/cast/_cast_actor.rhtml (copied) (copied from branches/2007.1/app/views/casts/_cast_actor.rhtml)
- branches/2007.1/app/views/cast/_cast_default.rhtml (copied) (copied from branches/2007.1/app/views/casts/_cast_default.rhtml)
- branches/2007.1/app/views/cast/_edit_character.rhtml (copied) (copied from branches/2007.1/app/views/casts/_edit_character.rhtml)
- branches/2007.1/app/views/cast/_edit_character_name.rhtml (copied) (copied from branches/2007.1/app/views/casts/_edit_character_name.rhtml)
- branches/2007.1/app/views/cast/assign_character.rjs (copied) (copied from branches/2007.1/app/views/casts/assign_character.rjs)
- branches/2007.1/app/views/cast/create.rjs (copied) (copied from branches/2007.1/app/views/casts/create.rjs)
- branches/2007.1/app/views/cast/create_character.rhtml (copied) (copied from branches/2007.1/app/views/casts/create_character.rhtml)
- branches/2007.1/app/views/cast/delete.rjs (copied) (copied from branches/2007.1/app/views/casts/delete.rjs)
- branches/2007.1/app/views/cast/edit_alias.rhtml (copied) (copied from branches/2007.1/app/views/casts/edit_alias.rhtml)
- branches/2007.1/app/views/cast/edit_character.rhtml (copied) (copied from branches/2007.1/app/views/casts/edit_character.rhtml)
- branches/2007.1/app/views/cast/edit_comment.rhtml (copied) (copied from branches/2007.1/app/views/casts/edit_comment.rhtml)
- branches/2007.1/app/views/cast/edit_job.rhtml (copied) (copied from branches/2007.1/app/views/casts/edit_job.rhtml)
- branches/2007.1/app/views/cast/index.rhtml (copied) (copied from branches/2007.1/app/views/casts/index.rhtml) (4 diffs)
- branches/2007.1/app/views/cast/new.rhtml (copied) (copied from branches/2007.1/app/views/casts/new.rhtml)
- branches/2007.1/app/views/cast/new_cast.rhtml (copied) (copied from branches/2007.1/app/views/casts/new_cast.rhtml)
- branches/2007.1/app/views/cast/set_cast_character_name.rhtml (copied) (copied from branches/2007.1/app/views/casts/set_cast_character_name.rhtml)
- branches/2007.1/app/views/cast/show.rxml (copied) (copied from branches/2007.1/app/views/casts/show.rxml)
- branches/2007.1/app/views/cast/update.rjs (copied) (copied from branches/2007.1/app/views/casts/update.rjs)
- branches/2007.1/app/views/cast/xml (copied) (copied from branches/2007.1/app/views/casts/xml)
- branches/2007.1/app/views/casts/department.rxml (deleted)
- branches/2007.1/app/views/movies/_overview_details.rhtml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2007.1/app/controllers/application_controller.rb
r2031 r2049 257 257 render :nothing => true, :status => 404 258 258 end 259 260 protected 261 262 # Define global before filters, needed by several controllers 263 264 # Select the requestes movie, identified by +movie_id+ in the params hash 265 def select_movie 266 @movie = Movie.find(params[:movie_id]) 267 end 268 269 259 270 end 260 271 branches/2007.1/app/controllers/cast_controller.rb
r2038 r2049 21 21 # = CastController 22 22 # 23 # Handles all cast related actions. 23 # Handles all cast related actions. This is a subresource of movies, so you 24 # should expect an url like /movies/123/cast. 25 # 26 # @see DepartmentController 24 27 25 class Cast sController < ApplicationController28 class CastController < ApplicationController 26 29 cache_sweeper :cast_log_observer 27 30 cache_sweeper :generic_log_observer 28 31 29 # Verify all nec cessary parameters for all public actions.32 # Verify all necessary parameters for all public actions. 30 33 # The filter chain will stop the processing, if one of the parameters 31 34 # is missing. But as this would mean someone is trying to bother us 32 35 # with invalid requests, its okay to simply stop handling the request. 33 verify :params => [ :id ], :only => [ :show ]34 verify :params => [ :id, :job ], :only => [ :update ]35 verify :params => [ :movie , :department ], :only => [ :department ]36 verify :params => [ :movie , :person, :job ], :only => [ :create ]36 verify :params => [ :id ], :only => [ :show ] 37 verify :params => [ :id, :job ], :only => [ :update ] 38 verify :params => [ :movie_id, :department ], :only => [ :department ] 39 verify :params => [ :movie_id, :person, :job ], :only => [ :create ] 37 40 38 # set @cast and/or @movie 39 before_filter :select_cast, :except => [ :new, :create, :department ] 40 before_filter :select_movie, :only => [ :new, :create, :department ] 41 # set @cast and/or @movie, select_movie is defined in the application 42 # controller. 43 before_filter :select_cast, :except => [ :new, :create, :department, :index ] 44 before_filter :select_movie, :only => [ :new, :create, :department, :index ] 41 45 42 46 helper :character … … 44 48 caches_page :show 45 49 50 def index 51 52 end 53 46 54 def create 47 55 if select_job and select_or_create_person … … 49 57 if @cast.save 50 58 respond_to do |type| 51 type.js { update_movie_cast_list( @cast.job.department )}52 type.xml { render :xml => { :success => true, :id => @cast.id }.to_xml, :status => :created }59 type.js { render :template => 'department/update', :layout => false } 60 type.xml { render :xml => { :success => true, :id => @cast.id }.to_xml, :status => :created } 53 61 type.html { redirect_to url_for( :controller => 'movies', :id => @cast.movie.id, :action => 'cast' ) } 54 62 end … … 82 90 end 83 91 end 84 85 def department86 @department = Department.find( params[:department] )87 if request.put?88 klass = (@department == Department.acting) ? Actor : Cast89 remove_unwanted_casts90 create_new_casts klass91 respond_to do |format|92 format.js { update_movie_cast_list @department }93 format.xml { render :nothing => true }94 end95 elsif request.get?96 @results = Cast.employees( @movie, @department )97 render :layout => false98 end99 end100 101 92 102 93 # == Private methods … … 168 159 end 169 160 170 def update_movie_cast_list( department )171 @movie.reload172 render :update do |page|173 page.replace_html "movie-list-#{department.id}", :partial => 'movies/cast', :locals => { :department => department, :show_edit_links => true }174 if Department.crew_departments.include?( department )175 page.replace_html "overview-crew", :partial => 'movies/overview_crew'176 end177 end178 end179 180 161 def select_cast 181 162 begin … … 189 170 end 190 171 191 def select_movie192 @movie = Movie.find(params[:movie])193 end194 195 def remove_unwanted_casts196 Cast.employees( @movie, @department ).each {|c|197 next if c.frozen? or c.movie_id != @movie.id198 if params[:casts].nil? or not params[:casts].include?(c.id.to_s)199 c.destroy200 end201 }202 end203 204 def create_new_casts( klass )205 job = @department.default_job206 params[:people].each { |id|207 p = Person.find(id) rescue nil208 cast = klass.new.init(p, @movie, job)209 cast.save210 } unless params[:people].nil?211 end212 213 172 end branches/2007.1/app/controllers/movies_controller.rb
r2046 r2049 34 34 before_filter :select_movie, :except => [ :create, :list, :status, :random ] 35 35 before_filter :login_required, :only => [ :display_category_vote_icons, :display_keyword_vote_icons, :destroy_alias, :new_image, :upload_image ] 36 37 36 38 37 refresh_action :movie, :overview_votes … … 63 62 end 64 63 65 def cast66 respond_to do |format|67 format.html { render }68 format.xml { render :action => 'xml/cast' }69 end70 end71 72 64 def statistics 73 65 @object = @movie branches/2007.1/app/helpers/cast_helper.rb
r2018 r2049 1 module Cast sHelper1 module CastHelper 2 2 def actor_has_alias 3 3 return false branches/2007.1/app/models/job/department.rb
r2018 r2049 1 1 class Department < Job 2 3 2 if not defined?(DEPARTMENT_TYPES) 4 3 DEPARTMENT_TYPES = ["Writing", "Production", "Directing", "Acting", "Camera", "Lightning", 5 4 "Sound", "Art", "Costume", "Editing", "VisualEffects", "Crew"] 6 5 end 6 7 sluggable_finder :to_permalink, :to => :permalink 7 8 8 9 belongs_to :default_job, … … 20 21 } 21 22 } 23 24 def to_permalink 25 DEPARTMENT_TYPES[id - 1].downcase 26 end 22 27 23 28 def self.initialize branches/2007.1/app/views/cast/index.rhtml
r2048 r2049 19 19 20 20 <div id="new-cast" class="new-cast" style="display: none;"> 21 <%= render 'cast s/new_cast' %>21 <%= render 'cast/new_cast' %> 22 22 </div> 23 23 … … 27 27 28 28 <div id="new-crew" class="new-cast" style="display: none;"> 29 <%= render 'cast s/new' %>29 <%= render 'cast/new' %> 30 30 </div> 31 31 … … 36 36 <% Department.departments.each { |dep| %> 37 37 <div class="list" id="movie-list-<%= dep.id %>"> 38 <%= render :partial => 'cast ', :locals => { :department => dep, :show_edit_links => true } %>38 <%= render :partial => 'cast/cast', :locals => { :department => dep, :show_edit_links => true } %> 39 39 </div> 40 40 <% } %> … … 42 42 <% if @movie.stub? %> 43 43 <div id="stub"> 44 <%= render :partial => 'movie _stub' %>44 <%= render :partial => 'movies/movie_stub' %> 45 45 </div> 46 46 <% end %> branches/2007.1/app/views/movies/_overview_details.rhtml
r2048 r2049 6 6 7 7 <div class="headline-box"> 8 <%= link_to 'show full crew'.t, movie_cast s_path(@movie), :class => 'help-button' %>8 <%= link_to 'show full crew'.t, movie_cast_path(@movie, :id => nil), :class => 'help-button' %> 9 9 <h3><%= 'Crew'.t %></h3> 10 10 </div>
