Module: Droom
- Defined in:
- lib/droom/folders.rb,
lib/droom.rb,
lib/droom/engine.rb,
lib/droom/version.rb,
lib/droom/lazy_hash.rb,
app/models/droom/tag.rb,
app/models/droom/user.rb,
lib/droom/auth_cookie.rb,
lib/droom/taggability.rb,
lib/droom/user_config.rb,
app/models/droom/event.rb,
app/models/droom/group.rb,
app/models/droom/scrap.rb,
app/models/droom/venue.rb,
app/models/droom/folder.rb,
app/models/droom/ability.rb,
app/models/droom/service.rb,
app/models/droom/tagging.rb,
app/models/droom/calendar.rb,
app/models/droom/category.rb,
app/models/droom/document.rb,
app/models/droom/event_set.rb,
app/models/droom/event_type.rb,
app/models/droom/invitation.rb,
app/models/droom/membership.rb,
app/models/droom/permission.rb,
app/models/droom/preference.rb,
app/models/droom/organisation.rb,
app/helpers/droom/droom_helper.rb,
app/models/droom/dropbox_token.rb,
app/models/droom/agenda_category.rb,
app/models/droom/personal_folder.rb,
app/models/droom/user_permission.rb,
app/models/droom/dropbox_document.rb,
app/models/droom/group_invitation.rb,
app/models/droom/group_permission.rb,
app/controllers/droom/users_controller.rb,
app/controllers/droom/engine_controller.rb,
app/controllers/droom/events_controller.rb,
app/controllers/droom/groups_controller.rb,
app/controllers/droom/scraps_controller.rb,
app/controllers/droom/venues_controller.rb,
app/controllers/droom/folders_controller.rb,
app/controllers/droom/youtube_controller.rb,
app/models/droom/mailing_list_membership.rb,
app/controllers/droom/services_controller.rb,
app/controllers/droom/calendars_controller.rb,
app/controllers/droom/dashboard_controller.rb,
app/controllers/droom/documents_controller.rb,
lib/generators/droom/views/views_generator.rb,
app/controllers/droom/invitations_controller.rb,
app/controllers/droom/memberships_controller.rb,
app/controllers/droom/permissions_controller.rb,
app/controllers/droom/preferences_controller.rb,
app/controllers/droom/suggestions_controller.rb,
app/controllers/droom/confirmations_controller.rb,
app/controllers/droom/organisations_controller.rb,
lib/generators/droom/install/install_generator.rb,
app/controllers/droom/dropbox_tokens_controller.rb,
app/controllers/droom/agenda_categories_controller.rb,
app/controllers/droom/group_invitations_controller.rb,
app/controllers/droom/group_permissions_controller.rb,
lib/generators/droom/dashboard/dashboard_generator.rb
Overview
This class has the awkward job of giving access to the mailing list membership records stored in legacy mailman mysql tables. They’re likely to be held in another database, and they have an extremely un-rails-like schema, so our main job is to translate between their and our conventions.
This whole mechanism and its configuration requirements can safely be ignored unless you want to use it, in which case you should set ‘Droom.enable_mailing_lists` to true in an initializer and read on.
If you don’t set ‘enable_mailing_lists` then some database activity will still go on, but with no consequence, and the mailing list interface controls will not appear.
Requirements
The MailingListMembership class is able to interface directly with your existing mailman data, with the addition of a couple of columns to support activerecord associations. It’s mostly just a case of configuring access to the old data.
### Mailman data held in MySQL tables with the ‘flat’ data structure
There are two options here. Either you can use the standard table that has already been created here, or you can define a ‘mailman_` connection in database.yml that points to an external mailman database. In that case see the notes below about adding a couple of columns.
### Mailman configured to use MySQL
If you don’t have an existing mailmanmysql setup, it takes a few steps to point your mailman installation at this database and table. It can be done either globally or on a per-list basis, so it is possible to keep your existing mailman installation but add a new database-backed mailing list.
Mysql storage is considered modern and a bit racy in the mailman community, having only been available since the early 2000s. It’s not officially supported until mailman 3 coalesces out of the ether but if you speak any python it’s easy to make it work with 2.x. Two sets of dusty patches are available here:
http://wiki.list.org/pages/viewpage.action?pageId=15564884
and I’ve found the slightly less ancient version from rezo.net works well:
http://trac.rezo.net/trac/rezo/browser/Mailman
In order that we can store membership of different lists in the same table, please make sure that mailman is using the ‘flat’ data structure. If you want to enable mysql just for selected lists, put an ‘extend.py` in each list directory and leave the rest of your configuration as it is.
It is currently a good idea to avoid reserved words in your mailing list names. They’ll work in rails but not in python, where the quoting of some database queries seems to be less than perfect.
### Minor changes to the mailman table
The local table is already set up in a way that should work equally well with rails and mailman. If you’re using a remote mailman table, it will need a couple of small changes:
**An id column as primary key.** Strictly speaking we should define a composite primary key based on address & listname, but it’s much easier just to add an auto_incrementing id column and make that the primary key. Mailman doesn’t care as long as its columns are there. You probably also want to create a unique index on address+listname so that mailman gets the benefit and sees the expected behaviour.
**A membership_id column** We could (and used to) twist Activerecord out of shape by defining associations with address and listname primary keys between mailing list memberships and people and groups, but again it’s much easier just to belong_to a group membership. For that we need a membership_id column. Again, you will want an index on that column.
Defined Under Namespace
Modules: Api, DroomHelper, Folders, Taggability, Users Classes: Ability, AgendaCategoriesController, AgendaCategory, AuthCookie, AuthRequired, Calendar, CalendarsController, Category, ConfirmationsController, DashboardController, DashboardGenerator, Document, DocumentsController, DroomError, DropboxDocument, DropboxToken, DropboxTokensController, Engine, EngineController, Event, EventSet, EventType, EventsController, Folder, FoldersController, Group, GroupInvitation, GroupInvitationsController, GroupPermission, GroupPermissionsController, GroupsController, InstallGenerator, Invitation, InvitationsController, LazyHash, MailingListMembership, Membership, MembershipsController, Organisation, OrganisationsController, Permission, PermissionDenied, PermissionsController, PersonalFolder, Preference, PreferencesController, PreferencesHash, Scrap, ScrapsController, Service, ServicesController, SuggestionsController, Tag, Tagging, User, UserPermission, UserSerializer, UsersController, Venue, VenueSerializer, VenuesController, ViewsGenerator, YoutubeController
Constant Summary collapse
- VERSION =
"0.5.3"
Class Method Summary collapse
- .add_suggestible_class(label, klass = nil) ⇒ Object
- .all_documents_public? ⇒ Boolean
- .all_events_public? ⇒ Boolean
- .aws_bucket ⇒ Object
- .aws_bucket_name ⇒ Object
- .calendar_closed? ⇒ Boolean
- .default_scrap_type ⇒ Object
- .devise_layout ⇒ Object
- .dropbox_app_name ⇒ Object
- .email_from ⇒ Object
- .email_from_name ⇒ Object
- .email_host ⇒ Object
- .email_layout ⇒ Object
- .email_return_path ⇒ Object
- .enable_mailing_lists? ⇒ Boolean
- .home_country ⇒ Object
- .home_url ⇒ Object
- .layout ⇒ Object
- .mailing_lists_active_by_default? ⇒ Boolean
- .mailing_lists_digest_by_default? ⇒ Boolean
- .mailman_table_name ⇒ Object
- .main_dashboard_modules ⇒ Object
- .margin_dashboard_modules ⇒ Object
- .panels ⇒ Object
- .password_pattern ⇒ Object
- .people_sort ⇒ Object
- .required_calendar_names ⇒ Object
- .root_path ⇒ Object
- .scrap_types ⇒ Object
- .second_time_zone? ⇒ Boolean
- .separate_calendars? ⇒ Boolean
-
.set_user_default(key, value) ⇒ Object
Here we are overriding droom default settings in a host app initializer to create local default settings.
- .show_venue_map? ⇒ Boolean
- .sign_out_path ⇒ Object
- .stream_shared? ⇒ Boolean
- .suggestible_classes ⇒ Object
- .use_biogs? ⇒ Boolean
- .use_chinese_names? ⇒ Boolean
- .use_honours? ⇒ Boolean
- .use_organisations? ⇒ Boolean
- .use_separate_mobile_number? ⇒ Boolean
- .use_titles? ⇒ Boolean
- .user_default(key) ⇒ Object
-
.user_defaults ⇒ Object
Droom’s preferences are arbitrary and open-ended.
- .yt_client ⇒ Object
Class Method Details
.add_suggestible_class(label, klass = nil) ⇒ Object
207 208 209 210 |
# File 'lib/droom.rb', line 207 def add_suggestible_class(label, klass=nil) klass ||= label.camelize suggestible_classes[label] = klass.to_s end |
.all_documents_public? ⇒ Boolean
173 174 175 |
# File 'lib/droom.rb', line 173 def all_documents_public? !!@@all_documents_public end |
.all_events_public? ⇒ Boolean
169 170 171 |
# File 'lib/droom.rb', line 169 def all_events_public? !!@@all_events_public end |
.aws_bucket ⇒ Object
220 221 222 |
# File 'lib/droom.rb', line 220 def aws_bucket @@aws_bucket ||= Fog::Storage.new(Droom::Engine.config.paperclip_defaults[:fog_credentials]).directories.get(@@aws_bucket_name) end |
.aws_bucket_name ⇒ Object
216 217 218 |
# File 'lib/droom.rb', line 216 def aws_bucket_name @@aws_bucket_name ||= nil end |
.calendar_closed? ⇒ Boolean
165 166 167 |
# File 'lib/droom.rb', line 165 def calendar_closed? !!@@calendar_closed end |
.default_scrap_type ⇒ Object
129 130 131 |
# File 'lib/droom.rb', line 129 def default_scrap_type @@default_scrap_type ||= 'text' end |
.devise_layout ⇒ Object
73 74 75 |
# File 'lib/droom.rb', line 73 def devise_layout @@devise_layout ||= "application" end |
.dropbox_app_name ⇒ Object
177 178 179 |
# File 'lib/droom.rb', line 177 def dropbox_app_name @@dropbox_app_name ||= 'droom' end |
.email_from ⇒ Object
85 86 87 |
# File 'lib/droom.rb', line 85 def email_from @@email_from ||= "[email protected]" end |
.email_from_name ⇒ Object
89 90 91 |
# File 'lib/droom.rb', line 89 def email_from_name @@email_from ||= "Please Set Email-From Name In Droom Initializer" end |
.email_host ⇒ Object
77 78 79 |
# File 'lib/droom.rb', line 77 def email_host @@email_host ||= "please-change-email-host-in-droom-initializer.example.com" end |
.email_layout ⇒ Object
81 82 83 |
# File 'lib/droom.rb', line 81 def email_layout @@email_layout ||= "email" end |
.email_return_path ⇒ Object
93 94 95 |
# File 'lib/droom.rb', line 93 def email_return_path @@email_return_path ||= email_from end |
.enable_mailing_lists? ⇒ Boolean
161 162 163 |
# File 'lib/droom.rb', line 161 def enable_mailing_lists? !!@@enable_mailing_lists end |
.home_country ⇒ Object
109 110 111 |
# File 'lib/droom.rb', line 109 def home_country Snail.home_country = @@home_country ||= 'gb' end |
.home_url ⇒ Object
65 66 67 |
# File 'lib/droom.rb', line 65 def home_url @@home_url ||= "http://example.com" end |
.layout ⇒ Object
69 70 71 |
# File 'lib/droom.rb', line 69 def layout @@layout ||= "application" end |
.mailing_lists_active_by_default? ⇒ Boolean
185 186 187 |
# File 'lib/droom.rb', line 185 def mailing_lists_active_by_default? !!@@mailing_lists_active_by_default end |
.mailing_lists_digest_by_default? ⇒ Boolean
189 190 191 |
# File 'lib/droom.rb', line 189 def mailing_lists_digest_by_default? !!@@mailing_lists_digest_by_default end |
.mailman_table_name ⇒ Object
181 182 183 |
# File 'lib/droom.rb', line 181 def mailman_table_name @@mailman_table_name ||= 'mailman_mysql' end |
.main_dashboard_modules ⇒ Object
113 114 115 |
# File 'lib/droom.rb', line 113 def main_dashboard_modules @@main_dashboard_modules ||= %w{my_future_events my_folders} end |
.margin_dashboard_modules ⇒ Object
117 118 119 |
# File 'lib/droom.rb', line 117 def margin_dashboard_modules @@margin_dashboard_modules ||= %w{quicksearch stream} end |
.panels ⇒ Object
121 122 123 |
# File 'lib/droom.rb', line 121 def panels @@panels ||= %w{configuration search admin} end |
.password_pattern ⇒ Object
236 237 238 |
# File 'lib/droom.rb', line 236 def password_pattern @@password_pattern ||= ".{6,}" end |
.people_sort ⇒ Object
97 98 99 |
# File 'lib/droom.rb', line 97 def people_sort @@people_sort ||= "position ASC" end |
.required_calendar_names ⇒ Object
224 225 226 |
# File 'lib/droom.rb', line 224 def required_calendar_names @@required_calendar_names ||= %w{main stream} end |
.root_path ⇒ Object
105 106 107 |
# File 'lib/droom.rb', line 105 def root_path @@root_path ||= "dashboard#index" end |
.scrap_types ⇒ Object
125 126 127 |
# File 'lib/droom.rb', line 125 def scrap_types @@scrap_types ||= %w{image video text quote link event document} end |
.second_time_zone? ⇒ Boolean
232 233 234 |
# File 'lib/droom.rb', line 232 def second_time_zone? !!@@second_time_zone end |
.separate_calendars? ⇒ Boolean
228 229 230 |
# File 'lib/droom.rb', line 228 def separate_calendars? !!@@separate_calendars end |
.set_user_default(key, value) ⇒ Object
Here we are overriding droom default settings in a host app initializer to create local default settings. key should be dot-separated and string-like:
Droom.set_default('email.digest', true)
LazyHash#deep_set is a setter that can take compound keys and set nested values. It’s defined in lib/lazy_hash.rb.
266 267 268 |
# File 'lib/droom.rb', line 266 def set_user_default(key, value) user_defaults.set(key, value) end |
.show_venue_map? ⇒ Boolean
193 194 195 |
# File 'lib/droom.rb', line 193 def show_venue_map? !!@@show_venue_map end |
.sign_out_path ⇒ Object
101 102 103 |
# File 'lib/droom.rb', line 101 def sign_out_path @@sign_out_path ||= "/users/sign_out" end |
.stream_shared? ⇒ Boolean
153 154 155 |
# File 'lib/droom.rb', line 153 def stream_shared? !!@@stream_shared end |
.suggestible_classes ⇒ Object
197 198 199 200 201 202 203 204 205 |
# File 'lib/droom.rb', line 197 def suggestible_classes @@suggestible_classes ||= { "event" => "Droom::Event", "user" => "Droom::User", "document" => "Droom::Document", "group" => "Droom::Group", "venue" => "Droom::Venue" } end |
.use_biogs? ⇒ Boolean
145 146 147 |
# File 'lib/droom.rb', line 145 def use_biogs? !!@@use_biogs end |
.use_chinese_names? ⇒ Boolean
133 134 135 |
# File 'lib/droom.rb', line 133 def use_chinese_names? !!@@use_chinese_names end |
.use_honours? ⇒ Boolean
141 142 143 |
# File 'lib/droom.rb', line 141 def use_honours? !!@@use_honours end |
.use_organisations? ⇒ Boolean
149 150 151 |
# File 'lib/droom.rb', line 149 def use_organisations? !!@@use_organisations end |
.use_separate_mobile_number? ⇒ Boolean
157 158 159 |
# File 'lib/droom.rb', line 157 def use_separate_mobile_number? !!@@use_separate_mobile_number end |
.use_titles? ⇒ Boolean
137 138 139 |
# File 'lib/droom.rb', line 137 def use_titles? !!@@use_titles end |
.user_default(key) ⇒ Object
270 271 272 |
# File 'lib/droom.rb', line 270 def user_default(key) user_defaults.get(key) end |
.user_defaults ⇒ Object
Droom’s preferences are arbitrary and open-ended. You can ask for any preference key: if it doesn’t exist you just get back the default value, or nil if there isn’t one. This is where you set the defaults.
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/droom.rb', line 244 def user_defaults @@user_defaults ||= Droom::LazyHash.new({ :email => { :enabled? => true, :mailing_lists? => true, :event_invitations? => false, :digest? => false }, :dropbox => { :strategy => "clicked", :events? => true, } }) end |
.yt_client ⇒ Object
212 213 214 |
# File 'lib/droom.rb', line 212 def yt_client @@yt_client ||= YouTubeIt::Client.new(:dev_key => "AI39si473p0K4e6id0ZrM1vniyk8pdbqr67hH39hyFjW_JQoLg9xi6BecWFtraoPMCeYQmRgIc_XudGKVU8tmeQF8VHwjOUg8Q") end |