Merge branch 'gallery_orbit' of https://github.com/Rulingcom/orbit into gallery_orbit

Conflicts:
	vendor/built_in_modules/gallery/config/routes.rb
This commit is contained in:
Harry Bomrah 2012-11-14 16:25:02 +08:00
commit 46f80ade6a
22 changed files with 1042 additions and 880 deletions

View File

@ -7,12 +7,12 @@ module AdminHelper
# Check if the current_user is manager in current module app # Check if the current_user is manager in current module app
def is_manager? def is_manager?
@module_app.is_manager?(current_or_guest_user) || is_admin? (@module_app.is_manager?(current_or_guest_user) rescue nil) || is_admin?
end end
# Check if the current_user is sub manager in current module app # Check if the current_user is sub manager in current module app
def is_sub_manager? def is_sub_manager?
@module_app.is_sub_manager?(current_or_guest_user)|| is_admin? (@module_app.is_sub_manager?(current_or_guest_user) rescue nil) || is_admin?
end end
def is_admin? def is_admin?

View File

@ -163,7 +163,7 @@ protected
result << "</div>" result << "</div>"
result << "<ul class='nav nav-pills'>" result << "<ul class='nav nav-pills'>"
VALID_LOCALES.each do |key| VALID_LOCALES.each do |key|
result << content_tag(:li,link_to(t(:_locale, :locale => key),"#tab"+id.to_s+"_#{key}",:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil)) result << content_tag(:li,link_to(I18n.t(:_locale, :locale => key),"#tab"+id.to_s+"_#{key}",:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil))
end end
result << "</ul>" result << "</ul>"
result << "</div>" result << "</div>"

View File

@ -368,176 +368,176 @@ en:
errors: errors:
at_least_one: must at least have one value at_least_one: must at least have one value
admin: # admin:
access: # access:
denied: # denied:
app: # app:
not_sub_manager: Access Denied for you are not SubManager for this app # not_sub_manager: Access Denied for you are not SubManager for this app
not_manager: Access Denied for you are not SubManager for this app # not_manager: Access Denied for you are not SubManager for this app
not_authed_user: Access Denied for you are not User for this app # not_authed_user: Access Denied for you are not User for this app
not_admin: Access Denied for you are not Admin # not_admin: Access Denied for you are not Admin
object: "Access Denied for you don't have permission for this object" # object: "Access Denied for you don't have permission for this object"
action: Action # action: Action
ad_banner: AD Banner # ad_banner: AD Banner
orbit_gallery: Gallery # orbit_gallery: Gallery
calendar: Calendar # calendar: Calendar
ad: # ad:
sec_place_holder: Enter 3 if 3 sec # sec_place_holder: Enter 3 if 3 sec
ab_fx: FX # ab_fx: FX
all_banners: AdBanner list # all_banners: AdBanner list
banner_best_size: Banner Best Size # banner_best_size: Banner Best Size
best_size: Best size # best_size: Best size
new_banner: New banner # new_banner: New banner
new_image: New image # new_image: New image
showing: Showing # showing: Showing
not_showing: NotShowing # not_showing: NotShowing
picture_list: Picture List # picture_list: Picture List
title: Title # title: Title
transition_sec: Transition time # transition_sec: Transition time
trans_unit_sec: sec # trans_unit_sec: sec
update_banner: Update Banner # update_banner: Update Banner
widget_info_for_ad_image_size: "Best size with: %{best_size}" # widget_info_for_ad_image_size: "Best size with: %{best_size}"
add: Add # add: Add
add_item: Add item # add_item: Add item
add_language: Add language # add_language: Add language
add_drop_down_item: +Add Menu Item # add_drop_down_item: +Add Menu Item
admin: Admin # admin: Admin
action: Action # action: Action
all_articles: List # all_articles: List
always_display_title: Always displayed in the title bar # always_display_title: Always displayed in the title bar
announcement: Announcement # announcement: Announcement
asset: Asset # asset: Asset
assets: # assets:
file: File # file: File
album: Album # album: Album
video: Video # video: Video
book: Book # book: Book
attributes: Attributes # attributes: Attributes
author: Author # author: Author
calendar: Calendar # calendar: Calendar
gprs: GPS # gprs: GPS
cant_delete_self: You can not delete yourself. # cant_delete_self: You can not delete yourself.
cant_revoke_self_admin: You can not revoke your admin role yourself. # cant_revoke_self_admin: You can not revoke your admin role yourself.
category: Category # category: Category
choose_file: Choose a file... # choose_file: Choose a file...
class: Class # class: Class
content: Content # content: Content
create_error_link: Error when creating link. # create_error_link: Error when creating link.
create_error_page: Error when creating page. # create_error_page: Error when creating page.
create_success_home: Homepage was successfully created. # create_success_home: Homepage was successfully created.
create_success_layout: Layout was successfully created. # create_success_layout: Layout was successfully created.
create_success_link: Link was successfully created. # create_success_link: Link was successfully created.
create_success_page: Page was successfully created. # create_success_page: Page was successfully created.
create_success_snippet: Snippet was successfully created. # create_success_snippet: Snippet was successfully created.
create_success_user: User was successfully created. # create_success_user: User was successfully created.
data: Data # data: Data
dashboard: Dashboard # dashboard: Dashboard
delete_language: Delete language # delete_language: Delete language
description: Description # description: Description
design: Template # design: Template
disable_language: Disable language # disable_language: Disable language
editing_home: Editing homepage # editing_home: Editing homepage
editing_layout: Editing layout # editing_layout: Editing layout
editing_link: Editing link # editing_link: Editing link
editing_page: Editing page # editing_page: Editing page
editing_snippet: Editing snippet # editing_snippet: Editing snippet
editing_info: Editing user information # editing_info: Editing user information
editing_role: Editing user role # editing_role: Editing user role
email: Email # email: Email
enable_language: Enable language # enable_language: Enable language
enabled_for: Enabled for # enabled_for: Enabled for
file_name: Filename # file_name: Filename
file_size: File size # file_size: File size
file_upload: File upload # file_upload: File upload
format: Format # format: Format
home: Home # home: Home
id: ID # id: ID
info: Information # info: Information
intro: Introduction # intro: Introduction
is_published: Is published # is_published: Is published
item: Item # item: Item
key: Key # key: Key
keywords: Keywords # keywords: Keywords
language: Language # language: Language
layout: Layout # layout: Layout
layout_name: Layout name # layout_name: Layout name
links: Links # links: Links
link: Links # link: Links
list_assets: Assets list # list_assets: Assets list
list_designs: Designs list # list_designs: Designs list
list_items: Items list # list_items: Items list
list_puchases: Purchases list # list_puchases: Purchases list
list_snippets: Snippets list # list_snippets: Snippets list
list_users: Users list # list_users: Users list
list_infos: User information list # list_infos: User information list
list_roles: User roles list # list_roles: User roles list
mail_address: Address # mail_address: Address
mail_port: Port # mail_port: Port
mail_domain: Domain # mail_domain: Domain
mail_authentication: Authentication # mail_authentication: Authentication
mail_user_name: User Name # mail_user_name: User Name
mail_password: Password # mail_password: Password
mail_tls: TLS # mail_tls: TLS
mail_enable_starttls_auto: Enable Start TLS Auto # mail_enable_starttls_auto: Enable Start TLS Auto
member: Member # member: Member
menu_enabled_for: Menu enabled for # menu_enabled_for: Menu enabled for
module: # module:
authorization: Module Authorization # authorization: Module Authorization
move_down: Move down # move_down: Move down
move_up: Move up # move_up: Move up
multilingual: Multilingual # multilingual: Multilingual
my_avatar: My Avatar # my_avatar: My Avatar
no_home_page: You don't have a homepage # no_home_page: You don't have a homepage
no_layout: You don't have a layout # no_layout: You don't have a layout
name: Name # name: Name
nccu: NCCU Custom # nccu: NCCU Custom
nccu_c: # nccu_c:
nccu_ldap_uid: NCCU LDAP Account # nccu_ldap_uid: NCCU LDAP Account
new_asset: New asset # new_asset: New asset
new_component: New component # new_component: New component
new_design: New design # new_design: New design
new_home: New homepage # new_home: New homepage
new_layout: New layout # new_layout: New layout
new_link: New link # new_link: New link
new_page: New page # new_page: New page
new_snippet: New snippet # new_snippet: New snippet
new_user: New user # new_user: New user
new_info: New user information # new_info: New user information
new_role: New user role # new_role: New user role
news: News # news: News
non_multilingual: Non multilingual # non_multilingual: Non multilingual
object_auth: # object_auth:
list_title_of_users: %{auth_title} Auth List # list_title_of_users: %{auth_title} Auth List
update_done: Update done,reulst showing in list # update_done: Update done,reulst showing in list
update_failed: Update failed # update_failed: Update failed
options: Options # options: Options
orig_upload_file: Original filename # orig_upload_file: Original filename
page: Page # page: Page
page_context: # page_context:
edit: Edit # edit: Edit
ob_auth: # ob_auth:
edit: Category authorization # edit: Category authorization
page_part_kinds: # page_part_kinds:
text: Text Area # text: Text Area
public_r_tag: System Widget # public_r_tag: System Widget
module_widget: Plug-in Module Widget # module_widget: Plug-in Module Widget
position: Position # position: Position
published?: Published? # published?: Published?
purchase: Purchase # purchase: Purchase
registered: Registered # registered: Registered
role: Role # role: Role
roles: Roles # roles: Roles
setup_member: Member setup # setup_member: Member setup
setup_translations: Translations setup # setup_translations: Translations setup
setup_designs: Designs setup # setup_designs: Designs setup
site: Site # site: Site
site_description: Site description # site_description: Site description
site_footer: Site footer # site_footer: Site footer
site_settings: Site Setting # site_settings: Site Setting
site_sub_menu: Site sub-menu # site_sub_menu: Site sub-menu
site_title: Site title # site_title: Site title
super_pages: Super pages # super_pages: Super pages
structure: Structure # structure: Structure
# : >>>>>>> various_bugs # : >>>>>>> various_bugs
tags: Tags tags: Tags
url: URL url: URL

View File

@ -350,278 +350,278 @@ zh_tw:
# : ======= # : =======
errors: errors:
at_least_one: 必須至少有一個值 at_least_one: 必須至少有一個值
admin: # admin:
infos: # infos:
add_attribute_field: 新增 # add_attribute_field: 新增
save: 儲存 # save: 儲存
initial: 起始值 # initial: 起始值
markup: 輸入模式 # markup: 輸入模式
item_name: 資料表名稱 # item_name: 資料表名稱
name: 名稱 # name: 名稱
options: 選項 # options: 選項
multilingual: 多語言輸入 # multilingual: 多語言輸入
add_more: 使用者可自行延伸欄位 # add_more: 使用者可自行延伸欄位
add: 新增 # add: 新增
placeholder: 輸入協助 # placeholder: 輸入協助
type: 類型 # type: 類型
placeholder: 提示內容 # placeholder: 提示內容
list: 自定選單 # list: 自定選單
is_range: # is_range: 是
not_range: # not_range: 否
date: # date:
claendar: 紀年法 # claendar: 紀年法
range: 本欄為時間區段 # range: 本欄為時間區段
format: 格式 # format: 格式
tw_claendar: 民國 # tw_claendar: 民國
west_claendar: 西元 # west_claendar: 西元
access: # access:
denied: # denied:
app: # app:
not_sub_manager: 拒絕存取因你不是此應用程式次管理員 # not_sub_manager: 拒絕存取因你不是此應用程式次管理員
not_manager: 拒絕存取因你不是此應用程式管理員 # not_manager: 拒絕存取因你不是此應用程式管理員
not_authed_user: 拒絕存取因你不是此應用程式授權使用者 # not_authed_user: 拒絕存取因你不是此應用程式授權使用者
not_admin: 拒絕存取因你不是此應用程式次管理員 # not_admin: 拒絕存取因你不是此應用程式次管理員
object: 拒絕存取因你不是網站管理者 # object: 拒絕存取因你不是網站管理者
action: 操作 # action: 操作
ad_banner: 廣告輪播 # ad_banner: 廣告輪播
orbit_gallery: 活動花絮 # orbit_gallery: 活動花絮
ad: # ad:
sec_place_holder: 3秒請輸入3 # sec_place_holder: 3秒請輸入3
ab_fx: 轉場特效 # ab_fx: 轉場特效
all_banners: 輪播清單 # all_banners: 輪播清單
banner_best_size: Banner 尺寸 # banner_best_size: Banner 尺寸
best_size: 最佳尺寸 # best_size: 最佳尺寸
cate_auth: 分類授權 # cate_auth: 分類授權
delete_banner: 刪除整組輪播 # delete_banner: 刪除整組輪播
new_banner: 新增輪播 # new_banner: 新增輪播
new_image: 新增橫幅 # new_image: 新增橫幅
showing: 顯示中 # showing: 顯示中
not_showing: 沒有顯示 # not_showing: 沒有顯示
picture_list: 圖片列表 # picture_list: 圖片列表
title: 標題 # title: 標題
transition_sec: 轉場單位時間 # transition_sec: 轉場單位時間
trans_unit_sec: # trans_unit_sec: 秒
update_banner: 更新輪播 # update_banner: 更新輪播
widget_info_for_ad_image_size: "此區塊圖片尺寸請使用 %{best_size}" # widget_info_for_ad_image_size: "此區塊圖片尺寸請使用 %{best_size}"
add: 新增 # add: 新增
add_item: 新增項目 # add_item: 新增項目
add_language: 新增語言 # add_language: 新增語言
add_drop_down_item: 增加Orbit選單 # add_drop_down_item: 增加Orbit選單
admin: 網站管理者 # admin: 網站管理者
all_articles: 列表 # all_articles: 列表
always_display_title: 永遠顯示於標題列 # always_display_title: 永遠顯示於標題列
announcement: 公告管理 # announcement: 公告管理
asset: 資產 # asset: 資產
assets: # assets:
file: 檔案 # file: 檔案
album: 相簿 # album: 相簿
video: 影片 # video: 影片
book: 書籍 # book: 書籍
attributes: 屬性 # attributes: 屬性
author: 作者 # author: 作者
calendar: 行事曆 # calendar: 行事曆
cant_delete_self: 您不可以刪除自己。 # cant_delete_self: 您不可以刪除自己。
cant_revoke_self_admin: 您不可以撤銷自己的管理身份。 # cant_revoke_self_admin: 您不可以撤銷自己的管理身份。
category: 類別 # category: 類別
choose_file: 請選擇一個文件... # choose_file: 請選擇一個文件...
class: 階級 # class: 階級
content: 內容 # content: 內容
contenteditable: # contenteditable:
update_done: 更新完成 # update_done: 更新完成
update_failed: 更新失敗 # update_failed: 更新失敗
create_error_link: 新增連接時出錯。 # create_error_link: 新增連接時出錯。
create_error_page: 新增頁面時出錯。 # create_error_page: 新增頁面時出錯。
create_success_home: 首頁已成功新增。 # create_success_home: 首頁已成功新增。
create_success_layout: 樣板已成功新增。 # create_success_layout: 樣板已成功新增。
create_success_link: 連結已成功新增。 # create_success_link: 連結已成功新增。
create_success_page: 頁面已成功新增。 # create_success_page: 頁面已成功新增。
create_success_home: 首頁已成功新增。 # create_success_home: 首頁已成功新增。
create_success_layout: 佈局已成功新增。 # create_success_layout: 佈局已成功新增。
create_success_link: 連結已成功新增。 # create_success_link: 連結已成功新增。
create_success_page: 頁面已成功新增。 # create_success_page: 頁面已成功新增。
create_success_snippet: 片段已成功新增。 # create_success_snippet: 片段已成功新增。
create_success_user: 用戶已成功新增。。 # create_success_user: 用戶已成功新增。。
dashboard: 儀表板 # dashboard: 儀表板
data: 選擇檔案 # data: 選擇檔案
delete_language: 刪除語言 # delete_language: 刪除語言
description: 描述 # description: 描述
design: 版型管理 # design: 版型管理
disable_language: 禁用語言 # disable_language: 禁用語言
edit: 編輯 # edit: 編輯
editing_home: 編輯首頁 # editing_home: 編輯首頁
editing_layout: 編輯樣板 # editing_layout: 編輯樣板
editing_link: 編輯連結 # editing_link: 編輯連結
editing_page: 編輯頁面 # editing_page: 編輯頁面
editing_snippet: 編輯片段 # editing_snippet: 編輯片段
editing_info: 編輯用戶資料 # editing_info: 編輯用戶資料
editing_role: 編輯用戶身份 # editing_role: 編輯用戶身份
email: Email # email: Email
enable_language: 啟用語言 # enable_language: 啟用語言
enabled_for: 啟用 # enabled_for: 啟用
file_name: 檔名 # file_name: 檔名
file_size: 檔案大小 # file_size: 檔案大小
file_upload: 文件上載 # file_upload: 文件上載
format: 格式 # format: 格式
home: 首頁 # home: 首頁
id: ID # id: ID
info: 資料 # info: 資料
intro: 簡介 # intro: 簡介
is_published: 被出版 # is_published: 被出版
item: 網站架構 # item: 網站架構
key: 關鍵 # key: 關鍵
keywords: 關鍵字 # keywords: 關鍵字
language: 語言 # language: 語言
layout: 佈局 # layout: 佈局
layout_name: 佈局名字 # layout_name: 佈局名字
link: 連結管理 # link: 連結管理
links: 網路資源 # links: 網路資源
list_assets: 資產列表 # list_assets: 資產列表
list_designs: 設計列表 # list_designs: 設計列表
list_items: 項目列表 # list_items: 項目列表
list_puchases: 購買清單 # list_puchases: 購買清單
list_snippets: 斷片列表 # list_snippets: 斷片列表
list_users: 使用列表 # list_users: 使用列表
list_infos: 用戶資料列表 # list_infos: 用戶資料列表
list_roles: 用戶身份列表 # list_roles: 用戶身份列表
mail_address: 郵件地址 # mail_address: 郵件地址
mail_port: 傳輸埠 # mail_port: 傳輸埠
mail_domain: 網域名稱 # mail_domain: 網域名稱
mail_authentication: 認證 # mail_authentication: 認證
mail_user_name: 帳號 # mail_user_name: 帳號
mail_password: 密碼 # mail_password: 密碼
mail_tls: TLS # mail_tls: TLS
mail_enable_starttls_auto: Enable Start TLS Auto # mail_enable_starttls_auto: Enable Start TLS Auto
member: 會員 # member: 會員
menu_enabled_for: 選單啟用 # menu_enabled_for: 選單啟用
module: # module:
authorization: 模組授權 # authorization: 模組授權
move_down: 往下移 # move_down: 往下移
move_up: 往上移 # move_up: 往上移
multilingual: 多種語言 # multilingual: 多種語言
my_avatar: 我的頭像 # my_avatar: 我的頭像
no_home_page: 您沒有首頁 # no_home_page: 您沒有首頁
no_layout: 您沒有佈局 # no_layout: 您沒有佈局
name: 名稱 # name: 名稱
new_admin: # new_admin:
side_bar: # side_bar:
all_user: 所有使用者 # all_user: 所有使用者
add_user: 新增使用者 # add_user: 新增使用者
user_roles: 角色 # user_roles: 角色
user_info: 使用者資訊 # user_info: 使用者資訊
user: 會員 # user: 會員
users: # users:
all_plugin_summary: 全部 # all_plugin_summary: 全部
profile: 基本資料 # profile: 基本資料
roles: # roles:
staff: 職員資料 # staff: 職員資料
student: 學生資料 # student: 學生資料
teacher: 教師資料 # teacher: 教師資料
action: # action:
add: 新增 # add: 新增
edit: 編輯 # edit: 編輯
delete: 刪除 # delete: 刪除
quick_edit: 快速編輯 # quick_edit: 快速編輯
next: 下一頁 # next: 下一頁
prev: 上一頁 # prev: 上一頁
attributes: # attributes:
roles: 角色 # roles: 角色
name: 名稱 # name: 名稱
publications: 出版數 # publications: 出版數
courses: 開課數 # courses: 開課數
followers: 被關注數 # followers: 被關注數
show_mode: # show_mode:
index: 清單 # index: 清單
summary: 摘要 # summary: 摘要
thumbnail: 縮圖 # thumbnail: 縮圖
table_header: # table_header:
status: 狀態 # status: 狀態
category: 分類 # category: 分類
tags: 標籤 # tags: 標籤
clear_filter: 重置 # clear_filter: 重置
new_asset: 新增資產 # new_asset: 新增資產
new_component: 新增元件 # new_component: 新增元件
new_design: 新設計 # new_design: 新設計
new_home: 新增首頁 # new_home: 新增首頁
new_layout: 新增樣板 # new_layout: 新增樣板
new_link: 新增連結 # new_link: 新增連結
new_page: 新增頁面 # new_page: 新增頁面
new_snippet: 新增片段 # new_snippet: 新增片段
new_user: 新增使用 # new_user: 新增使用
new_info: 新增用戶資料 # new_info: 新增用戶資料
new_role: 新增用戶身份 # new_role: 新增用戶身份
news: 新聞 # news: 新聞
non_multilingual: # non_multilingual:
object_auth: # object_auth:
list_title_of_users: 授權清單-%{auth_title} # list_title_of_users: 授權清單-%{auth_title}
update_done: 更新完成,結果顯示於清單 # update_done: 更新完成,結果顯示於清單
update_failed: 更新失敗 # update_failed: 更新失敗
options: 選項 # options: 選項
orig_upload_file: 原上傳檔名 # orig_upload_file: 原上傳檔名
page: 頁面管理 # page: 頁面管理
page_context: # page_context:
edit: 編輯 # edit: 編輯
ob_auth: # ob_auth:
edit: 分類授權 # edit: 分類授權
page_part_kinds: # page_part_kinds:
text: 文字區塊 # text: 文字區塊
public_r_tag: 系統模塊 # public_r_tag: 系統模塊
module_widget: 外掛模塊 # module_widget: 外掛模塊
position: 位置 # position: 位置
published?: 發布? # published?: 發布?
purchase: 購買 # purchase: 購買
role: 身份 # role: 身份
roles: 身份 # roles: 身份
site_description: 網站描述 # site_description: 網站描述
site_footer: 網站頁尾 # site_footer: 網站頁尾
site_settings: 基本設定 # site_settings: 基本設定
site_sub_menu: 網站次選單 # site_sub_menu: 網站次選單
site_title: 網站標題 # site_title: 網站標題
setup_member: 成員設置 # setup_member: 成員設置
setup_translations: 語系設定 # setup_translations: 語系設定
setup_designs: 版型設定 # setup_designs: 版型設定
site: 網站 # site: 網站
site_setting: 網站設定 # site_setting: 網站設定
super_pages: 可編頁面 # super_pages: 可編頁面
structure: 網站結構 # structure: 網站結構
tags: 標籤 # tags: 標籤
title: 標題 # title: 標題
translation: 翻譯 # translation: 翻譯
type: 類型 # type: 類型
up_to_date: 最新版本 # up_to_date: 最新版本
update_error_link: 更新鏈接時出現錯誤。 # update_error_link: 更新鏈接時出現錯誤。
update_error_page: 更新頁面時出現錯誤。 # update_error_page: 更新頁面時出現錯誤。
update_success_content: 內容已成功更新。 # update_success_content: 內容已成功更新。
update_success_home: 首頁已成功更新。 # update_success_home: 首頁已成功更新。
update_success_layout: 樣板已成功更新。 # update_success_layout: 樣板已成功更新。
update_success_link: 連結已成功更新。 # update_success_link: 連結已成功更新。
update_success_page: 頁面已成功更新。 # update_success_page: 頁面已成功更新。
update_success_snippet: 片段已成功更新。 # update_success_snippet: 片段已成功更新。
update_success_user: 用戶已成功更新 # update_success_user: 用戶已成功更新
upload_design: 上傳設計 # upload_design: 上傳設計
url: URL # url: URL
user: 用戶 # user: 用戶
user_new_interface: # user_new_interface:
sys_basic_form: 系統基本資料表 # sys_basic_form: 系統基本資料表
password: 密碼 # password: 密碼
password_confirmation: 確認密碼 # password_confirmation: 確認密碼
email: 使用者帳號信箱 # email: 使用者帳號信箱
user_role: # user_role:
auth: # auth:
all_member: 所有會員 # all_member: 所有會員
manager: 管理員 # manager: 管理員
sub_manager: 次管理員 # sub_manager: 次管理員
by_role: 根據身份 # by_role: 根據身份
by_sub_role: 根據次身份 # by_sub_role: 根據次身份
block_list: 封鎖名單 # block_list: 封鎖名單
add_manager: 增加到管理員 # add_manager: 增加到管理員
add_sub_manager: 增加到次管理員 # add_sub_manager: 增加到次管理員
add_to_block_list: 封鎖名單 # add_to_block_list: 封鎖名單
add_to_privilege_list: 特許名單 # add_to_privilege_list: 特許名單
auth_by: -由%{user_display_name}授權 # auth_by: -由%{user_display_name}授權
user: 使用會員 # user: 使用會員
info: 用戶資料 # info: 用戶資料
panel: 用戶面板 # panel: 用戶面板
role: 用戶身份 # role: 用戶身份
dashboard: dashboard:
bulletin: 公告 bulletin: 公告

View File

@ -4,11 +4,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
before_filter :clean_values, :only => [:create, :update] before_filter :clean_values, :only => [:create, :update]
# before_filter :for_admin_only,:only => [:] # before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,] # before_filter :for_app_manager,:only => [:index,:show,]
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins] before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins] before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins,:get_bulletins_json]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins] before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins,:get_bulletins_json]
before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| before_filter :only => [ :new,:create,:edit,:update,:create] do |controller|
controller.get_categorys('BulletinCategory') controller.get_categorys('BulletinCategory')
@ -22,6 +22,39 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
render '/shared/preview/preview.html.erb',:layout=>false render '/shared/preview/preview.html.erb',:layout=>false
end end
def get_bulletins_json
@bulletins = Bulletin.all
@data = Hash.new
@data[I18n.t("category")] = Hash.new
@bulletins.each do |b|
deadline = b.deadline
if not deadline.nil?
deadline = display_date_time(deadline)
else
deadline = I18n.t("no_deadline")
end
if @data[I18n.t("category")][b.bulletin_category.title].nil?
@data[I18n.t("category")][b.bulletin_category.title] = Array.new
@data[I18n.t("category")][b.bulletin_category.title] << { title: b.title,
postdate: display_date_time(b.postdate),
deadline: deadline,
tag: b.sorted_tags.to_a,
}
else
@data[I18n.t("category")][b.bulletin_category.title] << { title: b.title,
postdate: display_date_time(b.postdate),
deadline: deadline,
tag: b.sorted_tags.to_a,
}
end
end
#render :json => @data.to_json
#to print readable json
render :json => JSON.pretty_generate(@data)
end
def index def index
# @bulletins = Bulletin.all # @bulletins = Bulletin.all
# @bulletins = Bulletin.desc("postdate desc") # @bulletins = Bulletin.desc("postdate desc")
@ -52,10 +85,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin_link = BulletinLink.new @bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path @link_url = panel_announcement_back_end_bulletins_path
@bulletin_file = BulletinFile.new @bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path @file_url = panel_announcement_back_end_bulletins_path
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.js { } format.js { }
@ -84,13 +117,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin = session[:in_validate_object] @bulletin = session[:in_validate_object]
session[:in_validate_object] = {} session[:in_validate_object] = {}
end end
@link_url = panel_announcement_back_end_bulletins_path @link_url = panel_announcement_back_end_bulletins_path
get_tags get_tags
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.xml { render :xml => @bulletin } format.xml { render :xml => @bulletin }
end end
end end
# GET /bulletins/1/edit # GET /bulletins/1/edit
@ -100,85 +133,82 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
redirect_to :action => :index redirect_to :action => :index
else else
# @summary_variable = @bulletin.summary_variable # @summary_variable = @bulletin.summary_variable
@link_url = panel_announcement_back_end_bulletin_path(@bulletin) @link_url = panel_announcement_back_end_bulletin_path(@bulletin)
get_tags get_tags
end end
end end
# POST /bulletins # POST /bulletins
# POST /bulletins.xml # POST /bulletins.xml
def create def create
get_tags get_tags
if params[:bulletin_link] if params[:bulletin_link]
@bulletin_link = BulletinLink.new(params[:bulletin_link])
respond_to do |format| @bulletin_link = BulletinLink.new(params[:bulletin_link])
if @bulletin_link.save
format.js { render 'create_bulletin_link' }
end
end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.new(params[:bulletin_file])
respond_to do |format| respond_to do |format|
if @bulletin_file.save if @bulletin_link.save
format.js { render 'create_bulletin_file' } format.js { render 'create_bulletin_link' }
end end
end end
else
@bulletin = Bulletin.new(params[:bulletin])
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@bulletin.is_checked = true
@bulletin.is_rejected = false
@bulletin.de_pending
end
respond_to do |format| elsif params[:bulletin_file]
if @bulletin.save
@bulletin_file = BulletinFile.new(params[:bulletin_file])
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin } respond_to do |format|
# format.js if @bulletin_file.save
format.js { format.js { render 'create_bulletin_file' }
@info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url} end
flash[:notice] = t('bulletin.create_bulletin_success') end
render "/shared/preview/after_create.js.erb"
} else
else
format.html { render :action => "new" } @bulletin = Bulletin.new(params[:bulletin])
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
format.js {
@info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)} @bulletin.create_user_id = current_user.id
session[:in_validate_object] = @bulletin @bulletin.update_user_id = current_user.id
render "/shared/preview/after_create.js.erb" if(is_manager? || is_admin?)
} @bulletin.is_checked = true
end @bulletin.is_rejected = false
end @bulletin.de_pending
end
end
respond_to do |format|
if @bulletin.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
# format.js
format.js {
@info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
flash[:notice] = t('bulletin.create_bulletin_success')
render "/shared/preview/after_create.js.erb"
}
else
format.html { render :action => "new" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
format.js {
@info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
session[:in_validate_object] = @bulletin
render "/shared/preview/after_create.js.erb"
}
end
end
end
end end
def link_quick_add def link_quick_add
@bulletin_link = BulletinLink.new @bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path @link_url = panel_announcement_back_end_bulletins_path
@bulletin_link.bulletin_id = params[:bulletin_id] @bulletin_link.bulletin_id = params[:bulletin_id]
respond_to do |format| respond_to do |format|
format.js format.js
end end
end end
def link_quick_edit def link_quick_edit
@ -189,14 +219,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end end
end end
def file_quick_add def file_quick_add
@bulletin_file = BulletinFile.new @bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path @file_url = panel_announcement_back_end_bulletins_path
@bulletin_file.bulletin_id = params[:bulletin_id] @bulletin_file.bulletin_id = params[:bulletin_id]
respond_to do |format| respond_to do |format|
format.js format.js
end end
end end
def file_quick_edit def file_quick_edit
@ -211,75 +240,71 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# PUT /bulletins/1.xml # PUT /bulletins/1.xml
def update def update
if params[:bulletin_link] if params[:bulletin_link]
@bulletin_link = BulletinLink.find(params[:id])
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link) @bulletin_link = BulletinLink.find(params[:id])
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
respond_to do |format| respond_to do |format|
if @bulletin_link.update_attributes(params[:bulletin_link])
if @bulletin_link.update_attributes(params[:bulletin_link]) # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) } format.js { render 'update_bulletin_link' }
format.js { render 'update_bulletin_link' } end
end end
end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.find(params[:id])
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format| elsif params[:bulletin_file]
if @bulletin_file.update_attributes(params[:bulletin_file]) @bulletin_file = BulletinFile.find(params[:id])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) } @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
format.js { render 'update_bulletin_file' } respond_to do |format|
end
end if @bulletin_file.update_attributes(params[:bulletin_file])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
else format.js { render 'update_bulletin_file' }
end
@bulletin = Bulletin.find(params[:id]) end
# @bulletin.image.clear if params[:bulletin][:image_del] == '1' else
# if params[:bulletin][:image_del] == '1'
# @bulletin.remove_image! @bulletin = Bulletin.find(params[:id])
# @bulletin.image_del = nil
# params[:bulletin][:image_del] = nil # @bulletin.image.clear if params[:bulletin][:image_del] == '1'
# end # if params[:bulletin][:image_del] == '1'
# @bulletin.remove_image!
# @bulletin.image_del = nil
# params[:bulletin][:image_del] = nil
# end
delete_out_invalid_date_from_params delete_out_invalid_date_from_params
respond_to do |format| respond_to do |format|
if @bulletin.update_attributes(params[:bulletin]) if @bulletin.update_attributes(params[:bulletin])
if(is_manager? || is_admin?) if(is_manager? || is_admin?)
@bulletin.is_checked = true @bulletin.is_checked = true
@bulletin.is_rejected = false @bulletin.is_rejected = false
@bulletin.de_pending! @bulletin.de_pending!
end end
# if (params[:bulletin][:is_checked] == "false") # if (params[:bulletin][:is_checked] == "false")
# @bulletin.is_rejected = true # @bulletin.is_rejected = true
# @bulletin.save! # @bulletin.save!
# end # end
# if (@bulletin.deadline < @bulletin.postdate rescue nil) # if (@bulletin.deadline < @bulletin.postdate rescue nil)
# @bulletin.deadline = nil # @bulletin.deadline = nil
# @bulletin.update_user_id = current_user.id # @bulletin.update_user_id = current_user.id
# @bulletin.save! # @bulletin.save!
# end # end
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' } format.js { render 'toggle_enable' }
format.xml { head :ok } format.xml { head :ok }
else else
get_tags get_tags
format.html { render :action => "edit" } format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end end
end end
end end
end end
@ -291,7 +316,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin.destroy @bulletin.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to(panel_announcement_back_end_bulletins_url) } format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
# format.xml { head :ok } # format.xml { head :ok }
format.js format.js
@ -299,21 +324,21 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end end
# def top_edit # def top_edit
# Bulletin.where(id: params[:id]).update_all( is_top: true ) # Bulletin.where(id: params[:id]).update_all( is_top: true )
# respond_to do |format| # respond_to do |format|
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) } # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
# format.xml { head :ok } # format.xml { head :ok }
# end
# end # end
# end
def load_quick_edit def load_quick_edit
@bulletin = Bulletin.find(params[:id]) @bulletin = Bulletin.find(params[:id])
@type = params[:type] @type = params[:type]
@bulletin_categories = BulletinCategory.all @bulletin_categories = BulletinCategory.all
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好 #TODO 需要做 manager ,admin 才可以 all. 其他 available就好
get_tags get_tags
end end
@ -325,9 +350,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end end
protected protected
def delete_out_invalid_date_from_params def delete_out_invalid_date_from_params
if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?)) if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?))
params[:bulletin].delete("deadline(1i)") params[:bulletin].delete("deadline(1i)")
@ -361,10 +386,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# redirect_to :action => :index # redirect_to :action => :index
# end # end
# end # end
def get_tags def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue [] @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
end end
def clean_values def clean_values
@ -377,5 +402,4 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end rescue nil end rescue nil
end end
end end
end end

View File

@ -10,13 +10,13 @@
<table class="table main-list"> <table class="table main-list">
<thead> <thead>
<tr> <tr>
<th class="span1"><%= t('bulletin.category') %></th> <th class="span1"><%= t('category') %></th>
<th class="span3"><%= t('bulletin.title') %></th> <th class="span3"><%= t('title') %></th>
<th class="span1"><%= t('bulletin.start_date') %></th> <th class="span1"><%= t('start_date') %></th>
<th class="span1"><%= t('bulletin.end_date') %></th> <th class="span1"><%= t('end_date') %></th>
<th class="span1"><%= t('bulletin.tags') %></th> <th class="span1"><%= t('tags') %></th>
<% if not @user%> <% if not @user%>
<th class="span1"><%= t('bulletin.last_modified') %></th> <th class="span1"><%= t('last_modified') %></th>
<% end %> <% end %>
</tr> </tr>
</thead> </thead>
@ -35,7 +35,7 @@
<% if not bulletin.deadline.nil?%> <% if not bulletin.deadline.nil?%>
<td><%= display_date_time(bulletin.deadline) %></td> <td><%= display_date_time(bulletin.deadline) %></td>
<%else%> <%else%>
<td><%= t('bulletin.no_deadline') %></td> <td><%= t('no_deadline') %></td>
<% end %> <% end %>
<td> <td>
<div class="label-group"> <div class="label-group">

View File

@ -6,6 +6,7 @@ Rails.application.routes.draw do
match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
#match 'get_bulletins_json' => "bulletins#get_bulletins_json" ,:as => :bulletins_json_list,:via => :get
resources :bulletins do resources :bulletins do
match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post
@ -18,21 +19,22 @@ Rails.application.routes.draw do
post "preview" post "preview"
put "preview" put "preview"
get 'delete' get 'delete'
get 'get_bulletins_json'
end end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
end end
resources :bulletin_categorys resources :bulletin_categorys
resources :bulletin_links, :controller => 'bulletin_links' do resources :bulletin_links, :controller => 'bulletin_links' do
match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit
end end
resources :bulletin_files, :controller => 'bulletin_files' do resources :bulletin_files, :controller => 'bulletin_files' do
match "file_quick_edit/:bulletin_file_id" => "bulletin_files#file_quick_edit" ,:as => :file_quick_edit match "file_quick_edit/:bulletin_file_id" => "bulletin_files#file_quick_edit" ,:as => :file_quick_edit
end end
resources :tags resources :tags
end end
namespace :front_end do namespace :front_end do

View File

@ -1,190 +1,232 @@
class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
include AdminHelper include AdminHelper
# before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user#,:except => [:index]
def index before_filter :force_order_for_user, :except => [:index,:get_album_json]
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
@categorylist = GalleryCategory.all
@cid = params['cat']
@tags = GalleryTag.all
end
def show def index
if is_manager? || is_admin? || is_sub_manager? if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only @authenticated = true #turn this value to false for view only
else else
@authenticated = false @authenticated = false
end end
@album = GalleryAlbum.find(params[:id]) @categorylist = GalleryCategory.all
@tags = GalleryTag.all @cid = params['cat']
end @tags = GalleryTag.all
end
def new def show
if is_manager? || is_admin? if is_manager? || is_admin? || is_sub_manager?
@categorylist = GalleryCategory.all @authenticated = true #turn this value to false for view only
elsif is_sub_manager? else
@categorylist = GalleryCategory.authed_for_user(current_user,"new_album") @authenticated = false
end end
@album = GalleryAlbum.new @album = GalleryAlbum.find(params[:id])
render :layout => false @tags = GalleryTag.all
end end
def create def new
album = GalleryAlbum.new(params[:gallery_album]) if is_manager? || is_admin?
album.save! @categorylist = GalleryCategory.all
respond_to do |h| elsif is_sub_manager?
h.js @categorylist = GalleryCategory.authed_for_user(current_user,"new_album")
end end
end @album = GalleryAlbum.new
render :layout => false
end
def get_albums def create
@categoryids = params["cid"] album = GalleryAlbum.new(params[:gallery_album])
@tags = params["tid"] album.save!
@albums = Array.new respond_to do |h|
if @categoryids == "all" h.js
if @tags end
if @tags.kind_of?(Array) end
@tags.each do |tag|
@albums << GalleryAlbum.where(tag_ids: tag)
end
else
@albums << GalleryAlbum.where(tag_ids: @tags)
end
else
@albums << GalleryAlbum.all
end
else
@categoryids.each do |id|
category = GalleryCategory.find(id)
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << category.gallery_albums.where(tag_ids: tag)
end
else
@albums << category.gallery_albums.where(tag_ids: @tags)
end
else
@albums << category.gallery_albums.all
end
end
end
@output = Array.new
@albums.each do |album|
@albs = Array.new
album.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
category = GalleryCategory.find(values.gallery_category_id).name
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
@output << @albs
end
render :json=>@output.to_json
end
def destroy def get_albums
album = GalleryAlbum.find(params[:id]) @categoryids = params["cid"]
album.delete @tags = params["tid"]
render :json =>{"success"=>true}.to_json @albums = Array.new
end if @categoryids == "all"
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << GalleryAlbum.where(tag_ids: tag)
end
else
@albums << GalleryAlbum.where(tag_ids: @tags)
end
else
@albums << GalleryAlbum.all
end
else
@categoryids.each do |id|
category = GalleryCategory.find(id)
if @tags
if @tags.kind_of?(Array)
@tags.each do |tag|
@albums << category.gallery_albums.where(tag_ids: tag)
end
else
@albums << category.gallery_albums.where(tag_ids: @tags)
end
else
@albums << category.gallery_albums.all
end
end
end
@output = Array.new
@albums.each do |album|
@albs = Array.new
album.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
category = GalleryCategory.find(values.gallery_category_id).name
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
@output << @albs
end
render :json=>@output.to_json
end
def edit def destroy
if is_manager? || is_admin? || is_sub_manager? album = GalleryAlbum.find(params[:id])
@album = GalleryAlbum.find(params[:id]) album.delete
@images = @album.gallery_images.all render :json =>{"success"=>true}.to_json
@album_name = @album.name_translations end
@cover = @album.cover
@tags = GalleryTag.all
end
end
def set_cover def edit
album = GalleryAlbum.find(params[:album_id]) if is_manager? || is_admin? || is_sub_manager?
image = GalleryImage.find(params[:imageid]) @album = GalleryAlbum.find(params[:id])
album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:imageid]}) @images = @album.gallery_images.all
render :json =>{"success"=>true}.to_json @album_name = @album.name_translations
end @cover = @album.cover
@tags = GalleryTag.all
end
end
def imgs def set_cover
@album = GalleryAlbum.find(params[:album_id]) album = GalleryAlbum.find(params[:album_id])
@tag_names = Array.new image = GalleryImage.find(params[:imageid])
@images = @album.gallery_images.all album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:imageid]})
@output = Array.new render :json =>{"success"=>true}.to_json
@images.each do |values| end
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
@output << {"_id"=>values.id,"theater_link"=>panel_gallery_back_end_album_image_path(values),"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if @authenticated
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
else
@album.tag_ids.each do |tag|
@tag_names << GalleryTag.find(tag)[I18n.locale]
end
render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json
end
end
def upload_panel
@album = GalleryAlbum.find(params[:album_id])
render :layout => false
end
def upload_image
@album = GalleryAlbum.find(params[:album_id])
@files = params['files']
a = Array.new
@files.each do |file|
@image = @album.gallery_images.new
@image.file = file
@image.save!
a << {"thumbnail_url"=>@image.file.thumb.url}
end
render :json=>a.to_json
end
def images_tags
album = GalleryAlbum.find(params[:album_id])
tags = Array.new
images = album.gallery_images.all
images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids}
end
render :json=>tags.to_json
end
def update def get_album_json
@album = GalleryAlbum.find(params[:id]) albums = GalleryAlbum.all
@album.update_attributes(params[:gallery_album]) output = Array.new
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if params['delete_cover'] == "true"
@album.update_attributes(:cover=>"default")
end
@tags = GalleryTag.all
render :action => :show
end
albums.each do |album|
tag_names = Array.new
all_image = Array.new
images = album.gallery_images.all
images.each do |image|
tags = Array.new
image.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
all_image << {
image_title: image.title,
image_description: image.description,
image_file: { url: "http://#{request.host_with_port+image.file.url}",
thumb: "http://#{request.host_with_port+image.file.thumb.to_s}"},
image_tag_names: tags}
end
album.tag_ids.each do |tag|
tag_names << GalleryTag.find(tag)[I18n.locale]
end
output << {
album_cover_file: "http://#{request.host_with_port+album.cover_path}",
album_name: album.name,
album_tag_names: tag_names,
images: all_image
}
end
#render :json=>{:images => @output,
# :tag_names => @tag_names}.to_json
render :json=>JSON.pretty_generate(output)
end
def imgs
@album = GalleryAlbum.find(params[:album_id])
@tag_names = Array.new
@images = @album.gallery_images.all
@output = Array.new
@images.each do |values|
tags = Array.new
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
@output << { _id: values.id,
theater_link: panel_gallery_back_end_album_image_path(values),
description: values.description,
title: values.title,
file: values.file,
gallery_album_id: values.gallery_album_id,
tag_ids: values.tag_ids,
tag_names: tags}
end
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if @authenticated
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
else
@album.tag_ids.each do |tag|
@tag_names << GalleryTag.find(tag)[I18n.locale]
end
render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json
end
end
def upload_panel
@album = GalleryAlbum.find(params[:album_id])
render :layout => false
end
def upload_image
@album = GalleryAlbum.find(params[:album_id])
@files = params['files']
a = Array.new
@files.each do |file|
@image = @album.gallery_images.new
@image.file = file
@image.save!
a << {"thumbnail_url"=>@image.file.thumb.url}
end
render :json=>a.to_json
end
def images_tags
album = GalleryAlbum.find(params[:album_id])
tags = Array.new
images = album.gallery_images.all
images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids}
end
render :json=>tags.to_json
end
def update
@album = GalleryAlbum.find(params[:id])
@album.update_attributes(params[:gallery_album])
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if params['delete_cover'] == "true"
@album.update_attributes(:cover=>"default")
end
@tags = GalleryTag.all
render :action => :show
end
end end

View File

@ -1,4 +1,5 @@
Rails.application.routes.draw do Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :gallery do namespace :gallery do
namespace :back_end do namespace :back_end do
@ -16,12 +17,11 @@ Rails.application.routes.draw do
match "album_images/#!/:id" => "album_images#show" match "album_images/#!/:id" => "album_images#show"
resources :album_images resources :album_images
resources :gallery_categories
resources :tags
resources :gallery_categories end
resources :tags
end namespace :front_end do
namespace :front_end do
match "get_albums" => "albums#get_albums" match "get_albums" => "albums#get_albums"
# match "orbit_galleries" => "orbit_galleries#index" # match "orbit_galleries" => "orbit_galleries#index"
# match "gallery_category_save" => "orbit_galleries#new_category" # match "gallery_category_save" => "orbit_galleries#new_category"
@ -51,6 +51,6 @@ Rails.application.routes.draw do
namespace :widget do namespace :widget do
match "widget1" => "albums#widget1" match "widget1" => "albums#widget1"
end end
end end
end end
end end

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -1,29 +1,77 @@
class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
def index
@newlocation = Location.new
end
def create #before_filter :clean_values, :only => [:create, :update]
debugger
@newlocation = Location.new(params[:location])
@newlocation.save!
render :action => "index"
end
def get_locations before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
locations = Location.all before_filter :force_order_for_user,:except => :get_locations
@data = Array.new #before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations]
locations.each do |location| def index
picurl = "http://"+request.host + location.file.url @locations = Location.all
thumburl = "http://"+request.host + location.file.thumb.url respond_to do |format|
@data << {"name"=>location.name,"pic_url"=>picurl,"thumb_url"=>thumburl,"description"=>location.description} format.html # new.html.erb
end format.json { render json: @locations }
render :json => @data.to_json end
end end
def new
@location = Location.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @location }
end
end
def edit
@location = Location.find(params[:id])
end
def show
@location = Location.find(params[:id])
respond_to do |format|
format.html
format.json { render json: @location }
end
end
def create
@location = Location.new(params[:location])
@location.save!
redirect_to panel_gprs_back_end_locations_url
end
def update
@location = Location.find(params[:id])
@location.update_attributes(params[:location])
redirect_to panel_gprs_back_end_locations_url
end
def destroy
@location = Location.find(params[:id])
@location.destroy
redirect_to panel_gprs_back_end_locations_url
end
def get_locations
locations = Location.all
@data = Array.new
locations.each do |location|
picurl = "http://#{request.host_with_port + location.file.url}",
thumburl = "http://#{request.host_with_port + location.file.thumb.url}"
@data << { name: location.name,
pic_url: picurl,
thumb_url: thumburl,
longitude: location.longitude,
latitude: location.latitude,
description: location.description }
end
#print readable json
render :json => JSON.pretty_generate({location: @data})
#render :json => {location: @data}.to_json
end
end end

View File

@ -0,0 +1,2 @@
module Panel::Gprs::BackEnd::LocationsHelper
end

View File

@ -1,12 +1,11 @@
class Location class Location
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
mount_uploader :file, GprsUploader mount_uploader :file, GprsUploader
field :name field :name
field :description field :description
field :longitude, type: Float field :longitude, type: Float
field :latitude, type: Float field :latitude, type: Float
end
end

View File

@ -0,0 +1,30 @@
<div class="control-group">
<label class="control-label" for="">Name</label>
<div class="controls">
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Picture</label>
<div class="controls">
<%= f.file_field :file %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Coordinates</label>
<div class="controls">
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Description</label>
<div class="controls">
<%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.submit "Save", :class=>"btn" %>
</div>
</div>

View File

@ -0,0 +1,4 @@
<%= form_for @location, :url=> panel_gprs_back_end_location_path(@location), :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -1,42 +1,28 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('location.picture') %></th>
<th class="span1"><%= t('location.name') %></th>
<th class="span1"><%= t('location.longitude') %></th>
<th class="span1"><%= t('location.latitude') %></th>
<th class="span3"><%= t('location.description') %></th>
<th class="span1"><%= t('location.edit') %></th>
<th class="span1"><%= t('location.delete') %></th>
</tr>
</thead>
<tbody id="tbody_locations" class="sort-holder">
<% @locations.each do |location| %>
<tr class="with_action">
<td><%= image_tag(location.file, alt: location.file, size: "50x50" )%></td>
<td><%= location.name%></td>
<td><%= location.longitude%></td>
<td><%= location.latitude%></td>
<td><%= location.description%></td>
<td><%= link_to 'Edit', edit_panel_gprs_back_end_location_path(location) %></td>
<td><%= link_to 'Destroy', panel_gprs_back_end_location_path(location), method: :delete , :confirm => t(:sure?) %></td>
</tr>
<% end %>
</tbody>
</table>
<!-- <form class="form-horizontal"> --> <td><%= link_to 'New', new_panel_gprs_back_end_location_path %></td>
<%= form_for @newlocation, :url=>{:action => "create"}, :remote => true, :class=>"form-horizontal" do |f| %>
<div class="control-group">
<label class="control-label" for="">Name</label>
<div class="controls">
<!-- <input type="text" id="" class="span4" placeholder="Taipei 101"> -->
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Picture</label>
<div class="controls">
<!-- <input type="file" id=""> -->
<%= f.file_field :file %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Coordinates</label>
<div class="controls">
<!-- <input type="text" id="" class="span2" placeholder="long"> -->
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
<!-- <input type="text" id="" class="span2" placeholder="lat"> -->
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Description</label>
<div class="controls">
<!-- <textarea name="" id="" class="span4" cols="30" rows="5"></textarea> -->
<%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<!-- <textarea name="" id="" class="span4" cols="30" rows="5"></textarea> -->
<%= f.submit "Save", :class=>"btn" %>
</div>
</div>
<% end %>
<!-- </form> -->

View File

@ -0,0 +1,3 @@
<%= form_for @location, :url=> panel_gprs_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -1,14 +1,12 @@
Rails.application.routes.draw do Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :gprs do namespace :gprs do
namespace :back_end do namespace :back_end do
match "locations/get_locations" => "locations#get_locations" match "locations/get_locations" => "locations#get_locations"
resources :locations
end
end
end
resources :locations
end
end
end
end end

View File

@ -0,0 +1,14 @@
require 'test_helper'
class Panel::Gprs::BackEnd::LocationsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
test "should get edit" do
get :edit
assert_response :success
end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class Panel::Gprs::BackEnd::LocationsHelperTest < ActionView::TestCase
end