forked from saurabh/personal-honor
desktop honor
This commit is contained in:
parent
877b622c13
commit
446bf1ac8a
|
@ -1,5 +1,6 @@
|
|||
class Admin::HonorsController < OrbitMemberController
|
||||
layout "member_plugin"
|
||||
include Admin::PersonalHonorsHelper
|
||||
|
||||
before_action :set_honor, only: [:show, :edit , :update, :destroy]
|
||||
before_action :set_plugin
|
||||
|
@ -15,28 +16,49 @@ class Admin::HonorsController < OrbitMemberController
|
|||
def new
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@honor = Honor.new
|
||||
|
||||
if params[:desktop]
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@member = MemberProfile.find(honor_params['member_profile_id']) rescue nil
|
||||
@honor = Honor.new(honor_params)
|
||||
@honor.save
|
||||
redirect_to params['referer_url']
|
||||
if params[:desktop] == "true"
|
||||
render json: {"data" => get_paper_list}.to_json
|
||||
else
|
||||
redirect_to params['referer_url']
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@member = @honor.member_profile rescue nil
|
||||
if params[:desktop]
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@member = @honor.member_profile rescue nil
|
||||
@honor.update_attributes(honor_params)
|
||||
@honor.save
|
||||
redirect_to params['referer_url']
|
||||
if params[:desktop] == "true"
|
||||
render json: {"data" => get_paper_list}.to_json
|
||||
else
|
||||
redirect_to params['referer_url']
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@honor.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_honor_url) }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
format.json {render json: {"success" => true}}
|
||||
end
|
||||
end
|
||||
|
||||
def toggle_hide
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
class Desktop::PersonalHonorsController < DesktopAdminController
|
||||
include Admin::PersonalHonorsHelper
|
||||
|
||||
def menu
|
||||
user = OrbitHelper.current_user
|
||||
[
|
||||
{
|
||||
"title" => "List",
|
||||
"layout" => "list"
|
||||
},
|
||||
{
|
||||
"title" => "Add/Edit",
|
||||
"layout" => "form",
|
||||
"new_path" => "/admin/members/#{user.member_profile.to_param}/honors/new"
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
def list
|
||||
get_paper_list
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
module Admin::PersonalHonorsHelper
|
||||
|
||||
def get_paper_list
|
||||
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
||||
user_profile = user.member_profile
|
||||
honors = Honor.where(:member_profile_id => user_profile.id)
|
||||
honors = honors.collect do |h|
|
||||
{
|
||||
"id" => h.id.to_s,
|
||||
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/honors/#{h.to_param}/edit",
|
||||
"delete_url" => "/#{I18n.locale.to_s}/admin/honors/#{h.id.to_s}",
|
||||
"paper_title" => h.award_name,
|
||||
"keywords" => h.keywords,
|
||||
"files" => []
|
||||
}
|
||||
end
|
||||
honors
|
||||
end
|
||||
end
|
|
@ -7,6 +7,7 @@ module PersonalHonor
|
|||
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Honor", :intro_app_name=>"PersonalHonorIntro",:path=>"/plugin/personal_honor/profile",:front_path=>"/profile",:admin_path=>"/admin/honors",:i18n=>'module_name.personal_honor', :module_app_name=>'PersonalHonor'
|
||||
|
||||
version "0.1"
|
||||
desktop_enabled true
|
||||
organization "Rulingcom"
|
||||
author "RD dep"
|
||||
intro "I am intro"
|
||||
|
|
Loading…
Reference in New Issue