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
43791089
Commit
43791089
authored
Feb 10, 2019
by
Zac Wood
Browse files
Added Semesters endpoint to API
parent
a3f53830
Pipeline
#3849
failed with stage
in 2 minutes and 45 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
schedules/app/controllers/api/semesters_controller.rb
0 → 100644
View file @
43791089
class
API::SemestersController
<
ApplicationController
def
index
result
=
Semester
.
all
.
map
do
|
s
|
{
id:
s
.
id
,
season:
s
.
season
,
year:
s
.
year
}
end
render
json:
result
end
end
schedules/app/helpers/api/semesters_helper.rb
0 → 100644
View file @
43791089
module
API::SemestersHelper
end
schedules/config/routes.rb
View file @
43791089
...
@@ -12,6 +12,7 @@ Rails.application.routes.draw do
...
@@ -12,6 +12,7 @@ Rails.application.routes.draw do
get
'schedule/view'
,
to:
'schedules#view'
,
as:
'view_schedule'
get
'schedule/view'
,
to:
'schedules#view'
,
as:
'view_schedule'
scope
:api
,
module:
'api'
do
# Register /api routes
scope
:api
,
module:
'api'
do
# Register /api routes
resources
:semesters
,
only:
[
:index
],
as:
'api_semesters'
resources
:courses
,
only:
[
:index
,
:show
],
as:
'api_courses'
resources
:courses
,
only:
[
:index
,
:show
],
as:
'api_courses'
resources
:course_sections
,
only:
[
:index
],
as:
'api_course_sections'
resources
:course_sections
,
only:
[
:index
],
as:
'api_course_sections'
resources
:instructors
,
only:
[
:index
,
:show
],
as:
'api_instructors'
resources
:instructors
,
only:
[
:index
,
:show
],
as:
'api_instructors'
...
...
schedules/db/seeds.rb
View file @
43791089
...
@@ -116,7 +116,7 @@ def main
...
@@ -116,7 +116,7 @@ def main
[
parser
.
parse_semesters
.
first
]
[
parser
.
parse_semesters
.
first
]
else
else
# expand to include however many semesters you want
# expand to include however many semesters you want
parser
.
parse_semesters
[
0
..
2
]
parser
.
parse_semesters
[
0
..
6
]
end
end
...
...
schedules/test/controllers/api/semesters_controller_test.rb
0 → 100644
View file @
43791089
require
'test_helper'
class
API::SemestersControllerTest
<
ActionDispatch
::
IntegrationTest
# test "the truth" do
# assert true
# 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