-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic admin panel to add/remove queues and instructor for a pre-existing coruse. Closes #30.
- Loading branch information
Showing
21 changed files
with
258 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the CourseInstructors controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class CourseInstructorsController < ApplicationController | ||
before_action :set_course, :authorize_current_user | ||
|
||
def new | ||
@course_instructor = CourseInstructor.new | ||
end | ||
|
||
def create | ||
@course_instructor = CourseInstructor.new | ||
@course_instructor.course = @course | ||
@course_instructor.instructor = User.find_or_create_by({ | ||
email: params[:instructor_email] | ||
}) | ||
|
||
if @course_instructor.save | ||
redirect_to @course | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def destroy | ||
@course_instructor = CourseInstructor.find(params[:id]) | ||
|
||
@course_instructor.destroy! | ||
|
||
redirect_to @course | ||
end | ||
|
||
private | ||
def set_course | ||
@course = Course.find(params[:course_id]) | ||
end | ||
|
||
def authorize_current_user | ||
unless @course.instructors.include?(current_user) | ||
redirect_to root_url | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CoursesController < ApplicationController | ||
before_action :set_course, :authorize_current_user | ||
|
||
def show | ||
end | ||
|
||
private | ||
def set_course | ||
@course = Course.find(params[:id]) | ||
end | ||
|
||
def authorize_current_user | ||
unless @course.instructors.include?(current_user) | ||
redirect_to root_url | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module CourseInstructorsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module CoursesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="six wide column"> | ||
<h1 class="ui header"> | ||
Add Instructor for <%= @course.name %> | ||
</h1> | ||
|
||
<%= form_for [@course, @course_instructor], html: {class: 'ui form'} do |f| %> | ||
<div class="field"> | ||
<label>Email</label> | ||
<input type="email" name="instructor_email" placeholder="instructor@umich.edu"> | ||
</div> | ||
|
||
<%= f.submit 'Add', class: 'ui button' %> | ||
<% end %> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= form_for [@course, @course_queue], html: {class: 'ui form'} do |f| %> | ||
<div class="field"> | ||
<%= f.label :name %> | ||
<%= f.text_field :name %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.label :location %> | ||
<%= f.text_field :location %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.label :description %> | ||
<%= f.text_field :description %> | ||
</div> | ||
|
||
<%= f.submit 'Submit', class: 'ui button' %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="six wide column"> | ||
<h1 class="ui header"> | ||
Edit Queue for <%= @course.name %> | ||
</h1> | ||
|
||
<%= render 'form' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="six wide column"> | ||
<h1 class="ui header"> | ||
Add Queue for <%= @course.name %> | ||
</h1> | ||
|
||
<%= render 'form' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<table class="ui table"> | ||
<thead> | ||
<tr><th style="width: 50%">Name</th> | ||
<th style="width: 50%">Email</th> | ||
<th> | ||
<a href="<%= new_course_course_instructor_url(@course) %>" class="ui primary fluid labeled icon button"> | ||
<i class="plus icon"></i> | ||
Add | ||
</a> | ||
</th> | ||
</tr></thead> | ||
<tbody> | ||
<% @course.course_instructors.each do |course_instructor| %> | ||
<tr> | ||
<td><%= course_instructor.instructor.name %></td> | ||
<td><%= course_instructor.instructor.email %></td> | ||
<td> | ||
<div class="ui fluid basic buttons"> | ||
<%= link_to 'Delete', course_course_instructor_url(@course, course_instructor), method: :delete, data: { confirm: 'Are you sure?' }, class: 'ui button' %> | ||
</div> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<table class="ui table"> | ||
<thead> | ||
<tr><th style="width: 50%">Course Queue Name</th> | ||
<th style="width: 50%">Location</th> | ||
<th> | ||
<a href="<%= new_course_course_queue_url(@course) %>" class="ui primary labeled icon fluid button"> | ||
<i class="plus icon"></i> | ||
New | ||
</a> | ||
</th> | ||
</tr></thead> | ||
<tbody> | ||
<% @course.course_queues.each do |queue| %> | ||
<tr> | ||
<td><%= queue.name %></td> | ||
<td><%= queue.location %></td> | ||
<td> | ||
<div class="ui fluid basic buttons"> | ||
<%= link_to 'Edit', edit_course_course_queue_url(@course, queue), class: 'ui button' %> | ||
<%= link_to 'Delete', course_course_queue_url(@course, queue), method: :delete, data: { confirm: 'Are you sure?' }, class: 'ui button' %> | ||
</div> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="ten wide column"> | ||
<h1 class="ui header"> | ||
<%= @course.name %> | ||
Course Administration | ||
</h1> | ||
|
||
<h2>Course Queues</h2> | ||
<%= render 'queues' %> | ||
|
||
<h2>Course Instructors</h2> | ||
<%= render 'instructors' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class CourseInstructorsControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class CoursesControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |