diff --git a/app/assets/images/discussion_settings.png b/app/assets/images/discussion_settings.png new file mode 100644 index 0000000..2d7a1df Binary files /dev/null and b/app/assets/images/discussion_settings.png differ diff --git a/app/controllers/comment_thread_subscriptions_controller.rb b/app/controllers/comment_thread_subscriptions_controller.rb index 1bd38b6..b6dc1c5 100644 --- a/app/controllers/comment_thread_subscriptions_controller.rb +++ b/app/controllers/comment_thread_subscriptions_controller.rb @@ -40,7 +40,7 @@ def destroy respond_to do |format| format.html do - if @comment_thread.commentable_type == 'Message' + if @comment_thread.commentable_type == 'Discussion' redirect_to inbox_path else redirect_to(polymorphic_path([@commentable, :comments])) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 3689bc3..b5e41e6 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -30,7 +30,7 @@ def new @comment = Comment.new @comment.comment_thread = @comment_thread @comment.creator = present_user - if @comment_thread.commentable_type == 'Message' + if @comment_thread.commentable_type == 'Discussion' @create_verb = 'Send' @comment_name = 'Reply' else @@ -55,7 +55,7 @@ def create @comment.comment_thread = @comment_thread @comment.creator = present_user - if @comment_thread.commentable_type == 'Message' + if @comment_thread.commentable_type == 'Discussion' @comment_notice = 'Reply sent.' @hide_votes = true else @@ -94,7 +94,7 @@ def show def edit raise SecurityTransgression unless present_user.can_update?(@comment) - if @comment_thread.commentable_type == 'Message' + if @comment_thread.commentable_type == 'Discussion' @comment_name = 'Reply' else @comment_name = 'Comment' @@ -110,7 +110,7 @@ def edit def update raise SecurityTransgression unless present_user.can_update?(@comment) - if @comment_thread.commentable_type == 'Message' + if @comment_thread.commentable_type == 'Discussion' @comment_notice = 'Reply updated.' else @comment_notice = 'Comment updated.' diff --git a/app/controllers/messages_controller.rb b/app/controllers/discussions_controller.rb similarity index 51% rename from app/controllers/messages_controller.rb rename to app/controllers/discussions_controller.rb index 926d579..57bced6 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/discussions_controller.rb @@ -1,19 +1,19 @@ # Copyright 2011-2012 Rice University. Licensed under the Affero General Public # License version 3 or later. See the COPYRIGHT file for details. -class MessagesController < ApplicationController +class DiscussionsController < ApplicationController before_filter :include_jquery - before_filter :get_message, :only => [:add_recipient, :search_recipients, :leave] + before_filter :get_discussion, :only => [:add_recipient, :search_recipients, :leave] - # GET /messages/1 + # GET /discussions/1 def show - @message = Message.find(params[:id]) + @discussion = Discussion.find(params[:id]) - raise SecurityTransgression unless present_user.can_read?(@message) + raise SecurityTransgression unless present_user.can_read?(@discussion) - @message.comment_thread.mark_as_read_for(present_user) + @discussion.comment_thread.mark_as_read_for(present_user) present_user.reload respond_to do |format| @@ -21,55 +21,55 @@ def show end end - # GET /messages/new + # GET /discussions/new def new - @message = Message.new + @discussion = Discussion.new - raise SecurityTransgression unless present_user.can_create?(@message) + raise SecurityTransgression unless present_user.can_create?(@discussion) respond_to do |format| - if @message.save - @message.comment_thread.subscribe!(present_user) - format.html { redirect_to @message } + if @discussion.save + @discussion.comment_thread.subscribe!(present_user) + format.html { redirect_to @discussion } else format.html { redirect_to inbox_path } end end end - # PUT /messages/1 + # PUT /discussions/1 def update - @message = Message.find(params[:id]) + @discussion = Discussion.find(params[:id]) - raise SecurityTransgression unless present_user.can_create?(@message) + raise SecurityTransgression unless present_user.can_create?(@discussion) - @message.subject = params[:message][:subject] + @discussion.subject = params[:discussion][:subject] @comment = Comment.new - @comment.message = params[:message][:body] - @comment.comment_thread = @message.comment_thread + @comment.message = params[:discussion][:body] + @comment.comment_thread = @discussion.comment_thread @comment.creator = present_user raise SecurityTransgression unless present_user.can_create?(@comment) respond_to do |format| - if @message.save && @comment.save - @message.comment_thread.add_unread_except_for(present_user) + if @discussion.save && @comment.save + @discussion.comment_thread.add_unread_except_for(present_user) flash[:notice] = 'Message was sent successfully.' - format.html { redirect_to @message } + format.html { redirect_to @discussion } else - format.html { redirect_to @message } + format.html { redirect_to @discussion } end end end def leave - @message.comment_thread.unsubscribe!(present_user) + @discussion.comment_thread.unsubscribe!(present_user) end def new_recipient @action_dialog_title = "Add a recipient" - @action_search_path = message_search_recipients_path(params[:message_id]) + @action_search_path = discussion_search_recipients_path(params[:discussion_id]) respond_to do |format| format.js { render :template => 'users/action_new' } @@ -82,39 +82,39 @@ def search_recipients @users = User.search(@selected_type, @text_query) @users.reject! do |user| - @message.has_recipient?(user) + @discussion.has_recipient?(user) end - @action_partial = 'messages/create_recipient_form' + @action_partial = 'discussions/create_recipient_form' respond_to do |format| format.js { render :template => 'users/action_search' } end end - # POST /messages/1/add_recipient + # POST /discussions/1/add_recipient def add_recipient - raise SecurityTransgression unless present_user.can_update?(@message) + raise SecurityTransgression unless present_user.can_update?(@discussion) @recipient = User.find_by_username(params[:username]) if @recipient.nil? flash[:alert] = 'User ' + params[:username] + ' not found!' respond_to do |format| - format.html { redirect_to @message } + format.html { redirect_to @discussion } format.js { render :template => 'shared/display_flash' } end return end respond_to do |format| - if @message.comment_thread.subscribe!(@recipient) - @message.comment_thread.mark_as_unread_for(@recipient) - format.html { redirect_to @message } + if @discussion.comment_thread.subscribe!(@recipient) + @discussion.comment_thread.mark_as_unread_for(@recipient) + format.html { redirect_to @discussion } format.js else - flash[:alert] = @message.comment_thread.errors.values.to_sentence - format.html { redirect_to @message } + flash[:alert] = @discussion.comment_thread.errors.values.to_sentence + format.html { redirect_to @discussion } format.js { render :template => 'shared/display_flash' } end end @@ -122,8 +122,8 @@ def add_recipient protected - def get_message - @message = Message.find(params[:message_id]) + def get_discussion + @discussion = Discussion.find(params[:discussion_id]) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fc1947e..b6808fe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -143,8 +143,8 @@ def commentable_name(comment_thread) question_id_text(comment_thread.commentable.question) when 'Project' comment_thread.commentable.name - when 'Message' - "message: " + comment_thread.commentable.subject + when 'Discussion' + "discussion: " + comment_thread.commentable.subject end end diff --git a/test/unit/message_test.rb b/app/helpers/discussions_helper.rb similarity index 50% rename from test/unit/message_test.rb rename to app/helpers/discussions_helper.rb index c4ce2dd..fac42c6 100644 --- a/test/unit/message_test.rb +++ b/app/helpers/discussions_helper.rb @@ -1,11 +1,5 @@ # Copyright 2011-2012 Rice University. Licensed under the Affero General Public # License version 3 or later. See the COPYRIGHT file for details. -require 'test_helper' - -class MessageTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end +module DiscussionsHelper end diff --git a/app/mailers/subscription_notifier.rb b/app/mailers/subscription_notifier.rb index dd1072b..4c4b774 100644 --- a/app/mailers/subscription_notifier.rb +++ b/app/mailers/subscription_notifier.rb @@ -10,7 +10,7 @@ def comment_created_email(comment) mail(:bcc => @active_subscribers.reject{ |as| as == @creator }.collect { |as| as.email }, :subject => @creator.full_name + - (@is_message ? " sent you a message: " + @commentable.subject : + (@is_discussion ? " sent you a message: " + @commentable.subject : " has commented on a thread to which you subscribe")).deliver end @@ -23,7 +23,7 @@ def setup_variables(comment) @commentable = @comment_thread.commentable.becomes( Kernel.const_get(@comment_thread.commentable_type)) @active_subscribers = User.subscribers_for(@comment_thread).active_users - @is_message = @comment_thread.commentable_type == 'Message' + @is_discussion = @comment_thread.commentable_type == 'Discussion' end end diff --git a/app/models/comment.rb b/app/models/comment.rb index ecaf1c8..c5e2e16 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -29,16 +29,16 @@ def can_be_created_by?(user) end def can_be_updated_by?(user) - !user.is_anonymous? && user == creator && (comment_thread.commentable_type != 'Message' || comment_thread.comments.last == self) + !user.is_anonymous? && user == creator && (comment_thread.commentable_type != 'Discussion' || comment_thread.comments.last == self) end def can_be_destroyed_by?(user) !user.is_anonymous? && (user == creator || user.is_administrator?) && - (comment_thread.commentable_type != 'Message' || comment_thread.comments.last == self) + (comment_thread.commentable_type != 'Discussion' || comment_thread.comments.last == self) end def can_be_voted_on_by?(user) - can_be_read_by?(user) && user != creator && comment_thread.commentable_type != 'Message' + can_be_read_by?(user) && user != creator && comment_thread.commentable_type != 'Discussion' end end diff --git a/app/models/comment_thread_subscription.rb b/app/models/comment_thread_subscription.rb index 05e9c22..5111bcf 100644 --- a/app/models/comment_thread_subscription.rb +++ b/app/models/comment_thread_subscription.rb @@ -10,34 +10,33 @@ class CommentThreadSubscription < ActiveRecord::Base validates_uniqueness_of :user_id, :scope => :comment_thread_id - scope :message_subscriptions, joins{comment_thread}.where{comment_thread.commentable_type == "Message"} + scope :discussion_subscriptions, joins{comment_thread}.where{comment_thread.commentable_type == "Discussion"} - def self.message_subscriptions_for(user) - where{user_id == user.id}.message_subscriptions + def self.discussion_subscriptions_for(user) + where{user_id == user.id}.discussion_subscriptions end def mark_all_as_read! update_attribute(:unread_count, 0) - update_message_cache + update_discussion_cache end def mark_all_as_unread! update_attribute(:unread_count, comment_thread.comments.count) - update_message_cache + update_discussion_cache end def add_unread! update_attribute(:unread_count, unread_count + 1) - update_message_cache + update_discussion_cache end protected - def update_message_cache - return unless comment_thread.commentable_type == 'Message' - user.update_attribute(:unread_message_count, - Array.new(CommentThreadSubscription.message_subscriptions_for(user)).sum { |ms| - ms.unread_count }) + def update_discussion_cache + return unless comment_thread.commentable_type == 'Discussion' + user.update_attribute(:unread_discussion_count, + Array.new(CommentThreadSubscription.discussion_subscriptions_for(user)).sum { |ms| + ms.unread_count }) end - end diff --git a/app/models/message.rb b/app/models/discussion.rb similarity index 85% rename from app/models/message.rb rename to app/models/discussion.rb index 49ba3c6..89766e4 100644 --- a/app/models/message.rb +++ b/app/models/discussion.rb @@ -1,7 +1,7 @@ # Copyright 2011-2012 Rice University. Licensed under the Affero General Public # License version 3 or later. See the COPYRIGHT file for details. -class Message < ActiveRecord::Base +class Discussion < ActiveRecord::Base has_one :comment_thread, :as => :commentable, :dependent => :destroy before_validation :build_comment_thread, :on => :create @@ -12,8 +12,8 @@ class Message < ActiveRecord::Base attr_accessible #none - def self.messages_for(user) - CommentThreadSubscription.message_subscriptions_for(user).collect { |cts| cts.comment_thread.commentable } + def self.discussions_for(user) + CommentThreadSubscription.discussion_subscriptions_for(user).collect { |cts| cts.comment_thread.commentable } end def subject @@ -59,7 +59,7 @@ def can_be_joined_by?(user) def subject_not_changed return if !subject_changed? || comment_thread.comments.blank? - errors.add(:base, "You can't change a message's subject after it is sent.") + errors.add(:base, "You can't change a discussion's subject after it is sent.") false end diff --git a/app/models/user.rb b/app/models/user.rb index 1ac0f1a..0abf056 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -128,8 +128,8 @@ def can_join?(container_type, container_id) return Question.find(container_id).can_be_joined_by?(self) when 'project' return Project.find(container_id).can_be_joined_by?(self) - when 'message' - return Message.find(container_id).can_be_joined_by?(self) + when 'discussion' + return Discussion.find(container_id).can_be_joined_by?(self) end end diff --git a/app/views/comment_thread_subscriptions/_subscription_link.html.erb b/app/views/comment_thread_subscriptions/_subscription_link.html.erb index b47640f..dd8d2c7 100644 --- a/app/views/comment_thread_subscriptions/_subscription_link.html.erb +++ b/app/views/comment_thread_subscriptions/_subscription_link.html.erb @@ -7,10 +7,10 @@ subscription ||= false %> <% sub_string = subscription ? "Unsubscribe" : "Subscribe" %> -<% show_confirm = (subscription && commentable.comment_thread.commentable_type == 'Message') %> +<% show_confirm = (subscription && commentable.comment_thread.commentable_type == 'Discussion') %> <%= link_to sub_string, polymorphic_path([sub_string.downcase, commentable, :comments]), :confirm => (show_confirm ? "Are you sure?\n" + - "Once you unsubscribe from this message, " + + "Once you unsubscribe from this discussion, " + "you will not be able to see it anymore." : nil), :remote => true %> diff --git a/app/views/comment_thread_subscriptions/destroy.js.erb b/app/views/comment_thread_subscriptions/destroy.js.erb index 8795f71..edbf544 100644 --- a/app/views/comment_thread_subscriptions/destroy.js.erb +++ b/app/views/comment_thread_subscriptions/destroy.js.erb @@ -1,7 +1,7 @@ <%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file for details. %> -<% if @comment_thread.commentable_type == 'Message' %> +<% if @comment_thread.commentable_type == 'Discussion' %> window.location.replace("<%= escape_javascript(inbox_path) %>") <% else %> <%= display_flash %> diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 1950837..9117f3c 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -3,7 +3,7 @@ <%= display_flash(false) %> -<% if @comment_thread.commentable_type == 'Message' %> +<% if @comment_thread.commentable_type == 'Discussion' %> $(".edit_link").hide(); $(".delete_link").hide(); <% end %> diff --git a/app/views/messages/_create_recipient_form.html.erb b/app/views/discussions/_create_recipient_form.html.erb similarity index 85% rename from app/views/messages/_create_recipient_form.html.erb rename to app/views/discussions/_create_recipient_form.html.erb index c1ccc1d..81aed08 100644 --- a/app/views/messages/_create_recipient_form.html.erb +++ b/app/views/discussions/_create_recipient_form.html.erb @@ -3,9 +3,9 @@ <%# Callers must supply a 'user' local variable %> -<%= form_tag(message_add_recipient_path(@message), +<%= form_tag(discussion_add_recipient_path(@discussion), :method => :post, :remote => true) do %> <%= hidden_field_tag :username, user.username %> <%= submit_tag "Add", :class => submit_classes, :onclick => please_wait_js %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/discussions/_discussion_list.html.erb b/app/views/discussions/_discussion_list.html.erb new file mode 100644 index 0000000..0e0b5ea --- /dev/null +++ b/app/views/discussions/_discussion_list.html.erb @@ -0,0 +1,22 @@ +<%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public + License version 3 or later. See the COPYRIGHT file for details. %> + +<% discussions = Discussion.discussions_for(current_user) %> + +
Subject | ++ | Recipients | +
---|---|---|
No Discussions | +
To: | - <% @message.recipients.each do |recipient| %> + <% @discussion.recipients.each do |recipient| %> <%= render :partial => 'recipient', :locals => {:recipient => recipient} %> <% end %> | <%= link_to "Add recipients ...", - message_new_recipient_path(@message), + discussion_new_recipient_path(@discussion), :remote => true %> |
Discussions in Quadbase are different than what one would think, you can't specifically send a discussion to someone as you would in an email. Instead discussions are automatically generated when question attributes are altered from the default settings.
+The alterable attributes include toggling role requests and adding a collaborator to a workspace. Settings regarding when discussions are sent to a user are personable, and can be edited under the account tab on the upper-right hand corner of every Quadbase page. Click on this tab, and you will see discussion settings towards the bottom.
+These discussion settings are in the form of check boxes. Click on the boxes next to the setting you want to alter, and then click the update button near the bottom left of the screen. Here is an example configuration for discussion settings.
+Play around with the discussion settings to see when you would prefer to be notified of new entries in a discussion
diff --git a/app/views/help/roles_help.html.erb b/app/views/help/roles_help.html.erb index 2a98fa9..e7112e0 100644 --- a/app/views/help/roles_help.html.erb +++ b/app/views/help/roles_help.html.erb @@ -42,4 +42,4 @@If the user accepts the role request, he or she becomes the author or copyright holder or whatever role was assigned to them. If the user rejects the role request, the roles remain unchanged and as they were before the role change request was made.
\ No newline at end of file +If the user accepts the role request, he or she becomes the author or copyright holder or whatever role was assigned to them. If the user rejects the role request, the roles remain unchanged and as they were before the role change request was made.
diff --git a/app/views/help/topics/_discussions.html.erb b/app/views/help/topics/_discussions.html.erb new file mode 100644 index 0000000..1141d95 --- /dev/null +++ b/app/views/help/topics/_discussions.html.erb @@ -0,0 +1,4 @@ +<%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public + License version 3 or later. See the COPYRIGHT file for details. %> + +Discussions allow you to communicate with other Quadbase users. They work just like e-mail discussions, except that e-mail addresses are never revealed. diff --git a/app/views/inbox/index.html.erb b/app/views/inbox/index.html.erb index e67a407..fe8ed13 100644 --- a/app/views/inbox/index.html.erb +++ b/app/views/inbox/index.html.erb @@ -45,10 +45,10 @@Subject | -- | Recipients | -
---|---|---|
None | -