Changeset 2049

Show
Ignore:
Timestamp:
11/16/07 17:18:01 (1 year ago)
Author:
benjamin
Message:

renames casts_controller to cast_controller

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2007.1/app/controllers/application_controller.rb

    r2031 r2049  
    257257    render :nothing => true, :status => 404 
    258258  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   
    259270end 
    260271 
  • branches/2007.1/app/controllers/cast_controller.rb

    r2038 r2049  
    2121# = CastController 
    2222# 
    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 
    2427 
    25 class CastsController < ApplicationController 
     28class CastController < ApplicationController 
    2629  cache_sweeper :cast_log_observer 
    2730  cache_sweeper :generic_log_observer 
    2831 
    29   # Verify all neccessary parameters for all public actions. 
     32  # Verify all necessary parameters for all public actions. 
    3033  # The filter chain will stop the processing, if one of the parameters 
    3134  # is missing. But as this would mean someone is trying to bother us 
    3235  # 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 ] 
    3740   
    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 ] 
    4145 
    4246  helper :character 
     
    4448  caches_page :show 
    4549 
     50  def index 
     51     
     52  end 
     53   
    4654  def create 
    4755    if select_job and select_or_create_person 
     
    4957      if @cast.save 
    5058        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 } 
    5361          type.html { redirect_to url_for( :controller => 'movies', :id => @cast.movie.id, :action => 'cast' ) } 
    5462        end 
     
    8290    end 
    8391  end 
    84  
    85   def department 
    86     @department = Department.find( params[:department] ) 
    87     if request.put? 
    88       klass = (@department == Department.acting) ? Actor : Cast 
    89       remove_unwanted_casts 
    90       create_new_casts klass 
    91       respond_to do |format| 
    92         format.js  { update_movie_cast_list @department } 
    93         format.xml { render :nothing => true } 
    94       end 
    95     elsif request.get? 
    96       @results    = Cast.employees( @movie, @department ) 
    97       render :layout => false 
    98     end 
    99   end 
    100  
    10192 
    10293  # == Private methods 
     
    168159  end 
    169160 
    170   def update_movie_cast_list( department ) 
    171     @movie.reload 
    172     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       end 
    177     end 
    178   end 
    179    
    180161  def select_cast 
    181162    begin  
     
    189170  end 
    190171 
    191   def select_movie 
    192     @movie  = Movie.find(params[:movie]) 
    193   end 
    194  
    195   def remove_unwanted_casts 
    196     Cast.employees( @movie, @department ).each {|c| 
    197       next if c.frozen? or c.movie_id != @movie.id 
    198       if params[:casts].nil? or not params[:casts].include?(c.id.to_s) 
    199         c.destroy 
    200       end 
    201     } 
    202   end 
    203  
    204   def create_new_casts( klass ) 
    205     job = @department.default_job 
    206     params[:people].each { |id| 
    207       p = Person.find(id) rescue nil 
    208       cast = klass.new.init(p, @movie, job) 
    209       cast.save 
    210     } unless params[:people].nil? 
    211   end 
    212  
    213172end 
  • branches/2007.1/app/controllers/movies_controller.rb

    r2046 r2049  
    3434  before_filter :select_movie, :except => [ :create, :list, :status, :random ] 
    3535  before_filter :login_required, :only => [ :display_category_vote_icons, :display_keyword_vote_icons, :destroy_alias, :new_image, :upload_image ] 
    36    
    3736 
    3837  refresh_action :movie, :overview_votes 
     
    6362  end 
    6463   
    65   def cast 
    66     respond_to do |format| 
    67       format.html { render } 
    68       format.xml  { render :action => 'xml/cast' } 
    69     end 
    70   end 
    71  
    7264  def statistics 
    7365    @object = @movie 
  • branches/2007.1/app/helpers/cast_helper.rb

    r2018 r2049  
    1 module CastsHelper 
     1module CastHelper 
    22  def actor_has_alias 
    33    return false 
  • branches/2007.1/app/models/job/department.rb

    r2018 r2049  
    11class Department < Job 
    2  
    32  if not defined?(DEPARTMENT_TYPES) 
    43    DEPARTMENT_TYPES = ["Writing", "Production", "Directing", "Acting", "Camera", "Lightning",  
    54                        "Sound", "Art", "Costume", "Editing", "VisualEffects", "Crew"] 
    65  end 
     6   
     7  sluggable_finder :to_permalink, :to => :permalink 
    78 
    89  belongs_to :default_job, 
     
    2021     } 
    2122  } 
     23   
     24  def to_permalink 
     25    DEPARTMENT_TYPES[id - 1].downcase 
     26  end 
    2227 
    2328  def self.initialize 
  • branches/2007.1/app/views/cast/index.rhtml

    r2048 r2049  
    1919 
    2020  <div id="new-cast" class="new-cast" style="display: none;"> 
    21     <%= render 'casts/new_cast' %> 
     21    <%= render 'cast/new_cast' %> 
    2222  </div> 
    2323 
     
    2727   
    2828  <div id="new-crew" class="new-cast" style="display: none;"> 
    29     <%= render 'casts/new' %> 
     29    <%= render 'cast/new' %> 
    3030  </div> 
    3131 
     
    3636  <% Department.departments.each { |dep| %> 
    3737    <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 } %> 
    3939    </div> 
    4040  <% } %> 
     
    4242  <% if @movie.stub? %> 
    4343    <div id="stub"> 
    44       <%= render :partial => 'movie_stub' %> 
     44      <%= render :partial => 'movies/movie_stub' %> 
    4545    </div> 
    4646  <% end %> 
  • branches/2007.1/app/views/movies/_overview_details.rhtml

    r2048 r2049  
    66 
    77  <div class="headline-box"> 
    8     <%= link_to 'show full crew'.t, movie_casts_path(@movie), :class => 'help-button'  %> 
     8    <%= link_to 'show full crew'.t, movie_cast_path(@movie, :id => nil), :class => 'help-button'  %> 
    99    <h3><%= 'Crew'.t %></h3> 
    1010  </div>