Commit 4659ac66cc5510431a50fdaa8fc936eb9ccb2b23
Exists in
staging
and in
42 other branches
Merge branch 'master' into rails3
Conflicts: app/models/person.rb
Showing
5 changed files
with
36 additions
and
945 deletions
Show diff stats
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 | ... | ... |
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 |
| ... | ... | @@ -20,11 +20,11 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 20 | 20 | def test_local_files_reference |
| 21 | 21 | assert_local_files_reference :get, :index, :profile => profile.identifier |
| 22 | 22 | end |
| 23 | - | |
| 23 | + | |
| 24 | 24 | def test_valid_xhtml |
| 25 | 25 | assert_valid_xhtml |
| 26 | 26 | end |
| 27 | - | |
| 27 | + | |
| 28 | 28 | def test_index |
| 29 | 29 | get :index, :profile => profile.identifier |
| 30 | 30 | assert_template 'index' |
| ... | ... | @@ -50,7 +50,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | should 'saving profile info' do |
| 53 | - person = profile | |
| 53 | + person = profile | |
| 54 | 54 | post :edit, :profile => profile.identifier, :profile_data => { 'name' => 'new person', 'contact_information' => 'new contact information', 'address' => 'new address', 'sex' => 'female' } |
| 55 | 55 | assert_redirected_to :controller => 'profile_editor', :action => 'index' |
| 56 | 56 | person = Person.find(person.id) |
| ... | ... | @@ -60,6 +60,15 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 60 | 60 | assert_equal 'female', person.sex |
| 61 | 61 | end |
| 62 | 62 | |
| 63 | + should 'mass assign all environment configurable person fields' do | |
| 64 | + person = profile | |
| 65 | + | |
| 66 | + 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" } | |
| 67 | + | |
| 68 | + assert_response :redirect | |
| 69 | + assert_redirected_to :controller => 'profile_editor', :action => 'index' | |
| 70 | + end | |
| 71 | + | |
| 63 | 72 | should 'not permmit if not logged' do |
| 64 | 73 | logout |
| 65 | 74 | get :index, :profile => profile.identifier |
| ... | ... | @@ -164,6 +173,15 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 164 | 173 | assert_tag :tag => 'input', :attributes => { :name => 'profile_data[contact_person]', :value => 'my contact' } |
| 165 | 174 | end |
| 166 | 175 | |
| 176 | + should 'mass assign all environment configurable community fields' do | |
| 177 | + cmm = fast_create(Community) | |
| 178 | + | |
| 179 | + 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" } | |
| 180 | + | |
| 181 | + assert_response :redirect | |
| 182 | + assert_redirected_to :controller => 'profile_editor', :action => 'index' | |
| 183 | + end | |
| 184 | + | |
| 167 | 185 | should 'show field values on edit enterprise info' do |
| 168 | 186 | Enterprise.any_instance.expects(:active_fields).returns(['contact_person']).at_least_once |
| 169 | 187 | org = fast_create(Enterprise) |
| ... | ... | @@ -173,6 +191,15 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 173 | 191 | assert_tag :tag => 'input', :attributes => { :name => 'profile_data[contact_person]', :value => 'my contact' } |
| 174 | 192 | end |
| 175 | 193 | |
| 194 | + should 'mass assign all environment configurable enterprise fields' do | |
| 195 | + enterprise = fast_create(Enterprise) | |
| 196 | + | |
| 197 | + 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",} | |
| 198 | + | |
| 199 | + assert_response :redirect | |
| 200 | + assert_redirected_to :controller => 'profile_editor', :action => 'index' | |
| 201 | + end | |
| 202 | + | |
| 176 | 203 | should 'display profile publication option in edit profile screen' do |
| 177 | 204 | get :edit, :profile => profile.identifier |
| 178 | 205 | assert_tag :tag => 'input', :attributes => { :type => 'radio', :checked => 'checked', :name => 'profile_data[public_profile]', :value => 'true' } |
| ... | ... | @@ -426,7 +453,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 426 | 453 | get :index, :profile => ent.identifier |
| 427 | 454 | assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{ent.identifier}/profile_editor/enable" } |
| 428 | 455 | end |
| 429 | - | |
| 456 | + | |
| 430 | 457 | should 'link to disable enterprise' do |
| 431 | 458 | ent = fast_create(Enterprise, :enabled => true) |
| 432 | 459 | get :index, :profile => ent.identifier | ... | ... |