Skip to content

Commit

Permalink
hw4
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcai committed Jun 18, 2012
1 parent 7157c9e commit 40dbe06
Show file tree
Hide file tree
Showing 70 changed files with 4,216 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ def destroy
redirect_to movies_path
end

def similar
movie = Movie.find(params[:id])
redirect_to movies_path if movie.director.nil? or movie.director.empty?

@movies = Movie.find_similar(movie)
end

end
Binary file added app/models/.movie.rb.swo
Binary file not shown.
4 changes: 4 additions & 0 deletions app/models/movie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class Movie < ActiveRecord::Base
def self.all_ratings
%w(G PG PG-13 NC-17 R)
end

def self.find_similar(movie)
where :director => movie.director
end
end
3 changes: 3 additions & 0 deletions app/views/movies/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
= label :movie, :rating, 'Rating'
= select :movie, :rating, ['G','PG','PG-13','R','NC-17']

= label :movie, :director, 'Director'
= text_field :movie, 'director'

= label :movie, :release_date, 'Released On'
= date_select :movie, :release_date

Expand Down
2 changes: 2 additions & 0 deletions app/views/movies/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
%tr
%th{:class => @title_header}= link_to 'Movie Title', movies_path(:sort => 'title', :ratings => @selected_ratings), :id => 'title_header'
%th Rating
%th Director
%th{:class => @date_header}= link_to 'Release Date', movies_path(:sort => 'release_date', :ratings => @selected_ratings), :id => 'release_date_header'
%th More Info
%tbody
- @movies.each do |movie|
%tr
%td= movie.title
%td= movie.rating
%td= movie.director
%td= movie.release_date
%td= link_to "More about #{movie.title}", movie_path(movie)

Expand Down
4 changes: 4 additions & 0 deletions app/views/movies/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
%li
Rating:
= @movie.rating
%li
Director:
= @movie.director
%li
Released on:
= @movie.release_date.strftime("%B %d, %Y")
Expand All @@ -14,6 +17,7 @@

%p#description= @movie.description

= link_to 'Find Movies With Same Director', similar_movie_path(@movie)
= link_to 'Edit', edit_movie_path(@movie)
= button_to 'Delete', movie_path(@movie), :method => :delete, :confirm => 'Are you sure?'
= link_to 'Back to movie list', movies_path
20 changes: 20 additions & 0 deletions app/views/movies/similar.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-# This file is app/views/movies/similar.html.haml
%h1 Similar Movies

%table#movies
%thead
%tr
%th Title
%th Rating
%th Director
%th Release date
%th More Info
%tbody
- @movies.each do |movie|
%tr
%td= movie.title
%td= movie.rating
%td= movie.director
%td= movie.release_date
%td= link_to "More about #{movie.title}", movie_path(movie)

8 changes: 8 additions & 0 deletions config/cucumber.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action

match '/movies/:id/similar' => 'movies#similar', :as => 'similar_movie'

# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
Expand Down
66 changes: 66 additions & 0 deletions coverage/assets/0.4.5/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
$(document).ready(function() {
$('.file_list').dataTable({
"aaSorting": [[ 1, "asc" ]],
"bPaginate": false,
"bJQueryUI": true,
"aoColumns": [
null,
{ "sType": "percent" },
null,
null,
null,
null
]
});

$('.source_table tbody tr:odd').addClass('odd');
$('.source_table tbody tr:even').addClass('even');

$("a.src_link").fancybox({
'hideOnContentClick': true
});

// Hide src files and file list container
$('.source_files').hide();
$('.file_list_container').hide();

// Add tabs based upon existing file_list_containers
$('.file_list_container h2').each(function(){
$('.group_tabs').append('<li><a href="#' + $(this).parent().attr('id') + '">' + $(this).html() + '</a></li>');
});

$('.group_tabs a').each( function() {
$(this).addClass($(this).attr('href').replace('#', ''));
});

$('.group_tabs a').live('focus', function() {
$(this).blur();
});

var favicon_path = $('link[rel="shortcut icon"]').attr('href')
$('.group_tabs a').live('click', function(){
if (!$(this).parent().hasClass('active')) {
$('.group_tabs a').parent().removeClass('active');
$(this).parent().addClass('active');
$('.file_list_container').hide();
$(".file_list_container" + $(this).attr('href')).show();
window.location.href = window.location.href.split('#')[0] + $(this).attr('href').replace('#', '#_');

// Force favicon reload - otherwise the location change containing anchor would drop the favicon...
// Works only on firefox, but still... - Anyone know a better solution to force favicon?
$('link[rel="shortcut icon"]').remove();
$('head').append('<link rel="shortcut icon" type="image/png" href="'+ favicon_path +'" />');
};
return false;
});

if (jQuery.url.attr('anchor')) {
$('.group_tabs a.'+jQuery.url.attr('anchor').replace('_', '')).click();
} else {
$('.group_tabs a:first').click();
};

$("abbr.timeago").timeago();
$('#loading').fadeOut();
$('#wrapper').show();
});
Binary file added coverage/assets/0.4.5/fancybox/blank.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_nav_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_ne.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_nw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_se.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_sw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_shadow_w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_title_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_title_main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_title_over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancy_title_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancybox-x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancybox-y.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coverage/assets/0.4.5/fancybox/fancybox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 40dbe06

Please sign in to comment.