diff --git a/app/assets/images/personal_honor/.keep b/app/assets/images/personal_conference/.keep
similarity index 100%
rename from app/assets/images/personal_honor/.keep
rename to app/assets/images/personal_conference/.keep
diff --git a/app/assets/javascripts/personal_honor/.keep b/app/assets/javascripts/personal_conference/.keep
similarity index 100%
rename from app/assets/javascripts/personal_honor/.keep
rename to app/assets/javascripts/personal_conference/.keep
diff --git a/app/assets/stylesheets/personal_honor/.keep b/app/assets/stylesheets/personal_conference/.keep
similarity index 100%
rename from app/assets/stylesheets/personal_honor/.keep
rename to app/assets/stylesheets/personal_conference/.keep
diff --git a/app/controllers/admin/honor_types_controller.rb b/app/controllers/admin/honor_types_controller.rb
new file mode 100644
index 0000000..0ccb48c
--- /dev/null
+++ b/app/controllers/admin/honor_types_controller.rb
@@ -0,0 +1,41 @@
+class Admin::HonorTypesController < OrbitAdminController
+ def new
+ @honor_type = HonorType.new
+ @url = admin_honor_types_path(@honor_type)
+ render :layout=>false
+ end
+
+ def create
+ @honor_type = HonorType.new(honor_type_params)
+ @honor_type.save
+ @honor_types = HonorType.all
+ render :partial=>'list', :layout=>false
+ end
+
+ def edit
+ @honor_type = HonorType.find(params[:id])
+ @url = admin_honor_type_path(@honor_type)
+ render :layout=>false
+ end
+
+ def update
+ @honor_type = HonorType.find(params[:id])
+ @honor_type.update_attributes(honor_type_params)
+ @honor_type.save
+ @honor_types = HonorType.all
+ render :partial=>'list', :layout=>false
+ end
+
+ def destroy
+ honor_type = HonorType.find(params[:id])
+ honor_type.destroy
+ @honor_types = HonorType.all
+ render :partial=>'list', :layout=>false
+ end
+
+ private
+
+ def honor_type_params
+ params.require(:honor_type).permit! rescue nil
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/admin/honors_controller.rb b/app/controllers/admin/honors_controller.rb
new file mode 100644
index 0000000..8a1fb65
--- /dev/null
+++ b/app/controllers/admin/honors_controller.rb
@@ -0,0 +1,89 @@
+class Admin::HonorsController < OrbitMemberController
+ layout "member_plugin"
+
+ before_action :set_plugin
+ before_action :get_settings,:only => [:new, :edit, :setting]
+
+ def index
+ @honors = Honor.all
+ end
+
+ def new
+ @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
+ @honor = Honor.new
+ end
+
+ def create
+ @member = MemberProfile.find(honor_params['member_profile_id']) rescue nil
+ @honor = Honor.new(honor_params)
+ @honor.save
+ redirect_to '/admin/members/'+@member.to_param+'/Honor'
+ end
+
+ def edit
+ @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
+ @honor = Honor.find(params[:id])
+ end
+
+ def update
+ @member = MemberProfile.find(honor_params['member_profile_id']) rescue nil
+ @honor = Honor.find(params[:id])
+ @honor.update_attributes(honor_params)
+ @honor.save
+ redirect_to '/admin/members/'+@member.to_param+'/Honor'
+ end
+
+ def destroy
+ @honor = Honor.find(params[:id])
+ @honor.destroy
+ end
+
+ def toggle_hide
+ if params[:ids]
+ @honors = Honor.any_in(_id: params[:ids])
+
+ @honors.each do |honor|
+ honor.is_hidden = params[:disable]
+ honor.save
+ end
+ end
+
+ render json: {"success"=>true}
+ end
+
+ def setting
+ end
+
+ def frontend_setting
+ @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
+ @intro = HonorIntro.find_by(:member_profile_id=>@member.id) rescue nil
+ @intro = @intro.nil? ? HonorIntro.new({:member_profile_id=>@member.id}) : @intro
+ end
+
+ def update_frontend_setting
+ @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
+ @intro = HonorIntro.find_by(:member_profile_id=>@member.id) rescue nil
+ @intro = @intro.nil? ? HonorIntro.new({:member_profile_id=>@member.id}) : @intro
+ @intro.update_attributes(intro_params)
+ @intro.save
+ redirect_to '/admin/members/'+@member.to_param+'/Honor'
+ end
+
+ def get_settings
+ @honor_types = HonorType.all
+ end
+
+ def set_plugin
+ @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Honor'}.first
+ end
+
+ private
+
+ def honor_params
+ params.require(:honor).permit! rescue nil
+ end
+
+ def intro_params
+ params.require(:honor_intro).permit! rescue nil
+ end
+end
\ No newline at end of file
diff --git a/app/models/honor.rb b/app/models/honor.rb
new file mode 100644
index 0000000..bfa77f9
--- /dev/null
+++ b/app/models/honor.rb
@@ -0,0 +1,36 @@
+class Honor
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include OrbitModel::Status
+ include Slug
+
+ belongs_to :honor_type
+ belongs_to :member_profile
+
+ field :year
+ field :award_name
+ field :awarding_unit
+ field :language
+ field :keywords
+ field :url
+ field :note
+ field :create_user_id, :type => BSON::ObjectId
+ field :update_user_id, :type => BSON::ObjectId
+
+ paginates_per 10
+
+ before_validation :add_http
+
+ def slug_title
+ self.award_name+' '+self.awarding_unit
+ end
+
+ protected
+
+ def add_http
+ unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
+ self.url = 'http://' + self.url
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/honor_intro.rb b/app/models/honor_intro.rb
new file mode 100644
index 0000000..0fcfdcc
--- /dev/null
+++ b/app/models/honor_intro.rb
@@ -0,0 +1,4 @@
+class HonorIntro < PersonalPluginIntro
+
+
+end
diff --git a/app/models/honor_type.rb b/app/models/honor_type.rb
new file mode 100644
index 0000000..543ddad
--- /dev/null
+++ b/app/models/honor_type.rb
@@ -0,0 +1,8 @@
+class HonorType
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ field :title, localize: true
+
+ has_many :honors
+end
\ No newline at end of file
diff --git a/app/views/admin/honor_types/_form.html.erb b/app/views/admin/honor_types/_form.html.erb
new file mode 100644
index 0000000..9c31358
--- /dev/null
+++ b/app/views/admin/honor_types/_form.html.erb
@@ -0,0 +1,24 @@
+<%= form_for(@honor_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
+
+
+
+ <%= f.fields_for :title_translations do |f| %>
+ <% @site_in_use_locales.each do |locale| %>
+
+ <%= label_tag t(locale), t(locale), :class => 'control-label' %>
+
+ <%= f.text_field locale, :value => (@honor_type.title_translations[locale] rescue nil) %>
+
+
+ <% end %>
+ <% end %>
+
+
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/honor_types/_list.js.erb b/app/views/admin/honor_types/_list.js.erb
new file mode 100644
index 0000000..1aa6ea2
--- /dev/null
+++ b/app/views/admin/honor_types/_list.js.erb
@@ -0,0 +1,2 @@
+$('#honor_types tbody').html("<%= j render :partial => '/admin/honors/list_honor_type', :collection => @honor_types %>");
+$('#honor_type_modal').modal('hide');
\ No newline at end of file
diff --git a/app/views/admin/honor_types/edit.js.erb b/app/views/admin/honor_types/edit.js.erb
new file mode 100644
index 0000000..101bc18
--- /dev/null
+++ b/app/views/admin/honor_types/edit.js.erb
@@ -0,0 +1 @@
+$('#honor_type_modal').html("<%= j render 'form' %>");
\ No newline at end of file
diff --git a/app/views/admin/honor_types/new.js.erb b/app/views/admin/honor_types/new.js.erb
new file mode 100644
index 0000000..101bc18
--- /dev/null
+++ b/app/views/admin/honor_types/new.js.erb
@@ -0,0 +1 @@
+$('#honor_type_modal').html("<%= j render 'form' %>");
\ No newline at end of file
diff --git a/app/views/admin/honors/_form.html.erb b/app/views/admin/honors/_form.html.erb
new file mode 100644
index 0000000..a1c1af6
--- /dev/null
+++ b/app/views/admin/honors/_form.html.erb
@@ -0,0 +1,131 @@
+<% # encoding: utf-8 %>
+<% content_for :page_specific_css do %>
+ <%= stylesheet_link_tag "lib/main-forms" %>
+ <%= stylesheet_link_tag "lib/main-list" %>
+<% end %>
+<% content_for :page_specific_javascript do %>
+ <%= javascript_include_tag "lib/file-type" %>
+ <%= javascript_include_tag "lib/module-area" %>
+<% end %>
+
+
+
+
+
+
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
+ <%= f.submit t('submit'), class: 'btn btn-primary' %>
+ <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
+
\ No newline at end of file
diff --git a/app/views/admin/honors/_honor.html.erb b/app/views/admin/honors/_honor.html.erb
new file mode 100644
index 0000000..43812e2
--- /dev/null
+++ b/app/views/admin/honors/_honor.html.erb
@@ -0,0 +1,16 @@
+<% @honors.each do |honor| %>
+ ">
+ <%= honor.year %>
+
+ <%= link_to honor.award_name, '', target: "blank"%>
+
+
+ <%= link_to t('edit'), '/admin/members/'+honor.member_profile.to_param+'/honors/'+honor.id+'/edit' %>
+ <%= link_to t(:delete_), admin_honor_path(id: honor.id, member_profile_id: honor.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %>
+
+
+
+ <%= honor.awarding_unit %>
+ <%= honor.member_profile.name %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/honors/_list_honor_type.html.erb b/app/views/admin/honors/_list_honor_type.html.erb
new file mode 100644
index 0000000..269de0e
--- /dev/null
+++ b/app/views/admin/honors/_list_honor_type.html.erb
@@ -0,0 +1,8 @@
+
+ <%= list_honor_type.title %>
+
+
+ <%= t(:edit) %>
+ <%= link_to t(:delete_), admin_honor_type_path(list_honor_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
+
+
\ No newline at end of file
diff --git a/app/views/admin/honors/destroy.js.erb b/app/views/admin/honors/destroy.js.erb
new file mode 100644
index 0000000..6bd7923
--- /dev/null
+++ b/app/views/admin/honors/destroy.js.erb
@@ -0,0 +1 @@
+$('#honor_<%= @honor.id.to_s%>').remove();
\ No newline at end of file
diff --git a/app/views/admin/honors/edit.html.erb b/app/views/admin/honors/edit.html.erb
new file mode 100644
index 0000000..8e7c793
--- /dev/null
+++ b/app/views/admin/honors/edit.html.erb
@@ -0,0 +1,5 @@
+<%= form_for @honor, url:'/admin/honors/'+@honor.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %>
+
+ <%= render partial: 'form', locals: {f: f} %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/honors/frontend_setting.html.erb b/app/views/admin/honors/frontend_setting.html.erb
new file mode 100644
index 0000000..e53ec6a
--- /dev/null
+++ b/app/views/admin/honors/frontend_setting.html.erb
@@ -0,0 +1,93 @@
+<% content_for :page_specific_css do %>
+ <%= stylesheet_link_tag "lib/main-forms" %>
+ <%= stylesheet_link_tag "lib/main-list" %>
+<% end %>
+
+<%= form_for(:honor_intro, :url => update_frontend_setting_admin_honors_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
+
+
+
+
+
+
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
+ <%= f.submit t('submit'), class: 'btn btn-primary' %>
+ <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/honors/index.html.erb b/app/views/admin/honors/index.html.erb
new file mode 100644
index 0000000..ef60eac
--- /dev/null
+++ b/app/views/admin/honors/index.html.erb
@@ -0,0 +1,21 @@
+
+
+
+ <%= t('personal_honor.year') %>
+ <%= t('personal_honor.award_name') %>
+ <%= t('personal_honor.awarding_unit') %>
+ <%= t('personal_honor.award_winner') %>
+
+
+
+ <%= render :partial => 'honor', :collection => @honors %>
+
+
+
+
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_honor_setting_path, :class => 'btn btn-primary pull-right' %>
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/honors/new.html.erb b/app/views/admin/honors/new.html.erb
new file mode 100644
index 0000000..204d5d5
--- /dev/null
+++ b/app/views/admin/honors/new.html.erb
@@ -0,0 +1,5 @@
+<%= form_for @honor, url: admin_honors_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
+
+ <%= render partial: 'form', locals: {f: f} %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/honors/setting.html.erb b/app/views/admin/honors/setting.html.erb
new file mode 100644
index 0000000..768d8c6
--- /dev/null
+++ b/app/views/admin/honors/setting.html.erb
@@ -0,0 +1,52 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/plugin/personal_honor/_profile.html.erb b/app/views/plugin/personal_honor/_profile.html.erb
new file mode 100644
index 0000000..5a88f96
--- /dev/null
+++ b/app/views/plugin/personal_honor/_profile.html.erb
@@ -0,0 +1,86 @@
+<% content_for :page_specific_css do %>
+ <%= stylesheet_link_tag "lib/list-check" %>
+<% end %>
+<% content_for :page_specific_javascript do %>
+ <%= javascript_include_tag "lib/list-check" %>
+<% end %>
+
+<%
+ is_autorized_user = (current_user==@member.user || current_user.is_admin?)
+ if is_autorized_user
+ @honors = Honor.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
+ else
+ @honors = Honor.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
+ end
+%>
+
+<% if is_autorized_user %>
+
+
+ <%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_honors_path(member_profile_id: params[:id], disable: 'true') ) %>
+ <%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_honors_path(member_profile_id: params[:id], disable: 'false') ) %>
+
+
+<% end -%>
+
+
+
+
+ <% if is_autorized_user %>
+
+ <% end -%>
+ <%= t('personal_honor.year') %>
+ <%= t('personal_honor.award_name') %>
+ <%= t('personal_honor.awarding_unit') %>
+ <%= t('personal_honor.award_winner') %>
+
+
+
+ <% @honors.each do |honor| %>
+ ">
+ <% if is_autorized_user %>
+
+ <%= check_box_tag 'to_change[]', honor.id.to_s, false, :class => "list-check" %>
+
+ <% end %>
+ <%= honor.year %>
+
+ <%= link_to honor.award_name, '', target: "blank"%>
+
+
+ <%= link_to t('edit'), '/admin/members/'+@member.to_param+'/honors/'+honor.id+'/edit' %>
+ <%= link_to t(:delete_), admin_honor_path(id: honor.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %>
+
+
+
+ <%= honor.awarding_unit %>
+ <%= honor.member_profile.name %>
+
+ <% end %>
+
+
+
+
+
+ <% if is_autorized_user %>
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/honors/frontend_setting', :class => 'btn btn-primary' %>
+ <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
+ '/admin/members/'+@member.to_param+'/honors/new', :class => 'btn btn-primary' %>
+
+ <% end %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index d96d9d4..0286f99 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,6 +2,28 @@ Rails.application.routes.draw do
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
+ get 'honor_setting' => "honors#setting"
+
+ resources :honors do
+ collection do
+ get 'toggle_hide' => 'honors#toggle_hide'
+ end
+ end
+
+ resources :members do
+ collection do
+ scope '(:name-:uid)' do
+ resources :honors do
+ collection do
+ get 'frontend_setting' => 'honors#frontend_setting'
+ post 'update_frontend_setting' => 'honors#update_frontend_setting'
+ end
+ end
+ end
+ end
+ end
+
+ resources :honor_types
end
end
end
diff --git a/lib/personal_honor/engine.rb b/lib/personal_honor/engine.rb
index a6579e8..44b0ad5 100644
--- a/lib/personal_honor/engine.rb
+++ b/lib/personal_honor/engine.rb
@@ -4,7 +4,7 @@ module PersonalHonor
OrbitApp.registration "PersonalHonor",:type=> 'ModuleApp' do
module_label 'module_name.personal_honor'
base_url File.expand_path File.dirname(__FILE__)
- personal_plugin :enable => true, :sort_number => '50', :app_name=>"Honor", :intro_app_name=>"PersonalHonorIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/honors",:i18n=>'module_name.personal_honor'
+ 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'
version "0.1"
organization "Rulingcom"