Skip to content

Commit

Permalink
CSS for courses new and edit page, user model testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
rgkavodkar committed Feb 27, 2016
1 parent 19642ae commit c6dc030
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 114 deletions.
2 changes: 1 addition & 1 deletion app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create
end
end
else
edirect_to unauthorized_url
redirect_to unauthorized_url
end
end

Expand Down
53 changes: 0 additions & 53 deletions app/views/courses/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,53 +0,0 @@
<%= form_for(@course) do |f| %>
<% if @course.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@course.errors.count, "error") %> prohibited this course from being saved:</h2>

<ul>
<% @course.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :title %><br>
<%= f.text_area :title %>
</div>
<div class="field">
<%= f.label :description %><br>
<%= f.text_area :description %>
</div>
<div class="field">
<%= f.label :start_date %><br>
<%= f.date_select :start_date %>
</div>
<div class="field">
<%= f.label :end_date %><br>
<%= f.date_select :end_date %>
</div>
<div class="field">

<%= f.label :user_id %><br>
<% users_array = User.all.map{|user| [user.name,user.id] if user.utype =="instructor"} %>
<%= f.select(:user_id) do %>
<% users_array.each do |u| -%>
<% if u!=nil %>
<%=content_tag(:option, u.first, value: u.last) %>
<% end %>
<% end %>
<% end %>


<!-- <%= options_from_collection_for_select(User.all, :id, :name) %>
<%= f.text_field :user_id %> -->
</div>
<div class="field">
<%= f.label :status %><br>
<%= f.text_field :status %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
62 changes: 58 additions & 4 deletions app/views/courses/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,60 @@
<h1>Editing Course</h1>
<% provide(:title, 'Edit ' + @course.title + ' details') %>

<%= render 'form' %>
<div class="container" style="height:80vh; overflow:auto">
<div class = "center">
<h1>Edit course</h1>
</div>

<%= link_to 'Show', @course %> |
<%= link_to 'Back', courses_path %>

<div class="row">
<div class="col-md-6 col-md-offset-3">
<% if @course.errors.any? %>
<div id="error_explanation">
<div class="alert alert-danger">
The form contains <%= pluralize(@course.errors.count, "error") %>.
<ul>
<% @course.errors.full_messages.each do |error_msg| %>
<li><%= error_msg %></li>
<% end %>
</ul>
</div>
</div>
<% end %>
<%= form_for(@course) do |f| %>
<%= f.label :title, "Title" %>
<%= f.text_field :title, class:'form-control' %>
<%= f.label :description, "Description" %>
<%= f.text_area :description, class:'form-control' %>
<%= f.label :start_date, "Start date" %>
<%= f.date_select :start_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %>
<%= f.label :end_date, "End date" %>
<%= f.date_select :end_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %>
<%= f.label :user_id, "Instructor" %><br>
<% users_array = User.all.map{|user| [user.name, user.id] if user.utype =="instructor"} %>
<%= f.select(:user_id, {}, {}, {class:'form-control'}) do %>
<% users_array.each do |user| %>
<% if user != nil %>
<%= content_tag(:option, user.first, value: user.last) %>
<% end %>
<% end %>
<% end %>
<%= f.select(:status, {}, {}, {class:'form-control'}) do %>
<%=content_tag(:option, "Inactive", value: "Inactive") %>
<%=content_tag(:option, "Active", value: "Active") %>
<% end %>
<%= f.submit "Edit course", class: "btn btn-primary" %>
<% end %>
</div>
</div>

</div>
96 changes: 49 additions & 47 deletions app/views/courses/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
<% provide(:title, 'Add a course') %>
<div class = "center">
<h1>Add a course</h1>
</div>


<div class="row">
<div class="col-md-6 col-md-offset-3">
<% if @course.errors.any? %>
<div id="error_explanation">
<div class="alert alert-danger">
The form contains <%= pluralize(@course.errors.count, "error") %>.
<ul>
<% @course.errors.full_messages.each do |error_msg| %>
<li><%= error_msg %></li>
<% end %>
</ul>
<div class="container" style="height:80vh; overflow:auto">
<div class = "center">
<h1>Add a course</h1>
</div>


<div class="row">
<div class="col-md-6 col-md-offset-3">
<% if @course.errors.any? %>
<div id="error_explanation">
<div class="alert alert-danger">
The form contains <%= pluralize(@course.errors.count, "error") %>.
<ul>
<% @course.errors.full_messages.each do |error_msg| %>
<li><%= error_msg %></li>
<% end %>
</ul>
</div>
</div>
</div>
<% end %>
<% end %>
<%= form_for(@course) do |f| %>
<%= form_for(@course) do |f| %>
<%= f.label :title, "Title" %>
<%= f.text_field :title, class:'form-control' %>
<%= f.label :title, "Title" %>
<%= f.text_field :title, class:'form-control' %>
<%= f.label :description, "Description" %>
<%= f.text_area :description, class:'form-control' %>
<%= f.label :description, "Description" %>
<%= f.text_area :description, class:'form-control' %>
<%= f.label :start_date, "Start date" %>
<%= f.date_select :start_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %>
<%= f.label :start_date, "Start date" %>
<%= f.date_select :start_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %>
<%= f.label :end_date, "End date" %>
<%= f.date_select :end_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %>
<%= f.label :end_date, "End date" %>
<%= f.date_select :end_date, { :order => [:year, :month, :day], :prompt => { year: 'Select year', day:'Select day', month:'Select month' }}, {class: "form-control"} %>
<%= f.label :user_id, "Instructor" %><br>
<% users_array = User.all.map{|user| [user.name, user.id] if user.utype =="instructor"} %>
<%= f.select(:user_id, {}, {}, {class:'form-control'}) do %>
<% users_array.each do |user| %>
<% if user != nil %>
<%= content_tag(:option, user.first, value: user.last) %>
<%= f.label :user_id, "Instructor" %><br>
<% users_array = User.all.map{|user| [user.name, user.id] if user.utype =="instructor"} %>
<%= f.select(:user_id, {}, {}, {class:'form-control'}) do %>
<% users_array.each do |user| %>
<% if user != nil %>
<%= content_tag(:option, user.first, value: user.last) %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= f.label :status, "Status" %><br>

<%= f.select(:status, {}, {}, {class:'form-control'}) do %>
<%=content_tag(:option, "Inactive", value: "Inactive") %>
<%=content_tag(:option, "Active", value: "Active") %>
<% end %>
<%= f.submit "Create course", class: "btn btn-primary" %>
<% end %>

</div>
</div>
<%= f.label :status, "Status" %><br>

<%= f.select(:status, {}, {}, {class:'form-control'}) do %>
<%=content_tag(:option, "Inactive", value: "Inactive") %>
<%=content_tag(:option, "Active", value: "Active") %>
<% end %>
<%= f.submit "Create course", class: "btn btn-primary" %>
<% end %>

</div>
</div>
</div>
8 changes: 4 additions & 4 deletions app/views/courses/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<% provide(:title, @course.title + ' details') %>

<div class="container" style="height:80vh; overflow:auto">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="container" style="height:80vh; overflow:auto">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-body">
<h3 style="display:inline-block;"> <%= @course.title %></h3>
Expand Down Expand Up @@ -75,8 +75,8 @@
</div>
<br/>
<% end %>
</div>
</div>
</div>

</div>

Expand Down
4 changes: 2 additions & 2 deletions app/views/messages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<% end %>
</div>
<script>
var objDiv = document.getElementById("messages");
objDiv.scrollTop = objDiv.scrollHeight;
var msgDiv = document.getElementById("messages");
msgDiv.scrollTop = msgDiv.scrollHeight;
</script>
</div>
</div>
Expand Down
Loading

0 comments on commit c6dc030

Please sign in to comment.