Skip to content

please review and assess completion and code #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .vscode/.ltici_apitoken.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
submission_url: https://grades.firstdraft.com
personal_access_token: 9ALV8qxZ8FFR4VKRcrNkN4ba
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.3'

gem "draft_generators", :github => "firstdraft/draft_generators"

gem "grade_runner", github: "firstdraft/grade_runner"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
Expand Down Expand Up @@ -82,4 +84,5 @@ group :development do
gem 'rubocop-rspec', require: false
gem 'skylight'
gem 'web_git', github: 'firstdraft/web_git'
gem "rails_db", "~> 2.4"
end
53 changes: 53 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: https://github.com/firstdraft/draft_generators.git
revision: 23069b562615e42e04c3343e330846594ce51fdb
specs:
draft_generators (0.0.3)
devise
indefinite_article

GIT
remote: https://github.com/firstdraft/grade_runner.git
revision: e19ab1764a5a4e0a89731fcab76e352d60240ddf
Expand Down Expand Up @@ -90,6 +98,7 @@ GEM
ast (2.4.2)
awesome_print (1.9.2)
backport (1.2.0)
bcrypt (3.1.18)
benchmark (0.2.0)
better_errors (2.9.1)
coderay (>= 1.0.0)
Expand Down Expand Up @@ -130,6 +139,12 @@ GEM
rexml
crass (1.0.6)
debug_inspector (1.1.0)
devise (4.9.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.0)
diffy (3.4.2)
e2mmap (0.1.0)
Expand Down Expand Up @@ -157,10 +172,24 @@ GEM
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
indefinite_article (0.2.5)
activesupport
jaro_winkler (1.5.4)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
kaminari-activerecord (= 1.2.2)
kaminari-core (= 1.2.2)
kaminari-actionview (1.2.2)
actionview
kaminari-core (= 1.2.2)
kaminari-activerecord (1.2.2)
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
Expand Down Expand Up @@ -193,6 +222,7 @@ GEM
faraday (>= 1, < 3)
sawyer (~> 0.9)
oj (3.10.18)
orm_adapter (0.5.0)
parallel (1.22.1)
parser (3.1.1.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -243,6 +273,13 @@ GEM
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
rails_db (2.4.2)
activerecord
kaminari
rails (>= 5.0.0)
ransack (>= 2.3.2)
simple_form (>= 5.0.1)
terminal-table
railties (6.1.5)
actionpack (= 6.1.5)
activesupport (= 6.1.5)
Expand All @@ -251,11 +288,18 @@ GEM
thor (~> 1.0)
rainbow (3.1.1)
rake (13.0.6)
ransack (4.0.0)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
rchardet (1.8.0)
regexp_parser (2.2.1)
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5)
Expand Down Expand Up @@ -330,6 +374,9 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2)
semantic_range (3.0.0)
simple_form (5.2.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
sinatra (3.0.4)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
Expand Down Expand Up @@ -364,6 +411,8 @@ GEM
standard (1.9.1)
rubocop (= 1.26.1)
rubocop-performance (= 1.13.3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.1)
tilt (2.0.11)
turbolinks (5.2.1)
Expand All @@ -375,6 +424,8 @@ GEM
tzinfo (>= 1.0.0)
unicode-display_width (2.1.0)
uniform_notifier (1.16.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand Down Expand Up @@ -417,6 +468,7 @@ DEPENDENCIES
byebug
capybara (>= 3.26)
carrierwave
draft_generators!
factory_bot_rails
grade_runner!
htmlbeautifier
Expand All @@ -429,6 +481,7 @@ DEPENDENCIES
rack-mini-profiler (~> 2.0)
rails (~> 6.1.3, >= 6.1.3.1)
rails-erd
rails_db (~> 2.4)
rollbar
rspec-html-matchers
rspec-rails
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/books.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the books controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
65 changes: 65 additions & 0 deletions app/assets/stylesheets/scaffolds.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
body {
background-color: #fff;
color: #333;
margin: 33px; }

body, p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

pre {
background-color: #eee;
padding: 10px;
font-size: 11px; }

a {
color: #000; }

a:visited {
color: #666; }

a:hover {
color: #fff;
background-color: #000; }

th {
padding-bottom: 5px; }

td {
padding: 0 5px 7px; }

div.field,
div.actions {
margin-bottom: 10px; }

#notice {
color: green; }

.field_with_errors {
padding: 2px;
background-color: red;
display: table; }

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px 7px 0;
margin-bottom: 20px;
background-color: #f0f0f0; }

#error_explanation h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px -7px 0;
background-color: #c00;
color: #fff; }

#error_explanation ul li {
font-size: 12px;
list-style: square; }

label {
display: block; }
70 changes: 70 additions & 0 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class BooksController < ApplicationController
before_action :set_book, only: %i[ show edit update destroy ]

# GET /books or /books.json
def index
@books = Book.all
end

# GET /books/1 or /books/1.json
def show
end

# GET /books/new
def new
@book = Book.new
end

# GET /books/1/edit
def edit
end

# POST /books or /books.json
def create
@book = Book.new(book_params)

respond_to do |format|
if @book.save
format.html { redirect_to book_url(@book), notice: "Book was successfully created." }
format.json { render :show, status: :created, location: @book }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /books/1 or /books/1.json
def update
respond_to do |format|
if @book.update(book_params)
format.html { redirect_to book_url(@book), notice: "Book was successfully updated." }
format.json { render :show, status: :ok, location: @book }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end

# DELETE /books/1 or /books/1.json
def destroy
@book.destroy

respond_to do |format|
format.html { redirect_to books_url, notice: "Book was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_book
@book = Book.find(params[:id])
end

# Only allow a list of trusted parameters through.
def book_params
params.require(:book).permit(:title, :description, :released)
end
end
71 changes: 71 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
class MoviesController < ApplicationController
def new
@the_movie = Movie.new

render template: "movies/new"
end

def edit
@the_movie = Movie.where(id: params.fetch(:id)).first

render template: "movies/edit.html.erb"
end

def index
matching_movies = Movie.all

@list_of_movies = matching_movies.order({ :created_at => :desc })

render({ :template => "movies/index.html.erb" })
end

def show
the_id = params.fetch("id")

matching_movies = Movie.where({ :id => the_id })

@the_movie = matching_movies.first

render({ :template => "movies/show.html.erb" })
end

def create
@the_movie = Movie.new
@the_movie.title = params.fetch("query_title")
@the_movie.description = params.fetch("query_description")
@the_movie.released = params.fetch("query_released", false)

if @the_movie.valid?
@the_movie.save
redirect_to("/movies", { :notice => "Movie created successfully." })
else

render template: "movies/new"
end
end

def update
the_id = params.fetch("id")
the_movie = Movie.where({ :id => the_id }).first

the_movie.title = params.fetch("query_title")
the_movie.description = params.fetch("query_description")
the_movie.released = params.fetch("query_released", false)

if the_movie.valid?
the_movie.save
redirect_to("/movies/#{the_movie.id}", { :notice => "Movie updated successfully."} )
else
redirect_to("/movies/#{the_movie.id}", { :alert => the_movie.errors.full_messages.to_sentence })
end
end

def destroy
the_id = params.fetch("id")
the_movie = Movie.where({ :id => the_id }).first

the_movie.destroy

redirect_to("/movies", { :notice => "Movie deleted successfully."} )
end
end
2 changes: 2 additions & 0 deletions app/helpers/books_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module BooksHelper
end
5 changes: 5 additions & 0 deletions app/models/book.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Book < ApplicationRecord
validates :title, presence: true
validates :description, presence: true

end
6 changes: 6 additions & 0 deletions app/models/movie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Movie < ApplicationRecord

validates :title, presence: true
validates :description, presence: true

end
2 changes: 2 additions & 0 deletions app/views/books/_book.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.extract! book, :id, :title, :description, :released, :created_at, :updated_at
json.url book_url(book, format: :json)
Loading