fix calendar broken

This commit is contained in:
Fu Matthew 2013-01-03 10:58:52 +08:00
parent 10473af154
commit 5d6279a9ea
6 changed files with 48 additions and 1 deletions

View File

@ -2,8 +2,9 @@ class ApplicationController < ActionController::Base
protect_from_forgery
include ParserFrontEnd, ParserBackEnd, ApplicationHelper
include OrbitApp::ErrorHandlers::ObjectAuthErrorHandler
include OrbitApp::ErrorHandlers
rescue_from ObjectAuthError, :with => :render_object_auth_error
rescue_from ModuleAppError, :with => :render_module_app_error
layout :layout_by_resource

View File

@ -13,6 +13,7 @@ class OrbitBackendController < ApplicationController
def setup_vars
@app_title ||= controller_path.split('/')[1].singularize
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
raise ModuleAppError, 'Can not find ModuleApp' if @module_app.nil?
end
private

View File

@ -0,0 +1,3 @@
class ModuleAppError < StandardError
end

View File

@ -0,0 +1,16 @@
module OrbitApp
module ErrorHandlers
module ModuleAppErrorHandler
def render_module_app_error(exception = nil)
default_message = 'ModuleAppErrorHandler'
meaasge = ''
if exception
meaasge = default_message + exception.message
end
render :text=>meaasge
end
end
end
end

View File

@ -338,4 +338,16 @@ namespace :migrate do
@module_app.save
end
task :reinstall_calendar => :environment do
old_calendar = ModuleApp.where(key: "calendar")
old_calendar.destroy_all unless old_calendar.empty?
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/calendar/calendar.json").read).save
end
task :reinstall_gallery => :environment do
old_gallery = ModuleApp.where(key: "gallery")
old_gallery.destroy_all unless old_gallery.empty?
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/gallery/gallery.json").read).save
end
end

View File

@ -0,0 +1,14 @@
{
"title": "calendar",
"version": "0.1",
"organization": "Rulingcom",
"author": "Visual dep",
"intro": "A simple and amazing calendar",
"update_info": "Some info",
"create_date": "11-08-2012",
"app_pages": ["calendar"],
"widgets": [],
"category": [],
"widget_fields":[],
"enable_frontend": true
}