# Mailing list types # # public: true -> anyone can post to it (spammy!) # false -> only members can post to it <-- DEFAULT # closed: true -> only the owner can post to it # false -> other people can post to it <-- DEFAULT # moderated: true -> posted messages go to the owner first # false -> posted messages are broadcast <-- DEFAULT # confirmation: true -> subscriptions have to be confirmed <-- DEFAULT # false -> subscriptions happen automatically # joinable: true -> people can subscribe to the list at will <- DEFAULT # false -> only the owner can subscribe or unsubscribe people # NOTE FOR JOSUIKAI! # ****************** # # There needs to be another kind of "joinable" which says that only # people who already have accounts on the system can join a mailing # list. class AddMailinglistTypes < ActiveRecord::Migration class MailinglistClass < ActiveRecord::Base; end class Mailinglist < ActiveRecord::Base; end class User < ActiveRecord::Base; end def self.up create_table :mailinglist_classes do |t| t.column 'name', :text, :null => false t.column 'description', :text t.column 'public', :boolean, :null => false, :default => false t.column 'closed', :boolean, :null => false, :default => false t.column 'moderated', :boolean, :null => false, :default => false t.column 'confirmation', :boolean, :null => false, :default => true t.column 'joinable', :boolean, :null => false, :default => true end MailinglistClass.new do |mlc| mlc.name = 'LTMA' mlc.description = 'Lifetime Mail Address' mlc.public = true mlc.closed = false mlc.moderated = false mlc.confirmation = true mlc.joinable = false end.save MailinglistClass.new do |mlc| mlc.name = 'Mailing List' mlc.description = 'A normal, unmoderated, private-posting mailing list' mlc.public = false mlc.closed = false mlc.moderated = false mlc.confirmation = true mlc.joinable = true end.save MailinglistClass.new do |mlc| mlc.name = 'Distribution List' # Lifetime Mail Address mlc.description = 'A private distribution list' mlc.public = false mlc.closed = false mlc.moderated = false mlc.confirmation = false mlc.joinable = false end.save add_column :mailinglists, :mailinglist_class_id, :integer ltma_class = MailinglistClass.find_by_name 'LTMA' ml_class = MailinglistClass.find_by_name 'Mailing List' Mailinglist.find_all.each do |ml| if ml.name == User.find(ml.user_id).login then ml.mailinglist_class_id = ltma_class.id else ml.mailinglist_class_id = ml_class.id end ml.save end # change_column :mailinglists, :mailinglist_class_id, :integer, # :null => false # ltma_class = MailinglistClass.find_by_name # Mailinglist.find_all.each do |ml| end def self.down remove_column :mailinglists, :mailinglist_class_id drop_table :mailinglist_classes end end