Commit 7e79c60e54a314a09f07f07f55aea2dafe9469ed
Exists in
master
and in
29 other branches
Merge branch 'stable'
Showing
63 changed files
with
679 additions
and
228 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
... | ... | @@ -3,11 +3,11 @@ class TasksController < MyProfileController |
3 | 3 | protect 'perform_task', :profile |
4 | 4 | |
5 | 5 | def index |
6 | - @tasks = profile.all_pending_tasks | |
6 | + @tasks = profile.all_pending_tasks.sort_by(&:created_at) | |
7 | 7 | end |
8 | 8 | |
9 | 9 | def processed |
10 | - @tasks = profile.all_finished_tasks | |
10 | + @tasks = profile.all_finished_tasks.sort_by(&:created_at) | |
11 | 11 | end |
12 | 12 | |
13 | 13 | VALID_DECISIONS = [ 'finish', 'cancel' ] | ... | ... |
app/controllers/public/enterprise_registration_controller.rb
... | ... | @@ -9,15 +9,20 @@ class EnterpriseRegistrationController < ApplicationController |
9 | 9 | # FIXME: shouldn't this action present some sort of welcome message and point |
10 | 10 | # to the first step explicitly? |
11 | 11 | def index |
12 | + @validation = environment.organization_approval_method | |
12 | 13 | @create_enterprise = CreateEnterprise.new(params[:create_enterprise]) |
13 | - if params[:create_enterprise] && params[:create_enterprise][:target_id] | |
14 | - @create_enterprise.target = Profile.find(params[:create_enterprise][:target_id]) | |
14 | + if @validation == :region | |
15 | + if params[:create_enterprise] && params[:create_enterprise][:target_id] | |
16 | + @create_enterprise.target = Profile.find(params[:create_enterprise][:target_id]) | |
17 | + end | |
18 | + elsif @validation == :admin | |
19 | + @create_enterprise.target = @create_enterprise.environment | |
15 | 20 | end |
16 | 21 | @create_enterprise.requestor = current_user.person |
17 | 22 | the_action = |
18 | 23 | if request.post? |
19 | 24 | if @create_enterprise.valid_before_selecting_target? |
20 | - if @create_enterprise.valid? | |
25 | + if @create_enterprise.valid? || @validation == :admin | |
21 | 26 | :confirmation |
22 | 27 | else |
23 | 28 | :select_validator |
... | ... | @@ -38,7 +43,9 @@ class EnterpriseRegistrationController < ApplicationController |
38 | 43 | # |
39 | 44 | # Posts back. |
40 | 45 | def basic_information |
41 | - @regions = environment.regions.select{|i| i.has_validator?}.map {|item| [item.name, item.id]} | |
46 | + if @validation == :region | |
47 | + @regions = @create_enterprise.available_regions.map {|region| [region.name, region.id]} | |
48 | + end | |
42 | 49 | end |
43 | 50 | |
44 | 51 | # present information about validator organizations, and the user one to | ... | ... |
app/helpers/application_helper.rb
... | ... | @@ -241,7 +241,7 @@ module ApplicationHelper |
241 | 241 | def button_to_remote_without_text(type, label, options, html_options = {}) |
242 | 242 | html_options[:class] = "" unless html_options[:class] |
243 | 243 | html_options[:class] << " button icon-#{type}" |
244 | - link_to_remote(content_tag('span', label), options, html_options) | |
244 | + link_to_remote(content_tag('span', label), options, html_options.merge(:title => label)) | |
245 | 245 | end |
246 | 246 | |
247 | 247 | def icon(icon_name, html_options = {}) | ... | ... |
app/helpers/folder_helper.rb
1 | 1 | module FolderHelper |
2 | 2 | |
3 | 3 | def list_articles(articles, recursive = false) |
4 | - content_tag( | |
5 | - 'table', | |
6 | - content_tag('tr', content_tag('th', _('Title')) + content_tag('th', _('Last update'))) + | |
7 | - articles.select { |item| item.public? }.map {|item| display_article_in_listing(item, recursive, 0)}.join('') | |
8 | - ) | |
4 | + if !articles.blank? | |
5 | + content_tag( | |
6 | + 'table', | |
7 | + content_tag('tr', content_tag('th', _('Title')) + content_tag('th', _('Last update'))) + | |
8 | + articles.map {|item| display_article_in_listing(item, recursive, 0)}.join('') | |
9 | + ) | |
10 | + else | |
11 | + content_tag('em', _('(empty folder)')) | |
12 | + end | |
13 | + end | |
14 | + | |
15 | + def available_articles(articles, user) | |
16 | + articles.select {|article| article.display_to?(user)} | |
9 | 17 | end |
10 | 18 | |
11 | 19 | def display_article_in_listing(article, recursive = false, level = 0) | ... | ... |
app/models/article.rb
... | ... | @@ -151,7 +151,7 @@ class Article < ActiveRecord::Base |
151 | 151 | # HTML. Other article types can override this method to provide customized |
152 | 152 | # views of themselves. |
153 | 153 | def to_html(options = {}) |
154 | - body | |
154 | + body || '' | |
155 | 155 | end |
156 | 156 | |
157 | 157 | # returns the data of the article. Must be overriden in each subclass to |
... | ... | @@ -224,6 +224,7 @@ class Article < ActiveRecord::Base |
224 | 224 | end |
225 | 225 | end |
226 | 226 | |
227 | + named_scope :published, :conditions => { :published => true } | |
227 | 228 | named_scope :folders, :conditions => { :type => ['Folder', 'Blog'] } |
228 | 229 | |
229 | 230 | def display_unpublished_article_to?(user) | ... | ... |
app/models/create_enterprise.rb
... | ... | @@ -11,7 +11,7 @@ class CreateEnterprise < Task |
11 | 11 | N_('Economic activity') |
12 | 12 | N_('Management information') |
13 | 13 | |
14 | - DATA_FIELDS = %w[ name identifier address contact_phone contact_person acronym foundation_year legal_form economic_activity management_information region_id reject_explanation ] | |
14 | + DATA_FIELDS = Enterprise.fields + %w[name identifier region_id reject_explanation] | |
15 | 15 | |
16 | 16 | serialize :data, Hash |
17 | 17 | attr_protected :data |
... | ... | @@ -31,20 +31,30 @@ class CreateEnterprise < Task |
31 | 31 | end |
32 | 32 | |
33 | 33 | # checks for virtual attributes |
34 | - validates_presence_of :name, :identifier, :address, :contact_phone, :contact_person, :legal_form, :economic_activity, :region_id | |
34 | + validates_presence_of :name, :identifier | |
35 | + | |
36 | + #checks if the validation method is region to validates | |
37 | + validates_presence_of :region_id, :if => lambda { |obj| obj.environment.organization_approval_method == :region } | |
38 | + | |
35 | 39 | validates_format_of :foundation_year, :with => /^\d*$/ |
36 | 40 | |
37 | 41 | # checks for actual attributes |
38 | 42 | validates_presence_of :requestor_id, :target_id |
39 | 43 | |
44 | + # checks for admins required attributes | |
45 | + DATA_FIELDS.each do |attribute| | |
46 | + validates_presence_of attribute, :if => lambda { |obj| obj.environment.required_enterprise_fields.include?(attribute) } | |
47 | + end | |
48 | + | |
40 | 49 | # check for explanation when rejecting |
41 | 50 | validates_presence_of :reject_explanation, :if => (lambda { |record| record.status == Task::Status::CANCELLED } ) |
42 | 51 | |
43 | 52 | xss_terminate :only => [ :acronym, :address, :contact_person, :contact_phone, :economic_activity, :legal_form, :management_information, :name ], :on => 'validation' |
44 | 53 | |
45 | 54 | def validate |
55 | + | |
46 | 56 | if self.region && self.target |
47 | - unless self.region.validators.include?(self.target) | |
57 | + unless self.region.validators.include?(self.target) || self.target_type == "Environment" | |
48 | 58 | self.errors.add(:target, '%{fn} is not a validator for the chosen region') |
49 | 59 | end |
50 | 60 | end |
... | ... | @@ -58,7 +68,7 @@ class CreateEnterprise < Task |
58 | 68 | if valid? |
59 | 69 | true |
60 | 70 | else |
61 | - self.errors.size == 1 and self.errors[:target_id] | |
71 | + self.errors.size == 1 && !self.errors[:target_id].nil? | |
62 | 72 | end |
63 | 73 | end |
64 | 74 | |
... | ... | @@ -81,7 +91,27 @@ class CreateEnterprise < Task |
81 | 91 | end |
82 | 92 | |
83 | 93 | def environment |
84 | - region ? region.environment : nil | |
94 | + region ? region.environment : self.requestor ? self.requestor.environment : Environment.default | |
95 | + end | |
96 | + | |
97 | + def available_regions | |
98 | + environment.regions.with_validators | |
99 | + end | |
100 | + | |
101 | + def active_fields | |
102 | + environment ? environment.active_enterprise_fields : [] | |
103 | + end | |
104 | + | |
105 | + def required_fields | |
106 | + environment ? environment.required_enterprise_fields : [] | |
107 | + end | |
108 | + | |
109 | + def community? | |
110 | + false | |
111 | + end | |
112 | + | |
113 | + def enterprise? | |
114 | + true | |
85 | 115 | end |
86 | 116 | |
87 | 117 | # Rejects the enterprise registration request. |
... | ... | @@ -107,21 +137,16 @@ class CreateEnterprise < Task |
107 | 137 | def perform |
108 | 138 | enterprise = Enterprise.new |
109 | 139 | |
110 | - profile_fields = %w[ name identifier contact_phone address region_id ] | |
111 | - profile_fields.each do |field| | |
140 | + DATA_FIELDS.reject{|field| field == "reject_explanation"}.each do |field| | |
112 | 141 | enterprise.send("#{field}=", self.send(field)) |
113 | 142 | end |
114 | 143 | |
115 | - organization_data = self.data.reject do |key,value| | |
116 | - profile_fields.include?(key.to_s) | |
117 | - end | |
118 | - | |
119 | 144 | enterprise.environment = environment |
120 | 145 | |
121 | 146 | enterprise.user = self.requestor.user |
122 | 147 | |
123 | - enterprise.update_attributes(organization_data) | |
124 | 148 | enterprise.save! |
149 | + enterprise.add_admin(enterprise.user.person) | |
125 | 150 | end |
126 | 151 | |
127 | 152 | def description |
... | ... | @@ -129,13 +154,13 @@ class CreateEnterprise < Task |
129 | 154 | end |
130 | 155 | |
131 | 156 | def task_created_message |
132 | - _('Your request for registering enterprise "%{enterprise}" at %{environment} was just received. It will be reviewed by the chosen validator organization you chose, according to its methods and creteria. | |
157 | + _('Your request for registering enterprise "%{enterprise}" at %{environment} was just received. It will be reviewed by the validator organization of your choice, according to its methods and criteria. | |
133 | 158 | |
134 | 159 | You will be notified as soon as the validator organization has a position about your request.') % { :enterprise => self.name, :environment => self.environment } |
135 | 160 | end |
136 | 161 | |
137 | 162 | def task_finished_message |
138 | - _('Your request for registering the enterprise "%{enterprise}" was approved. You can access %{environment} now and start using it for your new enterprise.') % { :enterprise => self.name, :environment => self.environment } | |
163 | + _('Your request for registering the enterprise "%{enterprise}" was approved. You can access %{environment} now and provide start providing all relevant information your new enterprise.') % { :enterprise => self.name, :environment => self.environment } | |
139 | 164 | end |
140 | 165 | |
141 | 166 | def task_cancelled_message | ... | ... |
app/models/enterprise.rb
... | ... | @@ -34,6 +34,8 @@ class Enterprise < Organization |
34 | 34 | organization_website |
35 | 35 | historic_and_current_context |
36 | 36 | activities_short_description |
37 | + acronym | |
38 | + foundation_year | |
37 | 39 | ] |
38 | 40 | |
39 | 41 | def self.fields |
... | ... | @@ -44,7 +46,7 @@ class Enterprise < Organization |
44 | 46 | super |
45 | 47 | self.required_fields.each do |field| |
46 | 48 | if self.send(field).blank? |
47 | - self.errors.add(field, _('%{fn} is mandatory')) | |
49 | + self.errors.add(field, _("%{fn} can't be blank")) | |
48 | 50 | end |
49 | 51 | end |
50 | 52 | end | ... | ... |
app/models/environment.rb
... | ... | @@ -89,6 +89,7 @@ class Environment < ActiveRecord::Base |
89 | 89 | 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), |
90 | 90 | 'disable_contact_person' => _('Disable contact for people'), |
91 | 91 | 'disable_contact_community' => _('Disable contact for groups/communities'), |
92 | + 'enterprise_registration' => _('Enterprise registration'), | |
92 | 93 | 'join_community_popup' => _('Ask users to join a group/community with a popup'), |
93 | 94 | |
94 | 95 | 'enterprise_activation' => _('Enable activation of enterprises'), | ... | ... |
app/models/folder.rb
... | ... | @@ -41,7 +41,10 @@ class Folder < Article |
41 | 41 | end |
42 | 42 | |
43 | 43 | def folder |
44 | - content_tag('div', body) + tag('hr') + (children.empty? ? content_tag('em', _('(empty folder)')) : list_articles(children)) | |
44 | + folder = self | |
45 | + lambda do | |
46 | + render :file => 'content_viewer/folder', :locals => { :folder => folder } | |
47 | + end | |
45 | 48 | end |
46 | 49 | |
47 | 50 | def image_gallery | ... | ... |
app/models/region.rb
... | ... | @@ -14,6 +14,10 @@ class Region < Category |
14 | 14 | def has_validator? |
15 | 15 | validators.count > 0 |
16 | 16 | end |
17 | + | |
18 | + def self.with_validators | |
19 | + Region.find(:all, :joins => 'INNER JOIN region_validators on (region_validators.region_id = categories.id)', :select => "distinct #{table_name}.*") | |
20 | + end | |
17 | 21 | |
18 | 22 | end |
19 | 23 | ... | ... |
app/models/slideshow_block.rb
... | ... | @@ -13,10 +13,14 @@ class SlideshowBlock < Block |
13 | 13 | gallery_id ? Folder.find(gallery_id) : nil |
14 | 14 | end |
15 | 15 | |
16 | + def block_images | |
17 | + gallery.images.reject {|item| item.folder?} | |
18 | + end | |
19 | + | |
16 | 20 | def content |
17 | 21 | block = self |
18 | 22 | if gallery |
19 | - images = gallery.images | |
23 | + images = block_images | |
20 | 24 | if shuffle |
21 | 25 | images = images.shuffle |
22 | 26 | end | ... | ... |
app/views/account/_login_form.rhtml
1 | 1 | <% labelled_form_for :user, @user, |
2 | - :url => { :controller => 'account', :action => (params[:enterprise_code] ? 'activate_enterprise' : 'login') }, | |
3 | - :html => { :help => _('If you are a registered user, enter your username and password to be authenticated.')+'<p/>'+_('To join on this environment, click on "<b>I want to be an user!</b>".')+'<p/>'+_('If you forgot your password, click on "<b>I forgot my password!</b>" link.') } do |f| %> | |
2 | + :url => { :controller => 'account', :action => (params[:enterprise_code] ? 'activate_enterprise' : 'login') } do |f| %> | |
4 | 3 | |
5 | 4 | <%= f.text_field :login, |
6 | 5 | :id => ( lightbox? ? 'lightbox_' : '' ) + 'user_login', |
7 | - :help => _('Here goes the nickname that you give on the registration.'), | |
8 | 6 | :onchange => 'this.value = convToValidLogin( this.value )' %> |
9 | 7 | |
10 | 8 | <%= f.password_field :password, |
11 | - :id => ( lightbox? ? 'lightbox_' : '' ) + 'user_password', | |
12 | - :help => _('your password is personal, protect it.') %> | |
9 | + :id => ( lightbox? ? 'lightbox_' : '' ) + 'user_password' %> | |
13 | 10 | |
14 | 11 | <% if params[:enterprise_code] %> |
15 | 12 | <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %> | ... | ... |
app/views/account/_signup_form.rhtml
... | ... | @@ -9,9 +9,7 @@ |
9 | 9 | <% end %> |
10 | 10 | <% end %> |
11 | 11 | |
12 | -<% labelled_form_for :user, @user, | |
13 | - :html => { :help=>_('Fill all these fields to join in this environment. <p/> If you forgot your password, do not create a new account, click on the "<b>I forgot my password!</b>" link. ;-)'), :id => 'profile-data' | |
14 | - } do |f| -%> | |
12 | +<% labelled_form_for :user, @user do |f| %> | |
15 | 13 | <%= icaptcha_field() %> |
16 | 14 | |
17 | 15 | <%= hidden_field_tag :invitation_code, @invitation_code %> |
... | ... | @@ -21,29 +19,23 @@ |
21 | 19 | <%= required_fields_message %> |
22 | 20 | |
23 | 21 | <div id='signup-email'> |
24 | -<%= required f.text_field(:email, | |
25 | - :help => help=_('This e-mail address will be used to contact you.')) %> | |
26 | -<div class='help-small-msg'><%= help %></div> | |
22 | + <%= required f.text_field(:email) %> | |
23 | + <%= content_tag(:small,_('This e-mail address will be used to contact you.')) %> | |
27 | 24 | </div> |
28 | 25 | |
29 | -<%= required f.text_field(:login, | |
30 | - :help => help=_('Insert your login'), | |
31 | - :onchange => 'this.value = convToValidLogin( this.value )') %> | |
32 | -<div id='url-check'> | |
33 | -<div class='help-small-msg'><%= help %></div> | |
34 | -</div> | |
26 | +<%= required f.text_field(:login, :onchange => 'this.value = convToValidLogin( this.value )') %> | |
27 | +<%= content_tag(:small,_('Insert your login')) %> | |
28 | +<div id='url-check'></div> | |
35 | 29 | |
36 | 30 | <%= observe_field 'user_login', :url => {:action => 'check_url'}, :with => 'identifier', :update => 'url-check' %> |
37 | 31 | |
38 | 32 | <div id='signup-password'> |
39 | -<%= required f.password_field(:password, | |
40 | - :help => help=_('Choose a password that you can remember easily. It must have at least 4 characters.')) %> | |
41 | -<div class='help-small-msg'><%= help %></div> | |
33 | + <%= required f.password_field(:password) %> | |
34 | + <%= content_tag(:small,_('Choose a password that you can remember easily. It must have at least 4 characters.')) %> | |
42 | 35 | </div> |
43 | 36 | |
44 | -<%= required f.password_field(:password_confirmation, | |
45 | - :help => help=_('To confirm, repeat your password.')) %> | |
46 | -<div class='help-small-msg'><%= help %></div> | |
37 | +<%= required f.password_field(:password_confirmation) %> | |
38 | +<%= content_tag(:small,_('To confirm, repeat your password.')) %> | |
47 | 39 | |
48 | 40 | <% labelled_fields_for :profile_data, @person do |f| %> |
49 | 41 | <%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %> | ... | ... |
app/views/account/activation_question.rhtml
... | ... | @@ -30,7 +30,7 @@ |
30 | 30 | |
31 | 31 | <p><%= _("This is a question to know if you really are part of this enterprise. Pay atention because you have only one chance to answer right and activate your enterprise. If you answer wrong you will not be able to activate the enterprise automaticaly and must get in touch with the admins of %s by email or phone.") % environment.name %> </p> |
32 | 32 | |
33 | - <%= ApplicationHelper::NoosferoFormBuilder::output_field(@question == :foundation_year ? (_("What year your enterprise was founded? It must have 4 digits, eg 1990. %s") % environment.tip_message_enterprise_activation_question) : _('What is the CNPJ of your enterprise?'), text_field_tag(:answer, nil, :id => 'enterprise-activation-answer', :help => help=_('We need to be sure that this is your enterprise'))) %> | |
33 | + <%= ApplicationHelper::NoosferoFormBuilder::output_field(@question == :foundation_year ? (_("What year your enterprise was founded? It must have 4 digits, eg 1990. %s") % environment.tip_message_enterprise_activation_question) : _('What is the CNPJ of your enterprise?'), text_field_tag(:answer, nil, :id => 'enterprise-activation-answer')) %> | |
34 | 34 | |
35 | 35 | <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %> |
36 | 36 | ... | ... |
app/views/account/forgot_password.rhtml
1 | -<h1><%= _('Password recovery') %></h1> | |
1 | +<h1><%= _('Forgot your password?') %></h1> | |
2 | 2 | |
3 | 3 | <%= error_messages_for :change_password %> |
4 | 4 | |
5 | -<% labelled_form_for :change_password, @change_password, | |
6 | - :url => { :action => 'forgot_password' }, | |
7 | - :html => { :help => _('To change your password, please fill the form on this screen using your username and your e-mail. You will receive a message at that e-mail address with a web address you can access to create a new password.') } do |f| %> | |
5 | +<% labelled_form_for :change_password, @change_password, :url => { :action => 'forgot_password' } do |f| %> | |
8 | 6 | |
9 | 7 | <%= f.text_field :login, |
10 | 8 | :onchange => 'this.value = convToValidLogin( this.value )' %> |
... | ... | @@ -13,9 +11,10 @@ |
13 | 11 | |
14 | 12 | <div> |
15 | 13 | <% button_bar do %> |
16 | - <%= submit_button('send', _('Send change password procedure by e-mail')) %> | |
14 | + <%= submit_button('send', _('Send instructions')) %> | |
17 | 15 | <% end %> |
18 | 16 | </div> |
17 | +<%= content_tag(:small,_('After clicking the button above, you will receive an email with a link to a page where you will be able to create a new password.')) %> | |
19 | 18 | |
20 | 19 | <% end %> |
21 | 20 | ... | ... |
app/views/account/index_anonymous.rhtml
1 | 1 | <h1><%= _('Identify yourself') %></h1> |
2 | 2 | |
3 | 3 | <p> |
4 | -<%= lightbox_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' }, | |
5 | - :help => _('Click here to enter your username and password and be recognized by the system.') %> | |
4 | +<%= lightbox_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' } %> | |
6 | 5 | |
7 | 6 | <%= _('You need to login to be able to use all the features in this environment.') %> |
8 | 7 | </p> | ... | ... |
app/views/account/login.rhtml
... | ... | @@ -5,9 +5,7 @@ |
5 | 5 | <% @user ||= User.new %> |
6 | 6 | <% is_thickbox ||= false %> |
7 | 7 | |
8 | -<% labelled_form_for :user, @user, | |
9 | - :url => login_url, | |
10 | - :html => { :help => _('If you are a registered user, enter your username and password to be authenticated.')+'<p/>'+_('To join on this environment, click on "<b>I want to be an user!</b>".')+'<p/>'+_('If you forgot your password, click on "<b>I forgot my password!</b>" link.') } do |f| %> | |
8 | +<% labelled_form_for :user, @user, :url => login_url do |f| %> | |
11 | 9 | |
12 | 10 | <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )' %> |
13 | 11 | ... | ... |
app/views/box_organizer/_slideshow_block.rhtml
1 | 1 | <% galleries = @block.box.owner.articles.select {|article| article.folder? && article.display_as_gallery? } %> |
2 | 2 | <%= labelled_form_field _('Choose a gallery'), select('block', 'gallery_id', galleries.map { |item| |
3 | - [ _('%{gallery} (%{count} images)') % {:gallery => item.path, :count => item.images.count}, item.id ] | |
3 | + [ _('%{gallery} (%{count} images)') % {:gallery => item.path, :count => item.images.reject{|image| image.folder?}.count}, item.id ] | |
4 | 4 | }) %> |
5 | 5 | |
6 | 6 | <%= labelled_form_field _('Image transition:'), select('block', 'interval', [[_('No automatic transition'), 0]] + [1, 2, 3, 4, 5, 10, 20, 30, 60].map {|item| [n_('Every 1 second', 'Every %d seconds', item) % item, item]}) %> | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +<% unless folder.body.blank? %> | |
2 | + <div> | |
3 | + <%= folder.body %> | |
4 | + </div> | |
5 | + <hr/> | |
6 | +<% end %> | |
7 | + | |
8 | +<% if folder.children.empty? %> | |
9 | + <em><%= _('(empty folder)') %></em> | |
10 | +<% else %> | |
11 | + <%= list_articles(available_articles(folder.children, user)) %> | |
12 | +<% end %> | ... | ... |
app/views/enterprise_registration/basic_information.rhtml
1 | 1 | <%= error_messages_for 'create_enterprise' %> |
2 | 2 | |
3 | -<h2><%= _('Register enterprise') %></h2> | |
4 | - | |
5 | -<h3> <%= _('How to proceed') %> </h3> | |
6 | -<p> <%= _('Fill the form and hit the Register button then the enterprise will be submitted for evaluation at the validation entitiy of your choice (within your state), when the enterprise is aproved you will be able to activate its profile') %> </p> | |
7 | - | |
8 | -<% labelled_form_for(:create_enterprise, @create_enterprise) do |f| %> | |
9 | - <%= f.text_field 'identifier', 'size' => 20 %> | |
10 | - | |
11 | - <%= f.text_field 'name', 'size' => 20 %> | |
12 | - | |
13 | - <%= f.text_field 'address', 'size' => 50 %> | |
14 | - | |
15 | - <%= f.text_field 'contact_phone', 'size' => 20 %> | |
16 | - | |
17 | - <%= f.text_field 'contact_person', 'size' => 20 %> | |
18 | - | |
19 | - <%= f.text_field 'acronym', 'size' => 20 %> | |
20 | - | |
21 | - <%= f.text_field 'foundation_year', 'size' => 20 %> | |
22 | - | |
23 | - <%= f.text_field 'legal_form', 'size' => 20 %> | |
24 | - | |
25 | - <%= f.text_field 'economic_activity', 'size' => 20 %> | |
26 | - | |
27 | - <%= labelled_form_field(_('Management information'), text_editor('create_enterprise', 'management_information')) %> | |
28 | - | |
29 | - <%= labelled_form_field(_('Region'), f.select('region_id', @regions)) %> | |
3 | +<h1><%= _('Enterprise registration') %></h1> | |
4 | + | |
5 | + | |
6 | +<% if @validation == :region && @regions.empty? %> | |
7 | + <div class='atention'> | |
8 | + <%= _('There are no validators to validate the registration of this new enterprise. Contact your administrator for instructions.') %> | |
9 | + </div> | |
30 | 10 | |
31 | 11 | <% button_bar do %> |
32 | - <%= submit_button('next', _('Next'), :cancel => {:action => 'index'}) %> | |
12 | + <%= button :back, _('Go back'), { :profile => current_user.person.identifier, :action=>"enterprises", :controller=>"profile" }%> | |
13 | + <% end %> | |
14 | +<% else %> | |
15 | + <div class='atention'> | |
16 | + <%= _('To register a new enterprise, fill in the form and hit the Register button. Then the enterprise will be submitted for evaluation at the validation entitiy of your choice (within your state) and when the enterprise is aproved you will be able to activate its profile.') %> | |
17 | + </div> | |
18 | + | |
19 | + <%= required_fields_message %> | |
20 | + | |
21 | + <% labelled_form_for(:create_enterprise, @create_enterprise) do |f| %> | |
22 | + <%= required f.text_field 'name', :onchange => "updateUrlField(this, 'create_enterprise_identifier')", :size => 40 %> | |
23 | + <%= required labelled_form_field(_('Address'), content_tag('code', environment.top_url + "/" + text_field(:create_enterprise, 'identifier', :size => 25))) %> | |
24 | + <%= render :partial => 'shared/custom_fields', :locals => { :f => f, :object_name => :create_enterprise, :profile => @create_enterprise, :only_required => false } %> | |
25 | + <%= required labelled_form_field(_('Region'), f.select('region_id', @regions)) if @validation == :region %> | |
26 | + | |
27 | + <% if @validation == :admin %> | |
28 | + <%= hidden_field_tag 'create_enterprise[target_id]', environment.id %> | |
29 | + <% end %> | |
30 | + | |
31 | + <% button_bar do %> | |
32 | + <%= submit_button('next', _('Next'), :cancel => {:profile => current_user.person.identifier, :action=>"enterprises", :controller=>"profile"}) %> | |
33 | + <% end %> | |
33 | 34 | <% end %> |
34 | - | |
35 | 35 | <% end %> | ... | ... |
app/views/enterprise_registration/confirmation.rhtml
1 | -<h2><%= _('Enterprise Registration completed') %></h2> | |
1 | +<h1><%= _('Enterprise registration completed') %></h1> | |
2 | 2 | |
3 | 3 | <p> |
4 | -<%= _("Your enterprise registration request was successfully registered. The validator organization you choose (%s) should get in touch with to start the validation process. As soon as the validators approve (or reject) your request, you will be notified by e-mail.") % @create_enterprise.target.name %> | |
4 | +<%= _("Your enterprise registration request was successfully registered. The validator organization you choose (%s) should get in touch with to start the validation process. As soon as the validators approve (or reject) your request, you will be notified by e-mail.") % @create_enterprise.target.name %> | |
5 | 5 | </p> |
6 | 6 | |
7 | 7 | <p> | ... | ... |
app/views/enterprise_registration/select_validator.rhtml
1 | -<h2><%= _('Enterprise Registration: Select a validator organization') %></h2> | |
1 | +<h1><%= _('Enterprise registration: validator organization') %></h1> | |
2 | 2 | |
3 | 3 | <p> |
4 | 4 | <%= _('Select one organization to validate your enterprise registration request. Check the provided information about their validation methodoly and criteria.') %> |
... | ... | @@ -7,15 +7,20 @@ |
7 | 7 | <% form_tag do %> |
8 | 8 | <%= render :partial => 'hidden_fields' %> |
9 | 9 | |
10 | - <% for validator in @validators %> | |
11 | - <div> | |
12 | - <%= radio_button_tag('create_enterprise[target_id]', validator.id) %> | |
13 | - <%= validator.name %> | |
14 | - | |
15 | - <%= labelled_form_field(_('Validation Methodology:'), validator.validation_methodology || _("(not informed)")) %> | |
16 | - <%= labelled_form_field(_('Restrictions (if any):'), validator.validation_restrictions || _("(not informed)")) %> | |
17 | - </div> | |
10 | + <table> | |
11 | + <tr> | |
12 | + <th><%= _('Name') %></th> | |
13 | + <th><%= _('Validation Methodology:') %></th> | |
14 | + <th><%= _('Restrictions (if any):') %></th> | |
15 | + </tr> | |
16 | + <% @validators.each do |validator| %> | |
17 | + <tr> | |
18 | + <td><%= labelled_radio_button validator.name, 'create_enterprise[target_id]', validator.id %></td> | |
19 | + <td><%= validator.validation_methodology || _("(not informed)") %></td> | |
20 | + <td><%= validator.validation_restrictions || _("(not informed)") %></td> | |
21 | + </tr> | |
18 | 22 | <% end %> |
23 | + </table> | |
19 | 24 | |
20 | 25 | <% button_bar do %> |
21 | 26 | <%= submit_button 'save', _('Confirm') %> | ... | ... |
app/views/enterprise_validation/index.rhtml
1 | 1 | <h1><%= __('Enterprise validations') %></h1> |
2 | 2 | |
3 | 3 | <% button_bar do %> |
4 | - <%= button(:edit, _('Edit validation info'), { :action => 'edit_validation_info' }, :help => __('Validation info is the information the enterprises will see about how your organization processes the enterprises validations it receives: validation methodology, restrictions to the types of enterprises the organization validates etc.')) %> | |
5 | - <%= button(:back, _('Go Back'), { :controller => 'profile_editor' }, :help => _('Go back to the control panel.')) %> | |
4 | + <%= button(:edit, _('Edit validation info'), { :action => 'edit_validation_info' }) %> | |
5 | + <%= button(:back, _('Go Back'), { :controller => 'profile_editor' }) %> | |
6 | 6 | <% end %> |
7 | 7 | |
8 | 8 | <h2><%= __("Pending enterprise validations") %></h2> | ... | ... |
app/views/favorite_enterprises/index.rhtml
... | ... | @@ -12,8 +12,7 @@ |
12 | 12 | <%= link_to content_tag('span',_('remove')), |
13 | 13 | { :action => 'remove', :id => enterprise.id }, |
14 | 14 | :class => 'button icon-delete', |
15 | - :title => _('remove'), | |
16 | - :help => _('Clicking on this button will remove your friend relation with %s.') % enterprise.name %> | |
15 | + :title => _('remove') %> | |
17 | 16 | </div><!-- end class="controll" --> |
18 | 17 | </li> |
19 | 18 | <% end %> | ... | ... |
app/views/friends/index.rhtml
... | ... | @@ -27,13 +27,11 @@ |
27 | 27 | <%= link_to content_tag('span',_('remove')), |
28 | 28 | { :action => 'remove', :id => friend.id }, |
29 | 29 | :class => 'button icon-delete', |
30 | - :title => _('remove'), | |
31 | - :help => __('Clicking on this button will remove your friend relation with %s.') % friend.name %> | |
30 | + :title => _('remove') %> | |
32 | 31 | <%= link_to content_tag('span',_('contact')), |
33 | 32 | friend.url.merge(:controller => 'contact', :action => 'new'), |
34 | 33 | :class => 'button icon-menu-mail', |
35 | - :title => _('contact'), | |
36 | - :help => __('Clicking on this button will let you send a message to %s.') % friend.name %> | |
34 | + :title => _('contact') %> | |
37 | 35 | </div><!-- end class="controll" --> |
38 | 36 | </li> |
39 | 37 | <% end %> | ... | ... |
app/views/memberships/index.rhtml
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | |
5 | 5 | <% button_bar do %> |
6 | 6 | <%= button(:add, __('Create a new community'), :controller => 'memberships', :action => 'new_community') %> |
7 | + <%= button :add, __('Register a new enterprise'), :controller => 'enterprise_registration' if environment.enabled?('enterprise_registration') %> | |
7 | 8 | <%= button :back, _('Go back'), :controller => 'profile_editor' %> |
8 | 9 | <% end %> |
9 | 10 | ... | ... |
app/views/profile/communities.rhtml
1 | -<div class="common-profile-list-block" | |
2 | - help="<%= _('Here are all <b>%s</b>\'s communities.') % profile.name %>"> | |
1 | +<div class="common-profile-list-block"> | |
3 | 2 | |
4 | 3 | <h1><%= _("%s's communities") % profile.name %></h1> |
5 | 4 | |
... | ... | @@ -16,8 +15,7 @@ |
16 | 15 | <% end %> |
17 | 16 | |
18 | 17 | <% button_bar do %> |
19 | - <%= button :back, _('Go back'), { :controller => 'profile' }, | |
20 | - :help => _('Back to the page where you come from.') %> | |
18 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
21 | 19 | <%= button :add, _('Create a new community'), |
22 | 20 | :controller => 'memberships', :action => 'new_community' if logged_in? && user == profile %> |
23 | 21 | <% end %> | ... | ... |
app/views/profile/enterprises.rhtml
1 | -<div class="common-profile-list-block" | |
2 | - help="<%= __('Here are all <b>%s</b>\'s enterprises.') % profile.name %>"> | |
1 | +<div class="common-profile-list-block"> | |
3 | 2 | |
4 | 3 | <h1><%= __("%s's enterprises") % profile.name %></h1> |
5 | 4 | |
... | ... | @@ -10,10 +9,8 @@ |
10 | 9 | </ul> |
11 | 10 | |
12 | 11 | <% button_bar do %> |
13 | - <%= button :back, _('Go back'), { :controller => 'profile' }, | |
14 | - :help => _('Back to the page where you come from.') %> | |
15 | - <%= button :add, __('Register a new Enterprise'), | |
16 | - :controller => 'enterprise_registration' if logged_in? %> | |
12 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
13 | + <%= button :add, __('Register a new Enterprise'), :controller => 'enterprise_registration' if logged_in? && environment.enabled?('enterprise_registration') %> | |
17 | 14 | <% end %> |
18 | 15 | |
19 | 16 | </div><!-- fim class="common-profile-list-block" --> | ... | ... |
app/views/profile/favorite_enterprises.rhtml
1 | -<div class="common-profile-list-block" | |
2 | - help="<%= __('Here are all <b>%s</b>\'s favorite enterprises.') % profile.name %>"> | |
1 | +<div class="common-profile-list-block"> | |
3 | 2 | |
4 | 3 | <h1><%= __("%s's favorite enterprises") % profile.name %></h1> |
5 | 4 | |
... | ... | @@ -10,8 +9,7 @@ |
10 | 9 | </ul> |
11 | 10 | |
12 | 11 | <% button_bar do %> |
13 | - <%= button :back, _('Go back'), { :controller => 'profile' }, | |
14 | - :help => _('Back to the page where you come from.') %> | |
12 | + <%= button :back, _('Go back'), { :controller => 'profile' }%> | |
15 | 13 | <% end %> |
16 | 14 | |
17 | 15 | </div><!-- fim class="common-profile-list-block" --> | ... | ... |
app/views/profile/friends.rhtml
1 | -<div class="common-profile-list-block" | |
2 | - help="<%= __('Here are all <b>%s</b>\'s friends.') % profile.name %>"> | |
1 | +<div class="common-profile-list-block"> | |
3 | 2 | |
4 | 3 | <h1><%= __("%s's friends") % profile.name %></h1> |
5 | 4 | |
... | ... | @@ -16,7 +15,7 @@ |
16 | 15 | <% end %> |
17 | 16 | |
18 | 17 | <% button_bar do %> |
19 | - <%= button :back, _('Go back'), { :controller => 'profile' }, :help => _('Back to the page where you come from.') %> | |
18 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
20 | 19 | <% if user == profile %> |
21 | 20 | <%= button :edit, _('Manage my friends'), :controller => 'friends', :action => 'index', :profile => profile.identifier %> |
22 | 21 | <%= button(:search, _('Invite people from my e-mail contacts'), :controller => 'invite', :action => 'friends') %> | ... | ... |
app/views/profile/index.rhtml
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | <tr> |
22 | 22 | <td><%= blog.name + ':' %></td> |
23 | 23 | <td> |
24 | - <%= link_to(n_('One post', '%{num} posts', blog.posts.count) % { :num => blog.posts.count }, blog.url) %> | |
24 | + <%= link_to(n_('One post', '%{num} posts', blog.posts.published.count) % { :num => blog.posts.published.count }, blog.url) %> | |
25 | 25 | </td> |
26 | 26 | </tr> |
27 | 27 | <% end %> |
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | <tr> |
30 | 30 | <td><%= gallery.name + ':' %></td> |
31 | 31 | <td> |
32 | - <%= link_to(n_('One picture', '%{num} pictures', gallery.images.count) % { :num => gallery.images.count }, gallery.url) %> | |
32 | + <%= link_to(n_('One picture', '%{num} pictures', gallery.images.published.count) % { :num => gallery.images.published.count }, gallery.url) %> | |
33 | 33 | </td> |
34 | 34 | </tr> |
35 | 35 | <% end %> |
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | <tr> |
38 | 38 | <td><%= _('Events:') %></td> |
39 | 39 | <td> |
40 | - <%= link_to profile.events.count, :controller => 'events', :action => 'events' %> | |
40 | + <%= link_to profile.events.published.count, :controller => 'events', :action => 'events' %> | |
41 | 41 | </td> |
42 | 42 | </tr> |
43 | 43 | <tr> | ... | ... |
app/views/profile/members.rhtml
1 | -<div class="common-profile-list-block" | |
2 | - help="<%= _('Here are all <b>%s</b>\'s members.') % profile.name %>"> | |
1 | +<div class="common-profile-list-block"> | |
3 | 2 | |
4 | 3 | <h1><%= _("%s's members") % profile.name %></h1> |
5 | 4 | |
... | ... | @@ -16,7 +15,7 @@ |
16 | 15 | <% end %> |
17 | 16 | |
18 | 17 | <% button_bar do %> |
19 | - <%= button :back, _('Go back'), { :controller => 'profile' }, :help => _('Back to the page where you come from.') %> | |
18 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
20 | 19 | <% if profile.community? and user and user.has_permission?(:invite_members, profile) %> |
21 | 20 | <%= button :search, _('Invite your friends to join %s') % profile.name, :controller => 'invite', :action => 'friends' %> |
22 | 21 | <% end %> | ... | ... |
app/views/profile/sitemap.rhtml
app/views/profile_editor/_organization.rhtml
1 | 1 | <h2><%= _('General information') %></h2> |
2 | 2 | |
3 | - <%= required_fields_message if @profile.required_fields.any? %> | |
3 | + <%= required_fields_message %> | |
4 | 4 | |
5 | 5 | <%= required f.text_field(:name) %> |
6 | 6 | |
... | ... | @@ -66,9 +66,6 @@ |
66 | 66 | </div> |
67 | 67 | <% end %> |
68 | 68 | |
69 | - <%= f.text_field(:acronym) %> | |
70 | - <%= f.text_field(:foundation_year) %> | |
71 | - | |
72 | 69 | <%= render :partial => 'shared/custom_fields', :locals => { :f => f, :object_name => 'profile_data', :profile => @profile, :only_required => false } %> |
73 | 70 | |
74 | 71 | <%= labelled_check_box(_('Enable "contact us"'), 'profile_data[enable_contact_us]', "1", @profile.enable_contact_us) if @profile.enterprise? %> | ... | ... |
app/views/profile_editor/index.rhtml
... | ... | @@ -74,7 +74,7 @@ |
74 | 74 | <p><strong><%= __('Activate your enterprise') %></strong></p> |
75 | 75 | <p><%= _("If you received a letter with information about your enterprise activation, add here the activation code that was sent.") %></p> |
76 | 76 | <p><%= environment.help_message_to_add_enterprise %> </p> |
77 | - <%= labelled_form_field(__('Enterprise activation code') + ':', text_field_tag('enterprise_code')) %> | |
77 | + <%= labelled_form_field(__('Enterprise activation code') + ': ', text_field_tag('enterprise_code')) %> | |
78 | 78 | <%= submit_button(:ok, _('Activate')) %> |
79 | 79 | <% end %> |
80 | 80 | </div> | ... | ... |
app/views/profile_members/_members_list.rhtml
... | ... | @@ -11,12 +11,13 @@ |
11 | 11 | <td> |
12 | 12 | <div class="members-buttons-cell"> |
13 | 13 | <%= button_without_text :edit, _('Edit'), :action => 'change_role', :id => m %> |
14 | - <%= button_to_remote_without_text :remove, _('Remove'), | |
14 | + <%= button_to_remote_without_text(:remove, _('Remove'), | |
15 | 15 | :update => 'members-list', |
16 | 16 | :loading => '$("members-list").addClassName("loading")', |
17 | 17 | :success => "$('tr-#{m.identifier}').show()", |
18 | 18 | :complete => '$("members-list").removeClassName("loading")', |
19 | - :url => {:action => 'unassociate', :id => m} %> | |
19 | + :confirm => _('Are you sure that you want to remove this member?'), | |
20 | + :url => {:action => 'unassociate', :id => m}) if m != user %> | |
20 | 21 | </div> |
21 | 22 | </td> |
22 | 23 | </tr> | ... | ... |
app/views/shared/_custom_fields.rhtml
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 | <%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(object_name, :address)), only_required) %> |
13 | 13 | |
14 | 14 | <% if profile.enterprise? %> |
15 | + <%= optional_field(profile, 'business_name', f.text_field(:business_name), only_required) %> | |
15 | 16 | <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(object_name, :zip_code)), only_required) %> |
16 | 17 | <%= optional_field(profile, 'city', f.text_field(:city), only_required) %> |
17 | 18 | <%= optional_field(profile, 'state', f.text_field(:state), only_required) %> |
... | ... | @@ -19,4 +20,6 @@ |
19 | 20 | <%= optional_field(profile, 'organization_website', f.text_field(:organization_website), only_required) %> |
20 | 21 | <%= optional_field(profile, 'historic_and_current_context', f.text_area(:historic_and_current_context, :rows => 5), only_required) %> |
21 | 22 | <%= optional_field(profile, 'activities_short_description', f.text_area(:activities_short_description, :rows => 5), only_required) %> |
23 | + <%= optional_field(profile, 'acronym', f.text_field(:acronym), only_required) %> | |
24 | + <%= optional_field(profile, 'foundation_year', f.text_field(:foundation_year), only_required) %> | |
22 | 25 | <% end %> | ... | ... |
app/views/shared/user_menu.rhtml
1 | -<div id="user_menu" class="top_extra_menu AOM_paddingBottom_6"<%= | |
2 | - ' help="'+ _('This menu gives you access to your personal functionalities.') +'"' if logged_in? | |
3 | - %>> | |
1 | +<div id="user_menu" class="top_extra_menu AOM_paddingBottom_6"> | |
4 | 2 | |
5 | 3 | <% if logged_in? %> |
6 | 4 | |
... | ... | @@ -16,7 +14,7 @@ |
16 | 14 | <ul> |
17 | 15 | |
18 | 16 | <li> |
19 | - <%= link_to( '<span class="icon-menu-home"></span>' + __('My Home Page'), user.url, :help => _('Go to your home page.'))%> | |
17 | + <%= link_to( '<span class="icon-menu-home"></span>' + __('My Home Page'), user.url)%> | |
20 | 18 | </li> |
21 | 19 | |
22 | 20 | <li> |
... | ... | @@ -40,22 +38,20 @@ |
40 | 38 | <% end %> |
41 | 39 | |
42 | 40 | <li> |
43 | - <%= link_to('<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), { :controller => 'profile_editor', :action => 'index', :profile => user.identifier }, :id => 'link_edit_profile', :help => _('Control panel: change your picture, edit your personal information, create content or change the way your home page looks.')) %> | |
41 | + <%= link_to('<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), { :controller => 'profile_editor', :action => 'index', :profile => user.identifier }, :id => 'link_edit_profile') %> | |
44 | 42 | </li> |
45 | 43 | |
46 | 44 | <% if user.is_admin?(environment) %> |
47 | 45 | <li><%= link_to( '<span class="icon-menu-admin"></span>'+ _('Admin'), |
48 | 46 | {:controller => 'admin_panel' }, |
49 | - :id => 'link_admin_panel', | |
50 | - :help => _('Access the site administration panel.') | |
51 | - )%></li> | |
47 | + :id => 'link_admin_panel' ) %> | |
48 | + </li> | |
52 | 49 | <% end %> |
53 | 50 | |
54 | 51 | <li><%= link_to( '<span class="icon-menu-logout"></span>'+ _('Logout'), |
55 | 52 | {:controller => 'account', :action => 'logout'}, |
56 | - :id => 'link_logout', | |
57 | - :help => _('This link takes you out of the system. You should logout if other people are willing to use the same computer after you.') | |
58 | - ) %></li> | |
53 | + :id => 'link_logout' ) %> | |
54 | + </li> | |
59 | 55 | |
60 | 56 | </ul> |
61 | 57 | </div><!-- id="user_menu_ul" --> | ... | ... |
app/views/tasks/_add_friend.rhtml
... | ... | @@ -21,18 +21,17 @@ |
21 | 21 | :onclick => "Element.hide('group-for-friend-#{task.id}')") %> |
22 | 22 | <label for="<%= "decision-cancel-#{task.id}" %>"><b><%= _('Ignore') %></b></label> |
23 | 23 | |
24 | - <% | |
25 | - content_tag('div', :id => "group-for-friend-#{task.id}", | |
26 | - :help => _('You can type the first letters of an existing group and have the system present you the available options, or you can type the name of a new group if you want.')) do %> | |
27 | - <%= _('Classify your new friend:') %> | |
28 | - <%= text_field_with_local_autocomplete("task[group_for_friend]", | |
29 | - profile.suggested_friend_groups, | |
30 | - {:id => "field-group-for-friend-#{task.id}", :maxlength => 150}) %> | |
24 | + <% content_tag('div', :id => "group-for-friend-#{task.id}") do %> | |
25 | + <%= _('Classify your new friend:') %> | |
26 | + <%= text_field_with_local_autocomplete("task[group_for_friend]", | |
27 | + profile.suggested_friend_groups, | |
28 | + {:id => "field-group-for-friend-#{task.id}", :maxlength => 150}) %> | |
29 | + | |
31 | 30 | <p class="friend-classify-suggestions"> |
32 | - <%= _('Suggestions: %s') % profile.suggested_friend_groups.join(', ') %> | |
31 | + <%= _('Suggestions: %s') % profile.suggested_friend_groups.join(', ') %> | |
33 | 32 | </p> |
34 | - | |
35 | 33 | <% end %> |
34 | + | |
36 | 35 | </div> |
37 | 36 | |
38 | 37 | <% button_bar do %> | ... | ... |
app/views/tasks/_task.rhtml
... | ... | @@ -4,12 +4,14 @@ |
4 | 4 | <% form_for('task', task, :url => { :action => 'close', :id => task.id}) do |f| %> |
5 | 5 | |
6 | 6 | <div> |
7 | - <%= radio_button_tag(:decision, 'finish', true) %> | |
8 | - <%= _('OK') %> | |
7 | + <%= labelled_radio_button _('OK'), :decision, 'finish', true, :onclick => 'if(this.checked) $("rejection-field").style.display="none"' %> | |
9 | 8 | </div> |
10 | 9 | <div> |
11 | - <%= radio_button_tag(:decision, 'cancel', false) %> | |
12 | - <%= _('Cancel') %> | |
10 | + <%= labelled_radio_button _('Cancel'), :decision, 'cancel', false, :onclick => 'if(this.checked) $("rejection-field").style.display="block"' %> | |
11 | + </div> | |
12 | + | |
13 | + <div id="rejection-field" style='display: none'> | |
14 | + <%= required labelled_form_field(_('Rejection explanation'), text_area(:task, :reject_explanation, :rows => 5))%> | |
13 | 15 | </div> |
14 | 16 | |
15 | 17 | <% button_bar do %> | ... | ... |
features/location.feature
... | ... | @@ -10,7 +10,7 @@ Feature: Location |
10 | 10 | And I am logged in as "zezinho" |
11 | 11 | |
12 | 12 | Scenario: editing my address |
13 | - Given the following Person fields are enabled | |
13 | + Given the following Person fields are active | |
14 | 14 | | address | |
15 | 15 | | country | |
16 | 16 | | state | |
... | ... | @@ -29,7 +29,7 @@ Feature: Location |
29 | 29 | | Rua Marechal Floriano, 28 | BR | Bahia | Salvador | 40110010 | |
30 | 30 | |
31 | 31 | Scenario Outline: editing address of collectives |
32 | - Given the following <class> fields are enabled | |
32 | + Given the following <class> fields are active | |
33 | 33 | | address | |
34 | 34 | | country | |
35 | 35 | | state | | ... | ... |
... | ... | @@ -0,0 +1,192 @@ |
1 | +Feature: register enterprise | |
2 | + As a noosfero user | |
3 | + I want to register an enterprise | |
4 | + In order to interact in the web with my enterprise | |
5 | + | |
6 | + Background: | |
7 | + Given the following users | |
8 | + | login | name | | |
9 | + | joaosilva | Joao Silva | | |
10 | + | |
11 | + And I am logged in as "joaosilva" | |
12 | + And I am on Joao Silva's control panel | |
13 | + And feature "enterprise_registration" is enabled on environment | |
14 | + | |
15 | + Scenario: enterprise registration is disabled by admin | |
16 | + Given feature "enterprise_registration" is disabled on environment | |
17 | + When I follow "Manage my groups" | |
18 | + Then I should not see "Register a new enterprise" | |
19 | + | |
20 | + Scenario: approval method is admin | |
21 | + Given organization_approval_method is "admin" on environment | |
22 | + And I follow "Manage my groups" | |
23 | + When I follow "Register a new enterprise" | |
24 | + Then I should not see "Region" | |
25 | + | |
26 | + Scenario: approval method is region | |
27 | + Given organization_approval_method is "region" on environment | |
28 | + And the following enterprise | |
29 | + | name | identifier | owner | | |
30 | + | Validator | validator | joaosilva | | |
31 | + And the following validation info | |
32 | + | validation_methodology | organization_name | | |
33 | + | "Sample methodology" | Validator | | |
34 | + And the following states | |
35 | + | name | validator_name | | |
36 | + | Sample State | Validator | | |
37 | + And I follow "Manage my groups" | |
38 | + When I follow "Register a new enterprise" | |
39 | + Then I should see "Region" | |
40 | + | |
41 | + Scenario: approval method is by region validator but there are no validators | |
42 | + Given organization_approval_method is "region" on environment | |
43 | + And I follow "Manage my groups" | |
44 | + When I follow "Register a new enterprise" | |
45 | + Then I should see "There are no validators to validate the registration of this new enterprise. Contact your administrator for instructions." | |
46 | + | |
47 | + Scenario: some active fields | |
48 | + Given the following enterprise fields are active | |
49 | + | foundation_year | | |
50 | + | contact_person | | |
51 | + | contact_email | | |
52 | + And I follow "Manage my groups" | |
53 | + When I follow "Register a new enterprise" | |
54 | + Then I should see "Foundation year" | |
55 | + Then I should see "Contact person" | |
56 | + Then I should see "Contact email" | |
57 | + | |
58 | + Scenario: some required fields | |
59 | + Given organization_approval_method is "admin" on environment | |
60 | + And I follow "Manage my groups" | |
61 | + And the following states | |
62 | + | name | | |
63 | + | Sample State | | |
64 | + And the following enterprise fields are required | |
65 | + | foundation_year | | |
66 | + | contact_person | | |
67 | + | contact_email | | |
68 | + And I follow "Register a new enterprise" | |
69 | + And I fill in the following: | |
70 | + | Identifier | my-enterprise | | |
71 | + | Name | My Enterprise | | |
72 | + | Foundation year | | | |
73 | + | Contact person | | | |
74 | + | Contact email | | | |
75 | + When I press "Next" | |
76 | + Then I should see "Foundation year can't be blank" | |
77 | + Then I should see "Contact person can't be blank" | |
78 | + Then I should see "Contact email can't be blank" | |
79 | + | |
80 | + Scenario: a user register an enterprise successfully through the admin | |
81 | + validator method and the admin accepts | |
82 | + Given organization_approval_method is "admin" on environment | |
83 | + And I follow "Manage my groups" | |
84 | + And the following states | |
85 | + | name | | |
86 | + | Sample State | | |
87 | + And I follow "Register a new enterprise" | |
88 | + And I fill in the following: | |
89 | + | Identifier | my-enterprise | | |
90 | + | Name | My Enterprise | | |
91 | + And I press "Next" | |
92 | + Then I should see "Enterprise Registration completed" | |
93 | + And I am logged in as admin | |
94 | + And I follow "Control panel" | |
95 | + When I follow "Tasks" | |
96 | + Then I should see /Processing task: Enterprise registration: "My Enterprise"/ | |
97 | + And I choose "Ok" | |
98 | + And I press "Ok" | |
99 | + And I am logged in as "joaosilva" | |
100 | + And I am on Joao Silva's control panel | |
101 | + When I follow "Manage my groups" | |
102 | + Then I should see "My Enterprise" | |
103 | + | |
104 | + Scenario: a user register an enterprise successfully through the admin | |
105 | + validator method and the admin rejects | |
106 | + Given organization_approval_method is "admin" on environment | |
107 | + And I follow "Manage my groups" | |
108 | + And the following states | |
109 | + | name | | |
110 | + | Sample State | | |
111 | + And I follow "Register a new enterprise" | |
112 | + And I fill in the following: | |
113 | + | Identifier | my-enterprise | | |
114 | + | Name | My Enterprise | | |
115 | + And I press "Next" | |
116 | + Then I should see "Enterprise Registration completed" | |
117 | + And I am logged in as admin | |
118 | + And I follow "Control panel" | |
119 | + When I follow "Tasks" | |
120 | + Then I should see /Processing task: Enterprise registration: "My Enterprise"/ | |
121 | + And I choose "Cancel" | |
122 | + And I fill in "Rejection explanation" with "This enterprise has some irregularities." | |
123 | + And I press "Ok" | |
124 | + And I am logged in as "joaosilva" | |
125 | + And I am on Joao Silva's control panel | |
126 | + When I follow "Manage my groups" | |
127 | + Then I should not see "My Enterprise" | |
128 | + | |
129 | + Scenario: a user register an enterprise successfully through the region | |
130 | + validator method and the validator accepts | |
131 | + Given organization_approval_method is "region" on environment | |
132 | + And I follow "Manage my groups" | |
133 | + And the following enterprise | |
134 | + | name | identifier | owner | | |
135 | + | Validator | validator | joaosilva | | |
136 | + And the following validation info | |
137 | + | validation_methodology | organization_name | | |
138 | + | "Sample methodology" | Validator | | |
139 | + And the following states | |
140 | + | name | validator_name | | |
141 | + | Sample State | Validator | | |
142 | + And I follow "Register a new enterprise" | |
143 | + And I fill in the following: | |
144 | + | Identifier | my-enterprise | | |
145 | + | Name | My Enterprise | | |
146 | + And I select "Sample State" from "Region" | |
147 | + And I press "Next" | |
148 | + Then I should see "Validator" | |
149 | + Then I should see "Sample methodology" | |
150 | + When I press "Confirm" | |
151 | + Then I should see "Enterprise Registration completed" | |
152 | + And I am on Validator's control panel | |
153 | + When I follow "Tasks" | |
154 | + Then I should see /Processing task: Enterprise registration: "My Enterprise"/ | |
155 | + And I choose "Ok" | |
156 | + And I press "Ok" | |
157 | + And I am on Joao Silva's control panel | |
158 | + When I follow "Manage my groups" | |
159 | + Then I should see "My Enterprise" | |
160 | + | |
161 | + Scenario: a user register an enterprise successfully through the region | |
162 | + validator method and the validator rejects | |
163 | + Given organization_approval_method is "region" on environment | |
164 | + And I follow "Manage my groups" | |
165 | + And the following enterprise | |
166 | + | name | identifier | owner | | |
167 | + | Validator | validator | joaosilva | | |
168 | + And the following validation info | |
169 | + | validation_methodology | organization_name | | |
170 | + | "Sample methodology" | Validator | | |
171 | + And the following states | |
172 | + | name | validator_name | | |
173 | + | Sample State | Validator | | |
174 | + And I follow "Register a new enterprise" | |
175 | + And I fill in the following: | |
176 | + | Identifier | my-enterprise | | |
177 | + | Name | My Enterprise | | |
178 | + And I select "Sample State" from "Region" | |
179 | + And I press "Next" | |
180 | + Then I should see "Validator" | |
181 | + Then I should see "Sample methodology" | |
182 | + When I press "Confirm" | |
183 | + Then I should see "Enterprise Registration completed" | |
184 | + And I am on Validator's control panel | |
185 | + When I follow "Tasks" | |
186 | + Then I should see /Processing task: Enterprise registration: "My Enterprise"/ | |
187 | + And I choose "Cancel" | |
188 | + And I fill in "Rejection explanation" with "This enterprise has some irregularities." | |
189 | + And I press "Ok" | |
190 | + And I am on Joao Silva's control panel | |
191 | + When I follow "Manage my groups" | |
192 | + Then I should not see "My Enterprise" | ... | ... |
features/step_definitions/noosfero_steps.rb
... | ... | @@ -65,7 +65,27 @@ Given /^the following products$/ do |table| |
65 | 65 | end |
66 | 66 | end |
67 | 67 | |
68 | +Given /^the following states$/ do |table| | |
69 | + table.hashes.each do |item| | |
70 | + data = item.dup | |
71 | + if validator = Enterprise.find_by_name(data.delete("validator_name")) | |
72 | + State.create!(data.merge(:environment => Environment.default, :validators => [validator])) | |
73 | + else | |
74 | + r = State.create!(data.merge(:environment => Environment.default)) | |
75 | + end | |
76 | + end | |
77 | +end | |
78 | + | |
79 | +Given /^the following validation info$/ do |table| | |
80 | + table.hashes.each do |item| | |
81 | + data = item.dup | |
82 | + organization = Organization.find_by_name(data.delete("organization_name")) | |
83 | + ValidationInfo.create!(data.merge(:organization => organization)) | |
84 | + end | |
85 | +end | |
86 | + | |
68 | 87 | Given /^I am logged in as "(.+)"$/ do |username| |
88 | + visit('/account/logout') | |
69 | 89 | visit('/account/login') |
70 | 90 | fill_in("Username", :with => username) |
71 | 91 | fill_in("Password", :with => '123456') |
... | ... | @@ -73,6 +93,7 @@ Given /^I am logged in as "(.+)"$/ do |username| |
73 | 93 | end |
74 | 94 | |
75 | 95 | Given /^I am logged in as admin$/ do |
96 | + visit('/account/logout') | |
76 | 97 | user = User.create!(:login => 'admin_user', :password => '123456', :password_confirmation => '123456', :email => 'admin_user@example.com') |
77 | 98 | e = Environment.default |
78 | 99 | e.add_admin(user.person) |
... | ... | @@ -86,15 +107,16 @@ Given /^I am not logged in$/ do |
86 | 107 | visit('/account/logout') |
87 | 108 | end |
88 | 109 | |
89 | -Given /^feature "(.+)" is enabled on environment$/ do |feature| | |
110 | +Given /^feature "(.+)" is (enabled|disabled) on environment$/ do |feature, status| | |
90 | 111 | e = Environment.default |
91 | - e.enable(feature) | |
112 | + status.chop! | |
113 | + e.send status, feature | |
92 | 114 | e.save |
93 | 115 | end |
94 | 116 | |
95 | -Given /^feature "(.+)" is disabled on environment$/ do |feature| | |
117 | +Given /^organization_approval_method is "(.+)" on environment$/ do |approval_method| | |
96 | 118 | e = Environment.default |
97 | - e.disable(feature) | |
119 | + e.organization_approval_method = approval_method | |
98 | 120 | e.save |
99 | 121 | end |
100 | 122 | |
... | ... | @@ -122,17 +144,18 @@ Given /^"([^\"]*)" has no articles$/ do |profile| |
122 | 144 | (Profile[profile] || Profile.find_by_name(profile)).articles.delete_all |
123 | 145 | end |
124 | 146 | |
125 | -Given /^the following (\w+) fields are enabled$/ do |klass, table| | |
147 | +Given /^the following (\w+) fields are (\w+)$/ do |klass, status, table| | |
126 | 148 | env = Environment.default |
127 | 149 | fields = table.raw.inject({}) do |hash, line| |
128 | 150 | hash[line.first] = { "active" => 'true' } |
151 | + hash[line.first].merge!({ "required" => 'true'}) if status == "required" | |
129 | 152 | hash |
130 | 153 | end |
131 | 154 | |
132 | 155 | env.send("custom_#{klass.downcase}_fields=", fields) |
133 | 156 | env.save! |
134 | - if fields.keys != env.send("active_#{klass.downcase}_fields") | |
135 | - raise "Not all fields enabled! Requested: %s; Enabled: %s" % [fields.keys.inspect, env.send("active_#{klass.downcase}_fields").inspect] | |
157 | + if fields.keys != env.send("#{status}_#{klass.downcase}_fields") | |
158 | + raise "Not all fields #{status}! Requested: %s; #{status.camelcase}: %s" % [fields.keys.inspect, env.send("#{status}_#{klass.downcase}_fields").inspect] | |
136 | 159 | end |
137 | 160 | end |
138 | 161 | ... | ... |
lib/noosfero.rb
lib/tasks/error_messages.rake
1 | -namespace :error do | |
2 | - task :messages => :makemo do | |
1 | +templates = Dir.glob(RAILS_ROOT + '/public/*.html.erb') | |
2 | +targets = [] | |
3 | +templates.each do |template| | |
4 | + target = template.gsub(/.erb$/, '') | |
5 | + targets << target | |
6 | + file target => [:makemo, template] do | |
3 | 7 | require 'erb' |
4 | - Dir.glob(RAILS_ROOT + '/public/*.html.erb').each do |template| | |
5 | - puts "Processing #{template}" | |
6 | - target = template.gsub(/.erb$/, '') | |
7 | - erb = ERB.new(File.read(template)) | |
8 | - File.open(target, 'w') do |file| | |
9 | - file.write(erb.result) | |
10 | - end | |
8 | + erb = ERB.new(File.read(template)) | |
9 | + File.open(target, 'w') do |file| | |
10 | + file.write(erb.result) | |
11 | 11 | end |
12 | + puts "#{template} -> #{target}" | |
13 | + end | |
14 | +end | |
15 | + | |
16 | +namespace :noosfero do | |
17 | + namespace 'error-pages' do | |
18 | + desc 'Translates Noosfero error pages' | |
19 | + task :translate => targets | |
12 | 20 | end |
13 | 21 | end | ... | ... |
lib/tasks/gettext.rake
... | ... | @@ -4,12 +4,12 @@ |
4 | 4 | |
5 | 5 | require 'noosfero' |
6 | 6 | |
7 | +makemo_stamp = 'tmp/makemo.stamp' | |
7 | 8 | desc "Create mo-files for L10n" |
8 | -task :makemo do | |
9 | - require 'gettext' | |
10 | - require 'gettext/rails' | |
11 | - require 'gettext/utils' | |
12 | - GetText.create_mofiles(true, "po", "locale") | |
9 | +task :makemo => makemo_stamp | |
10 | +file makemo_stamp do | |
11 | + ruby '-rconfig/boot -rgettext -rgettext/rails -rgettext/utils -e \'GetText.create_mofiles(true, "po", "locale")\' 2>/dev/null' | |
12 | + FileUtils.touch makemo_stamp | |
13 | 13 | end |
14 | 14 | |
15 | 15 | desc "Update pot/po files to match new version." | ... | ... |
lib/tasks/release.rake
... | ... | @@ -57,7 +57,7 @@ EOF |
57 | 57 | end |
58 | 58 | |
59 | 59 | desc 'prepares a release tarball' |
60 | - task :release => [ :check_tag, 'noosfero:doc:translate', :authors, :check_repo ] do | |
60 | + task :release => [ :check_tag, 'noosfero:doc:translate', 'noosfero:error-pages:translate', :authors, :check_repo ] do | |
61 | 61 | sh "git tag #{version}" |
62 | 62 | sh 'rake -f Rakefile.pkg' |
63 | 63 | puts "I: please upload the tarball to the website!" | ... | ... |
po/pt/noosfero-doc.po
... | ... | @@ -7,7 +7,7 @@ msgid "" |
7 | 7 | msgstr "" |
8 | 8 | "Project-Id-Version: PACKAGE VERSION\n" |
9 | 9 | "POT-Creation-Date: 2010-03-16 20:53-0300\n" |
10 | -"PO-Revision-Date: 2010-03-16 20:55-0300\n" | |
10 | +"PO-Revision-Date: 2010-04-12 16:13-0300\n" | |
11 | 11 | "Last-Translator: Automatically generated\n" |
12 | 12 | "Language-Team: none\n" |
13 | 13 | "MIME-Version: 1.0\n" |
... | ... | @@ -5094,7 +5094,7 @@ msgstr "<a href=\"/doc/user/sending-messages\">Enviando mensagens</a>" |
5094 | 5094 | # type: Content of: <ul><li> |
5095 | 5095 | #: doc/noosfero/user/toc.en.xhtml:8 |
5096 | 5096 | msgid "<a href=\"/doc/user/removing-comments\">Removing comments</a>" |
5097 | -msgstr "<a href=\"/doc/user/removing-comments\">Removedo comentários</a>" | |
5097 | +msgstr "<a href=\"/doc/user/removing-comments\">Removendo comentários</a>" | |
5098 | 5098 | |
5099 | 5099 | # type: Content of: <ul><li> |
5100 | 5100 | #: doc/noosfero/user/toc.en.xhtml:11 | ... | ... |
public/500.html
public/500.html.erb
... | ... | @@ -10,11 +10,6 @@ |
10 | 10 | <script type='text/javascript' src='/javascripts/errors.js'></script> |
11 | 11 | </head> |
12 | 12 | <body onload='display_error_message()'> |
13 | - <% | |
14 | - require 'gettext' | |
15 | - include GetText | |
16 | - bindtextdomain("noosfero") | |
17 | - %> | |
18 | 13 | <div id='wrap'> |
19 | 14 | <div id='header'> |
20 | 15 | <div id='logo'> |
... | ... | @@ -22,7 +17,7 @@ |
22 | 17 | </div> |
23 | 18 | </div> |
24 | 19 | <% Noosfero.each_locale do |language_code,language_name| %> |
25 | - <% GetText.locale = language_code %> | |
20 | + <% FastGettext.set_locale language_code %> | |
26 | 21 | <div id='<%= language_code %>' style='display: none' class='message'> |
27 | 22 | <h1><%= _('Temporary system problem') %></h1> |
28 | 23 | <p> | ... | ... |
public/503.html
public/503.html.erb
... | ... | @@ -11,11 +11,6 @@ |
11 | 11 | </head> |
12 | 12 | <body> |
13 | 13 | <body onload='display_error_message()'> |
14 | - <% | |
15 | - require 'gettext' | |
16 | - include GetText | |
17 | - bindtextdomain("noosfero") | |
18 | - %> | |
19 | 14 | <div id='wrap'> |
20 | 15 | <div id='header'> |
21 | 16 | <div id='logo'> |
... | ... | @@ -23,7 +18,7 @@ |
23 | 18 | </div> |
24 | 19 | </div> |
25 | 20 | <% Noosfero.each_locale do |language_code,language_name| %> |
26 | - <% GetText.locale = language_code %> | |
21 | + <% FastGettext.set_locale language_code %> | |
27 | 22 | <div id='<%= language_code %>' style='display: none' class='message'> |
28 | 23 | <h1><%= _('System maintainance') %></h1> |
29 | 24 | <p> | ... | ... |
public/stylesheets/application.css
... | ... | @@ -317,7 +317,7 @@ div.pending-tasks { |
317 | 317 | text-decoration: underline; |
318 | 318 | } |
319 | 319 | .last-update { |
320 | - font-size: small; | |
320 | + font-size: 12px; | |
321 | 321 | } |
322 | 322 | |
323 | 323 | /* * * icons for product category on profile * * */ |
... | ... | @@ -1148,7 +1148,7 @@ a.comment-picture { |
1148 | 1148 | |
1149 | 1149 | #content .created-at { |
1150 | 1150 | color: gray; |
1151 | - font-size: small; | |
1151 | + font-size: 12px; | |
1152 | 1152 | display: block; |
1153 | 1153 | text-align: right; |
1154 | 1154 | } |
... | ... | @@ -1892,7 +1892,7 @@ div#activation_enterprise div { |
1892 | 1892 | |
1893 | 1893 | .blog-archives-block .subscribe-feed { |
1894 | 1894 | padding: 5px 0px 10px 10px; |
1895 | - font-size: small; | |
1895 | + font-size: 12px; | |
1896 | 1896 | } |
1897 | 1897 | |
1898 | 1898 | /* ==> blocks/profile-info-block.css <<= */ |
... | ... | @@ -3025,6 +3025,16 @@ h1#agenda-title { |
3025 | 3025 | } |
3026 | 3026 | |
3027 | 3027 | /* ==> public/stylesheets/controller_profile_editor.css <== */ |
3028 | + | |
3029 | +.controller-profile_editor .categorie_box .button { | |
3030 | + float: left; | |
3031 | +} | |
3032 | + | |
3033 | +.controller-profile_editor #content ul.categories, | |
3034 | +.controller-profile_editor #content ul.categories li { | |
3035 | + list-style: none; | |
3036 | +} | |
3037 | + | |
3028 | 3038 | .controller-profile_editor .control-panel { |
3029 | 3039 | /*border: 1px solid red;*/ |
3030 | 3040 | padding: 0px 15px 0px 15px; | ... | ... |
test/functional/enterprise_registration_controller_test.rb
... | ... | @@ -30,23 +30,29 @@ all_fixtures |
30 | 30 | assert_template 'basic_information' |
31 | 31 | end |
32 | 32 | |
33 | - should 'prompt for basic information' do | |
34 | - get :index | |
35 | - %w[ name identifier address contact_phone contact_person | |
36 | - acronym foundation_year legal_form economic_activity ].each do |item| | |
37 | - assert_tag :tag => 'input', :attributes => { :name => "create_enterprise[#{item}]" } | |
38 | - end | |
39 | - assert_tag :tag => 'textarea', :attributes => { :name => "create_enterprise[management_information]"} | |
40 | - assert_tag :tag => 'select', :attributes => { :name => "create_enterprise[region_id]"} | |
41 | - end | |
42 | - | |
43 | 33 | should 'get back to entering basic information if data is invalid' do |
44 | 34 | post :index, :create_enterprise => {} |
45 | 35 | assert_response :success |
46 | 36 | assert_template 'basic_information' |
47 | 37 | end |
48 | 38 | |
49 | - should 'prompt for selecting validator' do | |
39 | + should 'skip prompt for selection validator if approval method is admin' do | |
40 | + env = Environment.default | |
41 | + env.organization_approval_method = :admin | |
42 | + env.save | |
43 | + region = fast_create(Region) | |
44 | + | |
45 | + data = { :name => 'My new enterprise', :identifier => 'mynew', :region => region } | |
46 | + create_enterprise = CreateEnterprise.new(data) | |
47 | + | |
48 | + post :index, :create_enterprise => data | |
49 | + assert_template 'confirmation' | |
50 | + end | |
51 | + | |
52 | + should 'prompt for selecting validator if approval method is region' do | |
53 | + env = Environment.default | |
54 | + env.organization_approval_method = :region | |
55 | + env.save | |
50 | 56 | data = { 'name' => 'My new enterprise', 'identifier' => 'mynew' } |
51 | 57 | |
52 | 58 | create_enterprise = CreateEnterprise.new |
... | ... | @@ -135,8 +141,10 @@ all_fixtures |
135 | 141 | assert_sanitized assigns(:create_enterprise).management_information |
136 | 142 | end |
137 | 143 | |
138 | - should 'load only regions with validator organizations' do | |
144 | + should 'load only regions with validator organizations if approval method is region' do | |
139 | 145 | env = Environment.default |
146 | + env.organization_approval_method = :region | |
147 | + env.save | |
140 | 148 | |
141 | 149 | reg1 = env.regions.create!(:name => 'Region with validator') |
142 | 150 | reg1.validators.create!(:name => 'Validator one', :identifier => 'validator-one') | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -639,9 +639,30 @@ class ProfileControllerTest < Test::Unit::TestCase |
639 | 639 | assert_nil @request.session[:before_join] |
640 | 640 | end |
641 | 641 | |
642 | - should 'show link to events in index' do | |
642 | + should 'show number of published events in index' do | |
643 | + profile.articles << Event.new(:name => 'Published event', :start_date => Date.today) | |
644 | + profile.articles << Event.new(:name => 'Unpublished event', :start_date => Date.today, :published => false) | |
645 | + | |
646 | + get :index, :profile => profile.identifier | |
647 | + assert_tag :tag => 'a', :content => '1', :attributes => { :href => "/profile/testuser/events" } | |
648 | + end | |
649 | + | |
650 | + should 'show number of published posts in index' do | |
651 | + profile.articles << blog = Blog.create(:name => 'Blog', :profile_id => profile.id) | |
652 | + blog.posts << TextileArticle.new(:name => 'Published post', :parent => profile.blog, :profile => profile) | |
653 | + blog.posts << TextileArticle.new(:name => 'Other published post', :parent => profile.blog, :profile => profile) | |
654 | + blog.posts << TextileArticle.new(:name => 'Unpublished post', :parent => profile.blog, :profile => profile, :published => false) | |
655 | + | |
643 | 656 | get :index, :profile => profile.identifier |
644 | - assert_tag :tag => 'a', :attributes => { :href => "/profile/#{profile.identifier}/events" } | |
657 | + assert_tag :tag => 'a', :content => '2 posts', :attributes => { :href => /\/testuser\/blog/ } | |
645 | 658 | end |
646 | 659 | |
660 | + should 'show number of published images in index' do | |
661 | + folder = Folder.create!(:name => 'gallery', :profile => profile, :view_as => 'image_gallery') | |
662 | + published_file = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | |
663 | + unpublished_file = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :published => false) | |
664 | + | |
665 | + get :index, :profile => profile.identifier | |
666 | + assert_tag :tag => 'a', :content => 'One picture', :attributes => { :href => /\/testuser\/gallery/ } | |
667 | + end | |
647 | 668 | end | ... | ... |
test/functional/profile_members_controller_test.rb
... | ... | @@ -162,6 +162,20 @@ class ProfileMembersControllerTest < Test::Unit::TestCase |
162 | 162 | assert_no_tag :tag => 'a', :attributes => {:href => /add_members/} |
163 | 163 | end |
164 | 164 | |
165 | + should 'not display remove button if the member is the current user' do | |
166 | + com = Community.create!(:name => 'Test Com', :identifier => 'test_com') | |
167 | + admin = create_user_with_permission('admin-member', 'manage_memberships', com) | |
168 | + member = fast_create(Person, :name => 'just-member') | |
169 | + com.add_member(member) | |
170 | + | |
171 | + login_as(admin.identifier) | |
172 | + | |
173 | + get :index, :profile => com.identifier | |
174 | + | |
175 | + assert_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{member.identifier}/} } | |
176 | + assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :attributes => {:class => /icon-remove/, :onclick => /#{admin.identifier}/} } | |
177 | + end | |
178 | + | |
165 | 179 | should 'have a add_members page' do |
166 | 180 | ent = Enterprise.create!(:name => 'Test Ent', :identifier => 'test_ent') |
167 | 181 | u = create_user_with_permission('test_user', 'manage_memberships', ent) | ... | ... |
test/integration/enterprise_registration_test.rb
... | ... | @@ -7,6 +7,8 @@ class EnterpriseRegistrationTest < ActionController::IntegrationTest |
7 | 7 | should 'be able to create an enterprise registration request' do |
8 | 8 | |
9 | 9 | environment = Environment.default |
10 | + environment.organization_approval_method = :region | |
11 | + environment.save | |
10 | 12 | region1 = environment.regions.build(:name => 'A region') |
11 | 13 | region1.save! |
12 | 14 | region2 = environment.regions.build(:name => 'Other region') | ... | ... |
test/unit/article_test.rb
... | ... | @@ -81,6 +81,11 @@ class ArticleTest < Test::Unit::TestCase |
81 | 81 | assert_equal 'the body of the article', a.to_html |
82 | 82 | end |
83 | 83 | |
84 | + should 'provide HTML version when body is nil' do | |
85 | + a = fast_create(Article, :profile_id => profile.id, :body => nil) | |
86 | + assert_equal '', a.to_html | |
87 | + end | |
88 | + | |
84 | 89 | should 'provide first paragraph of HTML version' do |
85 | 90 | profile = create_user('testinguser').person |
86 | 91 | a = Article.create!(:name => 'my article', :profile_id => profile.id) |
... | ... | @@ -829,4 +834,12 @@ class ArticleTest < Test::Unit::TestCase |
829 | 834 | assert_equal 'http://url.without.http', article.external_link |
830 | 835 | end |
831 | 836 | |
837 | + should 'list only published articles' do | |
838 | + profile = fast_create(Person) | |
839 | + | |
840 | + published = profile.articles.create(:name => 'Published', :published => true) | |
841 | + unpublished = profile.articles.create(:name => 'Unpublished', :published => false) | |
842 | + | |
843 | + assert_equal [ published ], profile.articles.published | |
844 | + end | |
832 | 845 | end | ... | ... |
test/unit/blog_helper_test.rb
... | ... | @@ -75,6 +75,15 @@ class BlogHelperTest < Test::Unit::TestCase |
75 | 75 | assert_equal 'TITLE TO_HTML', display_post(article) |
76 | 76 | end |
77 | 77 | |
78 | + should 'display empty post if body is nil' do | |
79 | + blog.children << article = fast_create(Article, :profile_id => profile.id, :parent_id => blog.id, :body => nil) | |
80 | + expects(:article_title).with(article).returns('TITLE') | |
81 | + expects(:content_tag).with('p', '').returns('') | |
82 | + self.stubs(:params).returns({:npage => nil}) | |
83 | + | |
84 | + assert_equal 'TITLE', display_post(article) | |
85 | + end | |
86 | + | |
78 | 87 | should 'display link to file if post is an uploaded_file' do |
79 | 88 | file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :profile => profile, :published => true, :parent => blog) |
80 | 89 | ... | ... |
test/unit/create_enterprise_test.rb
... | ... | @@ -219,6 +219,21 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
219 | 219 | assert request.errors.invalid?(:identifier) |
220 | 220 | end |
221 | 221 | |
222 | + should 'require the same fields as an enterprise does' do | |
223 | + environment = mock | |
224 | + request = CreateEnterprise.new | |
225 | + request.stubs(:environment).returns(environment) | |
226 | + environment.stubs(:organization_approval_method).returns(:region) | |
227 | + | |
228 | + environment.stubs(:required_enterprise_fields).returns([]) | |
229 | + request.valid? | |
230 | + assert_nil request.errors[:contact_person], 'should not require contact_person unless Enterprise requires it' | |
231 | + | |
232 | + environment.stubs(:required_enterprise_fields).returns(['contact_person']) | |
233 | + request.valid? | |
234 | + assert_not_nil request.errors[:contact_person], 'should require contact_person when Enterprise requires it' | |
235 | + end | |
236 | + | |
222 | 237 | should 'has permission to validate enterprise' do |
223 | 238 | t = CreateEnterprise.new |
224 | 239 | assert_equal :validate_enterprise, t.permission | ... | ... |
test/unit/folder_helper_test.rb
... | ... | @@ -15,4 +15,77 @@ class FolderHelperTest < Test::Unit::TestCase |
15 | 15 | assert_equal 'icons-mime/unknown.png', icon_for_article(art2) |
16 | 16 | end |
17 | 17 | |
18 | + should 'list all the folder\'s children to the owner' do | |
19 | + profile = create_user('Folder Owner').person | |
20 | + folder = fast_create(Folder, :profile_id => profile.id) | |
21 | + sub_folder = fast_create(Folder, {:parent_id => folder.id, :profile_id => profile.id}) | |
22 | + sub_blog = fast_create(Blog, {:parent_id => folder.id, :profile_id => profile.id}) | |
23 | + sub_article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id, :published => false}) | |
24 | + | |
25 | + result = available_articles(folder.children, profile) | |
26 | + | |
27 | + assert_includes result, sub_folder | |
28 | + assert_includes result, sub_article | |
29 | + assert_includes result, sub_blog | |
30 | + end | |
31 | + | |
32 | + should 'list the folder\'s children that are public to the user' do | |
33 | + profile = create_user('Folder Owner').person | |
34 | + profile2 = create_user('Folder Viwer').person | |
35 | + folder = fast_create(Folder, :profile_id => profile.id) | |
36 | + public_article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id, :published => true}) | |
37 | + not_public_article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id, :published => false}) | |
38 | + | |
39 | + result = available_articles(folder.children, profile2) | |
40 | + | |
41 | + assert_includes result, public_article | |
42 | + assert_not_includes result, not_public_article | |
43 | + end | |
44 | + | |
45 | + should ' not list the folder\'s children to the user because the owner\'s profile is not public' do | |
46 | + profile = create_user('folder-owner').person | |
47 | + profile.public_profile = false | |
48 | + profile.save! | |
49 | + profile2 = create_user('Folder Viwer').person | |
50 | + folder = fast_create(Folder, :profile_id => profile.id) | |
51 | + article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id}) | |
52 | + | |
53 | + result = available_articles(folder.children, profile2) | |
54 | + | |
55 | + assert_not_includes result, article | |
56 | + end | |
57 | + | |
58 | + should ' not list the folder\'s children to the user because the owner\'s profile is not visible' do | |
59 | + profile = create_user('folder-owner').person | |
60 | + profile.visible = false | |
61 | + profile.save! | |
62 | + profile2 = create_user('Folder Viwer').person | |
63 | + folder = fast_create(Folder, :profile_id => profile.id) | |
64 | + article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id}) | |
65 | + | |
66 | + result = available_articles(folder.children, profile2) | |
67 | + | |
68 | + assert_not_includes result, article | |
69 | + end | |
70 | + | |
71 | + should 'list subitems as HTML content' do | |
72 | + profile = create_user('folder-owner').person | |
73 | + folder = fast_create(Folder, {:name => 'Parent Folder', :profile_id => profile.id}) | |
74 | + article = fast_create(Article, {:name => 'Article1', :parent_id => folder.id, :profile_id => profile.id}) | |
75 | + article = fast_create(Article, {:name => 'Article2', :parent_id => folder.id, :profile_id => profile.id}) | |
76 | + | |
77 | + result = folder.list_articles(folder.children) | |
78 | + | |
79 | + assert_tag_in_string result, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/folder-owner\/my-article-[0-9]*(\?|$)/ } }, :content => /Article1/ | |
80 | + assert_tag_in_string result, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/folder-owner\/my-article-[0-9]*(\?|$)/ } }, :content => /Article2/ | |
81 | + end | |
82 | + | |
83 | + should 'explictly advise if empty' do | |
84 | + profile = create_user('folder-owner').person | |
85 | + folder = fast_create(Folder, {:name => 'Parent Folder', :profile_id => profile.id}) | |
86 | + result = folder.list_articles(folder.children) | |
87 | + | |
88 | + assert_match '(empty folder)', result | |
89 | + end | |
90 | + | |
18 | 91 | end | ... | ... |
test/unit/region_test.rb
... | ... | @@ -53,4 +53,20 @@ class RegionTest < Test::Unit::TestCase |
53 | 53 | assert !region.has_validator? |
54 | 54 | end |
55 | 55 | |
56 | + should 'list regions with validators' do | |
57 | + bahia = fast_create(Region, :name => 'Bahia') | |
58 | + bahia.validators << fast_create(Enterprise, :name => 'Forum Baiano de Economia Solidaria', :identifier => 'ecosol-ba') | |
59 | + | |
60 | + sergipe = fast_create(Region, :name => 'Sergipe') | |
61 | + # Sergipe has no validators | |
62 | + | |
63 | + assert_equivalent [bahia], Region.with_validators | |
64 | + end | |
65 | + | |
66 | + should 'list each region with validatores only once' do | |
67 | + bahia = fast_create(Region, :name => 'Bahia') | |
68 | + 2.times { |i| bahia.validators << fast_create(Enterprise, :name => "validator #{i}", :identifier => "validator-#{i}")} | |
69 | + assert_equal [bahia], Region.with_validators | |
70 | + end | |
71 | + | |
56 | 72 | end | ... | ... |
test/unit/slideshow_block_test.rb
... | ... | @@ -35,11 +35,11 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
35 | 35 | gallery = mock |
36 | 36 | images = [] |
37 | 37 | shuffled = [] |
38 | - gallery.stubs(:images).returns(images) | |
39 | - images.expects(:shuffle).once.returns(shuffled) | |
40 | - | |
41 | 38 | block = SlideshowBlock.new(:shuffle => true) |
42 | 39 | block.stubs(:gallery).returns(gallery) |
40 | + block.stubs(:block_images).returns(images) | |
41 | + images.expects(:shuffle).once.returns(shuffled) | |
42 | + | |
43 | 43 | block.content |
44 | 44 | end |
45 | 45 | |
... | ... | @@ -51,4 +51,14 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
51 | 51 | assert_equal false, SlideshowBlock.new.navigation |
52 | 52 | end |
53 | 53 | |
54 | + should 'not show folders' do | |
55 | + folder = fast_create(Folder, :profile_id => profile.id) | |
56 | + gallery = fast_create(Folder, :profile_id => profile.id) | |
57 | + gallery.children << folder | |
58 | + block = SlideshowBlock.new | |
59 | + block.stubs(:gallery).returns(gallery) | |
60 | + | |
61 | + assert_not_includes block.block_images, folder | |
62 | + end | |
63 | + | |
54 | 64 | end | ... | ... |