remove unused notification categories fixes #7394

also move notifications in "new email messages" to "administrative alerts",
because that's a much better description of them

test plan:
 * go to communication preferences
 * the last one should be "administrative alerts"
 * "Files", "Private message from student", "New email messages",
   and "Context Message" should be nowhere to be found

Change-Id: I8b30d53b8137ab4b17cb436920d87331327e01f9
Reviewed-on: https://gerrit.instructure.com/8996
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
This commit is contained in:
Cody Cutrer 2012-02-24 13:05:58 -07:00
parent bd76aad8b1
commit 0ce24b5887
19 changed files with 39 additions and 224 deletions

View File

@ -1,16 +0,0 @@
<% define_content :link do %>
http://<%= HostUrl.context_host(asset.context) %>/<%= asset.context.class.to_s.downcase.pluralize %>/<%= asset.context_id %>/files/<%= asset.id %>
<% end %>
<% define_content :subject do %>
New File Added: <%= asset.title %>, <%= asset.context.name %>
<% end %>
A new file has been added for the course, <%= asset.context.name %>:
<%= asset.title %>
<%= asset.readable_size %>
You can view it here:
<%= content :link %>

View File

@ -1,8 +0,0 @@
<% define_content :link do %>
http://<%= HostUrl.context_host(asset.context) %>/<%= asset.context.class.to_s.downcase.pluralize %>/<%= asset.context_id %>/files/<%= asset.id %>
<% end %>
A new file has been added for the course, <%= asset.context.name %>:
<b><a href="<%= content :link %>"><%= asset.title %></a></b> --
<%= asset.readable_size %>

View File

@ -1,6 +0,0 @@
New file added for <%= asset.context.name %>:
<%= asset.title %>
<%= asset.readable_size %>
More info at <%= HostUrl.context_host(asset.context) %>

View File

@ -1,10 +0,0 @@
<% define_content :link do %>
http://<%= HostUrl.context_host(asset.context) %>/<%= asset.context.class.to_s.downcase.pluralize %>/<%= asset.context_id %>/files/<%= asset.id %>
<% end %>
<% define_content :subject do %>
New File Added: <%= asset.title %>, <%= asset.context.name %>
<% end %>
<%= asset.title %>
<%= asset.readable_size %>

View File

@ -1,4 +0,0 @@
<% define_content :link do %>
http://<%= HostUrl.context_host(asset.context) %>/<%= asset.context.class.to_s.downcase.pluralize %>/<%= asset.context_id %>/files/<%= asset.id %>
<% end %>
Canvas Alert - New File: <%= asset.title %>, <%= asset.context.name %>. <%= asset.readable_size %>

View File

@ -219,7 +219,7 @@ class Attachment < ActiveRecord::Base
item.locked = true if hash[:locked]
item.file_state = 'hidden' if hash[:hidden]
item.display_name = hash[:display_name] if hash[:display_name]
item.save_without_broadcasting!
item.save!
context.imported_migration_items << item if context.imported_migration_items
end
item
@ -725,18 +725,7 @@ class Attachment < ActiveRecord::Base
end
filename
end
has_a_broadcast_policy
set_broadcast_policy do |p|
p.dispatch :new_file_added
p.to { context.participants - [user] }
p.whenever { |record|
!@skip_broadcast_messages and
record.context.state == :available and record.just_created and
record.folder.visible?
}
end
def infer_display_name
self.display_name ||= unencoded_filename
end

View File

@ -1868,7 +1868,7 @@ class Course < ActiveRecord::Base
new_folder_id = merge_mapped_id(file.folder)
end
new_file.folder_id = new_folder_id
new_file.save_without_broadcasting!
new_file.save!
map_merge(file, new_file)
end
end

View File

@ -266,7 +266,7 @@ class DiscussionEntry < ActiveRecord::Base
if !dup.attachment_id && self.attachment
attachment = self.attachment.clone_for(context)
attachment.folder_id = nil
attachment.save_without_broadcasting!
attachment.save!
context.map_merge(self.attachment, attachment)
context.warn_merge_result(t :file_added_warning, "Added file \"%{file_path}\" which is needed for an entry in the topic \"%{discussion_topic_title}\"", :file_path => "%{attachment.folder.full_name}/#{attachment.display_name}", :discussion_topic_title => self.discussion_topic.title)
dup.attachment_id = attachment.id

View File

@ -589,7 +589,7 @@ class DiscussionTopic < ActiveRecord::Base
if !dup.attachment_id && self.attachment
attachment = self.attachment.clone_for(context)
attachment.folder_id = nil
attachment.save_without_broadcasting!
attachment.save!
context.map_merge(self.attachment, attachment)
context.warn_merge_result("Added file \"#{attachment.folder.full_name}/#{attachment.display_name}\" which is needed for the topic \"#{self.title}\"")
dup.attachment_id = attachment.id

View File

@ -195,7 +195,7 @@ class Folder < ActiveRecord::Base
if item.is_a?(Attachment)
file = item.clone_for(context)
file.folder_id = dup.id
file.save_without_broadcasting!
file.save!
elsif item.is_a?(Folder)
sub = item.clone_for(context, nil, options)
sub.parent_folder_id = dup.id

View File

@ -282,15 +282,11 @@ class Notification < ActiveRecord::Base
end
end
end
def sort_order
case category
when 'Message'
0
when 'Announcement'
1
when 'Student Message'
2
when 'Grading'
3
when 'Late Grading'
@ -325,7 +321,7 @@ class Notification < ActiveRecord::Base
end
def summarizable?
return !self.registration? && self.category != 'Message'
return !self.registration?
end
def dashboard?
@ -368,8 +364,6 @@ class Notification < ActiveRecord::Base
'immediately'
when 'Course Content'
'never'
when 'Files'
'never'
when 'Discussion'
'never'
when 'DiscussionEntry'
@ -386,10 +380,6 @@ class Notification < ActiveRecord::Base
'daily'
when 'Membership Update'
'daily'
when 'Student Message'
'daily'
when 'Message'
'immediately'
when 'Other'
'daily'
when 'Registration'
@ -459,7 +449,6 @@ class Notification < ActiveRecord::Base
t 'names.new_discussion_entry', 'New Discussion Entry'
t 'names.new_discussion_topic', 'New Discussion Topic'
t 'names.new_event_created', 'New Event Created'
t 'names.new_file_added', 'New File Added'
t 'names.new_student_organized_group', 'New Student Organized Group'
t 'names.new_teacher_registration', 'New Teacher Registration'
t 'names.new_user', 'New User'
@ -501,17 +490,14 @@ class Notification < ActiveRecord::Base
t 'categories.discussion', 'Discussion'
t 'categories.discussion_entry', 'DiscussionEntry'
t 'categories.due_date', 'Due Date'
t 'categories.files', 'Files'
t 'categories.grading', 'Grading'
t 'categories.grading_policies', 'Grading Policies'
t 'categories.invitiation', 'Invitation'
t 'categories.late_grading', 'Late Grading'
t 'categories.membership_update', 'Membership Update'
t 'categories.message', 'Message'
t 'categories.other', 'Other'
t 'categories.registration', 'Registration'
t 'categories.reminder', 'Reminder'
t 'categories.student_message', 'Student Message'
t 'categories.submission_comment', 'Submission Comment'
end
@ -521,8 +507,6 @@ class Notification < ActiveRecord::Base
t(:announcement_description, "For new announcements")
when 'Course Content'
t(:course_content_description, "For changes to course pages")
when 'Files'
t(:files_description, "For new files")
when 'Discussion'
t(:discussion_description, "For new topics")
when 'DiscussionEntry'
@ -542,7 +526,7 @@ class Notification < ActiveRecord::Base
when 'Invitation'
t(:invitation_description, "For new invitations")
when 'Other'
t(:other_description, "For any other notifications")
t(:other_description, "For administrative alerts")
when 'Calendar'
t(:calendar_description, "For calendar changes")
when 'Student Appointment Signups'
@ -553,10 +537,6 @@ class Notification < ActiveRecord::Base
t(:appointment_signups_description, "For appointments you get signed up for")
when 'Appointment Cancelations'
t(:appointment_cancelations_description, "For your appointments that get canceled")
when 'Message'
t(:message_description, "For new email messages")
when 'Student Message'
t(:student_message_description, "For private messages from students")
when 'Conversation Message'
t(:conversation_message_description, "For new conversation messages")
when 'Added To Conversation'

View File

@ -0,0 +1,11 @@
class RemoveUnusedNotificationPolicies < ActiveRecord::Migration
tag :postdeploy
def self.up
ids = Notification.find(:all, :select => 'id', :conditions => { :category => ['Student Message', 'Files']}).map(&:id)
NotificationPolicy.delete_all(:notification_id => ids)
end
def self.down
end
end

View File

@ -0,0 +1,11 @@
class RemoveUnusedNotifications < ActiveRecord::Migration
tag :postdeploy
def self.up
Notification.update_all({:category => 'Other'}, :category => 'Message')
Notification.delete_all(:category => ['Files', 'Student Message'])
end
def self.down
end
end

View File

@ -140,7 +140,7 @@ namespace :db do
A new course, <%= asset.name %>, has been added for the account <%= asset.root_account.name %>
}
create_notification 'StudentReports', 'Message', 0,
create_notification 'StudentReports', 'Other', 0,
'http://<%= HostUrl.default_host %>', %{
Report Generated
@ -151,7 +151,7 @@ namespace :db do
Report generated successfully
}
create_notification 'StudentReports', 'Message', 0,
create_notification 'StudentReports', 'Other', 0,
'http://<%= HostUrl.default_host %>', %{
Report Generation Failed
@ -162,7 +162,7 @@ namespace :db do
Report generation failed
}
create_notification 'ContentMigration', 'Message', 0,
create_notification 'ContentMigration', 'Other', 0,
'http://<%= HostUrl.default_host %>', %{
Migration Export Ready
@ -173,7 +173,7 @@ namespace :db do
The extraction process for the course, <%= asset.migration_settings[:course_name] %>, has completed. To finish importing content into <%= asset.context.name %> you'll need to click the following link:
}
create_notification 'ContentMigration', 'Message', 0,
create_notification 'ContentMigration', 'Other', 0,
'http://<%= HostUrl.default_host %>', %{
Migration Import Finished
@ -184,7 +184,7 @@ namespace :db do
Importing <%= asset.migration_settings[:course_name] %> into <%= asset.context.name %> has finished.
}
create_notification 'ContentMigration', 'Message', 0,
create_notification 'ContentMigration', 'Other', 0,
'http://<%= HostUrl.default_host %>', %{
Migration Import Failed
@ -195,7 +195,7 @@ namespace :db do
There was a problem importing <%= asset.migration_settings[:course_name] %> into <%= asset.context.name %>. Please notify your system administrator, and give them the following error code: "ContentMigration:<%= asset.id %>:<%= asset.progress %>".
}
create_notification 'ContentExport', 'Message', 0,
create_notification 'ContentExport', 'Other', 0,
'http://<%= HostUrl.default_host %>', %{
Content Export Finished
@ -206,7 +206,7 @@ namespace :db do
Your course export for "<%= asset.context.name %>" has finished.
}
create_notification 'ContentExport', 'Message', 0,
create_notification 'ContentExport', 'Other', 0,
'http://<%= HostUrl.default_host %>', %{
Content Export Failed
@ -785,7 +785,7 @@ namespace :db do
You've been added to a new group for the <%= asset.group.context.class.to_s.downcase %> <%= asset.group.context.name %>. The name of the group is <%= asset.group.name %>.
}
create_notification 'Group', 'Message', 0,
create_notification 'Group', 'Other', 0,
'http://<%= HostUrl.context_host(asset.group.context) %>/<%= asset.group.context.class.to_s.downcase.pluralize %>/<%= asset.context_id %>/groups', %{
New Student Organized Group

View File

@ -113,27 +113,7 @@ notifications_018:
subject: "Assignment Graded: <%= asset.assignment.title %>, <%= asset.assignment.context.name %>"
workflow_state: active
created_at: 2009-04-30 23:55:46
notifications_007:
name: New File Added
sms_body: "\n New file added for <%= asset.context.name %>:\n <%= asset.title %>\n \n <%= asset.readable_size %>\n "
category: Course Content
updated_at: 2009-04-30 23:55:46
body: |-
A new file has been added for the course, <%= asset.context.name %>:
<%= asset.title %>
<%= asset.readable_size %>
You can view it here:
http://instructure.com/courses/<%= asset.context_id %>/files/<%= asset.id %>
delay_for: "120"
id: "7"
subject: "New File Added: <%= asset.title %>, <%= asset.context.name %>"
workflow_state: active
created_at: 2009-04-30 23:55:46
notifications_020:
notifications_020:
name: New Wiki Page
sms_body: "\n New wiki page for <%= asset.find_namespace_for_user(user).context.name rescue \"\" %>:\n \n <%= asset.title.titleize %>\n \n <%= strip_and_truncate(asset.body, :max_length => 200) %>\n "
category: Course Content

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
describe 'new_file_added.email' do
it "should render" do
attachment_model
@object = @attachment
generate_message(:new_file_added, :email, @object)
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
describe 'new_file_added.facebook' do
it "should render" do
attachment_model
@object = @attachment
generate_message(:new_file_added, :facebook, @object)
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
describe 'new_file_added.sms' do
it "should render" do
attachment_model
@object = @attachment
generate_message(:new_file_added, :sms, @object)
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
describe 'new_file_added.summary' do
it "should render" do
attachment_model
@object = @attachment
generate_message(:new_file_added, :summary, @object)
end
end