orbit diploma plugin
This commit is contained in:
parent
456a9da33a
commit
97ef6f3706
|
@ -1,5 +1,6 @@
|
||||||
class Admin::DiplomasController < OrbitMemberController
|
class Admin::DiplomasController < OrbitMemberController
|
||||||
layout "member_plugin"
|
layout "member_plugin"
|
||||||
|
include Admin::PersonalDiplomasHelper
|
||||||
|
|
||||||
before_action :set_diploma, only: [:show, :edit , :update, :destroy]
|
before_action :set_diploma, only: [:show, :edit , :update, :destroy]
|
||||||
before_action :set_plugin
|
before_action :set_plugin
|
||||||
|
@ -15,28 +16,48 @@ class Admin::DiplomasController < OrbitMemberController
|
||||||
def new
|
def new
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||||
@diploma = Diploma.new
|
@diploma = Diploma.new
|
||||||
|
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@member = MemberProfile.find(diploma_params['member_profile_id']) rescue nil
|
@member = MemberProfile.find(diploma_params['member_profile_id']) rescue nil
|
||||||
@diploma = Diploma.new(diploma_params)
|
@diploma = Diploma.new(diploma_params)
|
||||||
@diploma.save
|
@diploma.save
|
||||||
|
if params[:desktop] == "true"
|
||||||
|
render json: {"data" => get_paper_list}.to_json
|
||||||
|
else
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@member = @diploma.member_profile rescue nil
|
@member = @diploma.member_profile rescue nil
|
||||||
|
if params[:desktop]
|
||||||
|
render :layout =>false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = @diploma.member_profile rescue nil
|
@member = @diploma.member_profile rescue nil
|
||||||
@diploma.update_attributes(diploma_params)
|
@diploma.update_attributes(diploma_params)
|
||||||
@diploma.save
|
@diploma.save
|
||||||
|
if params[:desktop] == "true"
|
||||||
|
render json: {"data" => get_paper_list}.to_json
|
||||||
|
else
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@diploma.destroy
|
@diploma.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to(admin_diplomas_url) }
|
||||||
|
format.js
|
||||||
|
format.json {render json: {"success" => true}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggle_hide
|
def toggle_hide
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
class Desktop::PersonalDiplomasController < DesktopAdminController
|
||||||
|
include Admin::PersonalDiplomasHelper
|
||||||
|
|
||||||
|
def menu
|
||||||
|
user = OrbitHelper.current_user
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"title" => "List",
|
||||||
|
"layout" => "list"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title" => "Add/Edit",
|
||||||
|
"layout" => "form",
|
||||||
|
"new_path" => "/admin/members/#{user.member_profile.to_param}/diplomas/new"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def list
|
||||||
|
get_paper_list
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
module Admin::PersonalDiplomasHelper
|
||||||
|
|
||||||
|
def get_paper_list
|
||||||
|
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
||||||
|
user_profile = user.member_profile
|
||||||
|
diplomas = Diploma.where(:member_profile_id => user_profile.id)
|
||||||
|
|
||||||
|
diplomas = diplomas.collect do |d|
|
||||||
|
{
|
||||||
|
"id" => d.id.to_s,
|
||||||
|
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/diplomas/#{d.to_param}/edit",
|
||||||
|
"delete_url" => "/#{I18n.locale.to_s}/admin/diplomas/#{d.id.to_s}",
|
||||||
|
"paper_title" => d.school_name,
|
||||||
|
"files" => []
|
||||||
|
}
|
||||||
|
end
|
||||||
|
diplomas
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,6 +7,7 @@ module PersonalDiploma
|
||||||
personal_plugin :enable => true, :sort_number => '40', :app_name=>"Diploma", :intro_app_name=>"PersonalDiplomaIntro",:path=>"/plugin/personal_diploma/profile",:front_path=>"/profile",:admin_path=>"/admin/diplomas",:i18n=>'module_name.personal_diploma', :module_app_name=>'PersonalDiploma'
|
personal_plugin :enable => true, :sort_number => '40', :app_name=>"Diploma", :intro_app_name=>"PersonalDiplomaIntro",:path=>"/plugin/personal_diploma/profile",:front_path=>"/profile",:admin_path=>"/admin/diplomas",:i18n=>'module_name.personal_diploma', :module_app_name=>'PersonalDiploma'
|
||||||
|
|
||||||
version "0.1"
|
version "0.1"
|
||||||
|
desktop_enabled true
|
||||||
organization "Rulingcom"
|
organization "Rulingcom"
|
||||||
author "RD dep"
|
author "RD dep"
|
||||||
intro "I am intro"
|
intro "I am intro"
|
||||||
|
|
Loading…
Reference in New Issue