sort fixed and also name and url changed

This commit is contained in:
Harry Bomrah 2017-08-14 20:12:43 +08:00
parent 59e2fef80a
commit 3171868237
15 changed files with 35 additions and 33 deletions

View File

@ -1,6 +1,5 @@
require 'zip/zip'
class Admin::HpsLearningsController < OrbitAdminController
class Admin::OnlineCoursesController < OrbitAdminController
def index
@table_fields = ["hps_learning.course_pic", "hps_learning.title", :category, "hps_learning.runtime"]
@classes = HpsClass.all.desc(:created_at).page(params[:page]).per(10)
@ -22,19 +21,19 @@ class Admin::HpsLearningsController < OrbitAdminController
def create
hpsclass = HpsClass.new(hps_class_params)
hpsclass.save
redirect_to admin_hps_learnings_path
redirect_to admin_online_courses_path
end
def update
hpsclass = HpsClass.find(params[:id])
hpsclass.update_attributes(hps_class_params)
redirect_to admin_hps_learnings_path
redirect_to admin_online_courses_path
end
def destroy
hpsclass = HpsClass.find(params[:id])
hpsclass.destroy
redirect_to admin_hps_learnings_path
redirect_to admin_online_courses_path
end
def add_lecture
@ -49,7 +48,7 @@ class Admin::HpsLearningsController < OrbitAdminController
hpslecture = HpsLecture.find(params[:id])
clas = hpslecture.hps_class_id
hpslecture.destroy
redirect_to admin_hps_learning_path(clas)
redirect_to admin_online_course_path(clas)
end
def create_lecture
@ -59,7 +58,7 @@ class Admin::HpsLearningsController < OrbitAdminController
hpsfile = HpsLectureFile.find(params[:presentation_temp_id]) rescue nil
hpslecture.hps_lecture_file = hpsfile if !hpsfile.nil?
hpslecture.save
redirect_to admin_hps_learning_path(hpsclass.id)
redirect_to admin_online_course_path(hpsclass.id)
end
def update_lecture
@ -68,7 +67,7 @@ class Admin::HpsLearningsController < OrbitAdminController
hpsfile = HpsLectureFile.find(params[:presentation_temp_id]) rescue nil
hpslecture.hps_lecture_file = hpsfile if !hpsfile.nil?
hpslecture.save
redirect_to admin_hps_learning_path(hpslecture.hps_class_id)
redirect_to admin_online_course_path(hpslecture.hps_class_id)
end
def upload_temp_file
@ -132,5 +131,4 @@ class Admin::HpsLearningsController < OrbitAdminController
def hps_lecture_params
params.require(:hps_lecture).permit!
end
end

View File

@ -54,7 +54,7 @@ class HpsLearningsController < ApplicationController
def widget
tags = OrbitHelper.widget_tags
classes = HpsClass.filter_by_widget_categories.filter_by_tags(tags).collect do |hpsclass|
classes = HpsClass.filter_by_widget_categories.filter_by_tags(tags).desc(:created_at).collect do |hpsclass|
thumb = hpsclass.course_pic.thumb.url.nil? ? "http://www.placehold.it/150x150/EFEFEF/AAAAAA" : hpsclass.course_pic.thumb.url
{
"title" => hpsclass.title,

View File

@ -70,7 +70,7 @@
$("#presentation-file").fileupload({
autoUpload : false,
url : "/admin/hps_learnings/upload_temp_file",
url : "/admin/online_courses/upload_temp_file",
maxChunkSize : 8 * 1024 * 1024,
acceptFileTypes: /(\.|\/)(zip)$/i,
add : function(e, data){
@ -79,7 +79,7 @@
var uploadData = data;
uploadBtn.one("click",function(){
$.ajax({
url : "/admin/hps_learnings/get_temp_dir_name",
url : "/admin/online_courses/get_temp_dir_name",
dataType : "json",
type : "get",
data : {"filename" : uploadData.files[0].name}
@ -95,7 +95,7 @@
abortUploadBtn.addClass("hide");
uploadBtn.removeClass("hide");
$.ajax({
url : "/admin/hps_learnings/clear_temp_dir",
url : "/admin/online_courses/clear_temp_dir",
dataType : "json",
type : "post",
data : {presentation_id : presentation_path}
@ -140,7 +140,7 @@
var extract_zip = function(id, path, filename){
$.ajax({
url : "/admin/hps_learnings/extract_zip",
url : "/admin/online_courses/extract_zip",
dataType : "json",
type : "post",
data : {"presentation_id" : id, "path" : path}

View File

@ -15,13 +15,13 @@
<td><img src="http://www.placehold.it/150x150/EFEFEF/AAAAAA" width="150px"></td>
<% end %>
<td>
<a href="<%= admin_hps_learning_path(clas.id, :page => params[:page]) %>"> <%= clas.title %> </a>
<a href="<%= admin_online_course_path(clas.id, :page => params[:page]) %>"> <%= clas.title %> </a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(clas) %>
<li><a href="<%= admin_hps_learning_path(clas.id, :page => params[:page]) %>"><%= t("hps_learning.lectures") %></a></li>
<li><a href="<%= edit_admin_hps_learning_path(clas.id, :page => params[:page]) %>"><%= t(:edit) %></a></li>
<li><a href="<%= admin_hps_learning_path(clas.id,:page => params[:page]) %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
<li><a href="<%= admin_online_course_path(clas.id, :page => params[:page]) %>"><%= t("hps_learning.lectures") %></a></li>
<li><a href="<%= edit_admin_online_course_path(clas.id, :page => params[:page]) %>"><%= t(:edit) %></a></li>
<li><a href="<%= admin_online_course_path(clas.id,:page => params[:page]) %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>

View File

@ -19,8 +19,8 @@
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(@hpsclass) %>
<li><a href="<%= edit_lecture_admin_hps_learning_path(lecture.id, :page => params[:page]) %>"><%= t(:edit) %></a></li>
<li><a href="<%= delete_lecture_admin_hps_learning_path(lecture.id,:page => params[:page]) %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
<li><a href="<%= edit_lecture_admin_online_course_path(lecture.id, :page => params[:page]) %>"><%= t(:edit) %></a></li>
<li><a href="<%= delete_lecture_admin_online_course_path(lecture.id,:page => params[:page]) %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
@ -45,8 +45,8 @@
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, class: "pull-right" do
link_to(t("hps_learning.add_lecture"), add_lecture_admin_hps_learning_path(@hpsclass.id), :class => "btn btn-primary") + " " +
link_to(t("back"), admin_hps_learnings_path, :class => "btn")
link_to(t("hps_learning.add_lecture"), add_lecture_admin_online_course_path(@hpsclass.id), :class => "btn btn-primary") + " " +
link_to(t("back"), admin_online_courses_path, :class => "btn")
end
end
%>

View File

@ -1,6 +1,8 @@
en:
module_name:
hps_learning: Online Courses
hps_learning:
hps_learning: E Learning
hps_learning: Online Courses
classes: Classes
new_class: Create New Class
course_pic: Course Picture

View File

@ -1,6 +1,8 @@
zh_tw:
module_name:
hps_learning: 開課系統
hps_learning:
hps_laerning: E Learning
hps_learning: 開課系統
classes: Classes
new_class: Create New Class
course_pic: Course Pic

View File

@ -4,7 +4,7 @@ Rails.application.routes.draw do
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
resources :hps_learnings do
resources :online_courses do
collection do
get "get_temp_dir_name"
post "upload_temp_file"

View File

@ -15,31 +15,31 @@ module HpsLearning
side_bar do
head_label_i18n 'hps_learning.hps_learning', icon_class: "icons-screen"
available_for "users"
active_for_controllers (['admin/hps_learnings'])
head_link_path "admin_hps_learnings_path"
active_for_controllers (['admin/online_courses'])
head_link_path "admin_online_courses_path"
context_link 'hps_learning.classes',
:link_path=>"admin_hps_learnings_path" ,
:link_path=>"admin_online_courses_path" ,
:priority=>1,
:active_for_action=>{'admin/hps_learnings'=>'index'},
:active_for_action=>{'admin/online_courses'=>'index'},
:available_for => 'users'
context_link 'hps_learning.new_class',
:link_path=>"new_admin_hps_learning_path" ,
:link_path=>"new_admin_online_course_path" ,
:priority=>2,
:active_for_action=>{'admin/hps_learnings'=>'new'},
:active_for_action=>{'admin/online_courses'=>'new'},
:available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'hps_learning').id}",
:priority=>3,
:active_for_action=>{'admin/hps_learnings'=>'categories'},
:active_for_action=>{'admin/online_courses'=>'categories'},
:active_for_category => 'HpsLearning',
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'hps_learning').id}",
:priority=>4,
:active_for_action=>{'admin/hps_learnings'=>'tags'},
:active_for_action=>{'admin/online_courses'=>'tags'},
:active_for_tag => 'HpsLearning',
:available_for => 'managers'
end