Commit 804762aebfe8d80bca2b4bfad4f6499b50880520
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branches 'rails3' and 'rails3_stable' into rails3_stable
Showing
36 changed files
with
41 additions
and
1233 deletions
Show diff stats
Gemfile
Gemfile.lock
... | ... | @@ -61,7 +61,7 @@ GEM |
61 | 61 | database_cleaner (1.2.0) |
62 | 62 | diff-lcs (1.1.3) |
63 | 63 | erubis (2.7.0) |
64 | - eventmachine (0.12.11) | |
64 | + eventmachine (1.0.3) | |
65 | 65 | fast_gettext (0.6.8) |
66 | 66 | ffi (1.0.11) |
67 | 67 | gherkin (2.4.21) |
... | ... | @@ -75,7 +75,10 @@ GEM |
75 | 75 | i18n (>= 0.4.0) |
76 | 76 | mime-types (~> 1.16) |
77 | 77 | treetop (~> 1.4.8) |
78 | + metaclass (0.0.4) | |
78 | 79 | mime-types (1.19) |
80 | + mocha (0.11.3) | |
81 | + metaclass (~> 0.0.1) | |
79 | 82 | multi_json (1.3.6) |
80 | 83 | nokogiri (1.5.5) |
81 | 84 | pg (0.13.2) |
... | ... | @@ -164,6 +167,7 @@ DEPENDENCIES |
164 | 167 | database_cleaner |
165 | 168 | fast_gettext |
166 | 169 | hpricot |
170 | + mocha | |
167 | 171 | nokogiri |
168 | 172 | pg |
169 | 173 | prototype-rails | ... | ... |
app/models/community.rb
1 | 1 | class Community < Organization |
2 | 2 | |
3 | - attr_accessible :accessor_id, :accessor_type, :role_id, :resource_id, :resource_type | |
3 | + attr_accessible :accessor_id, :accessor_type, :role_id, :resource_id, :resource_type, :address_reference, :district, :tag_list, :language | |
4 | 4 | after_destroy :check_invite_member_for_destroy |
5 | 5 | |
6 | 6 | def self.type_name | ... | ... |
app/models/enterprise.rb
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 | # only enterprises can offer products and services. |
3 | 3 | class Enterprise < Organization |
4 | 4 | |
5 | + attr_accessible :business_name, :address_reference, :district, :tag_list, :organization_website, :historic_and_current_context, :activities_short_description, :products_per_catalog_page | |
6 | + | |
5 | 7 | SEARCH_DISPLAYS += %w[map full] |
6 | 8 | |
7 | 9 | def self.type_name | ... | ... |
app/models/environment.rb.orig
... | ... | @@ -1,938 +0,0 @@ |
1 | -# A Environment is like a website to be hosted in the platform. It may | |
2 | -# contain multiple Profile's and can be identified by several different | |
3 | -# domains. | |
4 | -class Environment < ActiveRecord::Base | |
5 | - | |
6 | -<<<<<<< HEAD | |
7 | - attr_accessible :name, :is_default, :signup_welcome_text_subject, :signup_welcome_text_body, :terms_of_use, :message_for_disabled_enterprise, :news_amount_by_folder, :default_language, :languages, :description, :organization_approval_method, :enabled_plugins, :enabled_features, :enabled_blocks, :redirection_after_login, :redirection_after_signup, :contact_email, :theme, :reports_lower_bound, :noreply_email, :signup_welcome_screen_body | |
8 | -======= | |
9 | - attr_accessible :name, :is_default, :signup_welcome_text_subject, :signup_welcome_text_body, :terms_of_use, :message_for_disabled_enterprise, :news_amount_by_folder, :default_language, :languages, :description, :organization_approval_method, :enabled_plugins, :enabled_features, :disabled_blocks, :redirection_after_login, :redirection_after_signup, :contact_email, :theme, :reports_lower_bound | |
10 | ->>>>>>> rails3_AI3163-enable_disable_blocks | |
11 | - | |
12 | - has_many :users | |
13 | - | |
14 | - self.partial_updates = false | |
15 | - | |
16 | - has_many :tasks, :dependent => :destroy, :as => 'target' | |
17 | - | |
18 | - IDENTIFY_SCRIPTS = /(php[0-9s]?|[sp]htm[l]?|pl|py|cgi|rb)/ | |
19 | - | |
20 | - def self.verify_filename(filename) | |
21 | - filename += '.txt' if File.extname(filename) =~ IDENTIFY_SCRIPTS | |
22 | - filename | |
23 | - end | |
24 | - | |
25 | - PERMISSIONS['Environment'] = { | |
26 | - 'view_environment_admin_panel' => N_('View environment admin panel'), | |
27 | - 'edit_environment_features' => N_('Edit environment features'), | |
28 | - 'edit_environment_design' => N_('Edit environment design'), | |
29 | - 'manage_environment_categories' => N_('Manage environment categories'), | |
30 | - 'manage_environment_roles' => N_('Manage environment roles'), | |
31 | - 'manage_environment_validators' => N_('Manage environment validators'), | |
32 | - 'manage_environment_users' => N_('Manage environment users'), | |
33 | - 'manage_environment_templates' => N_('Manage environment templates'), | |
34 | - 'manage_environment_licenses' => N_('Manage environment licenses'), | |
35 | - 'manage_environment_trusted_sites' => N_('Manage environment trusted sites'), | |
36 | - 'edit_appearance' => N_('Edit appearance'), | |
37 | - } | |
38 | - | |
39 | - module Roles | |
40 | - def self.admin(env_id) | |
41 | - Role.find_by_key_and_environment_id('environment_administrator', env_id) | |
42 | - end | |
43 | - end | |
44 | - | |
45 | - after_create :create_roles | |
46 | - def create_roles | |
47 | - Role.create!( | |
48 | - :key => 'environment_administrator', | |
49 | - :name => N_('Environment Administrator'), | |
50 | - :environment => self, | |
51 | - :permissions => PERMISSIONS[Environment.name].keys + PERMISSIONS[Profile.name].keys | |
52 | - ) | |
53 | - Role.create!( | |
54 | - :key => 'profile_admin', | |
55 | - :name => N_('Profile Administrator'), | |
56 | - :environment => self, | |
57 | - :permissions => PERMISSIONS[Profile.name].keys | |
58 | - ) | |
59 | - # members for enterprises, communities etc | |
60 | - Role.create!( | |
61 | - :key => "profile_member", | |
62 | - :name => N_('Member'), | |
63 | - :environment => self, | |
64 | - :permissions => [ | |
65 | - 'invite_members', | |
66 | - ] | |
67 | - ) | |
68 | - # moderators for enterprises, communities etc | |
69 | - Role.create!( | |
70 | - :key => 'profile_moderator', | |
71 | - :name => N_('Moderator'), | |
72 | - :environment => self, | |
73 | - :permissions => [ | |
74 | - 'manage_memberships', | |
75 | - 'edit_profile_design', | |
76 | - 'manage_products', | |
77 | - 'manage_friends', | |
78 | - 'perform_task' | |
79 | - ] | |
80 | - ) | |
81 | - end | |
82 | - | |
83 | - def add_admin(user) | |
84 | - self.affiliate(user, Environment::Roles.admin(self.id)) | |
85 | - end | |
86 | - | |
87 | - def remove_admin(user) | |
88 | - self.disaffiliate(user, Environment::Roles.admin(self.id)) | |
89 | - end | |
90 | - | |
91 | - def admins | |
92 | - Person.members_of(self).all(:conditions => ['role_assignments.role_id = ?', Environment::Roles.admin(self).id]) | |
93 | - end | |
94 | - | |
95 | - # returns the available features for a Environment, in the form of a | |
96 | - # hash, with pairs in the form <tt>'feature_name' => 'Feature name'</tt>. | |
97 | - def self.available_features | |
98 | - { | |
99 | - 'disable_asset_articles' => _('Disable search for articles '), | |
100 | - 'disable_asset_enterprises' => _('Disable search for enterprises'), | |
101 | - 'disable_asset_people' => _('Disable search for people'), | |
102 | - 'disable_asset_communities' => _('Disable search for communities'), | |
103 | - 'disable_asset_products' => _('Disable search for products'), | |
104 | - 'disable_asset_events' => _('Disable search for events'), | |
105 | - 'disable_categories' => _('Disable categories'), | |
106 | - 'disable_header_and_footer' => _('Disable header/footer editing by users'), | |
107 | - 'disable_gender_icon' => _('Disable gender icon'), | |
108 | - 'disable_categories_menu' => _('Disable the categories menu'), | |
109 | - 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), | |
110 | - 'disable_contact_person' => _('Disable contact for people'), | |
111 | - 'disable_contact_community' => _('Disable contact for groups/communities'), | |
112 | - | |
113 | - 'products_for_enterprises' => _('Enable products for enterprises'), | |
114 | - 'enterprise_registration' => _('Enterprise registration'), | |
115 | - 'enterprise_activation' => _('Enable activation of enterprises'), | |
116 | - 'enterprises_are_disabled_when_created' => _('Enterprises are disabled when created'), | |
117 | - 'enterprises_are_validated_when_created' => _('Enterprises are validated when created'), | |
118 | - | |
119 | - 'media_panel' => _('Media panel in WYSIWYG editor'), | |
120 | - 'select_preferred_domain' => _('Select preferred domains per profile'), | |
121 | - 'use_portal_community' => _('Use the portal as news source for front page'), | |
122 | - 'user_themes' => _('Allow users to create their own themes'), | |
123 | - 'search_in_home' => _("Display search form in home page"), | |
124 | - | |
125 | - 'cant_change_homepage' => _("Don't allow users to change which article to use as homepage"), | |
126 | - 'display_header_footer_explanation' => _("Display explanation about header and footer"), | |
127 | - 'articles_dont_accept_comments_by_default' => _("Articles don't accept comments by default"), | |
128 | - 'organizations_are_moderated_by_default' => _("Organizations have moderated publication by default"), | |
129 | - 'enable_organization_url_change' => _("Allow organizations to change their URL"), | |
130 | - 'admin_must_approve_new_communities' => _("Admin must approve creation of communities"), | |
131 | - 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'), | |
132 | - 'xmpp_chat' => _('XMPP/Jabber based chat'), | |
133 | - 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'), | |
134 | - 'captcha_for_logged_users' => _('Ask captcha when a logged user comments too'), | |
135 | - 'skip_new_user_email_confirmation' => _('Skip e-mail confirmation for new users'), | |
136 | - 'send_welcome_email_to_new_users' => _('Send welcome e-mail to new users'), | |
137 | - 'allow_change_of_redirection_after_login' => _('Allow users to set the page to redirect after login'), | |
138 | - 'display_my_communities_on_user_menu' => _('Display on menu the list of communities the user can manage'), | |
139 | - 'display_my_enterprises_on_user_menu' => _('Display on menu the list of enterprises the user can manage') | |
140 | - } | |
141 | - end | |
142 | - | |
143 | - def self.login_redirection_options | |
144 | - { | |
145 | - 'keep_on_same_page' => _('Stays on the same page the user was before login.'), | |
146 | - 'site_homepage' => _('Redirects the user to the environment homepage.'), | |
147 | - 'user_profile_page' => _('Redirects the user to his profile page.'), | |
148 | - 'user_homepage' => _('Redirects the user to his homepage.'), | |
149 | - 'user_control_panel' => _('Redirects the user to his control panel.') | |
150 | - } | |
151 | - end | |
152 | - validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true | |
153 | - | |
154 | - def self.signup_redirection_options | |
155 | - { | |
156 | - 'keep_on_same_page' => _('Stays on the same page the user was before signup.'), | |
157 | - 'site_homepage' => _('Redirects the user to the environment homepage.'), | |
158 | - 'user_profile_page' => _('Redirects the user to his profile page.'), | |
159 | - 'user_homepage' => _('Redirects the user to his homepage.'), | |
160 | - 'user_control_panel' => _('Redirects the user to his control panel.') | |
161 | - } | |
162 | - end | |
163 | - validates_inclusion_of :redirection_after_signup, :in => Environment.signup_redirection_options.keys, :allow_nil => true | |
164 | - | |
165 | - | |
166 | - # ################################################# | |
167 | - # Relationships and applied behaviour | |
168 | - # ################################################# | |
169 | - | |
170 | - acts_as_having_boxes | |
171 | - | |
172 | - after_create do |env| | |
173 | - 3.times do | |
174 | - env.boxes << Box.new | |
175 | - end | |
176 | - | |
177 | - # main area | |
178 | - env.boxes[0].blocks << MainBlock.new | |
179 | - | |
180 | - # "left" area | |
181 | - env.boxes[1].blocks << LoginBlock.new | |
182 | - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
183 | - # the Noosfero core soon, see ActionItem3045 | |
184 | - env.boxes[1].blocks << EnvironmentStatisticsBlock.new | |
185 | - env.boxes[1].blocks << RecentDocumentsBlock.new | |
186 | - | |
187 | - # "right" area | |
188 | - env.boxes[2].blocks << CommunitiesBlock.new(:limit => 6) | |
189 | - env.boxes[2].blocks << PeopleBlock.new(:limit => 6) | |
190 | - end | |
191 | - | |
192 | - # One Environment can be reached by many domains | |
193 | - has_many :domains, :as => :owner | |
194 | - has_many :profiles, :dependent => :destroy | |
195 | - | |
196 | - has_many :organizations | |
197 | - has_many :enterprises | |
198 | - has_many :products, :through => :enterprises | |
199 | - has_many :people | |
200 | - has_many :communities | |
201 | - has_many :licenses | |
202 | - | |
203 | - has_many :categories | |
204 | - has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null and parent_id is null', :order => 'display_color' | |
205 | - | |
206 | - has_many :product_categories, :conditions => { :type => 'ProductCategory'} | |
207 | - has_many :regions | |
208 | - has_many :states | |
209 | - has_many :cities | |
210 | - | |
211 | - has_many :roles, :dependent => :destroy | |
212 | - | |
213 | - has_many :qualifiers | |
214 | - has_many :certifiers | |
215 | - | |
216 | - has_many :mailings, :class_name => 'EnvironmentMailing', :foreign_key => :source_id, :as => 'source' | |
217 | - | |
218 | - acts_as_accessible | |
219 | - | |
220 | - has_many :units, :order => 'position' | |
221 | - has_many :production_costs, :as => :owner | |
222 | - | |
223 | - def superior_intances | |
224 | - [self, nil] | |
225 | - end | |
226 | - # ################################################# | |
227 | - # Attributes | |
228 | - # ################################################# | |
229 | - | |
230 | - # store the Environment settings as YAML-serialized Hash. | |
231 | - acts_as_having_settings :field => :settings | |
232 | - | |
233 | - # the environment's terms of use: every user must accept them before registering. | |
234 | - settings_items :terms_of_use, :type => String | |
235 | - | |
236 | - # the environment's terms of enterprise use: every enterprise member must accept them before | |
237 | - # registering or activating enterprises. | |
238 | - settings_items :terms_of_enterprise_use, :type => String | |
239 | - | |
240 | - # returns the approval method used for this environment. Possible values are: | |
241 | - # | |
242 | - # Defaults to <tt>:admim</tt>. | |
243 | - settings_items :organization_approval_method, :type => Symbol, :default => :admin | |
244 | - | |
245 | - # Whether this environment should force having 'www.' in its domain name or | |
246 | - # not. Defauls to false. | |
247 | - # | |
248 | - # Sets the value of #force_www. <tt>value</tt> must be a boolean. | |
249 | - # | |
250 | - # See also #default_hostname | |
251 | - settings_items :force_www, :default => false | |
252 | - | |
253 | - settings_items :message_for_friend_invitation, :type => String | |
254 | - def message_for_friend_invitation | |
255 | - settings[:message_for_member_invitation] || InviteFriend.mail_template | |
256 | - end | |
257 | - | |
258 | - settings_items :message_for_member_invitation, :type => String | |
259 | - def message_for_member_invitation | |
260 | - settings[:message_for_member_invitation] || InviteMember.mail_template | |
261 | - end | |
262 | - | |
263 | - settings_items :min_signup_delay, :type => Integer, :default => 3 #seconds | |
264 | - settings_items :activation_blocked_text, :type => String | |
265 | - settings_items :message_for_disabled_enterprise, :type => String, | |
266 | - :default => _('This enterprise needs to be enabled.') | |
267 | - settings_items :location, :type => String | |
268 | - settings_items :layout_template, :type => String, :default => 'default' | |
269 | - settings_items :homepage, :type => String | |
270 | - settings_items :description, :type => String, :default => '<div style="text-align: center"><a href="http://noosfero.org/"><img src="/images/noosfero-network.png" alt="Noosfero"/></a></div>' | |
271 | - settings_items :local_docs, :type => Array, :default => [] | |
272 | - settings_items :news_amount_by_folder, :type => Integer, :default => 4 | |
273 | - settings_items :help_message_to_add_enterprise, :type => String, :default => '' | |
274 | - settings_items :tip_message_enterprise_activation_question, :type => String, :default => '' | |
275 | - | |
276 | - settings_items :currency_unit, :type => String, :default => '$' | |
277 | - settings_items :currency_separator, :type => String, :default => '.' | |
278 | - settings_items :currency_delimiter, :type => String, :default => ',' | |
279 | - | |
280 | - settings_items :trusted_sites_for_iframe, :type => Array, :default => %w[ | |
281 | - developer.myspace.com | |
282 | - itheora.org | |
283 | - maps.google.com | |
284 | - platform.twitter.com | |
285 | - player.vimeo.com | |
286 | - stream.softwarelivre.org | |
287 | - tv.softwarelivre.org | |
288 | - www.facebook.com | |
289 | - www.flickr.com | |
290 | - www.gmodules.com | |
291 | - www.youtube.com | |
292 | - ] + ('a' .. 'z').map{|i| "#{i}.yimg.com"} | |
293 | - | |
294 | - settings_items :enabled_plugins, :type => Array, :default => [] | |
295 | - | |
296 | - settings_items :disabled_blocks, :type => Array, :default => [] | |
297 | - | |
298 | - settings_items :search_hints, :type => Hash, :default => {} | |
299 | - | |
300 | - # Set to return http forbidden to host not on the allow origin list bellow | |
301 | - settings_items :restrict_to_access_control_origins, :default => false | |
302 | - # Set this according to http://www.w3.org/TR/cors/. Headers are set at every response | |
303 | - # For multiple domains acts as suggested in http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains | |
304 | - settings_items :access_control_allow_origin, :type => Array, :default => [] | |
305 | - settings_items :access_control_allow_methods, :type => String | |
306 | - | |
307 | - settings_items :signup_welcome_screen_body, :type => String | |
308 | - | |
309 | - def has_custom_welcome_screen? | |
310 | - settings[:signup_welcome_screen_body].present? | |
311 | - end | |
312 | - | |
313 | - def news_amount_by_folder=(amount) | |
314 | - settings[:news_amount_by_folder] = amount.to_i | |
315 | - end | |
316 | - | |
317 | - # Enables a feature identified by its name | |
318 | - def enable(feature, must_save=true) | |
319 | - self.settings["#{feature}_enabled".to_sym] = true | |
320 | - self.save! if must_save | |
321 | - end | |
322 | - | |
323 | - def enable_plugin(plugin) | |
324 | - self.enabled_plugins += [plugin.to_s] | |
325 | - self.enabled_plugins.uniq! | |
326 | - self.save! | |
327 | - end | |
328 | - | |
329 | - # Disables a feature identified by its name | |
330 | - def disable(feature, must_save=true) | |
331 | - self.settings["#{feature}_enabled".to_sym] = false | |
332 | - self.save! if must_save | |
333 | - end | |
334 | - | |
335 | - def disable_plugin(plugin) | |
336 | - self.enabled_plugins.delete(plugin.to_s) | |
337 | - self.save! | |
338 | - end | |
339 | - | |
340 | - # Tells if a feature, identified by its name, is enabled | |
341 | - def enabled?(feature) | |
342 | - self.settings["#{feature}_enabled".to_sym] == true | |
343 | - end | |
344 | - def disabled?(feature) | |
345 | - !self.enabled?(feature) | |
346 | - end | |
347 | - | |
348 | - def plugin_enabled?(plugin) | |
349 | - enabled_plugins.include?(plugin.to_s) | |
350 | - end | |
351 | - | |
352 | - def block_disabled?(block) | |
353 | - disabled_blocks.include?(block.to_s) | |
354 | - end | |
355 | - | |
356 | - # enables the features identified by <tt>features</tt>, which is expected to | |
357 | - # be an Enumarable object containing the identifiers of the desired features. | |
358 | - # Passing <tt>nil</tt> is the same as passing an empty Array. | |
359 | - def enabled_features=(features) | |
360 | - features ||= [] | |
361 | - self.class.available_features.keys.each do |feature| | |
362 | - if features.include? feature | |
363 | - self.enable(feature) | |
364 | - else | |
365 | - self.disable(feature) | |
366 | - end | |
367 | - end | |
368 | - end | |
369 | - | |
370 | - def enabled_features | |
371 | - features = self.class.available_features | |
372 | - features.delete_if{ |k, v| !self.enabled?(k) } | |
373 | - end | |
374 | - | |
375 | - DEFAULT_FEATURES = %w( | |
376 | - disable_asset_products | |
377 | - disable_gender_icon | |
378 | - products_for_enterprises | |
379 | - disable_select_city_for_contact | |
380 | - enterprise_registration | |
381 | - media_panel | |
382 | - organizations_are_moderated_by_default | |
383 | - show_balloon_with_profile_links_when_clicked | |
384 | - show_zoom_button_on_article_images | |
385 | - use_portal_community | |
386 | - ) | |
387 | - | |
388 | - before_create :enable_default_features | |
389 | - def enable_default_features | |
390 | - DEFAULT_FEATURES.each do |feature| | |
391 | - enable(feature, false) | |
392 | - end | |
393 | - end | |
394 | - | |
395 | - # returns <tt>true</tt> if this Environment has terms of use to be | |
396 | - # accepted by users before registration. | |
397 | - def has_terms_of_use? | |
398 | - ! self.terms_of_use.blank? | |
399 | - end | |
400 | - | |
401 | - # returns <tt>true</tt> if this Environment has terms of enterprise use to be | |
402 | - # accepted by users before registration or activation of enterprises. | |
403 | - def has_terms_of_enterprise_use? | |
404 | - ! self.terms_of_enterprise_use.blank? | |
405 | - end | |
406 | - | |
407 | - # Sets the organization_approval_method. Only accepts the following values: | |
408 | - # | |
409 | - # * <tt>:admin</tt>: organization registration must be approved by the | |
410 | - # environment administrator. | |
411 | - # * <tt>:region</tt>: organization registering must be approved by some other | |
412 | - # organization asssigned as validator to the Region the new organization | |
413 | - # belongs to. | |
414 | - # * <tt>:none</tt>: organization registration is approved by default. | |
415 | - # | |
416 | - # Trying to set organization_approval_method to any other value will raise an | |
417 | - # ArgumentError. | |
418 | - # | |
419 | - # The value passed as argument is converted to a Symbol before being actually | |
420 | - # set to this setting. | |
421 | - def organization_approval_method=(value) | |
422 | - actual_value = value.to_sym | |
423 | - | |
424 | - accepted_values = %w[ | |
425 | - admin | |
426 | - region | |
427 | - none | |
428 | - ].map(&:to_sym) | |
429 | - raise ArgumentError unless accepted_values.include?(actual_value) | |
430 | - | |
431 | - self.settings[:organization_approval_method] = actual_value | |
432 | - end | |
433 | - | |
434 | - def custom_person_fields | |
435 | - self.settings[:custom_person_fields].nil? ? {} : self.settings[:custom_person_fields] | |
436 | - end | |
437 | - | |
438 | - def custom_person_fields=(values) | |
439 | - if values['schooling'] && values['schooling']['active'] == 'true' | |
440 | - schooling_status = values['schooling'] | |
441 | - end | |
442 | - | |
443 | - self.settings[:custom_person_fields] = values.delete_if { |key, value| ! Person.fields.include?(key)} | |
444 | - self.settings[:custom_person_fields].each_pair do |key, value| | |
445 | - if value['required'] == 'true' | |
446 | - self.settings[:custom_person_fields][key]['active'] = 'true' | |
447 | - self.settings[:custom_person_fields][key]['signup'] = 'true' | |
448 | - end | |
449 | - if value['signup'] == 'true' | |
450 | - self.settings[:custom_person_fields][key]['active'] = 'true' | |
451 | - end | |
452 | - end | |
453 | - | |
454 | - if schooling_status | |
455 | - self.settings[:custom_person_fields]['schooling_status'] = schooling_status | |
456 | - end | |
457 | - end | |
458 | - | |
459 | - def custom_person_field(field, status) | |
460 | - if (custom_person_fields[field] && custom_person_fields[field][status] == 'true') | |
461 | - return true | |
462 | - end | |
463 | - false | |
464 | - end | |
465 | - | |
466 | - def active_person_fields | |
467 | - (custom_person_fields.delete_if { |key, value| !custom_person_field(key, 'active')}).keys || [] | |
468 | - end | |
469 | - | |
470 | - def required_person_fields | |
471 | - required_fields = [] | |
472 | - active_person_fields.each do |field| | |
473 | - required_fields << field if custom_person_fields[field]['required'] == 'true' | |
474 | - end | |
475 | - required_fields | |
476 | - end | |
477 | - | |
478 | - def signup_person_fields | |
479 | - signup_fields = [] | |
480 | - active_person_fields.each do |field| | |
481 | - signup_fields << field if custom_person_fields[field]['signup'] == 'true' | |
482 | - end | |
483 | - signup_fields | |
484 | - end | |
485 | - | |
486 | - def invitation_mail_template(profile) | |
487 | - if profile.person? | |
488 | - message_for_friend_invitation | |
489 | - else | |
490 | - message_for_member_invitation | |
491 | - end | |
492 | - end | |
493 | - | |
494 | - def custom_enterprise_fields | |
495 | - self.settings[:custom_enterprise_fields].nil? ? {} : self.settings[:custom_enterprise_fields] | |
496 | - end | |
497 | - | |
498 | - def custom_enterprise_fields=(values) | |
499 | - self.settings[:custom_enterprise_fields] = values.delete_if { |key, value| ! Enterprise.fields.include?(key)} | |
500 | - self.settings[:custom_enterprise_fields].each_pair do |key, value| | |
501 | - if value['required'] == 'true' | |
502 | - self.settings[:custom_enterprise_fields][key]['active'] = 'true' | |
503 | - self.settings[:custom_enterprise_fields][key]['signup'] = 'true' | |
504 | - end | |
505 | - if value['signup'] == 'true' | |
506 | - self.settings[:custom_enterprise_fields][key]['active'] = 'true' | |
507 | - end | |
508 | - end | |
509 | - end | |
510 | - | |
511 | - def custom_enterprise_field(field, status) | |
512 | - if (custom_enterprise_fields[field] && custom_enterprise_fields[field][status] == 'true') | |
513 | - return true | |
514 | - end | |
515 | - false | |
516 | - end | |
517 | - | |
518 | - def active_enterprise_fields | |
519 | - (custom_enterprise_fields.delete_if { |key, value| !custom_enterprise_field(key, 'active')}).keys || [] | |
520 | - end | |
521 | - | |
522 | - def required_enterprise_fields | |
523 | - required_fields = [] | |
524 | - active_enterprise_fields.each do |field| | |
525 | - required_fields << field if custom_enterprise_fields[field]['required'] == 'true' | |
526 | - end | |
527 | - required_fields | |
528 | - end | |
529 | - | |
530 | - def signup_enterprise_fields | |
531 | - signup_fields = [] | |
532 | - active_enterprise_fields.each do |field| | |
533 | - signup_fields << field if custom_enterprise_fields[field]['signup'] == 'true' | |
534 | - end | |
535 | - signup_fields | |
536 | - end | |
537 | - | |
538 | - def custom_community_fields | |
539 | - self.settings[:custom_community_fields].nil? ? {} : self.settings[:custom_community_fields] | |
540 | - end | |
541 | - def custom_community_fields=(values) | |
542 | - self.settings[:custom_community_fields] = values.delete_if { |key, value| ! Community.fields.include?(key) } | |
543 | - self.settings[:custom_community_fields].each_pair do |key, value| | |
544 | - if value['required'] == 'true' | |
545 | - self.settings[:custom_community_fields][key]['active'] = 'true' | |
546 | - self.settings[:custom_community_fields][key]['signup'] = 'true' | |
547 | - end | |
548 | - if value['signup'] == 'true' | |
549 | - self.settings[:custom_community_fields][key]['active'] = 'true' | |
550 | - end | |
551 | - end | |
552 | - end | |
553 | - | |
554 | - def custom_community_field(field, status) | |
555 | - if (custom_community_fields[field] && custom_community_fields[field][status] == 'true') | |
556 | - return true | |
557 | - end | |
558 | - false | |
559 | - end | |
560 | - | |
561 | - def active_community_fields | |
562 | - (custom_community_fields.delete_if { |key, value| !custom_community_field(key, 'active')}).keys | |
563 | - end | |
564 | - | |
565 | - def required_community_fields | |
566 | - required_fields = [] | |
567 | - active_community_fields.each do |field| | |
568 | - required_fields << field if custom_community_fields[field]['required'] == 'true' | |
569 | - end | |
570 | - required_fields | |
571 | - end | |
572 | - | |
573 | - def signup_community_fields | |
574 | - signup_fields = [] | |
575 | - active_community_fields.each do |field| | |
576 | - signup_fields << field if custom_community_fields[field]['signup'] == 'true' | |
577 | - end | |
578 | - signup_fields | |
579 | - end | |
580 | - | |
581 | - serialize :signup_welcome_text, Hash | |
582 | - def signup_welcome_text | |
583 | - self[:signup_welcome_text] ||= {} | |
584 | - end | |
585 | - | |
586 | - def signup_welcome_text_subject | |
587 | - self.signup_welcome_text[:subject] | |
588 | - end | |
589 | - | |
590 | - def signup_welcome_text_subject=(subject) | |
591 | - self.signup_welcome_text[:subject] = subject | |
592 | - end | |
593 | - | |
594 | - def signup_welcome_text_body | |
595 | - self.signup_welcome_text[:body] | |
596 | - end | |
597 | - | |
598 | - def signup_welcome_text_body=(body) | |
599 | - self.signup_welcome_text[:body] = body | |
600 | - end | |
601 | - | |
602 | - def has_signup_welcome_text? | |
603 | - signup_welcome_text && !signup_welcome_text_body.blank? | |
604 | - end | |
605 | - | |
606 | - # ################################################# | |
607 | - # Validations | |
608 | - # ################################################# | |
609 | - | |
610 | - # <tt>name</tt> is mandatory | |
611 | - validates_presence_of :name | |
612 | - | |
613 | - # only one environment can be the default one | |
614 | - validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => N_('Only one Virtual Community can be the default one') | |
615 | - | |
616 | - validates_format_of :contact_email, :noreply_email, :with => Noosfero::Constants::EMAIL_FORMAT, :allow_blank => true | |
617 | - | |
618 | - xss_terminate :only => [ :message_for_disabled_enterprise ], :with => 'white_list', :on => 'validation' | |
619 | - | |
620 | - validates_presence_of :theme | |
621 | - validates_numericality_of :reports_lower_bound, :allow_nil => false, :only_integer => true, :greater_than_or_equal_to => 0 | |
622 | - | |
623 | - include WhiteListFilter | |
624 | - filter_iframes :message_for_disabled_enterprise | |
625 | - def iframe_whitelist | |
626 | - trusted_sites_for_iframe | |
627 | - end | |
628 | - | |
629 | - # ################################################# | |
630 | - # Business logic in general | |
631 | - # ################################################# | |
632 | - | |
633 | - # the default Environment. | |
634 | - def self.default | |
635 | - self.find(:first, :conditions => [ 'is_default = ?', true ] ) | |
636 | - end | |
637 | - | |
638 | - # returns an array with the top level categories for this environment. | |
639 | - def top_level_categories | |
640 | - Category.top_level_for(self) | |
641 | - end | |
642 | - | |
643 | - # Returns the hostname of the first domain associated to this environment. | |
644 | - # | |
645 | - # If #force_www is true, adds 'www.' at the beginning of the hostname. If the | |
646 | - # environment has not associated domains, returns 'localhost'. | |
647 | - def default_hostname(email_hostname = false) | |
648 | - domain = 'localhost' | |
649 | - unless self.domains(true).empty? | |
650 | - domain = (self.domains.find_by_is_default(true) || self.domains.find(:first, :order => 'id')).name | |
651 | - domain = email_hostname ? domain : (force_www ? ('www.' + domain) : domain) | |
652 | - end | |
653 | - domain | |
654 | - end | |
655 | - | |
656 | - def admin_url | |
657 | - { :controller => 'admin_panel', :action => 'index' } | |
658 | - end | |
659 | - | |
660 | - def top_url | |
661 | - url = 'http://' | |
662 | - url << (Noosfero.url_options.key?(:host) ? Noosfero.url_options[:host] : default_hostname) | |
663 | - url << ':' << Noosfero.url_options[:port].to_s if Noosfero.url_options.key?(:port) | |
664 | - url | |
665 | - end | |
666 | - | |
667 | - def to_s | |
668 | - self.name || '?' | |
669 | - end | |
670 | - | |
671 | - has_many :articles, :through => :profiles | |
672 | - def recent_documents(limit = 10, options = {}, pagination = true) | |
673 | - self.articles.recent(limit, options, pagination) | |
674 | - end | |
675 | - | |
676 | - has_many :events, :through => :profiles, :source => :articles, :class_name => 'Event' | |
677 | - | |
678 | - has_many :tags, :through => :articles | |
679 | - | |
680 | - def tag_counts | |
681 | - articles.tag_counts.inject({}) do |memo,tag| | |
682 | - memo[tag.name] = tag.count | |
683 | - memo | |
684 | - end | |
685 | - end | |
686 | - | |
687 | - def themes | |
688 | - if settings[:themes] | |
689 | - Theme.system_themes.select { |theme| settings[:themes].include?(theme.id) } | |
690 | - else | |
691 | - [] | |
692 | - end | |
693 | - end | |
694 | - | |
695 | - def themes=(values) | |
696 | - settings[:themes] = values | |
697 | - end | |
698 | - | |
699 | - def add_themes(values) | |
700 | - if settings[:themes].nil? | |
701 | - self.themes = values | |
702 | - else | |
703 | - settings[:themes] += values | |
704 | - end | |
705 | - end | |
706 | - | |
707 | - def update_theme(theme) | |
708 | - self.theme = theme | |
709 | - self.save! | |
710 | - end | |
711 | - | |
712 | - def update_layout_template(template) | |
713 | - self.layout_template = template | |
714 | - self.save! | |
715 | - end | |
716 | - | |
717 | - before_create do |env| | |
718 | - env.settings[:themes] ||= %w[ | |
719 | - aluminium | |
720 | - butter | |
721 | - chameleon | |
722 | - chocolate | |
723 | - noosfero | |
724 | - orange | |
725 | - plum | |
726 | - scarletred | |
727 | - skyblue | |
728 | - ] | |
729 | - end | |
730 | - | |
731 | - def community_template | |
732 | - template = Community.find_by_id settings[:community_template_id] | |
733 | - template if template && template.is_template | |
734 | - end | |
735 | - | |
736 | - def community_template=(value) | |
737 | - settings[:community_template_id] = value.id | |
738 | - end | |
739 | - | |
740 | - def person_template | |
741 | - template = Person.find_by_id settings[:person_template_id] | |
742 | - template if template && template.is_template | |
743 | - end | |
744 | - | |
745 | - def person_template=(value) | |
746 | - settings[:person_template_id] = value.id | |
747 | - end | |
748 | - | |
749 | - def enterprise_template | |
750 | - template = Enterprise.find_by_id settings[:enterprise_template_id] | |
751 | - template if template && template.is_template | |
752 | - end | |
753 | - | |
754 | - def enterprise_template=(value) | |
755 | - settings[:enterprise_template_id] = value.id | |
756 | - end | |
757 | - | |
758 | - def inactive_enterprise_template | |
759 | - template = Enterprise.find_by_id settings[:inactive_enterprise_template_id] | |
760 | - template if template && template.is_template | |
761 | - end | |
762 | - | |
763 | - def inactive_enterprise_template=(value) | |
764 | - settings[:inactive_enterprise_template_id] = value.id | |
765 | - end | |
766 | - | |
767 | - def replace_enterprise_template_when_enable | |
768 | - settings[:replace_enterprise_template_when_enable] || false | |
769 | - end | |
770 | - | |
771 | - def replace_enterprise_template_when_enable=(value) | |
772 | - settings[:replace_enterprise_template_when_enable] = value | |
773 | - end | |
774 | - | |
775 | - def portal_community | |
776 | - Community[settings[:portal_community_identifier]] | |
777 | - end | |
778 | - | |
779 | - def portal_community=(value) | |
780 | - settings[:portal_community_identifier] = value.nil? ? nil : value.identifier | |
781 | - end | |
782 | - | |
783 | - def unset_portal_community! | |
784 | - self.portal_community=nil | |
785 | - self.portal_folders=nil | |
786 | - self.news_amount_by_folder=nil | |
787 | - self.disable('use_portal_community') | |
788 | - self.save | |
789 | - end | |
790 | - | |
791 | - def is_portal_community?(profile) | |
792 | - portal_community == profile | |
793 | - end | |
794 | - | |
795 | - def portal_folders | |
796 | - (settings[:portal_folders] || []).map{|fid| portal_community.articles.find(:first, :conditions => { :id => fid }) }.compact | |
797 | - end | |
798 | - | |
799 | - def portal_folders=(folders) | |
800 | - settings[:portal_folders] = folders ? folders.map(&:id) : nil | |
801 | - end | |
802 | - | |
803 | - def portal_news_cache_key(language='en') | |
804 | - "home-page-news/#{cache_key}-#{language}" | |
805 | - end | |
806 | - | |
807 | - def notification_emails | |
808 | - [noreply_email.blank? ? nil : noreply_email].compact + admins.map(&:email) | |
809 | - end | |
810 | - | |
811 | - after_create :create_templates | |
812 | - | |
813 | - def create_templates | |
814 | - prefix = self.name.to_slug + '_' | |
815 | - | |
816 | - enterprise_template = Enterprise.new( | |
817 | - :name => 'Enterprise template', | |
818 | - :identifier => prefix + 'enterprise_template' | |
819 | - ) | |
820 | - | |
821 | - inactive_enterprise_template = Enterprise.new( | |
822 | - :name => 'Inactive Enterprise template', | |
823 | - :identifier => prefix + 'inactive_enterprise_template' | |
824 | - ) | |
825 | - | |
826 | - community_template = Community.new( | |
827 | - :name => 'Community template', | |
828 | - :identifier => prefix + 'community_template' | |
829 | - ) | |
830 | - | |
831 | - [ | |
832 | - enterprise_template, | |
833 | - inactive_enterprise_template, | |
834 | - community_template | |
835 | - ].each do |profile| | |
836 | - profile.is_template = true | |
837 | - profile.visible = false | |
838 | - profile.environment = self | |
839 | - profile.save! | |
840 | - end | |
841 | - | |
842 | - pass = Digest::MD5.hexdigest rand.to_s | |
843 | - user = User.new(:login => (prefix + 'person_template'), :email => (prefix + 'template@template.noo'), :password => pass, :password_confirmation => pass) | |
844 | - user.environment = self | |
845 | - user.save! | |
846 | - | |
847 | - person_template = user.person | |
848 | - person_template.name = "Person template" | |
849 | - person_template.is_template = true | |
850 | - person_template.visible = false | |
851 | - person_template.save! | |
852 | - | |
853 | - self.enterprise_template = enterprise_template | |
854 | - self.inactive_enterprise_template = inactive_enterprise_template | |
855 | - self.community_template = community_template | |
856 | - self.person_template = person_template | |
857 | - self.save! | |
858 | - end | |
859 | - | |
860 | - after_create :create_default_licenses | |
861 | - def create_default_licenses | |
862 | - [ | |
863 | - { :name => 'CC (by)', :url => 'http://creativecommons.org/licenses/by/3.0/legalcode'}, | |
864 | - { :name => 'CC (by-nd)', :url => 'http://creativecommons.org/licenses/by-nd/3.0/legalcode'}, | |
865 | - { :name => 'CC (by-sa)', :url => 'http://creativecommons.org/licenses/by-sa/3.0/legalcode'}, | |
866 | - { :name => 'CC (by-nc)', :url => 'http://creativecommons.org/licenses/by-nc/3.0/legalcode'}, | |
867 | - { :name => 'CC (by-nc-nd)', :url => 'http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode'}, | |
868 | - { :name => 'CC (by-nc-sa)', :url => 'http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode'}, | |
869 | - { :name => 'Free Art', :url => 'http://artlibre.org/licence/lal/en'}, | |
870 | - { :name => 'GNU FDL', :url => 'http://www.gnu.org/licenses/fdl-1.3.txt'}, | |
871 | - ].each do |data| | |
872 | - license = License.new(data) | |
873 | - license.environment = self | |
874 | - license.save! | |
875 | - end | |
876 | - end | |
877 | - | |
878 | - def highlighted_products_with_image(options = {}) | |
879 | - Product.find(:all, {:conditions => {:highlighted => true, :profile_id => self.enterprises.find(:all, :select => :id) }, :joins => :image}.merge(options)) | |
880 | - end | |
881 | - | |
882 | - settings_items :home_cache_in_minutes, :type => :integer, :default => 5 | |
883 | - settings_items :general_cache_in_minutes, :type => :integer, :default => 15 | |
884 | - settings_items :profile_cache_in_minutes, :type => :integer, :default => 15 | |
885 | - | |
886 | - def image_galleries | |
887 | - portal_community ? portal_community.image_galleries : [] | |
888 | - end | |
889 | - | |
890 | - serialize :languages | |
891 | - | |
892 | - before_validation do |environment| | |
893 | - environment.default_language = nil if environment.default_language.blank? | |
894 | - end | |
895 | - | |
896 | - validate :default_language_available | |
897 | - validate :languages_available | |
898 | - | |
899 | - def locales | |
900 | - if languages.present? | |
901 | - languages.inject({}) {|r, l| r.merge({l => Noosfero.locales[l]})} | |
902 | - else | |
903 | - Noosfero.locales | |
904 | - end | |
905 | - end | |
906 | - | |
907 | - def default_locale | |
908 | - default_language || Noosfero.default_locale | |
909 | - end | |
910 | - | |
911 | - def available_locales | |
912 | - locales_list = locales.keys | |
913 | - # move English to the beginning | |
914 | - if locales_list.include?('en') | |
915 | - locales_list = ['en'] + (locales_list - ['en']).sort | |
916 | - end | |
917 | - locales_list | |
918 | - end | |
919 | - | |
920 | - private | |
921 | - | |
922 | - def default_language_available | |
923 | - if default_language.present? && !available_locales.include?(default_language) | |
924 | - errors.add(:default_language, _('is not available.')) | |
925 | - end | |
926 | - end | |
927 | - | |
928 | - def languages_available | |
929 | - if languages.present? | |
930 | - languages.each do |language| | |
931 | - if !Noosfero.available_locales.include?(language) | |
932 | - errors.add(:languages, _('have unsupported languages.')) | |
933 | - break | |
934 | - end | |
935 | - end | |
936 | - end | |
937 | - end | |
938 | -end |
app/models/person.rb
1 | 1 | # A person is the profile of an user holding all relationships with the rest of the system |
2 | 2 | class Person < Profile |
3 | 3 | |
4 | - attr_accessible :organization, :contact_information, :sex, :birth_date, :professional_activity | |
4 | + attr_accessible :organization, :contact_information, :sex, :birth_date, :cell_phone, :comercial_phone, :jabber_id, :personal_website, :nationality, :address_reference, :district, :schooling, :schooling_status, :formation, :custom_formation, :area_of_study, :custom_area_of_study, :professional_activity, :organization_website | |
5 | 5 | |
6 | 6 | SEARCH_FILTERS += %w[ |
7 | 7 | more_popular | ... | ... |
plugins/display_content/lib/display_content_block.rb
... | ... | @@ -120,7 +120,7 @@ class DisplayContentBlock < Block |
120 | 120 | nodes_conditions = nodes.blank? ? '' : " AND articles.id IN(:nodes) " |
121 | 121 | nodes_conditions += ' OR articles.parent_id IN(:nodes) ' if !nodes.blank? && display_folder_children |
122 | 122 | |
123 | - docs = owner.articles.find(:all, :conditions => ["articles.type IN(:types) #{nodes.blank? ? '' : nodes_conditions}", {:nodes => self.nodes, :types => self.types}]) | |
123 | + docs = owner.articles.find(:all, :conditions => ["articles.type IN(:types) #{nodes.blank? ? '' : nodes_conditions}", {:nodes => self.nodes, :types => self.types}], :include => :profile) | |
124 | 124 | proc do |
125 | 125 | block.block_title(block.title) + |
126 | 126 | content_tag('ul', docs.map {|item| | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -21,14 +21,6 @@ class AccountControllerTest < ActionController::TestCase |
21 | 21 | disable_signup_bot_check |
22 | 22 | end |
23 | 23 | |
24 | - def test_local_files_reference | |
25 | - assert_local_files_reference | |
26 | - end | |
27 | - | |
28 | - def test_valid_xhtml | |
29 | - assert_valid_xhtml | |
30 | - end | |
31 | - | |
32 | 24 | def test_should_login_and_redirect |
33 | 25 | post :login, :user => {:login => 'johndoe', :password => 'test'} |
34 | 26 | assert session[:user] | ... | ... |
test/functional/admin_panel_controller_test.rb
... | ... | @@ -14,14 +14,6 @@ class AdminPanelControllerTest < ActionController::TestCase |
14 | 14 | login_as(create_admin_user(Environment.default)) |
15 | 15 | end |
16 | 16 | |
17 | - def test_local_files_reference | |
18 | - assert_local_files_reference | |
19 | - end | |
20 | - | |
21 | - def test_valid_xhtml | |
22 | - assert_valid_xhtml | |
23 | - end | |
24 | - | |
25 | 17 | should 'manage the correct environment' do |
26 | 18 | current = fast_create(Environment, :name => 'test environment', :is_default => false) |
27 | 19 | current.domains.create!(:name => 'example.com') | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -60,14 +60,6 @@ class ApplicationControllerTest < ActionController::TestCase |
60 | 60 | end |
61 | 61 | |
62 | 62 | |
63 | - def test_local_files_reference | |
64 | - assert_local_files_reference | |
65 | - end | |
66 | - | |
67 | - def test_valid_xhtml | |
68 | - assert_valid_xhtml | |
69 | - end | |
70 | - | |
71 | 63 | def test_exist_environment_variable_to_helper_environment_identification |
72 | 64 | get :index |
73 | 65 | assert_not_nil assigns(:environment) | ... | ... |
test/functional/catalog_controller_test.rb
... | ... | @@ -16,14 +16,6 @@ class CatalogControllerTest < ActionController::TestCase |
16 | 16 | end |
17 | 17 | attr_accessor :enterprise |
18 | 18 | |
19 | - def test_local_files_reference | |
20 | - assert_local_files_reference :get, :index, :profile => @enterprise.identifier | |
21 | - end | |
22 | - | |
23 | - def test_valid_xhtml | |
24 | - assert_valid_xhtml | |
25 | - end | |
26 | - | |
27 | 19 | should 'not display for non-enterprises' do |
28 | 20 | u = create_user('testinguser').person |
29 | 21 | get :index, :profile => 'testinguser' | ... | ... |
test/functional/categories_controller_test.rb
... | ... | @@ -20,14 +20,6 @@ class CategoriesControllerTest < ActionController::TestCase |
20 | 20 | |
21 | 21 | attr_reader :env, :cat1, :cat2 |
22 | 22 | |
23 | - def test_local_files_reference | |
24 | - assert_local_files_reference | |
25 | - end | |
26 | - | |
27 | - def test_valid_xhtml | |
28 | - assert_valid_xhtml | |
29 | - end | |
30 | - | |
31 | 23 | def test_index |
32 | 24 | login_as(create_admin_user(Environment.default)) |
33 | 25 | get :index | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -18,14 +18,6 @@ class CmsControllerTest < ActionController::TestCase |
18 | 18 | |
19 | 19 | attr_reader :profile |
20 | 20 | |
21 | - def test_local_files_reference | |
22 | - assert_local_files_reference :get, :index, :profile => profile.identifier | |
23 | - end | |
24 | - | |
25 | - def test_valid_xhtml | |
26 | - assert_valid_xhtml | |
27 | - end | |
28 | - | |
29 | 21 | should 'list top level documents on index' do |
30 | 22 | get :index, :profile => profile.identifier |
31 | 23 | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -18,16 +18,6 @@ class ContentViewerControllerTest < ActionController::TestCase |
18 | 18 | end |
19 | 19 | attr_reader :profile, :environment |
20 | 20 | |
21 | - def test_local_files_reference | |
22 | - page = profile.articles.build(:name => 'test') | |
23 | - page.save! | |
24 | - assert_local_files_reference :get, :view_page, :profile => profile.identifier, :page => [ 'test' ] | |
25 | - end | |
26 | - | |
27 | - def test_valid_xhtml | |
28 | - assert_valid_xhtml | |
29 | - end | |
30 | - | |
31 | 21 | def test_should_display_page |
32 | 22 | page = profile.articles.build(:name => 'test') |
33 | 23 | page.save! | ... | ... |
test/functional/edit_template_controller_test.rb
... | ... | @@ -15,14 +15,6 @@ class EditTemplateControllerTest < ActionController::TestCase |
15 | 15 | login_as 'ze' |
16 | 16 | end |
17 | 17 | |
18 | - def test_local_files_reference | |
19 | - assert_local_files_reference | |
20 | - end | |
21 | - | |
22 | - def test_valid_xhtml | |
23 | - assert_valid_xhtml | |
24 | - end | |
25 | - | |
26 | 18 | def test_redirect_to_design_editor_when_index_action_is_called |
27 | 19 | give_permission('ze', 'edit_environment_design', Environment.default) |
28 | 20 | get :index | ... | ... |
test/functional/enterprise_registration_controller_test.rb
... | ... | @@ -17,14 +17,6 @@ class EnterpriseRegistrationControllerTest < ActionController::TestCase |
17 | 17 | login_as 'ze' |
18 | 18 | end |
19 | 19 | |
20 | - def test_local_files_reference | |
21 | - assert_local_files_reference | |
22 | - end | |
23 | - | |
24 | - def test_valid_xhtml | |
25 | - assert_valid_xhtml | |
26 | - end | |
27 | - | |
28 | 20 | should 'go to the first step on index' do |
29 | 21 | get :index |
30 | 22 | assert_response :success | ... | ... |
test/functional/enterprise_validation_controller_test.rb
... | ... | @@ -19,18 +19,6 @@ class EnterpriseValidationControllerTest < ActionController::TestCase |
19 | 19 | Profile.expects(:find_by_identifier).with('myorg').returns(@org).at_least_once |
20 | 20 | end |
21 | 21 | |
22 | - def test_local_files_reference | |
23 | - assert_local_files_reference :get, :index, :profile => 'myorg' | |
24 | - end | |
25 | - | |
26 | - def test_valid_xhtml | |
27 | - | |
28 | - # FIXME remove this after enable assert_valid_xhtml | |
29 | - Profile.find_by_identifier('myorg') | |
30 | - | |
31 | - assert_valid_xhtml :get, :index, :profile => 'myorg' | |
32 | - end | |
33 | - | |
34 | 22 | should 'list pending validations on index' do |
35 | 23 | empty = [] |
36 | 24 | @org.expects(:pending_validations).returns(empty) | ... | ... |
test/functional/environment_design_controller_test.rb
... | ... | @@ -17,14 +17,6 @@ class EnvironmentDesignControllerTest < ActionController::TestCase |
17 | 17 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([]) |
18 | 18 | end |
19 | 19 | |
20 | - def test_local_files_reference | |
21 | - assert_local_files_reference | |
22 | - end | |
23 | - | |
24 | - def test_valid_xhtml | |
25 | - assert_valid_xhtml | |
26 | - end | |
27 | - | |
28 | 20 | should 'indicate only actual blocks as such' do |
29 | 21 | assert(@controller.available_blocks.all? {|item| item.new.is_a? Block}) |
30 | 22 | end | ... | ... |
test/functional/environment_role_manager_controller_test.rb
... | ... | @@ -11,16 +11,4 @@ class EnvironmentRoleManagerControllerTest < ActionController::TestCase |
11 | 11 | @response = ActionController::TestResponse.new |
12 | 12 | end |
13 | 13 | |
14 | - def test_local_files_reference | |
15 | - assert_local_files_reference | |
16 | - end | |
17 | - | |
18 | - def test_valid_xhtml | |
19 | - assert_valid_xhtml | |
20 | - end | |
21 | - | |
22 | - # Replace this with your real tests. | |
23 | - def test_truth | |
24 | - assert true | |
25 | - end | |
26 | 14 | end | ... | ... |
test/functional/favorite_enterprises_controller_test.rb
... | ... | @@ -18,14 +18,6 @@ class FavoriteEnterprisesControllerTest < ActionController::TestCase |
18 | 18 | end |
19 | 19 | attr_accessor :profile, :favorite_enterprise |
20 | 20 | |
21 | - def test_local_files_reference | |
22 | - assert_local_files_reference | |
23 | - end | |
24 | - | |
25 | - def test_valid_xhtml | |
26 | - assert_valid_xhtml | |
27 | - end | |
28 | - | |
29 | 21 | should 'list favorite enterprises' do |
30 | 22 | get :index |
31 | 23 | assert_response :success | ... | ... |
test/functional/features_controller_test.rb
... | ... | @@ -14,14 +14,6 @@ class FeaturesControllerTest < ActionController::TestCase |
14 | 14 | login_as(create_admin_user(Environment.find(2))) |
15 | 15 | end |
16 | 16 | |
17 | - def test_local_files_reference | |
18 | - assert_local_files_reference | |
19 | - end | |
20 | - | |
21 | - def test_valid_xhtml | |
22 | - assert_valid_xhtml | |
23 | - end | |
24 | - | |
25 | 17 | def test_listing_features |
26 | 18 | uses_host 'anhetegua.net' |
27 | 19 | get :index | ... | ... |
test/functional/friends_controller_test.rb
... | ... | @@ -18,14 +18,6 @@ class FriendsControllerTest < ActionController::TestCase |
18 | 18 | end |
19 | 19 | attr_accessor :profile, :friend |
20 | 20 | |
21 | - def test_local_files_reference | |
22 | - assert_local_files_reference | |
23 | - end | |
24 | - | |
25 | - def test_valid_xhtml | |
26 | - assert_valid_xhtml | |
27 | - end | |
28 | - | |
29 | 21 | should 'list friends' do |
30 | 22 | get :index |
31 | 23 | assert_response :success | ... | ... |
test/functional/home_controller_test.rb
... | ... | @@ -17,14 +17,6 @@ class HomeControllerTest < ActionController::TestCase |
17 | 17 | @response = ActionController::TestResponse.new |
18 | 18 | end |
19 | 19 | |
20 | - def test_local_files_reference | |
21 | - assert_local_files_reference | |
22 | - end | |
23 | - | |
24 | - def test_valid_xhtml | |
25 | - assert_valid_xhtml | |
26 | - end | |
27 | - | |
28 | 20 | should 'not display news from portal if disabled in environment' do |
29 | 21 | env = Environment.default |
30 | 22 | env.disable('use_portal_community') | ... | ... |
test/functional/manage_products_controller_test.rb
... | ... | @@ -18,14 +18,6 @@ class ManageProductsControllerTest < ActionController::TestCase |
18 | 18 | login_as :test_user |
19 | 19 | end |
20 | 20 | |
21 | - def test_local_files_reference | |
22 | - assert_local_files_reference :get, :index, :profile => @enterprise.identifier | |
23 | - end | |
24 | - | |
25 | - def test_valid_xhtml | |
26 | - assert_valid_xhtml | |
27 | - end | |
28 | - | |
29 | 21 | should "not have permission" do |
30 | 22 | u = create_user('user_test') |
31 | 23 | login_as :user_test | ... | ... |
test/functional/memberships_controller_test.rb
... | ... | @@ -19,14 +19,6 @@ class MembershipsControllerTest < ActionController::TestCase |
19 | 19 | end |
20 | 20 | attr_reader :profile |
21 | 21 | |
22 | - def test_local_files_reference | |
23 | - assert_local_files_reference :get, :index, :profile => profile.identifier | |
24 | - end | |
25 | - | |
26 | - def test_valid_xhtml | |
27 | - assert_valid_xhtml | |
28 | - end | |
29 | - | |
30 | 22 | should 'list current memberships' do |
31 | 23 | get :index, :profile => profile.identifier |
32 | 24 | ... | ... |
test/functional/my_profile_controller_test.rb
... | ... | @@ -20,16 +20,6 @@ class MyProfileControllerTest < ActionController::TestCase |
20 | 20 | @response = ActionController::TestResponse.new |
21 | 21 | end |
22 | 22 | |
23 | - def test_local_files_reference | |
24 | - @controller = OnlyForPersonTestController.new | |
25 | - user = create_user('test_user').person | |
26 | - assert_local_files_reference :get, :index, :profile => user.identifier | |
27 | - end | |
28 | - | |
29 | - def test_valid_xhtml | |
30 | - assert_valid_xhtml | |
31 | - end | |
32 | - | |
33 | 23 | def test_should_allow_person |
34 | 24 | @controller = OnlyForPersonTestController.new |
35 | 25 | person = create_user('random_joe') | ... | ... |
test/functional/plugins_controller_test.rb
... | ... | @@ -16,14 +16,6 @@ class PluginsControllerTest < ActionController::TestCase |
16 | 16 | end |
17 | 17 | attr_reader :environment |
18 | 18 | |
19 | - def test_local_files_reference | |
20 | - assert_local_files_reference | |
21 | - end | |
22 | - | |
23 | - def test_valid_xhtml | |
24 | - assert_valid_xhtml | |
25 | - end | |
26 | - | |
27 | 19 | should 'list system active plugins' do |
28 | 20 | class Plugin1 < Noosfero::Plugin |
29 | 21 | class << self | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -11,14 +11,6 @@ class ProfileControllerTest < ActionController::TestCase |
11 | 11 | end |
12 | 12 | attr_reader :profile |
13 | 13 | |
14 | - def test_local_files_reference | |
15 | - assert_local_files_reference | |
16 | - end | |
17 | - | |
18 | - def test_valid_xhtml | |
19 | - assert_valid_xhtml | |
20 | - end | |
21 | - | |
22 | 14 | noosfero_test :profile => 'testuser' |
23 | 15 | |
24 | 16 | should 'list friends' do | ... | ... |
test/functional/profile_design_controller_test.rb
... | ... | @@ -75,14 +75,6 @@ class ProfileDesignControllerTest < ActionController::TestCase |
75 | 75 | end |
76 | 76 | attr_reader :profile |
77 | 77 | |
78 | - def test_local_files_reference | |
79 | - assert_local_files_reference :get, :index, :profile => 'designtestuser' | |
80 | - end | |
81 | - | |
82 | - def test_valid_xhtml | |
83 | - assert_valid_xhtml | |
84 | - end | |
85 | - | |
86 | 78 | ###################################################### |
87 | 79 | # BEGIN - tests for BoxOrganizerController features |
88 | 80 | ###################################################### | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -6,7 +6,7 @@ class ProfileEditorController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class ProfileEditorControllerTest < ActionController::TestCase |
8 | 8 | all_fixtures |
9 | - | |
9 | + | |
10 | 10 | def setup |
11 | 11 | @controller = ProfileEditorController.new |
12 | 12 | @request = ActionController::TestRequest.new |
... | ... | @@ -17,14 +17,6 @@ class ProfileEditorControllerTest < ActionController::TestCase |
17 | 17 | end |
18 | 18 | attr_reader :profile |
19 | 19 | |
20 | - def test_local_files_reference | |
21 | - assert_local_files_reference :get, :index, :profile => profile.identifier | |
22 | - end | |
23 | - | |
24 | - def test_valid_xhtml | |
25 | - assert_valid_xhtml | |
26 | - end | |
27 | - | |
28 | 20 | def test_index |
29 | 21 | get :index, :profile => profile.identifier |
30 | 22 | assert_template 'index' |
... | ... | @@ -50,7 +42,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
50 | 42 | end |
51 | 43 | |
52 | 44 | should 'saving profile info' do |
53 | - person = profile | |
45 | + person = profile | |
54 | 46 | post :edit, :profile => profile.identifier, :profile_data => { 'name' => 'new person', 'contact_information' => 'new contact information', 'address' => 'new address', 'sex' => 'female' } |
55 | 47 | assert_redirected_to :controller => 'profile_editor', :action => 'index' |
56 | 48 | person = Person.find(person.id) |
... | ... | @@ -60,6 +52,15 @@ class ProfileEditorControllerTest < ActionController::TestCase |
60 | 52 | assert_equal 'female', person.sex |
61 | 53 | end |
62 | 54 | |
55 | + should 'mass assign all environment configurable person fields' do | |
56 | + person = profile | |
57 | + | |
58 | + post :edit, :profile => profile.identifier, :profile_data => { "nickname" => "ze", "description" => "Just a regular ze.", "contact_information" => "What?", "contact_phone" => "+0551133445566", "cell_phone" => "+0551188889999", "comercial_phone" => "+0551144336655", "jabber_id" => "ze1234", "personal_website" => "http://ze.com.br", "sex" => "male", "birth_date" => "2014-06-04", "nationality" => "Brazilian", "country" => "BR", "state" => "DF", "city" => "Brasilia", "zip_code" => "70300-010", "address" => "Palacio do Planalto", "address_reference" => "Praca dos tres poderes", "district" => "DF", "schooling" => "Undergraduate", "schooling_status" => "Concluded", "formation" => "Engineerings", "area_of_study" => "Metallurgy", "professional_activity" => "Metallurgic", "organization" => "Metal Corp.", "organization_website" => "http://metal.com" } | |
59 | + | |
60 | + assert_response :redirect | |
61 | + assert_redirected_to :controller => 'profile_editor', :action => 'index' | |
62 | + end | |
63 | + | |
63 | 64 | should 'not permmit if not logged' do |
64 | 65 | logout |
65 | 66 | get :index, :profile => profile.identifier |
... | ... | @@ -164,6 +165,15 @@ class ProfileEditorControllerTest < ActionController::TestCase |
164 | 165 | assert_tag :tag => 'input', :attributes => { :name => 'profile_data[contact_person]', :value => 'my contact' } |
165 | 166 | end |
166 | 167 | |
168 | + should 'mass assign all environment configurable community fields' do | |
169 | + cmm = fast_create(Community) | |
170 | + | |
171 | + post :edit, :profile => cmm.identifier, :profile_data => { "name" => "new name", "display_name" => "N&w N@me", "description"=>"We sell food and other stuff.", "contact_person"=>"Joseph of the Jungle", "contact_email"=>"sac@company.net", "contact_phone"=>"+0551133445566", "legal_form"=>"New Name corp.", "economic_activity"=>"Food", "management_information"=>"No need for that here.", "address"=>"123, baufas street", "address_reference"=>"Next to baufas house", "district"=>"DC", "zip_code"=>"123456", "city"=>"Whashington", "state"=>"DC", "country"=>"US", "tag_list"=>"food, corporations", "language"=>"English" } | |
172 | + | |
173 | + assert_response :redirect | |
174 | + assert_redirected_to :controller => 'profile_editor', :action => 'index' | |
175 | + end | |
176 | + | |
167 | 177 | should 'show field values on edit enterprise info' do |
168 | 178 | Enterprise.any_instance.expects(:active_fields).returns(['contact_person']).at_least_once |
169 | 179 | org = fast_create(Enterprise) |
... | ... | @@ -173,6 +183,15 @@ class ProfileEditorControllerTest < ActionController::TestCase |
173 | 183 | assert_tag :tag => 'input', :attributes => { :name => 'profile_data[contact_person]', :value => 'my contact' } |
174 | 184 | end |
175 | 185 | |
186 | + should 'mass assign all environment configurable enterprise fields' do | |
187 | + enterprise = fast_create(Enterprise) | |
188 | + | |
189 | + post :edit, :profile => enterprise.identifier, :profile_data => { "name"=>"Enterprise", "display_name"=>"Enterprise name", "business_name"=>"Enterprise", "description"=>"Hello IT.", "contact_person"=>"Joseph", "contact_email"=>"joe@enterprise.net", "contact_phone"=>"+0551133445566", "legal_form"=>"Enterprise corp.", "economic_activity"=>"Food", "management_information"=>"None.", "address"=>"123, baufas street", "address_reference"=>"Next to baufas house", "district"=>"DC", "zip_code"=>"123456", "city"=>"Washington", "state"=>"DC", "country"=>"US", "tag_list"=>"food, corporations", "organization_website"=>"http://enterprise.net", "historic_and_current_context"=>"Historic.", "activities_short_description"=>"Activies.", "acronym"=>"E", "foundation_year"=>"1995",} | |
190 | + | |
191 | + assert_response :redirect | |
192 | + assert_redirected_to :controller => 'profile_editor', :action => 'index' | |
193 | + end | |
194 | + | |
176 | 195 | should 'display profile publication option in edit profile screen' do |
177 | 196 | get :edit, :profile => profile.identifier |
178 | 197 | assert_tag :tag => 'input', :attributes => { :type => 'radio', :checked => 'checked', :name => 'profile_data[public_profile]', :value => 'true' } |
... | ... | @@ -426,7 +445,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
426 | 445 | get :index, :profile => ent.identifier |
427 | 446 | assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{ent.identifier}/profile_editor/enable" } |
428 | 447 | end |
429 | - | |
448 | + | |
430 | 449 | should 'link to disable enterprise' do |
431 | 450 | ent = fast_create(Enterprise, :enabled => true) |
432 | 451 | get :index, :profile => ent.identifier | ... | ... |
test/functional/profile_members_controller_test.rb
... | ... | @@ -12,15 +12,6 @@ class ProfileMembersControllerTest < ActionController::TestCase |
12 | 12 | @response = ActionController::TestResponse.new |
13 | 13 | end |
14 | 14 | |
15 | - def test_local_files_reference | |
16 | - user = create_user('test_user').person | |
17 | - assert_local_files_reference :get, :index, :profile => user.identifier | |
18 | - end | |
19 | - | |
20 | - def test_valid_xhtml | |
21 | - assert_valid_xhtml | |
22 | - end | |
23 | - | |
24 | 15 | should 'not access index if dont have permission' do |
25 | 16 | user = create_user('test_user') |
26 | 17 | fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') | ... | ... |
test/functional/region_validators_controller_test.rb
... | ... | @@ -12,14 +12,6 @@ class RegionValidatorsControllerTest < ActionController::TestCase |
12 | 12 | @response = ActionController::TestResponse.new |
13 | 13 | login_as('ze') |
14 | 14 | end |
15 | - | |
16 | - def test_local_files_reference | |
17 | - assert_local_files_reference | |
18 | - end | |
19 | - | |
20 | - def test_valid_xhtml | |
21 | - assert_valid_xhtml | |
22 | - end | |
23 | 15 | |
24 | 16 | # Replace this with your real tests. |
25 | 17 | should 'list regions at index' do | ... | ... |
test/functional/role_controller_test.rb
... | ... | @@ -15,14 +15,6 @@ class RoleControllerTest < ActionController::TestCase |
15 | 15 | login_as(:ze) |
16 | 16 | end |
17 | 17 | |
18 | - def test_local_files_reference | |
19 | - assert_local_files_reference | |
20 | - end | |
21 | - | |
22 | - def test_valid_xhtml | |
23 | - assert_valid_xhtml | |
24 | - end | |
25 | - | |
26 | 18 | def test_index_should_get_roles |
27 | 19 | get 'index' |
28 | 20 | assert_response :success | ... | ... |
test/functional/search_controller_test.rb
... | ... | @@ -45,14 +45,6 @@ class SearchControllerTest < ActionController::TestCase |
45 | 45 | fast_create(klass, { :name => name }.merge(data), :search => true, :category => category) |
46 | 46 | end |
47 | 47 | |
48 | - def test_local_files_reference | |
49 | - assert_local_files_reference | |
50 | - end | |
51 | - | |
52 | - def test_valid_xhtml | |
53 | - assert_valid_xhtml | |
54 | - end | |
55 | - | |
56 | 48 | should 'espape xss attack' do |
57 | 49 | get 'index', :query => '<wslite>' |
58 | 50 | assert_no_tag :tag => 'wslite' | ... | ... |
test/functional/tasks_controller_test.rb
... | ... | @@ -22,14 +22,6 @@ class TasksControllerTest < ActionController::TestCase |
22 | 22 | super({ :controller => 'tasks', :profile => profile.identifier }.merge(options)) |
23 | 23 | end |
24 | 24 | |
25 | - def test_local_files_reference | |
26 | - assert_local_files_reference | |
27 | - end | |
28 | - | |
29 | - def test_valid_xhtml | |
30 | - assert_valid_xhtml | |
31 | - end | |
32 | - | |
33 | 25 | should 'list pending tasks' do |
34 | 26 | get :index |
35 | 27 | ... | ... |
test/test_helper.rb
... | ... | @@ -3,7 +3,6 @@ ENV["RAILS_ENV"] = "test" |
3 | 3 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") |
4 | 4 | require 'rails/test_help' |
5 | 5 | require 'mocha' |
6 | -require 'tidy' | |
7 | 6 | require 'hpricot' |
8 | 7 | |
9 | 8 | require 'noosfero/test' |
... | ... | @@ -111,56 +110,6 @@ class ActiveSupport::TestCase |
111 | 110 | assert_equal parent, child.superclass, "Class #{child} expected to be a subclass of #{parent}" |
112 | 111 | end |
113 | 112 | |
114 | - def assert_valid_xhtml(method=:get, action=:index, params = {}) | |
115 | - return true | |
116 | - if method.to_s() == 'post' | |
117 | - post action, params | |
118 | - else | |
119 | - get action, params | |
120 | - end | |
121 | - tidy = Tidy.open(:show_warnings=>false) | |
122 | - tidy.options.output_xml = true | |
123 | - tidy.clean @response.body | |
124 | - if tidy.errors | |
125 | - flunk "HTML ERROR - Tidy Diagnostics:\n "+ | |
126 | - tidy.errors.join("\n ") +"\n "+ | |
127 | - tidy.diagnostics.join("\n ") | |
128 | - end | |
129 | - end | |
130 | - | |
131 | - def assert_local_files_reference(method=:get, action=:index, params = {}) | |
132 | - if method.to_s() == 'post' | |
133 | - post action, params | |
134 | - else | |
135 | - get action, params | |
136 | - end | |
137 | - doc = Hpricot @response.body | |
138 | - | |
139 | - # Test style references: | |
140 | - (doc/'style').each do |s| | |
141 | - s = s.to_s().gsub( /\/\*.*\*\//, '' ). | |
142 | - split( /;|<|>|\n/ ). | |
143 | - map do |l| | |
144 | - patch = l.match( /@import url\((.*)\)/ ) | |
145 | - patch ? patch[1] : nil | |
146 | - end.compact | |
147 | - s.each do |css_ref| | |
148 | - if ! File.exists?(File.join(Rails.root, 'public', css_ref)) | |
149 | - flunk 'CSS reference missed on HTML: "%s"' % css_ref | |
150 | - end | |
151 | - end | |
152 | - end | |
153 | - | |
154 | - # Test image references: | |
155 | - (doc/'img').each do |img| | |
156 | - src = img.get_attribute( 'src' ).gsub(/\?[0-9]+$/, '') | |
157 | - if ! File.exists?(File.join(Rails.root, 'public', src)) | |
158 | - flunk 'Image reference missed on HTML: "%s"' % src | |
159 | - end | |
160 | - end | |
161 | - | |
162 | - end | |
163 | - | |
164 | 113 | # this check only if text has html tag |
165 | 114 | def assert_sanitized(text) |
166 | 115 | assert !text.index('<'), "Text '#{text}' expected to be sanitized" | ... | ... |