merge stormand
|
@ -2,15 +2,12 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="d7b1c0f9-5303-4042-90a5-05cecbda0e94" name="Default" comment="">
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/app/assets/images/fallback/default.jpg" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/app/helpers/image_helper.rb" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/test/controllers/image_controller_test.rb" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/test/fixtures/images.yml" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/test/models/image_test.rb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/uploaders/avatar_uploader.rb" afterPath="$PROJECT_DIR$/app/uploaders/avatar_uploader.rb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/courses/detail.erb" afterPath="$PROJECT_DIR$/app/views/courses/detail.erb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/homes/index.html.erb" afterPath="$PROJECT_DIR$/app/views/homes/index.html.erb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/controllers/courses_controller.rb" afterPath="$PROJECT_DIR$/app/controllers/courses_controller.rb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/controllers/homes_controller.rb" afterPath="$PROJECT_DIR$/app/controllers/homes_controller.rb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/courses/index.html.erb" afterPath="$PROJECT_DIR$/app/views/courses/index.html.erb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/courses/list.html.erb" afterPath="$PROJECT_DIR$/app/views/courses/list.html.erb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/views/shared/_sidenav.html.erb" afterPath="$PROJECT_DIR$/app/views/shared/_sidenav.html.erb" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/config/routes.rb" afterPath="$PROJECT_DIR$/config/routes.rb" />
|
||||
</list>
|
||||
<ignored path="vim.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
|
@ -39,21 +36,11 @@
|
|||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="_form.html.erb" pinned="false" current-in-tab="false">
|
||||
<file leaf-file-name="_form.html.erb" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/app/views/courses/_form.html.erb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1944">
|
||||
<caret line="108" column="50" selection-start-line="108" selection-start-column="50" selection-end-line="108" selection-end-column="50" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="avatar_uploader.rb" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/app/uploaders/avatar_uploader.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="276">
|
||||
<caret line="24" column="0" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
|
||||
<state relative-caret-position="897">
|
||||
<caret line="125" column="0" selection-start-line="125" selection-start-column="0" selection-end-line="125" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -63,7 +50,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/Gemfile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="774">
|
||||
<caret line="43" column="17" selection-start-line="43" selection-start-column="17" selection-end-line="43" selection-end-column="17" />
|
||||
<caret line="46" column="0" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -73,7 +60,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/db/migrate/20160907152104_create_courses.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="72">
|
||||
<caret line="4" column="20" selection-start-line="4" selection-start-column="16" selection-end-line="4" selection-end-column="20" />
|
||||
<caret line="5" column="20" selection-start-line="4" selection-start-column="16" selection-end-line="4" selection-end-column="20" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -110,7 +97,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/app/views/courses/detail.erb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="324">
|
||||
<caret line="18" column="72" selection-start-line="18" selection-start-column="9" selection-end-line="18" selection-end-column="72" />
|
||||
<caret line="22" column="8" selection-start-line="21" selection-start-column="9" selection-end-line="21" selection-end-column="10" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -197,12 +184,12 @@
|
|||
<option value="$PROJECT_DIR$/app/controllers/image_controller.rb" />
|
||||
<option value="$PROJECT_DIR$/app/controllers/homes_controller.rb" />
|
||||
<option value="$PROJECT_DIR$/db/migrate/20161108164630_add_avatar_to_courses.rb" />
|
||||
<option value="$PROJECT_DIR$/app/views/courses/_form.html.erb" />
|
||||
<option value="$PROJECT_DIR$/app/models/course.rb" />
|
||||
<option value="$PROJECT_DIR$/app/controllers/courses_controller.rb" />
|
||||
<option value="$PROJECT_DIR$/app/views/courses/detail.erb" />
|
||||
<option value="$PROJECT_DIR$/app/views/homes/index.html.erb" />
|
||||
<option value="$PROJECT_DIR$/app/uploaders/avatar_uploader.rb" />
|
||||
<option value="$PROJECT_DIR$/app/views/courses/_form.html.erb" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -251,6 +238,8 @@
|
|||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scratches" />
|
||||
<pane id="RailsProjectView" />
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
|
@ -331,24 +320,6 @@
|
|||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="vim" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="CourseSelect" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="app" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="uploaders" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="vim" />
|
||||
|
@ -365,8 +336,6 @@
|
|||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="RailsProjectView" />
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
|
@ -604,6 +573,7 @@
|
|||
<workItem from="1478673639496" duration="1071000" />
|
||||
<workItem from="1478674726204" duration="2626000" />
|
||||
<workItem from="1478686736886" duration="167000" />
|
||||
<workItem from="1479035444853" duration="51000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="增加课程介绍,首页轮播的外观搭建">
|
||||
<created>1478067100340</created>
|
||||
|
@ -623,7 +593,7 @@
|
|||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="28734000" />
|
||||
<option name="totallyTimeSpent" value="28785000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
|
@ -638,7 +608,7 @@
|
|||
<frame x="65" y="24" width="1855" height="1056" extended-state="6" />
|
||||
<editor active="false" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.436845" sideWeight="0.4858757" order="1" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.44180915" sideWeight="0.4858757" order="1" side_tool="false" content_ui="combo" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3287483" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39889959" sideWeight="0.51373184" order="0" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
|
@ -866,13 +836,7 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/db/migrate/20161102052958_add_course_introduction_to_courses.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/db/migrate/20161102052958_add_course_introduction_to_courses.rb" />
|
||||
<entry file="file://$PROJECT_DIR$/app/models/course.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="36">
|
||||
|
@ -880,13 +844,7 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/db/migrate/20161108164630_add_avatar_to_courses.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/db/migrate/20161108164630_add_avatar_to_courses.rb" />
|
||||
<entry file="file://$PROJECT_DIR$/app/controllers/courses_controller.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="324">
|
||||
|
@ -914,8 +872,8 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/views/courses/_form.html.erb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1944">
|
||||
<caret line="108" column="50" selection-start-line="108" selection-start-column="50" selection-end-line="108" selection-end-column="50" />
|
||||
<state relative-caret-position="897">
|
||||
<caret line="125" column="0" selection-start-line="125" selection-start-column="0" selection-end-line="125" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -923,7 +881,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/db/migrate/20160907152104_create_courses.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="72">
|
||||
<caret line="4" column="20" selection-start-line="4" selection-start-column="16" selection-end-line="4" selection-end-column="20" />
|
||||
<caret line="5" column="20" selection-start-line="4" selection-start-column="16" selection-end-line="4" selection-end-column="20" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -939,7 +897,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/Gemfile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="774">
|
||||
<caret line="43" column="17" selection-start-line="43" selection-start-column="17" selection-end-line="43" selection-end-column="17" />
|
||||
<caret line="46" column="0" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -955,7 +913,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/app/views/courses/detail.erb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="324">
|
||||
<caret line="18" column="72" selection-start-line="18" selection-start-column="9" selection-end-line="18" selection-end-column="72" />
|
||||
<caret line="22" column="8" selection-start-line="21" selection-start-column="9" selection-end-line="21" selection-end-column="10" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -968,13 +926,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/uploaders/avatar_uploader.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="276">
|
||||
<caret line="24" column="0" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/uploaders/avatar_uploader.rb" />
|
||||
</component>
|
||||
</project>
|
|
@ -2,7 +2,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
|
||||
before_action :student_logged_in, only: [:select, :quit, :list]
|
||||
before_action :teacher_logged_in, only: [:new, :create, :edit, :destroy, :update]
|
||||
before_action :teacher_logged_in, only: [:new, :create, :edit, :destroy, :update, :open, :close]
|
||||
before_action :logged_in, only: [:index]
|
||||
|
||||
|
||||
|
@ -45,11 +45,24 @@ class CoursesController < ApplicationController
|
|||
redirect_to courses_path, flash: flash
|
||||
end
|
||||
|
||||
def open
|
||||
@course=Course.find_by_id(params[:id])
|
||||
@course.update_attributes(open:true)
|
||||
redirect_to courses_path, flash: {:success => "已经成功开启该课程:#{ @course.name}"}
|
||||
end
|
||||
|
||||
def close
|
||||
@course=Course.find_by_id(params[:id])
|
||||
@course.update_attributes(open:false)
|
||||
redirect_to courses_path, flash: {:success => "已经成功关闭该课程:#{ @course.name}"}
|
||||
end
|
||||
|
||||
#-------------------------for students----------------------
|
||||
|
||||
def list
|
||||
@course=Course.all
|
||||
@course=@course-current_user.courses
|
||||
@course_open=Course.where("open = ?", true)
|
||||
@course_open=@course_open-current_user.courses
|
||||
end
|
||||
|
||||
def select
|
||||
|
|
|
@ -3,6 +3,7 @@ class HomesController < ApplicationController
|
|||
def index
|
||||
@course=Course.all
|
||||
@course1=Course.find_by_id(1)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -36,6 +36,13 @@
|
|||
|
||||
<% if teacher_logged_in? %>
|
||||
<td><%= link_to "编辑", edit_course_url(course), class: 'btn btn-xs btn-info' %></td>
|
||||
<% if course.open %>
|
||||
<td><%= link_to "关闭", close_course_url(course), class: 'btn btn-xs btn-info' %></td>
|
||||
<% else %>
|
||||
<td><%= link_to "打开", open_course_url(course), class: 'btn btn-xs btn-info' %></td>
|
||||
<% end %>
|
||||
|
||||
|
||||
<td><%= link_to "删除", course_path(course), :method => "delete", class: 'btn btn-xs btn-danger', :data => {confirm: '确定要删除此课程?'} %></td>
|
||||
<% elsif student_logged_in? %>
|
||||
<td><%= link_to "删除", quit_course_path(course), class: 'btn-sm btn-danger' %></td>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
|
||||
<% @course.each do |course| %>
|
||||
<% @course_open.each do |course| %>
|
||||
<tr>
|
||||
|
||||
<td><%= course.course_code %></td>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<li class="list-group-item">
|
||||
<%= link_to list_courses_path do %>
|
||||
<span class="glyphicon glyphicon-chevron-right"></span> 选修课程
|
||||
<span class="label label-info pull-right"><%= (Course.all-current_user.courses).length %></span>
|
||||
<span class="label label-info pull-right"><%= (Course.where("open = ?", true)-current_user.courses.where("open = ?", true)).length %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
|
|
|
@ -22,6 +22,8 @@ Rails.application.routes.draw do
|
|||
get :select
|
||||
get :quit
|
||||
get :detail
|
||||
get :open
|
||||
get :close
|
||||
end
|
||||
collection do
|
||||
get :list
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddOpenToCourses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :courses, :open, :boolean, default: false
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 213 KiB |
After Width: | Height: | Size: 124 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 238 KiB |
After Width: | Height: | Size: 238 KiB |
After Width: | Height: | Size: 238 KiB |
After Width: | Height: | Size: 238 KiB |