Commit 4dc05706cd580e43683bc7efbe945d5bd45f0795
1 parent
861f38d9
Exists in
master
and in
22 other branches
ActionItem96: only validate e-mail if filled
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@618 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
9 additions
and
1 deletions
Show diff stats
app/models/environment.rb
@@ -123,7 +123,7 @@ class Environment < ActiveRecord::Base | @@ -123,7 +123,7 @@ class Environment < ActiveRecord::Base | ||
123 | # only one environment can be the default one | 123 | # only one environment can be the default one |
124 | validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => _('Only one Virtual Community can be the default one') | 124 | validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => _('Only one Virtual Community can be the default one') |
125 | 125 | ||
126 | - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT | 126 | + validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.nil? }) |
127 | 127 | ||
128 | # ################################################# | 128 | # ################################################# |
129 | # Business logic in general | 129 | # Business logic in general |
@@ -139,4 +139,12 @@ class Environment < ActiveRecord::Base | @@ -139,4 +139,12 @@ class Environment < ActiveRecord::Base | ||
139 | Category.top_level_for(self) | 139 | Category.top_level_for(self) |
140 | end | 140 | end |
141 | 141 | ||
142 | + def default_hostname | ||
143 | + if self.domains(true).empty? | ||
144 | + nil | ||
145 | + else | ||
146 | + self.domains.find(:first, :order => 'id').name | ||
147 | + end | ||
148 | + end | ||
149 | + | ||
142 | end | 150 | end |