2014-10-15 12:49:29 +00:00
|
|
|
class UpgradeController < ApplicationController
|
|
|
|
def index
|
|
|
|
data = nil
|
|
|
|
case params[:module]
|
|
|
|
when "announcement"
|
|
|
|
data = get_announcements
|
|
|
|
else
|
|
|
|
data = {"success" => false, "msg" => "Module not found."}
|
|
|
|
end
|
|
|
|
render :json => data.to_json
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_announcements
|
|
|
|
ma = ModuleApp.find_by_key("announcement")
|
|
|
|
|
|
|
|
categories = ma.categories.collect do |c|
|
|
|
|
{
|
|
|
|
"title" => c.title_translations,
|
|
|
|
"disable" => c.disable
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
tags = ma.tags.collect do |t|
|
|
|
|
{
|
|
|
|
"name" => t.name_translations,
|
|
|
|
"is_default" => t.is_default
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
bulletins = Bulletin.all.collect do |b|
|
|
|
|
image = request.protocol + request.host_with_port + b.image.url if !b.image.nil? && b.image.to_s != "sign-in-logo.png"
|
|
|
|
links = b.bulletin_links.collect do |bl|
|
|
|
|
{
|
|
|
|
"title" => bl.title_translations,
|
|
|
|
"url" => bl.url
|
|
|
|
}
|
|
|
|
end
|
|
|
|
files = b.bulletin_files.collect do |bf|
|
2014-10-17 06:24:15 +00:00
|
|
|
file = request.protocol + request.host_with_port + bf.file.url rescue nil
|
2014-10-15 12:49:29 +00:00
|
|
|
{
|
|
|
|
"title" => bf.title_translations,
|
|
|
|
"description" => bf.description_translations,
|
|
|
|
"file" => file
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
ts = b.tags.collect do |t|
|
|
|
|
{
|
|
|
|
"name" => t.name_translations
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
{
|
|
|
|
"id" => b.id.to_s,
|
|
|
|
"title" => b.title_translations,
|
|
|
|
"subtitle" => b.subtitle_translations,
|
|
|
|
"text" => b.text_translations,
|
|
|
|
"public" => b.public,
|
|
|
|
"email_sent" => b.email_sent,
|
|
|
|
"email_sentdate" => b.email_sentdate,
|
|
|
|
"other_mailaddress" => b.other_mailaddress,
|
|
|
|
"category" => b.category.title_translations,
|
|
|
|
"tags" => ts,
|
|
|
|
"image" => image,
|
|
|
|
"links" => links,
|
|
|
|
"files" => files
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
return {"announcements" => bulletins, "categories" => categories, "tags" => tags, "success" => true}
|
|
|
|
end
|
|
|
|
end
|