add admin :download_excel_format
This commit is contained in:
parent
048c9bc563
commit
7fca57c5fb
|
@ -64,6 +64,14 @@ class Admin::ActivitiesController < OrbitMemberController
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def download_excel_format
|
||||||
|
respond_to do |format|
|
||||||
|
format.xlsx {
|
||||||
|
response.headers['Content-Disposition'] = 'attachment; filename="activities_format.xlsx"'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_activity
|
def set_activity
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
wb = xlsx_package.workbook
|
||||||
|
|
||||||
|
wb.add_worksheet(name: "Activities") do |sheet|
|
||||||
|
|
||||||
|
heading = sheet.styles.add_style(:b => true, :locked => true)
|
||||||
|
example = sheet.styles.add_style(:i => true)
|
||||||
|
|
||||||
|
row = ["user_id"]
|
||||||
|
row1 = [""]
|
||||||
|
row2 = [""]
|
||||||
|
|
||||||
|
row << "name"
|
||||||
|
row1 << ""
|
||||||
|
row2 << ""
|
||||||
|
|
||||||
|
row << t("personal_activity.activity_name") + " - " + t("en")
|
||||||
|
row1 << "textfield"
|
||||||
|
row2 << ""
|
||||||
|
row << t("personal_activity.activity_name") + " - " + t("zh_tw")
|
||||||
|
row1 << "textfield"
|
||||||
|
row2 << ""
|
||||||
|
|
||||||
|
row << t("personal_activity.activity_organizer") + " - " + t("en")
|
||||||
|
row1 << "textfield"
|
||||||
|
row2 << ""
|
||||||
|
row << t("personal_activity.activity_organizer") + " - " + t("zh_tw")
|
||||||
|
row1 << "textfield"
|
||||||
|
row2 << ""
|
||||||
|
|
||||||
|
row << t("personal_activity.activity_area") + " - " + t("en")
|
||||||
|
row1 << "textfield"
|
||||||
|
row2 << ""
|
||||||
|
row << t("personal_activity.activity_area") + " - " + t("zh_tw")
|
||||||
|
row1 << "textfield"
|
||||||
|
row2 << ""
|
||||||
|
|
||||||
|
row << t("personal_activity.year")
|
||||||
|
row1 << "number"
|
||||||
|
row2 << "Example : 2015 or 2014 or 1987"
|
||||||
|
|
||||||
|
row << t("personal_activity.activity_start_date")
|
||||||
|
row1 << "date"
|
||||||
|
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10"
|
||||||
|
|
||||||
|
row << t("personal_activity.activity_end_date")
|
||||||
|
row1 << "date"
|
||||||
|
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10"
|
||||||
|
|
||||||
|
row << t("personal_activity.note")
|
||||||
|
row1 << "textarea"
|
||||||
|
row2 << ""
|
||||||
|
|
||||||
|
sheet.add_row row, :style => heading
|
||||||
|
sheet.add_row row1
|
||||||
|
sheet.add_row row2, :style => example
|
||||||
|
|
||||||
|
User.where(:user_name.ne => "rulingcom").each do |user|
|
||||||
|
r = [user.user_name]
|
||||||
|
r << user.name
|
||||||
|
sheet.add_row r
|
||||||
|
end
|
||||||
|
end
|
|
@ -17,6 +17,15 @@
|
||||||
|
|
||||||
<!-- buttons -->
|
<!-- buttons -->
|
||||||
<div class="action pull-right">
|
<div class="action pull-right">
|
||||||
|
<div class="dropup upload-button">
|
||||||
|
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||||
|
<i class="icon-upload-alt icon-white"></i><%= t('personal_activity.upload') %>
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu upload-box">
|
||||||
|
<a class="" href="/admin/activities/download_excel_format.xlsx">Download excel format</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_activity_path, :class => 'btn btn-primary' %>
|
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_activity_path, :class => 'btn btn-primary' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@ Rails.application.routes.draw do
|
||||||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
|
get 'activities/download_excel_format' => 'activities#download_excel_format'
|
||||||
|
#post 'books/import_from_excel' => 'books#import_from_excel'
|
||||||
|
|
||||||
resources :activities do
|
resources :activities do
|
||||||
collection do
|
collection do
|
||||||
# post 'merge_process' => 'books#merge_process'
|
# post 'merge_process' => 'books#merge_process'
|
||||||
|
|
Loading…
Reference in New Issue