2014-04-01 07:12:43 +00:00
|
|
|
class AnnouncementsController < ApplicationController
|
|
|
|
|
|
|
|
def index
|
2014-05-02 10:21:51 +00:00
|
|
|
announcements = Bulletin.can_display.order_by(:created_at=>'desc').filter_by_categories
|
2014-05-01 09:28:20 +00:00
|
|
|
anns = announcements.collect do |a|
|
|
|
|
{
|
|
|
|
"title" => a.title,
|
|
|
|
"subtitle" => a.subtitle,
|
2014-05-14 11:51:17 +00:00
|
|
|
"postdate" => a.postdate.strftime("%b %d, %Y at %I:%M %p"),
|
2014-05-01 09:28:20 +00:00
|
|
|
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
|
2014-05-14 11:51:17 +00:00
|
|
|
"img_src" => a.image.thumb.url || "http://placehold.it/100x100",
|
|
|
|
"more" => "More"
|
2014-05-01 09:28:20 +00:00
|
|
|
}
|
2014-04-01 07:12:43 +00:00
|
|
|
end
|
2014-04-02 06:44:36 +00:00
|
|
|
{
|
2014-05-14 11:51:17 +00:00
|
|
|
"announcements" => anns,
|
2014-06-04 12:38:33 +00:00
|
|
|
"extras" => {"widget-title"=>"Announcements"},
|
|
|
|
"total_pages" => announcements.total_pages
|
2014-04-02 06:44:36 +00:00
|
|
|
}
|
2014-04-01 07:12:43 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def widget
|
2014-05-23 05:56:28 +00:00
|
|
|
announcements = Bulletin.can_display.order_by(:created_at=>'desc').filter_by_widget_categories
|
2014-04-02 06:44:36 +00:00
|
|
|
anns = announcements.collect do |a|
|
2014-04-01 07:12:43 +00:00
|
|
|
{
|
|
|
|
"title" => a.title,
|
2014-05-01 09:28:20 +00:00
|
|
|
"subtitle" => a.subtitle,
|
2014-05-23 05:56:28 +00:00
|
|
|
"postdate" => a.postdate.strftime("%b %d, %Y at %I:%M %p"),
|
2014-05-24 11:36:23 +00:00
|
|
|
"link_to_show" => OrbitHelper.widget_item_url(a.to_param),
|
2014-05-23 05:56:28 +00:00
|
|
|
"img_src" => a.image.thumb.url || "http://placehold.it/100x100",
|
2014-04-01 07:12:43 +00:00
|
|
|
}
|
|
|
|
end
|
2014-04-02 06:44:36 +00:00
|
|
|
{
|
2014-05-23 05:56:28 +00:00
|
|
|
"announcements" => anns,
|
2014-05-24 11:36:23 +00:00
|
|
|
"extras" => {"widget-title"=>"Announcements","more_url"=>OrbitHelper.widget_more_url}
|
2014-04-02 06:44:36 +00:00
|
|
|
}
|
2014-04-01 07:12:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show
|
2014-04-21 07:39:13 +00:00
|
|
|
params = OrbitHelper.params
|
2014-05-15 11:27:05 +00:00
|
|
|
|
2014-05-02 10:21:51 +00:00
|
|
|
announcement = Bulletin.can_display.find_by(:uid=>params[:uid])
|
2014-05-05 07:48:49 +00:00
|
|
|
|
2014-05-14 11:51:17 +00:00
|
|
|
tags = announcement.tags.map{|tag| { "tag" => tag.name } } rescue []
|
|
|
|
files = announcement.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => file.title } } rescue []
|
|
|
|
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => link.title } } rescue []
|
|
|
|
update_user = announcement.update_user.member_profile.name rescue ""
|
2014-05-05 07:48:49 +00:00
|
|
|
{
|
2014-05-05 08:30:18 +00:00
|
|
|
"tags" => tags,
|
2014-05-05 07:48:49 +00:00
|
|
|
"bulletin_files" => files,
|
|
|
|
"bulletin_links" => links,
|
|
|
|
"data" => {
|
2014-05-02 10:21:51 +00:00
|
|
|
"title" => announcement.title,
|
2014-05-14 11:51:17 +00:00
|
|
|
"update_user" => update_user,
|
2014-05-05 08:30:18 +00:00
|
|
|
"updated_at" => announcement.updated_at.strftime('%Y-%m-%d %H:%M'),
|
2014-05-05 07:48:49 +00:00
|
|
|
"body" =>announcement.text,
|
|
|
|
"image" => announcement.image.url
|
2014-05-15 11:27:05 +00:00
|
|
|
},
|
|
|
|
"impressionist" => announcement
|
2014-05-05 07:48:49 +00:00
|
|
|
}
|
2014-04-02 06:44:36 +00:00
|
|
|
end
|
|
|
|
|
2014-04-01 07:12:43 +00:00
|
|
|
end
|