Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ gem "sinatra-activerecord"
gem "sqlite3"
gem "pry"
gem "require_all"


gem "artii", "~> 2.1"
gem "tty-prompt", "~> 0.21.0"
gem "colorize"
91 changes: 56 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,56 +1,77 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (6.0.3.1)
activesupport (= 6.0.3.1)
activerecord (6.0.3.1)
activemodel (= 6.0.3.1)
activesupport (= 6.0.3.1)
activesupport (6.0.3.1)
activemodel (6.1.3)
activesupport (= 6.1.3)
activerecord (6.1.3)
activemodel (= 6.1.3)
activesupport (= 6.1.3)
activesupport (6.1.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
coderay (1.1.1)
concurrent-ruby (1.1.6)
i18n (1.8.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
artii (2.1.2)
coderay (1.1.3)
colorize (0.8.1)
concurrent-ruby (1.1.8)
equatable (0.6.1)
i18n (1.8.9)
concurrent-ruby (~> 1.0)
method_source (0.8.2)
minitest (5.14.1)
mustermann (1.0.3)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
method_source (1.0.0)
minitest (5.14.4)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
necromancer (0.5.1)
pastel (0.7.4)
equatable (~> 0.6)
tty-color (~> 0.5)
pry (0.14.0)
coderay (~> 1.1)
method_source (~> 1.0)
rack (2.2.3)
rack-protection (2.0.7)
rack-protection (2.1.0)
rack
require_all (1.3.3)
sinatra (2.0.7)
require_all (3.0.0)
ruby2_keywords (0.0.4)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.7)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
sinatra-activerecord (2.0.12)
activerecord (>= 3.2)
sinatra-activerecord (2.0.22)
activerecord (>= 4.1)
sinatra (>= 1.0)
slop (3.6.0)
sqlite3 (1.3.13)
thread_safe (0.3.6)
sqlite3 (1.4.2)
tilt (2.0.10)
tzinfo (1.2.7)
thread_safe (~> 0.1)
zeitwerk (2.3.0)
tty-color (0.6.0)
tty-cursor (0.7.1)
tty-prompt (0.21.0)
necromancer (~> 0.5.0)
pastel (~> 0.7.0)
tty-reader (~> 0.7.0)
tty-reader (0.7.0)
tty-cursor (~> 0.7)
tty-screen (~> 0.7)
wisper (~> 2.0.0)
tty-screen (0.8.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
wisper (2.0.1)
zeitwerk (2.4.2)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
artii (~> 2.1)
colorize
pry
require_all
sinatra-activerecord
sqlite3
tty-prompt (~> 0.21.0)

BUNDLED WITH
1.14.6
2.2.11
8 changes: 8 additions & 0 deletions apps/models/genre.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Genre < ActiveRecord::Base
has_many :movies

# def self.genres
# #return all genres
# end

end
8 changes: 8 additions & 0 deletions apps/models/guest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Guest < ActiveRecord::Base
has_many :tickets

# def self.guestbook
# #return all guests
# end

end
41 changes: 41 additions & 0 deletions apps/models/movie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Movie < ActiveRecord::Base
belongs_to :theater
belongs_to :genre

# @@all = []

# def initialize
# @@all<<self
# end

# def all
# @@all
# end


# def self.browse
# #return all movies
# end



# def self.browse_by_genre(genre)
# #given argument of a genre returns list of all movies associated with genre)

# ####Solution1####
# #assign genre object a variable
# #call and return variables movies w/ variable.movies

# ###Solution2###
# #find genres genre_id
# #iterate through movies
# #select ones that have said genre_id => return array
# #use that array find each movie title
# #return each movie title in array


# end



end
10 changes: 10 additions & 0 deletions apps/models/theater.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Theater < ActiveRecord::Base
has_many :tickets
has_many :guests, through: :tickets
has_many :movies

# def self.theaters
# #return theaters
# #MAYBE RETURN THEATERS AND THEIR MOVIES
# end
end
10 changes: 10 additions & 0 deletions apps/models/ticket.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Ticket < ActiveRecord::Base
belongs_to :guest
belongs_to :theater
belongs_to :movie

# def self.purchases
# #return all purchases
# end

end
92 changes: 92 additions & 0 deletions bin/program.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
require 'pry'
require_relative '../config/environment'

def welcome
title=Artii::Base.new(:font=> "cursive")
puts "Welcome to"
puts title.asciify("Command Theater")
end


def signup
prompt = TTY::Prompt.new
login_choice = prompt.select("New users please Sign Up",["Sign Up", "Exit"])
if (login_choice == "Sign Up")
new_username = prompt.ask("What is your username?")
new_password = prompt.ask("What is your password?")
$g = Guest.create(name: "#{new_username}", password: "#{new_password}")

puts "Lets start watching!"
else
puts "Incorrect username or password"
exit!
end
end




def search
movies = Movie.all.map {|movie| movie.title}
genres = Genre.all.map {|genre| genre.genre}
prompt = TTY::Prompt.new
search_choice = prompt.select("What would you like to see?", ["All Movies", "Genres"])
if (search_choice == "All Movies")
prompt = TTY::Prompt.new
choice = prompt.select("Pick a movie", movies)
puts "You selected #{choice}!!! We love that one!"
select_movie = Movie.find_by(title: choice)

menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"])
if menu_options == "Purchase Ticket"
puts "Here is your ticket! Excited yet?!"
your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: $g.id)
puts your_ticket
puts "Please save this id for your confirmation number."
puts "You're going to see the #{select_movie.genre.genre} movie, #{your_ticket.movie.title}, @ #{select_movie.showtime} "
end

elsif (search_choice == "Genres")
prompt = TTY::Prompt.new
genre_choice = prompt.select("Pick a genre", genres)
puts "You selected #{genre_choice}. That's a popular one!"
select_genre = Genre.find_by(genre: genre_choice)
genre_titles = select_genre.movies.map {|movie| movie.title}
prompt = TTY::Prompt.new
genre_movie_choice = prompt.select("Which movie?", genre_titles)
ticket_choice = Movie.find_by(title: genre_movie_choice)


prompt = TTY::Prompt.new
menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"])
if menu_options == "Purchase Ticket"
puts "Here is your ticket! Excited yet?!"
your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: ticket_choice.id, guest_id: $g.id)
puts your_ticket
puts "Please save this id for your confirmation number."
puts "You're going to see a #{ticket_choice.genre.genre} movie, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} "

else
welcome
end
end
end





####how to save rat
def thanks
puts "Thank you for your purchase! Commando Theater is b.y.o.b so feel free and WELCOME to bring your own refreshments. We cant wait to watch a movie with you!"
prompt = TTY::Prompt.new
thanks_choice = prompt.ask("Please leave us a rating from 1-5")
puts "Thank you for your feedback!"
end



welcome
signup
search
thanks
5 changes: 0 additions & 5 deletions bin/run.rb

This file was deleted.

2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
development:
adapter: sqlite3
database: db/development.db
database: db/development.db
pool: 5
timeout: 5000
4 changes: 3 additions & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'bundler'
Bundler.require


ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db')
require_all 'lib'
ActiveRecord::Base.logger = nil
require_all 'apps'
10 changes: 10 additions & 0 deletions db/migrate/20210309224256_create_movies_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateMoviesTable < ActiveRecord::Migration[6.1]
def change
create_table :movies do |t|
t.string :title_id
t.string :genre_id
t.integer :showtime_id
t.string :theater
end
end
end
7 changes: 7 additions & 0 deletions db/migrate/20210309224721_create_theaters_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreateTheatersTable < ActiveRecord::Migration[6.1]
def change
create_table :theaters do |t|
t.string :name
end
end
end
7 changes: 7 additions & 0 deletions db/migrate/20210309224824_create_genres_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreateGenresTable < ActiveRecord::Migration[6.1]
def change
create_table :genres do |t|
t.string :genre
end
end
end
7 changes: 7 additions & 0 deletions db/migrate/20210309224916_create_guests_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreateGuestsTable < ActiveRecord::Migration[6.1]
def change
create_table :guests do |t|
t.string :name
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20210309225013_create_tickets_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateTicketsTable < ActiveRecord::Migration[6.1]
def change
create_table :tickets do |t|
t.string :theater
t.string :movie
t.string :guest
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class ChangeMovieTableColumnToAcceptIds < ActiveRecord::Migration[6.1]
def change
rename_column(:movies, :genre, :genre_id)
change_column(:movies, :genre_id, :integer)
end
end
13 changes: 13 additions & 0 deletions db/migrate/20210310163524_changing_table_columns_to_accept_ids.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class ChangingTableColumnsToAcceptIds < ActiveRecord::Migration[6.1]
def change
rename_column(:movies, :theater, :theater_id)
change_column(:movies, :theater_id, :integer)
rename_column(:tickets, :theater, :theater_id)
rename_column(:tickets, :movie, :movie_id)
rename_column(:tickets, :guest, :guest_id)
change_column(:tickets, :theater_id, :integer)
change_column(:tickets, :movie_id, :integer)
change_column(:tickets, :guest_id, :integer)

end
end
5 changes: 5 additions & 0 deletions db/migrate/20210310214457_hadichloun.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Hadichloun < ActiveRecord::Migration[6.1]
def change
add_column(:guests, :password, :integer)
end
end
Loading