From a6b6a0da3477719e0109ad6175b16f04d37b2550 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Tue, 10 Aug 2010 16:17:03 +1200 Subject: Better settings, update notified has a form but doesn't yet work. Created script files but not using them yet. --- app/controllers/admin/blog/settings_controller.rb | 14 ++++++++++--- app/models/blog_comment.rb | 20 +++++++++++++++--- app/views/admin/blog/_submenu.html.erb | 3 ++- .../blog/settings/notification_recipients.html.erb | 24 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 app/views/admin/blog/settings/notification_recipients.html.erb (limited to 'app') diff --git a/app/controllers/admin/blog/settings_controller.rb b/app/controllers/admin/blog/settings_controller.rb index 962e8d1..52a7e83 100644 --- a/app/controllers/admin/blog/settings_controller.rb +++ b/app/controllers/admin/blog/settings_controller.rb @@ -1,12 +1,20 @@ class Admin::Blog::SettingsController < Admin::BaseController - def update_notified + def notification_recipients + @recipients = BlogComment::Notification.recipients + if request.post? + BlogComment::Notification.recipients == params[:recipients] + end end def moderation - BlogComment::Moderation.toggle - redirect_back_or_default(admin_blog_posts_path) + enabled = BlogComment::Moderation.toggle + unless request.xhr? + redirect_back_or_default(admin_blog_posts_path) + else + render :json => {:enabled => enabled} + end end end diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index aced256..04651fe 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -17,10 +17,24 @@ class BlogComment < ActiveRecord::Base end def toggle - currently = self.enabled? - RefinerySetting[:comment_moderation] = !currently + RefinerySetting[:comment_moderation] = !(currently = self.enabled?) end end end -end + module Notification + class << self + def recipients + RefinerySetting.find_or_set(:comment_notification_recipients, { + :value => (Role[:refinery].users.first.email rescue ''), + :scoping => :blog + }) + end + + def recipients=(emails) + RefinerySetting[:comment_notification_recipients] = emails + end + end + end + +end \ No newline at end of file diff --git a/app/views/admin/blog/_submenu.html.erb b/app/views/admin/blog/_submenu.html.erb index 89fe69c..e03e476 100644 --- a/app/views/admin/blog/_submenu.html.erb +++ b/app/views/admin/blog/_submenu.html.erb @@ -59,7 +59,8 @@ :class => "#{BlogComment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
  • - <%= link_to t('.settings.update_notified'), update_notified_admin_blog_settings_url(:dialog => true), + <%= link_to t('.settings.update_notified'), + notification_recipients_admin_blog_settings_url(:dialog => true, :height => 400), :class => 'user_comment_icon' %>
  • diff --git a/app/views/admin/blog/settings/notification_recipients.html.erb b/app/views/admin/blog/settings/notification_recipients.html.erb new file mode 100644 index 0000000..ea36af1 --- /dev/null +++ b/app/views/admin/blog/settings/notification_recipients.html.erb @@ -0,0 +1,24 @@ +<% form_tag do %> + +
    + + <%= label_tag :recipients, t('.value') %> + + <%= text_field_tag :recipients, @recipients, :class => "larger widest" %> +
    + +

    + <%= t('.hint') %> +

    +

    + <%= t('.example') %> +

    + + <%= render :partial => "/shared/admin/form_actions", + :locals => { + :f => nil, + :continue_editing => false, + :cancel_url => admin_blog_posts_url, + :hide_delete => true + } %> +<% end %> -- cgit v1.2.3