Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
schedules
Commits
c2669df4
Commit
c2669df4
authored
Apr 07, 2018
by
Zac Wood
Browse files
Added controllers + docs
parent
212e258a
Changes
17
Hide whitespace changes
Inline
Side-by-side
schedules/Gemfile.lock
View file @
c2669df4
...
...
@@ -121,6 +121,9 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rubyXL (3.3.29)
nokogiri (>= 1.4.4)
rubyzip (>= 1.1.6)
ruby_dep (1.5.0)
rubyzip (1.2.1)
sass (3.5.6)
...
...
@@ -182,6 +185,7 @@ DEPENDENCIES
listen (>= 3.0.5, < 3.2)
puma (~> 3.7)
rails (~> 5.1.6)
rubyXL
sass-rails (~> 5.0)
selenium-webdriver
spring
...
...
schedules/app/assets/javascripts/courses.coffee
0 → 100644
View file @
c2669df4
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
schedules/app/assets/javascripts/sections.coffee
0 → 100644
View file @
c2669df4
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
schedules/app/assets/stylesheets/courses.scss
0 → 100644
View file @
c2669df4
// Place all the styles related to the Courses controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
schedules/app/assets/stylesheets/sections.scss
0 → 100644
View file @
c2669df4
// Place all the styles related to the Sections controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
schedules/app/controllers/courses_controller.rb
0 → 100644
View file @
c2669df4
# Contains all actions having to do with Courses.
class
CoursesController
<
ApplicationController
# Renders JSON of all courses.
def
index
@courses
=
Course
.
all
render
json:
@courses
end
end
schedules/app/controllers/sections_controller.rb
0 → 100644
View file @
c2669df4
# Contains all actions having to do with Sections.
# This is a nested controller -- see +config/routes.rb+ for details
class
SectionsController
<
ApplicationController
# Render JSON of all Sections belonging to a given Course.
def
index
@course
=
Course
.
find
(
params
[
:course_id
])
@sections
=
@course
.
sections
render
json:
@sections
end
end
schedules/app/helpers/courses_helper.rb
0 → 100644
View file @
c2669df4
module
CoursesHelper
end
schedules/app/helpers/sections_helper.rb
0 → 100644
View file @
c2669df4
module
SectionsHelper
end
schedules/app/models/course.rb
View file @
c2669df4
# Contains logic regarding the +Course+ model.
#
# TODO: Add more docs
class
Course
<
ApplicationRecord
# Each course belongs to a +Semester+
belongs_to
:semester
# Ensure all necessary fields are present.
validates
:course_number
,
presence:
true
validates
:subject
,
presence:
true
validates
:semester_id
,
presence:
true
# Returns all +Section+ objects that belong to this course.
def
sections
Section
.
where
:course_id
=>
id
end
end
schedules/app/models/section.rb
View file @
c2669df4
# Contains logic belonging to the +Section+ model.
#
# TODO: Add more docs
class
Section
<
ApplicationRecord
# Each +Section+ belongs to a +Course+.
belongs_to
:course
# Ensure all necessary fields are present.
validates
:name
,
presence:
true
validates
:crn
,
presence:
true
# Unsure if necessary
# validates :section_type, presence: true
validates
:title
,
presence:
true
validates
:start_date
,
presence:
true
validates
:end_date
,
presence:
true
validates
:days
,
presence:
true
validates
:start_time
,
presence:
true
validates
:end_time
,
presence:
true
end
schedules/app/models/semester.rb
View file @
c2669df4
# Contains logic having to do with the +Semester+ model.
#
# A +Semester+ is a simple model that consists of a +year+ and a +season+, e.g. "Fall 2018".
class
Semester
<
ApplicationRecord
# Ensure necessary fields are present.
validates
:year
,
presence:
true
validates
:season
,
presence:
true
end
schedules/app/views/courses/index.html.erb
0 → 100644
View file @
c2669df4
<h1>
Courses#index
</h1>
<p>
Find me in app/views/courses/index.html.erb
</p>
schedules/app/views/sections/index.html.erb
0 → 100644
View file @
c2669df4
<h1>
Sections#index
</h1>
<p>
Find me in app/views/sections/index.html.erb
</p>
schedules/config/routes.rb
View file @
c2669df4
Rails
.
application
.
routes
.
draw
do
resources
:courses
,
only:
[
:index
]
do
resources
:sections
,
only:
[
:index
]
end
root
'courses#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
schedules/test/controllers/courses_controller_test.rb
0 → 100644
View file @
c2669df4
require
'test_helper'
class
CoursesControllerTest
<
ActionDispatch
::
IntegrationTest
test
"should get index"
do
get
courses_index_url
assert_response
:success
end
end
schedules/test/controllers/sections_controller_test.rb
0 → 100644
View file @
c2669df4
require
'test_helper'
class
SectionsControllerTest
<
ActionDispatch
::
IntegrationTest
test
"should get index"
do
get
sections_index_url
assert_response
:success
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment