diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index fd0eae9f0..fb06768f6 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -36,6 +36,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon # GET /bulletins/1/edit def edit @bulletin_category = BulletinCategory.find(params[:id]) + @i18n_variable = @bulletin_category.i18n_variable end # POST /bulletins diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 5aaadd883..ee95a91ce 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -2,12 +2,16 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController layout 'admin' + before_filter :authenticate_user! + before_filter :is_admin? + def index # @bulletins = Bulletin.all # @bulletins = Bulletin.desc("postdate desc") get_categorys(params[:bulletin_category_id]) - @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] + # @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] + @bulletins = Bulletin.desc("postdate") respond_to do |format| @@ -19,16 +23,16 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # GET /bulletins/1 # GET /bulletins/1.xml def show - # @bulletin = Bulletin.find(params[:id]) + @bulletin = Bulletin.find(params[:id]) # get_categorys - @bulletin_categorys = BulletinCategory.where("_id" => params[:id]) + # @bulletin_categorys = BulletinCategory.where("_id" => params[:id]) - if params[:id] - @bulletins = Bulletin.where("bulletin_category_id" => params[:id]) - else - @bulletins = Bulletin.desc("postdate desc") - end + # if params[:id] + # @bulletins = Bulletin.where("bulletin_category_id" => params[:id]) + # else + # @bulletins = Bulletin.desc("postdate desc") + # end respond_to do |format| format.html # show.html.erb @@ -55,6 +59,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # GET /bulletins/1/edit def edit @bulletin = Bulletin.find(params[:id]) + # @summary_variable = @bulletin.summary_variable get_categorys end @@ -62,6 +67,9 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # POST /bulletins.xml def create @bulletin = Bulletin.new(params[:bulletin]) + + @bulletin.create_user_id = current_user.id + @bulletin.update_user_id = current_user.id respond_to do |format| if @bulletin.save @@ -80,6 +88,8 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController def update @bulletin = Bulletin.find(params[:id]) + @bulletin.update_user_id = current_user.id + # @bulletin.image.clear if params[:bulletin][:image_del] == '1' if params[:bulletin][:image_del] == '1' @bulletin.remove_image! @@ -104,7 +114,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # DELETE /bulletins/1.xml def destroy @bulletin = Bulletin.find(params[:id]) - @bulletin.bulletin_files.destroy + # @bulletin.bulletin_files.destroy @bulletin.destroy respond_to do |format| diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index ceab1e424..510950042 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -6,22 +6,27 @@ class Bulletin include Mongoid::MultiParameterAttributes # field :category_id, :type => Integer - field :title, :type => String - field :subtitle, :type => String - field :text, :type => String + field :title + field :summary + field :text field :postdate , :type => Date field :deadline , :type => Date + field :url + field :create_user_id + field :update_user_id mount_uploader :image, ImageUploader belongs_to :bulletin_category # embeds_many :bulletin_files - has_many :bulletin_files, :autosave => true, :dependent => :destroy + embeds_many :bulletin_files, :cascade_callbacks => true + + # has_many :bulletin_files, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :bulletin_files, :allow_destroy => true - validates_presence_of :title, :subtitle, :text + validates_presence_of :title after_save :save_bulletin_files diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb index 652b55483..bff246d11 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb @@ -3,10 +3,11 @@ class BulletinCategory include Mongoid::Document include Mongoid::Timestamps - include Mongoid::MultiParameterAttributes + # include Mongoid::MultiParameterAttributes field :key - field :name + # field :name + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :bulletins diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb index 5483a58e7..28062d40a 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb @@ -11,6 +11,7 @@ class BulletinFile # field :to_save, :type => Boolean field :should_destroy, :type => Boolean - belongs_to :bulletin + # belongs_to :bulletin + embedded_in :bulletin end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb index 3445cec45..68c12afd4 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb @@ -1,15 +1,29 @@ - <%= f.error_messages %> -
<%= t('bulletin_category.key') %> | + <% @site_valid_locales.each do |locale| %> +<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> | + <% end %> +
<%= f.text_field :key %> + <%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + | <%= f.text_field locale, :style => "width:130px" %> | + <% end %> + <% end %> +
<%= t('bulletin_category.key') %> | -<%= t('bulletin_category.name') %> | + <% @site_valid_locales.each do |locale| %> +<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> | + <% end %><%= t('bulletin.action') %> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%= post.key %> | -<%= post.name %> | + <% @site_valid_locales.each do |locale| %> +<%= post.i18n_variable[locale] rescue nil %> | + <% end %>
<%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(post) %> |
<%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(post), :confirm => t('announcement.sure?'), :method => :delete %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb
index 04e015d4d..b840a60b0 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb
@@ -4,7 +4,7 @@
<%= f.label :category %>
- <%= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.name, t.id ]} %> + <%= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %>
@@ -22,8 +22,8 @@
- <%= f.label :subtitle %>
- <%= f.text_field :subtitle %> + <%= f.label :summary %> + <%= f.text_area :summary, :rows => 10, :cols => 40 %>
@@ -40,6 +40,12 @@
<%= f.label :deadline %>
+
+ <%= f.date_select :deadline, :use_month_numbers => true, :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year'} %> + <%#= f.date_select :deadline, :order => [:year, :month, :day],:default => 1.years.from_now, :use_month_numbers => true %> +
+ <%= f.label :url %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - ¦³¤ÀÃþ.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - ¦³¤ÀÃþ.erb
new file mode 100644
index 000000000..80dc0e7e0
--- /dev/null
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - ¦³¤ÀÃþ.erb
@@ -0,0 +1,64 @@
+<% content_for :secondary do %>
++ <%= f.text_field :url, :size => 60 %> + + + + +
<%= t('bulletin.list_announcement') %>++ + + + + +<% @bulletin_categorys.each do |t| %> + + <%= link_to t.i18n_variable[I18n.locale], panel_announcement_back_end_bulletins_path(:bulletin_category_id => t.id ) %>+ +
+ diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb index ad25217e4..71895eef4 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb @@ -6,6 +6,7 @@
-<% @bulletin_categorys.each do |t| %> - - <%= link_to t.name, panel_announcement_back_end_bulletins_path(:bulletin_category_id => t.id ) %>-
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb index 35fbf4a52..4cf1132c7 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb @@ -1,59 +1,57 @@ -<% content_for :secondary do %> - - - - - -
<%= t('bulletin.list_announcement') %>-- -<% @bulletin_categorys.each do |t| %> + <%= flash_messages %> -<%= t.name %>- -
+<%= link_back %> |