Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a0d2dce
initial commit with project setup
Mar 8, 2021
da98023
migrated models and created tables
Mar 8, 2021
08d4802
created all tables
Mar 9, 2021
1530ba0
initial commit-new
hadichloun Mar 9, 2021
f95df87
wht da hell
Mar 9, 2021
02c3fe5
adds models on github
hadichloun Mar 9, 2021
3248c0e
small
Mar 9, 2021
c586e27
seed file populated
Mar 10, 2021
91aae33
adds many to many
hadichloun Mar 10, 2021
c88a69a
fixed_associations_and_columns_to_accept_ids
Mar 10, 2021
97a5147
stashing
hadichloun Mar 10, 2021
b3dc0ec
fixes merge
hadichloun Mar 10, 2021
6ad9646
added associations and put useless commented out methods in models
Mar 10, 2021
367976e
merging
hadichloun Mar 10, 2021
3ac71c4
working_welcome_method_but_broken_search_method_at_purchase_step_and_…
Mar 10, 2021
34f8799
adds login
hadichloun Mar 10, 2021
8eee319
adds login
hadichloun Mar 10, 2021
e34a7b1
adds login
hadichloun Mar 10, 2021
f1c7084
setting up more program
Mar 10, 2021
4e95a22
merging
hadichloun Mar 10, 2021
d91fc11
merges
hadichloun Mar 10, 2021
ad82681
merges1
hadichloun Mar 10, 2021
a342b89
merging
hadichloun Mar 10, 2021
9e5bc75
meh
Mar 10, 2021
caebc69
Merge branch 'master' of github.com:hadichloun/ruby-project-guidelines
Mar 10, 2021
92a100a
maerging
hadichloun Mar 11, 2021
701d241
this shit still confuses me
Mar 11, 2021
c86b8d0
adds login
hadichloun Mar 11, 2021
c98a82e
search by genre
Mar 11, 2021
0357112
merge conflicts
hadichloun Mar 11, 2021
6ac334c
fixes sign up
hadichloun Mar 11, 2021
01eac84
login
Mar 11, 2021
b03fe4f
delete ticket
Mar 11, 2021
3b9fbfd
added colors changed font
Mar 11, 2021
1e22a55
final touches and readme2
Mar 12, 2021
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"
92 changes: 57 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,56 +1,78 @@
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-darwin-20
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
28 changes: 28 additions & 0 deletions README2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Module One Project
## Commando Theater

###### Objectives

1. Practice many-to-many and one-to-many relationships.
2. Utilize ActiveRecord and maintain a database
3. Interact with data using a CLI application

### Introduction

In this application the guest will be able to sign up, browse movies, purchase a ticket,
review their purchases, and cancel a ticket if they so choose.
The application will be run using the program.rb file. To be clear, in the
terminal run ruby bin/program.rb to start the application. Guest will then be able to run through the
entire process and re-run in order to sign in and view purchases.

## Instructions
1. Open new terminal
2. Run ruby bin/program.rb
3. Enjoy your Commando experience.



# Notes
Be sure to have gems installed.
Prior to running the program file, user should "bundle install".

3 changes: 3 additions & 0 deletions apps/models/genre.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Genre < ActiveRecord::Base
has_many :movies
end
3 changes: 3 additions & 0 deletions apps/models/guest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Guest < ActiveRecord::Base
has_many :tickets
end
4 changes: 4 additions & 0 deletions apps/models/movie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Movie < ActiveRecord::Base
belongs_to :theater
belongs_to :genre
end
6 changes: 6 additions & 0 deletions apps/models/theater.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Theater < ActiveRecord::Base
has_many :tickets
has_many :guests, through: :tickets
has_many :movies
end

5 changes: 5 additions & 0 deletions apps/models/ticket.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Ticket < ActiveRecord::Base
belongs_to :guest
belongs_to :theater
belongs_to :movie
end
102 changes: 102 additions & 0 deletions bin/program.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
require 'pry'
require_relative '../config/environment'

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


def signup

prompt = TTY::Prompt.new
login_choice = prompt.select("New users please Sign Up",["Sign Up", "Login", ("Exit").colorize(:red)]) #could say "Log in or new user please sign up and put login back in as an option IF

if (login_choice == "Sign Up")
$new_username = prompt.ask("What is your username?")
$new_password = prompt.ask("What is your password? Must only include numbers")
$g = Guest.create(name: "#{$new_username}", password: "#{$new_password}")

puts "Lets start watching!"
elsif login_choice == "Login"
name = prompt.ask("What username?")
password = prompt.ask("What pass?")
users = Guest.all.map{|u| u.name}
if users.include?(name) && Guest.find_by(password: password)
$g = Guest.find_by(name: name)
puts "Hello #{$g.name}."
guest_choice = prompt.select("What would you like to do?", ["Review Orders", "Continue Browsing"])
if guest_choice == "Review Orders"
puts $g.tickets
option = prompt.select("What next?", ["Cancel Ticket", "Continue Browsing"])
if option == "Cancel Ticket"
$g.tickets.delete
puts "#{$g.name}, your ticket has been deleted."
exit!
end
elsif guest_choice == "Continue Browsing"
search
end
end
else
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"])
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.").colorize(:magenta)
puts "You're going to see the #{select_movie.genre.genre}, #{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"])
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.").colorize(:magenta)
puts "You're going to see a #{ticket_choice.genre.genre} movie, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} "
end
end
end

def thanks
puts "Thank you for your purchase! 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!").colorize(:yellow)

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