Commit 785b56adcdd6b0a026d4c734063d4705054b0e2f
Exists in
staging
and in
22 other branches
Merge branch 'master' into field-of-interest
Showing
310 changed files
with
2575 additions
and
1519 deletions
Show diff stats
app/api/entities.rb
... | ... | @@ -93,7 +93,9 @@ module Api |
93 | 93 | class Box < Entity |
94 | 94 | root 'boxes', 'box' |
95 | 95 | expose :id, :position |
96 | - expose :blocks, :using => Block | |
96 | + expose :blocks, :using => Block do |box, options| | |
97 | + box.blocks.select {|block| block.visible_to_user?(options[:current_person]) } | |
98 | + end | |
97 | 99 | end |
98 | 100 | |
99 | 101 | class Profile < Entity |
... | ... | @@ -200,12 +202,21 @@ module Api |
200 | 202 | expose :accept_comments?, as: :accept_comments |
201 | 203 | end |
202 | 204 | |
205 | + def self.permissions_for_entity(entity, current_person, *method_names) | |
206 | + method_names.map { |method| entity.send(method, current_person) ? method.to_s.gsub(/\?/,'') : nil }.compact | |
207 | + end | |
208 | + | |
203 | 209 | class Article < ArticleBase |
204 | 210 | root 'articles', 'article' |
205 | 211 | expose :parent, :using => ArticleBase |
206 | 212 | expose :children, :using => ArticleBase do |article, options| |
207 | 213 | article.children.published.limit(V1::Articles::MAX_PER_PAGE) |
208 | 214 | end |
215 | + expose :permissions do |article, options| | |
216 | + Entities.permissions_for_entity(article, options[:current_person], | |
217 | + :allow_edit?, :allow_post_content?, :allow_delete?, :allow_create?, | |
218 | + :allow_publish_content?) | |
219 | + end | |
209 | 220 | end |
210 | 221 | |
211 | 222 | class User < Entity | ... | ... |
app/api/helpers.rb
... | ... | @@ -121,7 +121,7 @@ module Api |
121 | 121 | |
122 | 122 | def present_article(asset) |
123 | 123 | article = find_article(asset.articles, params[:id]) |
124 | - present_partial article, :with => Entities::Article, :params => params | |
124 | + present_partial article, with: Entities::Article, params: params, current_person: current_person | |
125 | 125 | end |
126 | 126 | |
127 | 127 | def present_articles_for_asset(asset, method = 'articles') |
... | ... | @@ -130,7 +130,7 @@ module Api |
130 | 130 | end |
131 | 131 | |
132 | 132 | def present_articles(articles) |
133 | - present_partial paginate(articles), :with => Entities::Article, :params => params | |
133 | + present_partial paginate(articles), :with => Entities::Article, :params => params, current_person: current_person | |
134 | 134 | end |
135 | 135 | |
136 | 136 | def find_articles(asset, method = 'articles') |
... | ... | @@ -407,9 +407,11 @@ module Api |
407 | 407 | |
408 | 408 | def parse_content_type(content_type) |
409 | 409 | return nil if content_type.blank? |
410 | - content_type.split(',').map do |content_type| | |
411 | - content_type.camelcase | |
410 | + content_types = content_type.split(',').map do |content_type| | |
411 | + content_type = content_type.camelcase | |
412 | + content_type == 'TextArticle' ? Article.text_article_types : content_type | |
412 | 413 | end |
414 | + content_types.flatten.uniq | |
413 | 415 | end |
414 | 416 | |
415 | 417 | def period(from_date, until_date) | ... | ... |
app/api/v1/activities.rb
1 | 1 | module Api |
2 | 2 | module V1 |
3 | 3 | class Activities < Grape::API |
4 | - before { authenticate! } | |
5 | 4 | |
6 | 5 | resource :profiles do |
7 | 6 | |
... | ... | @@ -9,7 +8,7 @@ module Api |
9 | 8 | profile = Profile.find_by id: params[:id] |
10 | 9 | |
11 | 10 | not_found! if profile.blank? || profile.secret || !profile.visible |
12 | - forbidden! if !profile.secret && profile.visible && !profile.display_private_info_to?(current_person) | |
11 | + forbidden! if !profile.display_private_info_to?(current_person) | |
13 | 12 | |
14 | 13 | activities = profile.activities.map(&:activity) |
15 | 14 | present activities, :with => Entities::Activity, :current_person => current_person | ... | ... |
app/api/v1/articles.rb
... | ... | @@ -54,6 +54,17 @@ module Api |
54 | 54 | present_partial article, :with => Entities::Article |
55 | 55 | end |
56 | 56 | |
57 | + delete ':id' do | |
58 | + article = environment.articles.find(params[:id]) | |
59 | + return forbidden! unless article.allow_delete?(current_person) | |
60 | + begin | |
61 | + article.destroy | |
62 | + { :success => true } | |
63 | + rescue Exception => exception | |
64 | + render_api_error!(_('The article couldn\'t be removed due to some problem. Please contact the administrator.'), 400) | |
65 | + end | |
66 | + end | |
67 | + | |
57 | 68 | desc 'Report a abuse and/or violent content in a article by id' do |
58 | 69 | detail 'Submit a abuse (in general, a content violation) report about a specific article' |
59 | 70 | params Entities::Article.documentation |
... | ... | @@ -262,7 +273,7 @@ module Api |
262 | 273 | article = forbidden! |
263 | 274 | end |
264 | 275 | |
265 | - present_partial article, :with => Entities::Article | |
276 | + present_partial article, :with => Entities::Article, current_person: current_person | |
266 | 277 | else |
267 | 278 | |
268 | 279 | present_articles_for_asset(profile) | ... | ... |
app/api/v1/boxes.rb
... | ... | @@ -12,7 +12,8 @@ module Api |
12 | 12 | resource :boxes do |
13 | 13 | get do |
14 | 14 | profile = environment.send(kind.pluralize).find(params["#{kind}_id"]) |
15 | - present profile.boxes, :with => Entities::Box | |
15 | + return forbidden! unless profile.display_info_to?(current_person) | |
16 | + present profile.boxes, with: Entities::Box, current_person: current_person | |
16 | 17 | end |
17 | 18 | end |
18 | 19 | end |
... | ... | @@ -32,7 +33,7 @@ module Api |
32 | 33 | else |
33 | 34 | env = Environment.find(params[:environment_id]) |
34 | 35 | end |
35 | - present env.boxes, :with => Entities::Box | |
36 | + present env.boxes, with: Entities::Box, current_person: current_person | |
36 | 37 | end |
37 | 38 | end |
38 | 39 | end | ... | ... |
app/api/v1/comments.rb
... | ... | @@ -34,6 +34,7 @@ module Api |
34 | 34 | post ":id/comments" do |
35 | 35 | authenticate! |
36 | 36 | article = find_article(environment.articles, params[:id]) |
37 | + return forbidden! unless article.accept_comments? | |
37 | 38 | options = params.select { |key,v| !['id','private_token'].include?(key) }.merge(:author => current_person, :source => article) |
38 | 39 | begin |
39 | 40 | comment = Comment.create!(options) |
... | ... | @@ -42,6 +43,19 @@ module Api |
42 | 43 | end |
43 | 44 | present comment, :with => Entities::Comment, :current_person => current_person |
44 | 45 | end |
46 | + | |
47 | + delete ":id/comments/:comment_id" do | |
48 | + article = find_article(environment.articles, params[:id]) | |
49 | + comment = article.comments.find_by_id(params[:comment_id]) | |
50 | + return not_found! if comment.nil? | |
51 | + return forbidden! unless comment.can_be_destroyed_by?(current_person) | |
52 | + begin | |
53 | + comment.destroy | |
54 | + present comment, with: Entities::Comment, :current_person => current_person | |
55 | + rescue => e | |
56 | + render_api_error!(e.message, 500) | |
57 | + end | |
58 | + end | |
45 | 59 | end |
46 | 60 | |
47 | 61 | end | ... | ... |
app/api/v1/profiles.rb
... | ... | @@ -22,6 +22,15 @@ module Api |
22 | 22 | not_found! |
23 | 23 | end |
24 | 24 | end |
25 | + | |
26 | + desc "Update profile information" | |
27 | + post ':id' do | |
28 | + authenticate! | |
29 | + profile = environment.profiles.find_by(id: params[:id]) | |
30 | + return forbidden! unless current_person.has_permission?(:edit_profile, profile) | |
31 | + profile.update_attributes!(params[:profile]) | |
32 | + present profile, :with => Entities::Profile, :current_person => current_person | |
33 | + end | |
25 | 34 | |
26 | 35 | delete ':id' do |
27 | 36 | authenticate! | ... | ... |
... | ... | @@ -0,0 +1,169 @@ |
1 | +module AuthenticatedSystem | |
2 | + | |
3 | + protected | |
4 | + | |
5 | + extend ActiveSupport::Concern | |
6 | + | |
7 | + included do | |
8 | + if self < ActionController::Base | |
9 | + around_filter :user_set_current | |
10 | + before_filter :override_user | |
11 | + before_filter :login_from_cookie | |
12 | + end | |
13 | + | |
14 | + # Inclusion hook to make #current_user and #logged_in? | |
15 | + # available as ActionView helper methods. | |
16 | + helper_method :current_user, :logged_in? | |
17 | + end | |
18 | + | |
19 | + # Returns true or false if the user is logged in. | |
20 | + # Preloads @current_user with the user model if they're logged in. | |
21 | + def logged_in? | |
22 | + current_user != nil | |
23 | + end | |
24 | + | |
25 | + # Accesses the current user from the session. | |
26 | + def current_user user_id = session[:user] | |
27 | + @current_user ||= begin | |
28 | + user = User.find_by id: user_id if user_id | |
29 | + user.session = session if user | |
30 | + User.current = user | |
31 | + user | |
32 | + end | |
33 | + end | |
34 | + | |
35 | + # Store the given user in the session. | |
36 | + def current_user=(new_user) | |
37 | + if new_user.nil? | |
38 | + session.delete(:user) | |
39 | + else | |
40 | + session[:user] = new_user.id | |
41 | + new_user.session = session | |
42 | + new_user.register_login | |
43 | + end | |
44 | + @current_user = User.current = new_user | |
45 | + end | |
46 | + | |
47 | + # See impl. from http://stackoverflow.com/a/2513456/670229 | |
48 | + def user_set_current | |
49 | + User.current = current_user | |
50 | + yield | |
51 | + ensure | |
52 | + # to address the thread variable leak issues in Puma/Thin webserver | |
53 | + User.current = nil | |
54 | + end | |
55 | + | |
56 | + # Check if the user is authorized. | |
57 | + # | |
58 | + # Override this method in your controllers if you want to restrict access | |
59 | + # to only a few actions or if you want to check if the user | |
60 | + # has the correct rights. | |
61 | + # | |
62 | + # Example: | |
63 | + # | |
64 | + # # only allow nonbobs | |
65 | + # def authorize? | |
66 | + # current_user.login != "bob" | |
67 | + # end | |
68 | + def authorized? | |
69 | + true | |
70 | + end | |
71 | + | |
72 | + # Filter method to enforce a login requirement. | |
73 | + # | |
74 | + # To require logins for all actions, use this in your controllers: | |
75 | + # | |
76 | + # before_filter :login_required | |
77 | + # | |
78 | + # To require logins for specific actions, use this in your controllers: | |
79 | + # | |
80 | + # before_filter :login_required, :only => [ :edit, :update ] | |
81 | + # | |
82 | + # To skip this in a subclassed controller: | |
83 | + # | |
84 | + # skip_before_filter :login_required | |
85 | + # | |
86 | + def login_required | |
87 | + username, passwd = get_auth_data | |
88 | + if username && passwd | |
89 | + self.current_user ||= User.authenticate(username, passwd) || nil | |
90 | + end | |
91 | + if logged_in? && authorized? | |
92 | + true | |
93 | + else | |
94 | + if params[:require_login_popup] | |
95 | + render :json => { :require_login_popup => true } | |
96 | + else | |
97 | + access_denied | |
98 | + end | |
99 | + end | |
100 | + end | |
101 | + | |
102 | + # Redirect as appropriate when an access request fails. | |
103 | + # | |
104 | + # The default action is to redirect to the login screen. | |
105 | + # | |
106 | + # Override this method in your controllers if you want to have special | |
107 | + # behavior in case the user is not authorized | |
108 | + # to access the requested action. For example, a popup window might | |
109 | + # simply close itself. | |
110 | + def access_denied | |
111 | + respond_to do |accepts| | |
112 | + accepts.html do | |
113 | + if request.xhr? | |
114 | + render :text => _('Access denied'), :status => 401 | |
115 | + else | |
116 | + store_location | |
117 | + redirect_to :controller => '/account', :action => 'login' | |
118 | + end | |
119 | + end | |
120 | + accepts.xml do | |
121 | + headers["Status"] = "Unauthorized" | |
122 | + headers["WWW-Authenticate"] = %(Basic realm="Web Password") | |
123 | + render :text => "Could't authenticate you", :status => '401 Unauthorized' | |
124 | + end | |
125 | + end | |
126 | + false | |
127 | + end | |
128 | + | |
129 | + # Store the URI of the current request in the session. | |
130 | + # | |
131 | + # We can return to this location by calling #redirect_back_or_default. | |
132 | + def store_location(location = request.url) | |
133 | + session[:return_to] = location | |
134 | + end | |
135 | + | |
136 | + # Redirect to the URI stored by the most recent store_location call or | |
137 | + # to the passed default. | |
138 | + def redirect_back_or_default(default) | |
139 | + if session[:return_to] | |
140 | + redirect_to(session.delete(:return_to)) | |
141 | + else | |
142 | + redirect_to(default) | |
143 | + end | |
144 | + end | |
145 | + | |
146 | + def override_user | |
147 | + return if params[:override_user].blank? | |
148 | + return unless logged_in? and user.is_admin? environment | |
149 | + @current_user = nil | |
150 | + current_user params[:override_user] | |
151 | + end | |
152 | + | |
153 | + # When called with before_filter :login_from_cookie will check for an :auth_token | |
154 | + # cookie and log the user back in if apropriate | |
155 | + def login_from_cookie | |
156 | + return if cookies[:auth_token].blank? or logged_in? | |
157 | + user = User.where(remember_token: cookies[:auth_token]).first | |
158 | + self.current_user = user if user and user.remember_token? | |
159 | + end | |
160 | + | |
161 | + private | |
162 | + @@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization) | |
163 | + # gets BASIC auth info | |
164 | + def get_auth_data | |
165 | + auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) } | |
166 | + auth_data = request.env[auth_key].to_s.split unless auth_key.blank? | |
167 | + return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil] | |
168 | + end | |
169 | +end | ... | ... |
app/controllers/application_controller.rb
... | ... | @@ -13,6 +13,13 @@ class ApplicationController < ActionController::Base |
13 | 13 | before_filter :verify_members_whitelist, :if => [:private_environment?, :user] |
14 | 14 | before_filter :redirect_to_current_user |
15 | 15 | |
16 | + before_filter :set_session_theme | |
17 | + def set_session_theme | |
18 | + if params[:theme] | |
19 | + session[:theme] = environment.theme_ids.include?(params[:theme]) ? params[:theme] : nil | |
20 | + end | |
21 | + end | |
22 | + | |
16 | 23 | def require_login_for_environment |
17 | 24 | login_required |
18 | 25 | end | ... | ... |
app/controllers/my_profile/profile_themes_controller.rb
... | ... | @@ -63,12 +63,12 @@ class ProfileThemesController < ThemesController |
63 | 63 | end |
64 | 64 | |
65 | 65 | def start_test |
66 | - session[:theme] = params[:id] | |
66 | + session[:user_theme] = params[:id] | |
67 | 67 | redirect_to :controller => 'content_viewer', :profile => profile.identifier, :action => 'view_page' |
68 | 68 | end |
69 | 69 | |
70 | 70 | def stop_test |
71 | - session[:theme] = nil | |
71 | + session[:user_theme] = nil | |
72 | 72 | redirect_to :action => 'index' |
73 | 73 | end |
74 | 74 | ... | ... |
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -209,7 +209,7 @@ class ContentViewerController < ApplicationController |
209 | 209 | end |
210 | 210 | |
211 | 211 | if @page.published && @page.uploaded_file? |
212 | - redirect_to @page.public_filename | |
212 | + redirect_to "#{Noosfero.root}#{@page.public_filename}" | |
213 | 213 | else |
214 | 214 | send_data data, @page.download_headers |
215 | 215 | end | ... | ... |
app/helpers/application_helper.rb
... | ... | @@ -233,13 +233,6 @@ module ApplicationHelper |
233 | 233 | link_to(content_tag('span', text), url, html_options.merge(:class => the_class, :title => text)) |
234 | 234 | end |
235 | 235 | |
236 | - def button_bar(options = {}, &block) | |
237 | - options[:class].nil? ? | |
238 | - options[:class]='button-bar' : | |
239 | - options[:class]+=' button-bar' | |
240 | - concat(content_tag('div', capture(&block).to_s + tag('br', :style => 'clear: left;'), options)) | |
241 | - end | |
242 | - | |
243 | 236 | def render_profile_actions klass |
244 | 237 | name = klass.to_s.underscore |
245 | 238 | begin |
... | ... | @@ -351,7 +344,7 @@ module ApplicationHelper |
351 | 344 | end |
352 | 345 | |
353 | 346 | def is_testing_theme |
354 | - !controller.session[:theme].nil? | |
347 | + !controller.session[:user_theme].nil? | |
355 | 348 | end |
356 | 349 | |
357 | 350 | def theme_owner |
... | ... | @@ -600,8 +593,8 @@ module ApplicationHelper |
600 | 593 | end |
601 | 594 | |
602 | 595 | if block |
603 | - field_html ||= '' | |
604 | - field_html += capture(&block) | |
596 | + field_html ||= ''.html_safe | |
597 | + field_html = [field_html, capture(&block)].safe_join | |
605 | 598 | end |
606 | 599 | |
607 | 600 | if controller.action_name == 'signup' || controller.action_name == 'new_community' || (controller.controller_name == "enterprise_registration" && controller.action_name == 'index') || (controller.controller_name == 'home' && controller.action_name == 'index' && user.nil?) |
... | ... | @@ -610,7 +603,9 @@ module ApplicationHelper |
610 | 603 | end |
611 | 604 | else |
612 | 605 | if profile.active_fields.include?(name) |
613 | - result = content_tag('div', field_html + profile_field_privacy_selector(profile, name), :class => 'field-with-privacy-selector') | |
606 | + result = content_tag :div, class: 'field-with-privacy-selector' do | |
607 | + [field_html, profile_field_privacy_selector(profile, name)].safe_join | |
608 | + end | |
614 | 609 | end |
615 | 610 | end |
616 | 611 | |
... | ... | @@ -618,10 +613,6 @@ module ApplicationHelper |
618 | 613 | result = required(result) |
619 | 614 | end |
620 | 615 | |
621 | - if block | |
622 | - concat(result) | |
623 | - end | |
624 | - | |
625 | 616 | result |
626 | 617 | end |
627 | 618 | |
... | ... | @@ -866,7 +857,7 @@ module ApplicationHelper |
866 | 857 | alias :browse_communities_menu :search_communities_menu |
867 | 858 | |
868 | 859 | def pagination_links(collection, options={}) |
869 | - options = {:previous_label => content_tag(:span, '« ', :class => 'previous-arrow') + _('Previous'), :next_label => _('Next') + content_tag(:span, ' »', :class => 'next-arrow'), :inner_window => 1, :outer_window => 0 }.merge(options) | |
860 | + options = {:previous_label => content_tag(:span, '« '.html_safe, :class => 'previous-arrow') + _('Previous'), :next_label => _('Next') + content_tag(:span, ' »'.html_safe, :class => 'next-arrow'), :inner_window => 1, :outer_window => 0 }.merge(options) | |
870 | 861 | will_paginate(collection, options) |
871 | 862 | end |
872 | 863 | |
... | ... | @@ -988,6 +979,7 @@ module ApplicationHelper |
988 | 979 | values = {} |
989 | 980 | values.merge!(task.information[:variables]) if task.information[:variables] |
990 | 981 | values.merge!({:requestor => link_to(task.requestor.name, task.requestor.url)}) if task.requestor |
982 | + values.merge!({:target => link_to(task.target.name, task.target.url)}) if (task.target && task.target.respond_to?(:url)) | |
991 | 983 | values.merge!({:subject => content_tag('span', task.subject, :class=>'task_target')}) if task.subject |
992 | 984 | values.merge!({:linked_subject => link_to(content_tag('span', task.linked_subject[:text], :class => 'task_target'), task.linked_subject[:url])}) if task.linked_subject |
993 | 985 | (task.information[:message] % values).html_safe |
... | ... | @@ -1138,7 +1130,7 @@ module ApplicationHelper |
1138 | 1130 | content_tag(:div, :class => 'errorExplanation', :id => 'errorExplanation') do |
1139 | 1131 | content_tag(:h2, _('Errors while saving')) + |
1140 | 1132 | content_tag(:ul) do |
1141 | - safe_join(errors.map { |err| content_tag(:li, err) }) | |
1133 | + safe_join(errors.map { |err| content_tag(:li, err.html_safe) }) | |
1142 | 1134 | end |
1143 | 1135 | end |
1144 | 1136 | end | ... | ... |
app/helpers/article_helper.rb
... | ... | @@ -187,9 +187,9 @@ module ArticleHelper |
187 | 187 | def following_button(page, user) |
188 | 188 | if !user.blank? and user != page.author |
189 | 189 | if page.is_followed_by? user |
190 | - button :cancel, unfollow_button_text(page), {:controller => 'profile', :action => 'unfollow_article', :article_id => page.id, :profile => page.profile.identifier} | |
190 | + button :cancel, unfollow_button_text(page), {controller: :profile, profile: page.profile.identifier, action: :unfollow_article, article_id: page.id} | |
191 | 191 | else |
192 | - button :add, follow_button_text(page), {:controller => 'profile', :action => 'follow_article', :article_id => page.id, :profile => page.profile.identifier} | |
192 | + button :add, follow_button_text(page), {controller: :profile, profile: page.profile.identifier, action: :follow_article, article_id: page.id} | |
193 | 193 | end |
194 | 194 | end |
195 | 195 | end | ... | ... |
app/helpers/boxes_helper.rb
... | ... | @@ -99,15 +99,10 @@ module BoxesHelper |
99 | 99 | end |
100 | 100 | |
101 | 101 | def render_block_content block |
102 | - # FIXME: this conditional should be removed after all | |
103 | - # block footer from plugins methods get refactored into helpers and views. | |
104 | - # They are a failsafe until all of them are done. | |
105 | - return block.content if block.method(:content).owner != Block | |
106 | 102 | render_block block |
107 | 103 | end |
108 | 104 | |
109 | 105 | def render_block_footer block |
110 | - return block.footer if block.method(:footer).owner != Block | |
111 | 106 | render_block block, 'footers/' |
112 | 107 | end |
113 | 108 | ... | ... |
app/helpers/buttons_helper.rb
1 | 1 | module ButtonsHelper |
2 | + | |
3 | + def button_bar(options = {}, &block) | |
4 | + options[:class] ||= '' | |
5 | + options[:class] << ' button-bar' | |
6 | + | |
7 | + content_tag :div, options do | |
8 | + [ | |
9 | + capture(&block).to_s, | |
10 | + tag(:br, style: 'clear: left;'), | |
11 | + ].safe_join | |
12 | + end | |
13 | + end | |
14 | + | |
2 | 15 | def button(type, label, url, html_options = {}) |
3 | 16 | html_options ||= {} |
4 | 17 | the_class = 'with-text' | ... | ... |
app/helpers/custom_fields_helper.rb
... | ... | @@ -61,6 +61,6 @@ module CustomFieldsHelper |
61 | 61 | |
62 | 62 | def form_for_format(customized_type, format) |
63 | 63 | field = CustomField.new(:format => format, :customized_type => customized_type, :environment => environment) |
64 | - CGI::escapeHTML((render(:partial => 'features/custom_fields/form', :locals => {:field => field}))) | |
64 | + CGI::escapeHTML((render(:partial => 'features/custom_fields/form', :locals => {:field => field}))).html_safe | |
65 | 65 | end |
66 | 66 | end | ... | ... |
app/helpers/theme_loader_helper.rb
... | ... | @@ -2,8 +2,8 @@ module ThemeLoaderHelper |
2 | 2 | def current_theme |
3 | 3 | @current_theme ||= |
4 | 4 | begin |
5 | - if session[:theme] | |
6 | - session[:theme] | |
5 | + if session[:user_theme] | |
6 | + session[:user_theme] | |
7 | 7 | else |
8 | 8 | # utility for developers: set the theme to 'random' in development mode and |
9 | 9 | # you will get a different theme every request. This is interesting for |
... | ... | @@ -11,8 +11,8 @@ module ThemeLoaderHelper |
11 | 11 | if Rails.env.development? && environment.theme == 'random' |
12 | 12 | @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand |
13 | 13 | @random_theme |
14 | - elsif Rails.env.development? && respond_to?(:params) && params[:theme] && File.exists?(Rails.root.join('public/designs/themes', params[:theme])) | |
15 | - params[:theme] | |
14 | + elsif Rails.env.development? && respond_to?(:params) && params[:user_theme] && File.exists?(Rails.root.join('public/designs/themes', params[:user_theme])) | |
15 | + params[:user_theme] | |
16 | 16 | else |
17 | 17 | if profile && !profile.theme.nil? |
18 | 18 | profile.theme |
... | ... | @@ -34,8 +34,10 @@ module ThemeLoaderHelper |
34 | 34 | end |
35 | 35 | |
36 | 36 | def theme_path |
37 | - if session[:theme] | |
37 | + if session[:user_theme] | |
38 | 38 | '/user_themes/' + current_theme |
39 | + elsif session[:theme] | |
40 | + '/designs/themes/' + session[:theme] | |
39 | 41 | else |
40 | 42 | '/designs/themes/' + current_theme |
41 | 43 | end | ... | ... |
app/helpers/url_helper.rb
app/helpers/users_helper.rb
1 | 1 | module UsersHelper |
2 | 2 | |
3 | - FILTER_TRANSLATION = { | |
3 | + def filter_translation | |
4 | + { | |
4 | 5 | 'all_users' => _('All users'), |
5 | 6 | 'admin_users' => _('Admin users'), |
6 | 7 | 'activated_users' => _('Activated users'), |
7 | 8 | 'deactivated_users' => _('Deativated users'), |
8 | - } | |
9 | + } | |
10 | + end | |
9 | 11 | |
10 | 12 | def filter_selector(filter, float = 'right') |
11 | - options = options_for_select(FILTER_TRANSLATION.map {|key, name| [name, key]}, :selected => filter) | |
13 | + options = options_for_select(filter_translation.map {|key, name| [name, key]}, :selected => filter) | |
12 | 14 | url_params = url_for(params.merge(:filter => 'FILTER')) |
13 | 15 | onchange = "document.location.href = '#{url_params}'.replace('FILTER', this.value)" |
14 | 16 | select_field = select_tag(:filter, options, :onchange => onchange) |
... | ... | @@ -19,7 +21,7 @@ module UsersHelper |
19 | 21 | end |
20 | 22 | |
21 | 23 | def users_filter_title(filter) |
22 | - FILTER_TRANSLATION[filter] | |
24 | + filter_translation[filter] | |
23 | 25 | end |
24 | 26 | |
25 | 27 | end | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +class DownloadReportedImagesJob < Struct.new(:abuse_report, :article) | |
2 | + def perform | |
3 | + images_paths = article.image? ? [File.join(article.profile.environment.top_url, article.public_filename(:display))] : article.body_images_paths | |
4 | + images_paths.each do |image_path| | |
5 | + image = get_image(image_path) | |
6 | + reported_image = ReportedImage.create!( :abuse_report => abuse_report, | |
7 | + :uploaded_data => image, | |
8 | + :filename => File.basename(image_path), | |
9 | + :size => image.size ) | |
10 | + abuse_report.content = parse_content(abuse_report, image_path, reported_image) | |
11 | + end | |
12 | + abuse_report.save! | |
13 | + end | |
14 | + | |
15 | + def get_image(image_path) | |
16 | + image = ActionController::UploadedTempfile.new('reported_image') | |
17 | + image.write(Net::HTTP.get(URI.parse(image_path))) | |
18 | + image.original_path = 'tmp/' + File.basename(image_path) | |
19 | + image.content_type = 'image/' + File.extname(image_path).gsub('.','') | |
20 | + image | |
21 | + end | |
22 | + | |
23 | + def parse_content(report, old_path, image) | |
24 | + old_path = old_path.gsub(report.reporter.environment.top_url, '') | |
25 | + report.content.gsub(/#{old_path}/, image.public_filename) | |
26 | + end | |
27 | +end | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +class GetEmailContactsJob < Struct.new(:import_from, :login, :password, :contact_list_id) | |
2 | + def perform | |
3 | + begin | |
4 | + Invitation.get_contacts(import_from, login, password, contact_list_id) | |
5 | + rescue Contacts::AuthenticationError => ex | |
6 | + ContactList.exists?(contact_list_id) && ContactList.find(contact_list_id).register_auth_error | |
7 | + rescue Exception => ex | |
8 | + ContactList.exists?(contact_list_id) && ContactList.find(contact_list_id).register_error | |
9 | + end | |
10 | + end | |
11 | +end | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +class InvitationJob < Struct.new(:person_id, :contacts_to_invite, :message, :profile_id, :contact_list_id, :locale) | |
2 | + def perform | |
3 | + Noosfero.with_locale(locale) do | |
4 | + person = Person.find(person_id) | |
5 | + profile = Profile.find(profile_id) | |
6 | + Invitation.invite(person, contacts_to_invite, message, profile) | |
7 | + ContactList.exists?(contact_list_id) && ContactList.find(contact_list_id).destroy | |
8 | + end | |
9 | + end | |
10 | +end | ... | ... |
... | ... | @@ -0,0 +1,22 @@ |
1 | +class LogMemoryConsumptionJob < Struct.new(:last_stat) | |
2 | + # Number of entries do display | |
3 | + N = 20 | |
4 | + | |
5 | + def perform | |
6 | + logpath = File.join(Rails.root, 'log', "#{ENV['RAILS_ENV']}_memory_consumption.log") | |
7 | + logger = Logger.new(logpath) | |
8 | + stats = Hash.new(0) | |
9 | + ObjectSpace.each_object {|o| stats[o.class.to_s] += 1} | |
10 | + i = 1 | |
11 | + | |
12 | + logger << "[#{Time.now.strftime('%F %T %z')}]\n" | |
13 | + stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v| | |
14 | + logger << (sprintf "%-60s %10d", k, v) | |
15 | + logger << (sprintf " | delta %10d", (v - last_stat[k])) if last_stat && last_stat[k] | |
16 | + logger << "\n" | |
17 | + break if i > N | |
18 | + i += 1 | |
19 | + end | |
20 | + logger << "\n" | |
21 | + end | |
22 | +end | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id) | |
2 | + NOTIFY_ONLY_COMMUNITY = [ | |
3 | + 'add_member_in_community' | |
4 | + ] | |
5 | + | |
6 | + NOT_NOTIFY_COMMUNITY = [ | |
7 | + 'join_community' | |
8 | + ] | |
9 | + def perform | |
10 | + return unless ActionTracker::Record.exists?(tracked_action_id) | |
11 | + tracked_action = ActionTracker::Record.find(tracked_action_id) | |
12 | + return unless tracked_action.user.present? | |
13 | + target = tracked_action.target | |
14 | + if target.is_a?(Community) && ( NOTIFY_ONLY_COMMUNITY.include?(tracked_action.verb) || ! target.public_profile ) | |
15 | + ActionTrackerNotification.create(:profile_id => target.id, :action_tracker_id => tracked_action.id) | |
16 | + return | |
17 | + end | |
18 | + | |
19 | + # Notify the user | |
20 | + ActionTrackerNotification.create(:profile_id => tracked_action.user.id, :action_tracker_id => tracked_action.id) | |
21 | + | |
22 | + # Notify all friends | |
23 | + ActionTrackerNotification.connection.execute("insert into action_tracker_notifications(profile_id, action_tracker_id) select f.friend_id, #{tracked_action.id} from friendships as f where person_id=#{tracked_action.user.id} and f.friend_id not in (select atn.profile_id from action_tracker_notifications as atn where atn.action_tracker_id = #{tracked_action.id})") | |
24 | + | |
25 | + if tracked_action.user.is_a? Organization | |
26 | + ActionTrackerNotification.connection.execute "insert into action_tracker_notifications(profile_id, action_tracker_id) " + | |
27 | + "select distinct accessor_id, #{tracked_action.id} from role_assignments where resource_id = #{tracked_action.user.id} and resource_type='Profile' " + | |
28 | + if tracked_action.user.is_a? Enterprise then "union select distinct person_id, #{tracked_action.id} from favorite_enterprise_people where enterprise_id = #{tracked_action.user.id}" else "" end | |
29 | + end | |
30 | + | |
31 | + if target.is_a?(Community) | |
32 | + ActionTrackerNotification.create(:profile_id => target.id, :action_tracker_id => tracked_action.id) unless NOT_NOTIFY_COMMUNITY.include?(tracked_action.verb) | |
33 | + | |
34 | + ActionTrackerNotification.connection.execute("insert into action_tracker_notifications(profile_id, action_tracker_id) select distinct profiles.id, #{tracked_action.id} from role_assignments, profiles where profiles.type = 'Person' and profiles.id = role_assignments.accessor_id and profiles.id != #{tracked_action.user.id} and profiles.id not in (select atn.profile_id from action_tracker_notifications as atn where atn.action_tracker_id = #{tracked_action.id}) and role_assignments.resource_type = 'Profile' and role_assignments.resource_id = #{target.id}") | |
35 | + end | |
36 | + | |
37 | + if target.is_a?(Article) && target.profile.is_a?(Community) | |
38 | + ActionTrackerNotification.create(:profile_id => target.profile.id, :action_tracker_id => tracked_action.id) unless NOT_NOTIFY_COMMUNITY.include?(tracked_action.verb) | |
39 | + | |
40 | + ActionTrackerNotification.connection.execute("insert into action_tracker_notifications(profile_id, action_tracker_id) select distinct profiles.id, #{tracked_action.id} from role_assignments, profiles where profiles.type = 'Person' and profiles.id = role_assignments.accessor_id and profiles.id != #{tracked_action.user.id} and profiles.id not in (select atn.profile_id from action_tracker_notifications as atn where atn.action_tracker_id = #{tracked_action.id}) and role_assignments.resource_type = 'Profile' and role_assignments.resource_id = #{target.profile.id}") | |
41 | + end | |
42 | + | |
43 | + end | |
44 | +end | ... | ... |
... | ... | @@ -0,0 +1,22 @@ |
1 | +class ProfileSuggestionsJob < Struct.new(:person_id) | |
2 | + | |
3 | + def self.exists?(person_id) | |
4 | + !find(person_id).empty? | |
5 | + end | |
6 | + | |
7 | + def self.find(person_id) | |
8 | + Delayed::Job.by_handler("--- !ruby/struct:ProfileSuggestionsJob\nperson_id: #{person_id}\n") | |
9 | + end | |
10 | + | |
11 | + def perform | |
12 | + logger = Delayed::Worker.logger | |
13 | + begin | |
14 | + person = Person.find(person_id) | |
15 | + ProfileSuggestion.calculate_suggestions(person) | |
16 | + UserMailer.profiles_suggestions_email(person).deliver if person.email_suggestions | |
17 | + rescue Exception => exception | |
18 | + logger.error("Error with suggestions for person ID %d: %s" % [person_id, exception.to_s]) | |
19 | + end | |
20 | + end | |
21 | + | |
22 | +end | ... | ... |
app/models/add_member.rb
... | ... | @@ -37,6 +37,10 @@ class AddMember < Task |
37 | 37 | true |
38 | 38 | end |
39 | 39 | |
40 | + def reject_details | |
41 | + true | |
42 | + end | |
43 | + | |
40 | 44 | def footer |
41 | 45 | true |
42 | 46 | end |
... | ... | @@ -72,8 +76,9 @@ class AddMember < Task |
72 | 76 | end |
73 | 77 | |
74 | 78 | def task_cancelled_message |
75 | - _("Your request to enter community \"%{target} with the profile \"%{requestor}\" was not accepted. Please contact any profile admin from %{url} for more information.") % | |
76 | - {:target => self.target.name, :url => self.target.url, | |
77 | - :requestor => self.requestor.name} | |
79 | + _("Your request to enter community \"%{target}\" with the profile \"%{requestor}\" was not accepted. Please contact any profile admin from %{target} for more information. The following explanation was given: \n\n\"%{explanation}\"") % | |
80 | + {:target => self.target.name, | |
81 | + :requestor => self.requestor.name, | |
82 | + :explanation => self.reject_explanation} | |
78 | 83 | end |
79 | 84 | end | ... | ... |
app/models/article.rb
app/models/block.rb
... | ... | @@ -181,30 +181,6 @@ class Block < ApplicationRecord |
181 | 181 | "/images/block_preview.png" |
182 | 182 | end |
183 | 183 | |
184 | - # Returns the content to be used for this block. | |
185 | - # | |
186 | - # This method can return several types of objects: | |
187 | - # | |
188 | - # * <tt>String</tt>: if the string starts with <tt>http://</tt> or <tt>https://</tt>, then it is assumed to be address of an IFRAME. Otherwise it's is used as regular HTML. | |
189 | - # * <tt>Hash</tt>: the hash is used to build an URL that is used as the address for a IFRAME. | |
190 | - # * <tt>Proc</tt>: the Proc is evaluated in the scope of BoxesHelper. The | |
191 | - # block can then use <tt>render</tt>, <tt>link_to</tt>, etc. | |
192 | - # | |
193 | - # The method can also return <tt>nil</tt>, which means "no content". | |
194 | - # | |
195 | - # See BoxesHelper#extract_block_content for implementation details. | |
196 | - def content(args={}) | |
197 | - "This is block number %d" % self.id | |
198 | - end | |
199 | - | |
200 | - # A footer to be appended to the end of the block. Returns <tt>nil</tt>. | |
201 | - # | |
202 | - # Override in your subclasses. You can return the same types supported by | |
203 | - # #content. | |
204 | - def footer | |
205 | - nil | |
206 | - end | |
207 | - | |
208 | 184 | # Is this block editable? (Default to <tt>true</tt>) |
209 | 185 | def editable?(user=nil) |
210 | 186 | self.edit_modes == "all" | ... | ... |
app/models/comment_handler.rb
1 | -class CommentHandler < Struct.new(:comment_id, :method) | |
1 | +class CommentHandler < Struct.new(:comment_id, :method, :locale) | |
2 | + def initialize(*args) | |
3 | + super | |
4 | + self.locale ||= FastGettext.locale | |
5 | + end | |
2 | 6 | |
3 | 7 | def perform |
8 | + saved_locale = FastGettext.locale | |
9 | + FastGettext.locale = locale | |
10 | + | |
4 | 11 | comment = Comment.find(comment_id) |
5 | 12 | comment.send(method) |
13 | + FastGettext.locale = saved_locale | |
6 | 14 | rescue ActiveRecord::RecordNotFound |
7 | 15 | # just ignore non-existing comments |
8 | 16 | end | ... | ... |
app/models/community.rb
app/models/enterprise.rb
app/models/environment.rb
app/models/link_list_block.rb
... | ... | @@ -81,10 +81,8 @@ class LinkListBlock < Block |
81 | 81 | end |
82 | 82 | end |
83 | 83 | |
84 | - def icons_options | |
85 | - ICONS.map do |i| | |
86 | - "<span title=\"#{i[1]}\" class=\"icon-#{i[0]}\" onclick=\"changeIcon(this, '#{i[0]}')\"></span>".html_safe | |
87 | - end | |
84 | + def icons | |
85 | + ICONS | |
88 | 86 | end |
89 | 87 | |
90 | 88 | end | ... | ... |
app/models/organization.rb
app/models/person.rb
app/models/person_notifier.rb
app/views/account/_login_form.html.erb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <%= hidden_field_tag :terms_accepted, params[:terms_accepted] %> |
12 | 12 | <% end %> |
13 | 13 | |
14 | -<% button_bar do %> | |
14 | +<%= button_bar do %> | |
15 | 15 | <%= submit_button( 'login', _('Log in') )%> |
16 | 16 | <%= modal_close_button _('Cancel') if request.xhr? %> |
17 | 17 | <% end %> | ... | ... |
app/views/account/accept_terms.html.erb
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | <%= hidden_field_tag :answer, params[:answer] %> |
21 | 21 | |
22 | 22 | <%= labelled_check_box(environment.terms_of_use_acceptance_text.blank? ? _('I read the terms of use and accepted them') : environment.terms_of_use_acceptance_text, :terms_accepted, '1', false, :id => 'accept-terms') %> |
23 | - <% button_bar do %> | |
23 | + <%= button_bar do %> | |
24 | 24 | <%= button 'cancel', _('Cancel'), :controller => 'home', :action => 'index' %> |
25 | 25 | <%= submit_button 'forward', _('Continue'), {:disabled => true, :class => 'disabled', :id => 'submit-accept-terms'} %> |
26 | 26 | <% end %> | ... | ... |
app/views/account/activation_question.html.erb
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | |
25 | 25 | <div class='activation-box'> |
26 | 26 | <h2><%= _('Enterprise activation') + ' - ' + (logged_in? ? _('part 1 of 2') : _('part 1 of 3')) %></h2> |
27 | - <%= form_tag( {:action => 'accept_terms'}, {:method => 'get', :onsubmit => (@question == :foundation_year ? 'return check_valid_year(this)' : 'return check_valid_cnpj(this)')}) do %> | |
27 | + <%= form_tag( {:action => 'accept_terms'}, {:method => 'get', :onsubmit => (@question == :foundation_year ? 'return check_valid_year(this)' : 'return check_valid_cnpj(this)')}) do %> | |
28 | 28 | |
29 | 29 | <p> <strong><%= _('Pay atention! You have only one chance!') %></strong> </p> |
30 | 30 | |
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | |
35 | 35 | <%= hidden_field_tag :enterprise_code, params[:enterprise_code] %> |
36 | 36 | |
37 | - <% button_bar do %> | |
37 | + <%= button_bar do %> | |
38 | 38 | <%= button 'cancel', _('Cancel'), :action => 'index' %> |
39 | 39 | <%= submit_button 'forward', _('Continue') %> |
40 | 40 | <% end %> | ... | ... |
app/views/account/forgot_password.html.erb
app/views/account/login.html.erb
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | |
23 | 23 | <%= safe_join(@plugins.dispatch(:login_extra_contents).collect { |content| instance_exec(&content) }, "") %> |
24 | 24 | |
25 | - <% button_bar do %> | |
25 | + <%= button_bar do %> | |
26 | 26 | <%= submit_button( 'login', _('Log in') )%> |
27 | 27 | <% if is_popin %> |
28 | 28 | <%= modal_close_button(_('Cancel')) %> |
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | |
32 | 32 | <% end %> |
33 | 33 | |
34 | -<% button_bar do %> | |
34 | +<%= button_bar do %> | |
35 | 35 | <% unless @plugins.dispatch(:allow_user_registration).include?(false) %> |
36 | 36 | <%= button :add, _("New user"), :controller => 'account', :action => 'signup' %> |
37 | 37 | <% end %> | ... | ... |
app/views/account/login_block.html.erb
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | |
18 | 18 | <%= safe_join(@plugins.dispatch(:login_extra_contents).collect { |content| instance_eval(&content) }, "") %> |
19 | 19 | |
20 | - <% button_bar do %> | |
20 | + <%= button_bar do %> | |
21 | 21 | <%= submit_button( 'login', _('Log in') )%> |
22 | 22 | <% unless @plugins.dispatch(:allow_user_registration).include?(false) %> |
23 | 23 | <%= button(:add, _('New user'), { :controller => 'account', :action => 'signup' }) %> | ... | ... |
app/views/account/logout_popup.html.erb
app/views/account/new_password.html.erb
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | |
11 | 11 | <%= labelled_form_field(_('Enter new password'), (f.password_field :password)) %> |
12 | 12 | <%= labelled_form_field(_('Confirm the new password'), (f.password_field :password_confirmation)) %> |
13 | - <% button_bar do %> | |
13 | + <%= button_bar do %> | |
14 | 14 | <%= submit_button(:ok, _('Change password')) %> |
15 | 15 | <% end %> |
16 | 16 | ... | ... |
app/views/account/welcome.html.erb
... | ... | @@ -3,8 +3,8 @@ |
3 | 3 | |
4 | 4 | <%= _('%s was successfuly activated. Now you may go to your control panel or to the control panel of your enterprise') % @enterprise.name %> |
5 | 5 | |
6 | - <% button_bar do %> | |
7 | - <%= button 'forward', _('Go to my control panel'), :action => 'index', :controller => 'profile_editor', :profile => current_user.person.identifier %> | |
6 | + <%= button_bar do %> | |
7 | + <%= button 'forward', _('Go to my control panel'), :action => 'index', :controller => 'profile_editor', :profile => current_user.person.identifier %> | |
8 | 8 | <%= button 'forward', _('Go to my enterprise control panel') % @enterprise.name, :action => 'index', :controller => 'profile_editor', :profile => @enterprise.identifier %> |
9 | 9 | <% end %> |
10 | 10 | <% end %> | ... | ... |
app/views/admin_panel/message_for_disabled_enterprise.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | <%= f.text_area :message_for_disabled_enterprise, :cols => 40, :style => 'width: 90%' %> |
8 | 8 | |
9 | - <% button_bar do %> | |
9 | + <%= button_bar do %> | |
10 | 10 | <%= submit_button(:save, _('Save')) %> |
11 | 11 | <%= button(:cancel, _('Cancel'), :action => 'index') %> |
12 | 12 | <% end %> | ... | ... |
app/views/admin_panel/set_portal_community.html.erb
... | ... | @@ -4,14 +4,14 @@ |
4 | 4 | <%= form_tag do %> |
5 | 5 | <%= labelled_form_field(_('Portal identifier'), text_field_tag('portal_community_identifier', @portal_community.identifier, :size => 40) ) %> |
6 | 6 | |
7 | - <% button_bar do %> | |
7 | + <%= button_bar do %> | |
8 | 8 | <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %> |
9 | 9 | <% end %> |
10 | 10 | <% end %> |
11 | 11 | <% else %> |
12 | 12 | <%= _('Portal identifier: %s').html_safe % link_to(@portal_community.identifier, @portal_community.url) %> |
13 | 13 | |
14 | - <% button_bar do %> | |
14 | + <%= button_bar do %> | |
15 | 15 | <%if @portal_community.environment.enabled?('use_portal_community') %> |
16 | 16 | <%= button 'cancel', _('Disable'), {:action => 'manage_portal_community', :activate => 0} %> |
17 | 17 | <% else %> | ... | ... |
app/views/admin_panel/set_portal_folders.html.erb
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | <%= _('The same order in which you arrange the folders here will be used for arranging the boxes in the environment initial page.') %> |
38 | 38 | </p> |
39 | 39 | |
40 | - <% button_bar do %> | |
40 | + <%= button_bar do %> | |
41 | 41 | <%= submit_button 'save', _('Save'), :cancel => {:action => 'index'} %> |
42 | 42 | <% end %> |
43 | 43 | <% end %> | ... | ... |
app/views/admin_panel/set_portal_news_amount.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | <%= labelled_form_field _('Number of portal news'), select(:environment, :portal_news_amount, (0..10).to_a) %> |
7 | 7 | <%= labelled_form_field _('Number of news by folder'), select(:environment, :news_amount_by_folder, (1..10).to_a) %> |
8 | 8 | |
9 | - <% button_bar do %> | |
9 | + <%= button_bar do %> | |
10 | 10 | <%= submit_button(:save, _('Save')) %> |
11 | 11 | <%= button(:cancel, _('Cancel'), :action => 'index') %> |
12 | 12 | <% end %> | ... | ... |
app/views/admin_panel/site_info.html.erb
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | <% tabs << {:title => _('Signup introduction text'), :id => 'signup-intro', |
21 | 21 | :content => (render :partial => 'signup_intro', :locals => {:f => f})} %> |
22 | 22 | <%= render_tabs(tabs) %> |
23 | - <% button_bar do %> | |
23 | + <%= button_bar do %> | |
24 | 24 | <%= submit_button(:save, _('Save'), :cancel => {:action => 'index'}) %> |
25 | 25 | <% end %> |
26 | 26 | <% end %> | ... | ... |
app/views/box_organizer/_icon_selector.html.erb
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 | <%= hidden_field_tag 'block[links][][icon]', icon %> |
3 | 3 | <span class='icon-<%= icon %>' style='display:block; width:16px; height:16px;'></span> |
4 | 4 | <div class="icon-selector" style='display:none;'> |
5 | - <%= @block.icons_options.join %> | |
5 | + <% @block.icons.map do |i| %> | |
6 | + <%= content_tag('span', '', :title => i[1], :class => "icon-#{i[0]}", :onclick => "changeIcon(this, '#{i[0]}')") %> | |
7 | + <% end %> | |
6 | 8 | </div> |
7 | 9 | </div> | ... | ... |
app/views/box_organizer/edit.html.erb
app/views/box_organizer/index.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | |
4 | 4 | <h1><%= _('Editing sideboxes')%></h1> |
5 | 5 | |
6 | -<% button_bar :class=>'design-menu' do %> | |
6 | +<%= button_bar :class=>'design-menu' do %> | |
7 | 7 | <%= button(:back, _('Back to control panel'), :controller => (profile.nil? ? 'admin_panel': 'profile_editor')) %> |
8 | 8 | <% end %> |
9 | 9 | ... | ... |
app/views/categories/_form.html.erb
app/views/cms/_media_new_folder.html.erb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | <%= labelled_radio_button _('Folder'), :folder_type, 'Folder', false %> |
10 | 10 | |
11 | 11 | <%= labelled_form_field _('Name:'), text_field_tag(:new_folder, nil, 'data-url' => url_for({:action => 'new', :profile => profile.identifier})) %> |
12 | - <% button_bar do %> | |
12 | + <%= button_bar do %> | |
13 | 13 | <%= submit_button(:newfolder, _('Create')) %> |
14 | 14 | <% end %> |
15 | 15 | <% end %> | ... | ... |
app/views/cms/_text_fields.html.erb
1 | -<%= labelled_form_field(_('Publish date'), date_field('article[published_at]', @article.published_at || DateTime.current, {:max_date => '+0d', :date_format => 'yy-mm-dd'}, {:id => "article_published_at"})) %> | |
1 | +<%= labelled_form_field(_('Publish date'), date_field('article[published_at]', @article.published_at || DateTime.current, {:max_date => '+0d', :time => true}, {:id => "article_published_at"})) %> | ... | ... |
app/views/cms/_upload_file_form.html.erb
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | |
13 | 13 | <%= hidden_field_tag('back_to', @back_to) %> |
14 | 14 | |
15 | -<% button_bar do %> | |
15 | +<%= button_bar do %> | |
16 | 16 | <%= button_to_function :add, _('More files'), "add_new_file_fields()" %> |
17 | 17 | <% if @back_to %> |
18 | 18 | <%= submit_button :save, _('Upload'), :cancel => @back_to %> | ... | ... |
app/views/cms/destroy.html.erb
app/views/cms/edit.html.erb
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | </div> |
22 | 22 | <% end %> |
23 | 23 | |
24 | - <% button_bar do %> | |
24 | + <%= button_bar do %> | |
25 | 25 | <%= submit_button :save, _('Save') %> |
26 | 26 | <%= submit_button :save, _('Save and continue'), :name => "continue" %> |
27 | 27 | <% end %> |
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | <%= options_for_article(@article, @tokenized_children) %> |
49 | 49 | </div> |
50 | 50 | |
51 | - <% button_bar do %> | |
51 | + <%= button_bar do %> | |
52 | 52 | <%= submit_button :save, _('Save') %> |
53 | 53 | |
54 | 54 | <% if @back_to %> | ... | ... |
app/views/cms/publish.html.erb
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | <%= hidden_field_tag :back_to, @back_to %> |
26 | 26 | <%= labelled_form_field _('Title'), text_field_tag('name', @article.name) %> |
27 | 27 | |
28 | - <% button_bar do %> | |
28 | + <%= button_bar do %> | |
29 | 29 | <%= submit_button 'spread', _('Spread this') %> |
30 | 30 | <% end %> |
31 | 31 | <% end %> |
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | <% search_action = url_for(:action => 'search_communities_to_publish') %> |
42 | 42 | <%= token_input_field_tag(:q, 'search-communities-to-publish', search_action, { :hint_text => _('Type in a search for your community'), :zindex => 10000, :focus => false }) %> |
43 | 43 | <%= labelled_form_field _('Title'), text_field_tag('name', @article.name) %> |
44 | - <% button_bar do %> | |
44 | + <%= button_bar do %> | |
45 | 45 | <%= submit_button 'spread', _('Spread this') %> |
46 | 46 | <% end %> |
47 | 47 | <% end %> |
... | ... | @@ -58,7 +58,7 @@ |
58 | 58 | <%= hidden_field_tag :back_to, @back_to %> |
59 | 59 | <%= labelled_form_field _('Title'), text_field_tag('name', @article.name) %> |
60 | 60 | |
61 | - <% button_bar do %> | |
61 | + <%= button_bar do %> | |
62 | 62 | <%= submit_button 'spread', _('Spread this') %> |
63 | 63 | <% end %> |
64 | 64 | <% end %> | ... | ... |
app/views/cms/publish_on_portal_community.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= hidden_field_tag :back_to, @back_to %> |
6 | 6 | <%= labelled_text_field _('Title') + ': ', :name, @article.name, :style => 'width: 100%' %> |
7 | 7 | |
8 | - <% button_bar do %> | |
8 | + <%= button_bar do %> | |
9 | 9 | <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %> |
10 | 10 | <% end %> |
11 | 11 | <% end %> |
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | <%= _("There is no portal community in this environment.") %> |
15 | 15 | </div> |
16 | 16 | |
17 | - <% button_bar do %> | |
17 | + <%= button_bar do %> | |
18 | 18 | <%= button :back, _('Back'), :controller => 'cms' %> |
19 | 19 | <% end %> |
20 | 20 | <% end %> | ... | ... |
app/views/cms/suggest_an_article.html.erb
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | |
24 | 24 | <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) unless logged_in? %> |
25 | 25 | |
26 | - <% button_bar do %> | |
26 | + <%= button_bar do %> | |
27 | 27 | <%= submit_button :save, _('Save') %> |
28 | 28 | <%= button :cancel, _('Cancel'), @back_to %> |
29 | 29 | <% end %> | ... | ... |
app/views/cms/view.html.erb
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | </div> |
15 | 15 | <% end %> |
16 | 16 | |
17 | -<% button_bar(:style => 'margin-bottom: 1em;') do %> | |
17 | +<%= button_bar(:style => 'margin-bottom: 1em;') do %> | |
18 | 18 | <% parent_id = ((@article && @article.allow_children?) ? @article : nil) %> |
19 | 19 | |
20 | 20 | <%= modal_button('new', _('New content'), url_for({:action => 'new', :parent_id => parent_id, :cms => true}).html_safe) %> | ... | ... |
app/views/cms/why_categorize.html.erb
... | ... | @@ -4,6 +4,6 @@ |
4 | 4 | <%= _('By categorizing your content, you increase the possibility that other people access it. When they are looking for, say, articles about Bahia and you categorize your article in "Regions/Bahia", then there is a good change that your article is going to be found.') %> |
5 | 5 | </p> |
6 | 6 | |
7 | -<% button_bar do %> | |
7 | +<%= button_bar do %> | |
8 | 8 | <%= modal_close_button _('Close') %> |
9 | 9 | <% end %> | ... | ... |
app/views/comment/_comment_form.html.erb
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | <div id="recaptcha-container" style="display: none"> |
9 | 9 | <h3><%= _('Please type the two words below') %></h3> |
10 | 10 | <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %> |
11 | - <% button_bar do %> | |
11 | + <%= button_bar do %> | |
12 | 12 | <%= button_to_function :add, _('Confirm'), "return false", :id => "confirm-captcha" %> |
13 | 13 | <%= button_to_function :cancel, _('Cancel'), "noosfero.modal.close()" %> |
14 | 14 | <% end %> |
... | ... | @@ -87,7 +87,7 @@ function check_captcha(button, confirm_action) { |
87 | 87 | |
88 | 88 | <%= safe_join(@plugins.dispatch(:comment_form_extra_contents, local_assigns.merge(:comment => @comment)).collect { |content| instance_exec(&content) }, "") %> |
89 | 89 | |
90 | - <% button_bar do %> | |
90 | + <%= button_bar do %> | |
91 | 91 | <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %> |
92 | 92 | <% if !edition_mode %> |
93 | 93 | <%= button :cancel, _('Cancel'), '', :id => 'cancel-comment' %> | ... | ... |
app/views/content_viewer/_comment_form.html.erb
... | ... | @@ -36,7 +36,7 @@ function submit_comment_form(button) { |
36 | 36 | <div id="recaptcha-container" style="display: none"> |
37 | 37 | <h3><%= _('Please type the two words below') %></h3> |
38 | 38 | <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %> |
39 | - <% button_bar do %> | |
39 | + <%= button_bar do %> | |
40 | 40 | <%= button_to_function :add, _('Confirm'), "return false", :id => "confirm-captcha" %> |
41 | 41 | <%= button_to_function :cancel, _('Cancel'), "noosfero.modal.close()" %> |
42 | 42 | <% end %> |
... | ... | @@ -73,7 +73,7 @@ function submit_comment_form(button) { |
73 | 73 | <%= hidden_field_tag(:confirm, 'false') %> |
74 | 74 | <%= hidden_field_tag(:view, params[:view])%> |
75 | 75 | |
76 | - <% button_bar do %> | |
76 | + <%= button_bar do %> | |
77 | 77 | <%= submit_button('add', _('Post comment'), :onclick => "submit_comment_form(this); return false") %> |
78 | 78 | <% if cancel_triggers_hide %> |
79 | 79 | <%= button :cancel, _('Cancel'), '', :id => 'cancel-comment' %> | ... | ... |
app/views/content_viewer/_confirm_unfollow.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= form_tag(@page.view_url.merge({:only_path => true}), {:method => 'post', :class => 'comment_form'}) do %> |
6 | 6 | <%= hidden_field_tag(:unfollow, 'commit') %> |
7 | 7 | <%= labelled_form_field(_('Enter your e-Mail'), text_field_tag(:email, nil, {:size => 40})) %> |
8 | - <% button_bar do %> | |
8 | + <%= button_bar do %> | |
9 | 9 | <%= submit_button(:ok, _('Cancel notifications for e-mail above') ) %> |
10 | 10 | <% end %> |
11 | 11 | <% end %> | ... | ... |
app/views/content_viewer/blog_page.html.erb
app/views/content_viewer/forum_page.html.erb
app/views/enterprise_registration/basic_information.html.erb
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | <%= _('There are no validators to validate the registration of this new enterprise. Contact your administrator for instructions.') %> |
9 | 9 | </div> |
10 | 10 | |
11 | - <% button_bar do %> | |
11 | + <%= button_bar do %> | |
12 | 12 | <%= button :back, _('Go back'), { :profile => current_user.person.identifier, :action=>"enterprises", :controller=>"profile" }%> |
13 | 13 | <% end %> |
14 | 14 | <% else %> |
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | |
37 | 37 | <%= template_options(:enterprises, 'create_enterprise')%> |
38 | 38 | |
39 | - <% button_bar do %> | |
39 | + <%= button_bar do %> | |
40 | 40 | <%= submit_button('next', _('Next'), :cancel => {:profile => current_user.person.identifier, :action=>"enterprises", :controller=>"profile"}) %> |
41 | 41 | <% end %> |
42 | 42 | <% end %> | ... | ... |
app/views/enterprise_registration/creation.html.erb
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | |
5 | 5 | <%= render :partial => 'shared/template_welcome_page', :locals => {:template => @enterprise.template, :header => _("What can I do with a %s?")} %> |
6 | 6 | |
7 | -<% button_bar do %> | |
7 | +<%= button_bar do %> | |
8 | 8 | <%= button :back, _('Back'), {:controller => 'memberships', :action => 'index', :profile => user.identifier} %> |
9 | 9 | <% end %> |
10 | 10 | ... | ... |
app/views/enterprise_registration/select_validator.html.erb
app/views/enterprise_validation/details.html.erb
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | <p><%= _('If this enterprise passes the criteria to be considered an solidarity enconomy enterprise, you can approve it by click the button below.') %></p> |
16 | 16 | |
17 | 17 | <%= form_tag :action => 'approve', :id => @pending.code do %> |
18 | - <% button_bar do %> | |
18 | + <%= button_bar do %> | |
19 | 19 | <%= submit_button('approve', _('Approve')) %> |
20 | 20 | <% end %> |
21 | 21 | <% end %> |
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | <%= form_tag :action => 'reject', :id => @pending.code do %> |
28 | 28 | <%= labelled_form_field(_('Please provide an explanation for the rejection. This explanation will be sent to the requestor (required).'), text_area_tag('reject_explanation'))%> |
29 | 29 | <div> |
30 | - <% button_bar do %> | |
30 | + <%= button_bar do %> | |
31 | 31 | <%= submit_button('reject', _('Reject')) %> |
32 | 32 | <% end %> |
33 | 33 | </div> | ... | ... |
app/views/enterprise_validation/edit_validation_info.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= labelled_form_for :info do |f| %> |
6 | 6 | <%= f.text_area(:validation_methodology, :cols => 50, :rows => 10) %> |
7 | 7 | <%= f.text_area(:restrictions, :cols => 50, :rows => 7) %> |
8 | - <% button_bar do %> | |
8 | + <%= button_bar do %> | |
9 | 9 | <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %> |
10 | 10 | <% end %> |
11 | 11 | <% end %> | ... | ... |
app/views/enterprise_validation/index.html.erb
app/views/environment_role_manager/affiliate.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <%= form_tag( {:action => 'give_role'}, {:method => :post}) do %> |
4 | 4 | <%= select_tag 'role', options_for_select(@roles.map{|r|[r.name,r.id]}) %> |
5 | 5 | <%= hidden_field_tag 'person', current_user.person.id %> |
6 | - <% button_bar do %> | |
6 | + <%= button_bar do %> | |
7 | 7 | <%= submit_button('affiliate', _('Affiliate', :cancel => {:action => 'index'}) %> |
8 | 8 | <% end %> |
9 | 9 | <% end %> | ... | ... |
app/views/environment_role_manager/change_role.html.erb
app/views/environment_role_manager/make_admin.html.erb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | <% @roles.each do |r| %> |
10 | 10 | <%= labelled_form_field(r.name, (check_box_tag "roles[]", r.id)) %> |
11 | 11 | <% end %> |
12 | - <% button_bar do %> | |
12 | + <%= button_bar do %> | |
13 | 13 | <%= submit_button( 'save', _('Make'), :cancel => {:action => 'index'} ) %> |
14 | 14 | <% end %> |
15 | 15 | <% end %> | ... | ... |
app/views/environment_themes/index.html.erb
app/views/favorite_enterprises/index.html.erb
app/views/features/_manage_community_fields.html.erb
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | </script> |
56 | 56 | |
57 | 57 | <div> |
58 | - <% button_bar do %> | |
58 | + <%= button_bar do %> | |
59 | 59 | <%= submit_button('save', _('Save changes'), :id=>"save_community_fields") %> |
60 | 60 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> |
61 | 61 | <% end %> | ... | ... |
app/views/features/_manage_custom_fields.html.erb
app/views/features/_manage_enterprise_fields.html.erb
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | </script> |
56 | 56 | |
57 | 57 | <div> |
58 | - <% button_bar do %> | |
58 | + <%= button_bar do %> | |
59 | 59 | <%= submit_button('save', _('Save changes'), :id=>"save_enterprise_fields") %> |
60 | 60 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> |
61 | 61 | <% end %> | ... | ... |
app/views/features/_manage_person_fields.html.erb
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | </script> |
56 | 56 | |
57 | 57 | <div> |
58 | - <% button_bar do %> | |
58 | + <%= button_bar do %> | |
59 | 59 | <%= submit_button('save', _('Save changes'), :id=>"save_person_fields") %> |
60 | 60 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> |
61 | 61 | <% end %> | ... | ... |
app/views/features/custom_fields/_form.html.erb
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | </tr> |
30 | 30 | </thead> |
31 | 31 | <tfoot> |
32 | - <tr><td colspan=3><%= button(:add, _('Add option'), 'javascript: void()', :id => "btn_opt_#{id}", :onclick => "add_content('##{id} .custom-field-extras', $('#btn_opt_#{id}').attr('value'), 'EXTRAS_ID');", :value => "#{render_extras_field(id)}") %></td></tr> | |
32 | + <tr><td colspan=3><%= button(:add, _('Add option'), 'javascript: void()', :id => "btn_opt_#{id}", :onclick => "add_content('##{id} .custom-field-extras', $('#btn_opt_#{id}').attr('value'), 'EXTRAS_ID');", :value => "#{render_extras_field(id)}".html_safe) %></td></tr> | |
33 | 33 | </tfoot> |
34 | 34 | <tbody class="custom-field-extras"> |
35 | 35 | <% if !field.extras.blank?%> | ... | ... |
app/views/features/index.html.erb
... | ... | @@ -69,7 +69,7 @@ Check all the features you want to enable for your environment, uncheck all the |
69 | 69 | <hr/> |
70 | 70 | |
71 | 71 | <div> |
72 | - <% button_bar do %> | |
72 | + <%= button_bar do %> | |
73 | 73 | <%= submit_button('save', _('Save changes')) %> |
74 | 74 | <%= button :back, _('Back to admin panel'), :controller => 'admin_panel', :action => 'index' %> |
75 | 75 | <% end %> | ... | ... |
app/views/friends/connections.html.erb
app/views/friends/index.html.erb
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | </p> |
13 | 13 | <% end %> |
14 | 14 | |
15 | - <% button_bar do %> | |
15 | + <%= button_bar do %> | |
16 | 16 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> |
17 | 17 | <%= button(:search, _('Find people'), :controller => 'search', :action => 'assets', :asset => 'people') %> |
18 | 18 | <% unless @plugins.dispatch(:remove_invite_friends_button).include?(true) %> | ... | ... |
app/views/friends/suggest.html.erb
app/views/invite/_select_address_book.html.erb
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | <%= labelled_form_field(_("Password") + ":", password_field_tag(:password)) %> |
35 | 35 | </div> |
36 | 36 | |
37 | - <% button_bar do %> | |
37 | + <%= button_bar do %> | |
38 | 38 | <%= submit_button(:forward, _("Next")) %> |
39 | 39 | <% end %> |
40 | 40 | <p><%= _("We won't store your password or contact anyone without your permission.") %></p> | ... | ... |
app/views/invite/invite_friends.html.erb
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | { :hint_text => _('Type in the person\'s %{search_fields}') % {:search_fields => @search_fields}, |
25 | 25 | :focus => false }) %> |
26 | 26 | |
27 | - <% button_bar do %> | |
27 | + <%= button_bar do %> | |
28 | 28 | <%= submit_button('save', _('Invite'))%> |
29 | 29 | <%= button('cancel', _('Cancel'), profile.url)%> |
30 | 30 | <% end %> | ... | ... |
app/views/invite/select_friends.html.erb
app/views/licenses/_form.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= required labelled_form_field(_('Name'), f.text_field(:name)) %> |
6 | 6 | <%= labelled_form_field(_('License url'), f.text_field(:url)) %> |
7 | 7 | |
8 | - <% button_bar do %> | |
8 | + <%= button_bar do %> | |
9 | 9 | <%= submit_button('save', _('Save'))%> |
10 | 10 | <%= button('cancel', _('Cancel'), {:action => 'index'})%> |
11 | 11 | <% end %> | ... | ... |
app/views/licenses/index.html.erb
app/views/mailconf/index.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | <p><%= _('You already request activation of your mailbox. Please wait until an administrator approves your request.') %></p> |
8 | 8 | |
9 | - <% button_bar do %> | |
9 | + <%= button_bar do %> | |
10 | 10 | <%= button :back, _('Back to control panel'), :controller => 'profile_editor' %> |
11 | 11 | <% end %> |
12 | 12 | |
... | ... | @@ -21,10 +21,10 @@ |
21 | 21 | <h2><%= _('Configuration') %></h2> |
22 | 22 | <ul> |
23 | 23 | <li> |
24 | - <%= link_to _('Mail configuration for POP and IMAP'), 'http://www.ynternet.org/move/infos-technique-pour-utiliser-multypass-pop3-smtp-imap-ftp-quotas...' %> | |
24 | + <%= link_to _('Mail configuration for POP and IMAP'), 'http://www.ynternet.org/move/infos-technique-pour-utiliser-multypass-pop3-smtp-imap-ftp-quotas...' %> | |
25 | 25 | </li> |
26 | 26 | </ul> |
27 | - <% button_bar do %> | |
27 | + <%= button_bar do %> | |
28 | 28 | <%= button :back, _('Back to control panel'), :controller => 'profile_editor' %> |
29 | 29 | <% end %> |
30 | 30 | |
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | <h2><%= _("Enable e-Mail account below:") %></h2> |
34 | 34 | <ul><%= safe_join(profile.email_addresses.map{|i| content_tag('li', i)}, "\n") %></ul> |
35 | 35 | <blockquote><%= _("You'll be able to access a webmail from your user menu.") %></blockquote> |
36 | - <% button_bar do %> | |
36 | + <%= button_bar do %> | |
37 | 37 | <%= button(:ok, _('Enable e-Mail'), { :action => 'enable' }, :method => 'post') %> |
38 | 38 | <%= button :back, _('Back to control panel'), :controller => 'profile_editor' %> |
39 | 39 | <% end %> | ... | ... |
app/views/maps/edit_location.html.erb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <%= labelled_form_field _('City'), f.text_field(:city) %> |
12 | 12 | <%= labelled_form_field _('ZIP code'), text_field(:profile_data, :zip_code) %> |
13 | 13 | <%= labelled_form_field _('Address (street and number)'), text_field(:profile_data, :address) %> |
14 | - <% button_bar do %> | |
14 | + <%= button_bar do %> | |
15 | 15 | <%= button_to_function :search, _('Locate in the map'), "addressToPoint()", :title => _("Locate the address informed above in the map below (note that you'll probably need to adjust the marker to get a precise position)") %> |
16 | 16 | <%= submit_button 'save', _('Save') %> |
17 | 17 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> | ... | ... |
app/views/memberships/connections.html.erb
app/views/memberships/index.html.erb
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | <h1><%= _('Manage my groups') %></h1> |
4 | 4 | |
5 | -<% button_bar do %> | |
5 | +<%= button_bar do %> | |
6 | 6 | <%= button(:add, _('Create a new community'), :controller => 'memberships', :action => 'new_community') %> |
7 | 7 | <%= button :add, _('Register a new enterprise'), :controller => 'enterprise_registration' if environment.enabled?('enterprise_registration') %> |
8 | 8 | <%= button :back, _('Go back'), :controller => 'profile_editor' %> | ... | ... |
app/views/memberships/new_community.html.erb
app/views/memberships/suggest.html.erb
app/views/memberships/welcome.html.erb
app/views/organizations/index.html.erb
app/views/plugins/index.html.erb
app/views/profile/_comment.html.erb
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 | </div> |
46 | 46 | |
47 | 47 | <% if logged_in? && (user == profile || user == comment.author || user.has_permission?(:moderate_comments, profile)) %> |
48 | - <% button_bar(:style => 'float: right; margin-top: 0px;') do %> | |
48 | + <%= button_bar(:style => 'float: right; margin-top: 0px;') do %> | |
49 | 49 | <%= link_to_function(_('Remove'), 'remove_item_wall(this, \'%s\', \'%s\', \'%s\'); return false ;' % [".article-comment", url_for(:profile => params[:profile], :action => :remove_comment, :comment_id => comment.id, :view => params[:view]), _('Are you sure you want to remove this comment and all its replies?')], :class => 'button icon-button icon-delete') %> |
50 | 50 | <% end %> |
51 | 51 | <% end %> | ... | ... |
app/views/profile/_private_profile.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <div class='private-profile-message'><%= @message %></div> |
6 | 6 | <div class='private-profile-description'><%= profile.description %></div> |
7 | 7 | |
8 | -<% button_bar do %> | |
8 | +<%= button_bar do %> | |
9 | 9 | <% if @action == :join && logged_in? %> |
10 | 10 | <%= join_community_button({:logged => true}) %> |
11 | 11 | <% end %> | ... | ... |
app/views/profile/_upload_image.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <%= link_to(profile_image(activity.user, :minor), activity.user.url) %> |
4 | 4 | </div> |
5 | 5 | <div class='profile-activity-description'> |
6 | - <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %> <%= describe activity %></p> | |
6 | + <p class='profile-activity-text'><%= link_to activity.user.name, activity.user.url %> <%= describe(activity).html_safe %></p> | |
7 | 7 | <p class='profile-activity-time'><%= time_ago_in_words(activity.created_at) %></p> |
8 | 8 | <div class='profile-wall-actions'> |
9 | 9 | <%= link_to_function(_('Remove'), 'remove_item_wall(this, \'%s\', \'%s\', \'%s\'); return false ;' % [".profile-activity-item", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]), _('Are you sure you want to remove this activity and all its replies?')]) if logged_in? && current_person == @profile %> | ... | ... |
app/views/profile/communities.html.erb
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | </div> |
15 | 15 | <% end %> |
16 | 16 | |
17 | -<% button_bar do %> | |
17 | +<%= button_bar do %> | |
18 | 18 | <%= button :back, _('Go back'), { :controller => 'profile' } %> |
19 | 19 | <%= button :add, _('Create a new community'), |
20 | 20 | :controller => 'memberships', :action => 'new_community' if logged_in? && user == profile %> | ... | ... |
app/views/profile/enterprises.html.erb
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | <% end %> |
9 | 9 | </ul> |
10 | 10 | |
11 | -<% button_bar do %> | |
11 | +<%= button_bar do %> | |
12 | 12 | <%= button :back, _('Go back'), { :controller => 'profile' } %> |
13 | 13 | <%= button :add, _('Register a new enterprise'), :controller => 'enterprise_registration' if logged_in? && environment.enabled?('enterprise_registration') %> |
14 | 14 | <% end %> | ... | ... |
app/views/profile/fans.html.erb
app/views/profile/favorite_enterprises.html.erb
app/views/profile/friends.html.erb
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | </div> |
15 | 15 | <% end %> |
16 | 16 | |
17 | -<% button_bar do %> | |
17 | +<%= button_bar do %> | |
18 | 18 | <%= button :back, _('Go back'), { :controller => 'profile' } %> |
19 | 19 | <% if user == profile %> |
20 | 20 | <%= button :edit, _('Manage my friends'), :controller => 'friends', :action => 'index', :profile => profile.identifier %> | ... | ... |
app/views/profile/members.html.erb
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | </div><!-- end of class="profile-members-tabs-container" --> |
37 | 37 | <% end %> |
38 | 38 | |
39 | -<% button_bar do %> | |
39 | +<%= button_bar do %> | |
40 | 40 | <%= button :back, _('Go back'), { :controller => 'profile' } %> |
41 | 41 | <% if profile.community? and user %> |
42 | 42 | <% if user.has_permission?(:invite_members, profile) %> | ... | ... |
app/views/profile_editor/destroy_profile.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <p><%= _('Are you sure you want to delete this profile?') %></p> |
4 | 4 | <p><%= _('You must be aware that all content of this profile (articles, events, files and pictures) will also be deleted.') %></p> |
5 | 5 | |
6 | -<% button_bar do %> | |
6 | +<%= button_bar do %> | |
7 | 7 | <%= button(:remove, _('Yes, I am sure'), {:action => 'destroy_profile'}, :method => :post) %> |
8 | 8 | <%= button(:cancel, _('No, I gave up'), profile.url) %> |
9 | 9 | <% end %> | ... | ... |
app/views/profile_editor/edit.html.erb
... | ... | @@ -67,13 +67,13 @@ |
67 | 67 | |
68 | 68 | <%= select_categories(:profile_data, _('Select the categories of your interest'), 2) %> |
69 | 69 | |
70 | - <% button_bar do %> | |
70 | + <%= button_bar do %> | |
71 | 71 | <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %> |
72 | 72 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> |
73 | 73 | <% end %> |
74 | 74 | |
75 | 75 | <% if user && user.has_permission?('destroy_profile', profile) %> |
76 | - <% button_bar(:id => 'delete-profile') do %> | |
76 | + <%= button_bar(:id => 'delete-profile') do %> | |
77 | 77 | |
78 | 78 | <% if !environment.enabled?('forbid_destroy_profile') || user.is_admin?(environment) %> |
79 | 79 | <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> | ... | ... |
app/views/profile_editor/header_footer.html.erb
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | <%= text_area_tag(:custom_header, @header, :style => 'width: 100%; height: 150px;', :class => 'mceEditor') %> |
25 | 25 | <h2><%= _('Content for footer') %></h2> |
26 | 26 | <%= text_area_tag(:custom_footer, @footer, :style => 'width: 100%; height: 150px;', :class => 'mceEditor') %> |
27 | - <% button_bar do %> | |
27 | + <%= button_bar do %> | |
28 | 28 | <%= submit_button(:save, _('Save')) %> |
29 | 29 | <%= button(:cancel, _('Cancel'), :action => 'index') %> |
30 | 30 | <% end %> | ... | ... |
app/views/profile_editor/welcome_page.html.erb
app/views/profile_members/_index_buttons.html.erb
app/views/profile_members/_manage_roles.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= hidden_field_tag(:last_admin, true) if from == 'last_admin'%> |
6 | 6 | <% end %> |
7 | 7 | |
8 | - <% button_bar(:style => 'margin-top: 30px;') do %> | |
8 | + <%= button_bar(:style => 'margin-top: 30px;') do %> | |
9 | 9 | <%= submit_button('save', _('Save'))%> |
10 | 10 | <%= button('cancel', _('Cancel'), {:controller => 'profile_editor'})%> |
11 | 11 | <% end %> | ... | ... |
app/views/profile_members/affiliate.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <%= form_tag( {:action => 'give_role'}, {:method => :post}) do %> |
4 | 4 | <%= select_tag 'role', options_for_select(@roles.map{|r|[r.name,r.id]}) %> |
5 | 5 | <%= hidden_field_tag 'person', current_user.person.id %> |
6 | - <% button_bar do %> | |
6 | + <%= button_bar do %> | |
7 | 7 | <%= submit_button('affiliate', _('Affiliate'), :cancel => {:action => 'index'}) %> |
8 | 8 | <% end %> |
9 | 9 | <% end %> | ... | ... |
app/views/profile_members/change_role.html.erb
app/views/profile_roles/_form.html.erb
app/views/profile_roles/assign.html.erb
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | <%=token_input_field_tag(:person_id, 'search-profile-members', {:action => 'assign_role_by_members'}, |
18 | 18 | {:focus => false, :hint_text => _('Select members to assign the role')}) %> |
19 | 19 | |
20 | - <% button_bar do %> | |
20 | + <%= button_bar do %> | |
21 | 21 | <%= submit_button(:forward, _("Confirm")) %> |
22 | 22 | <% end %> |
23 | 23 | </div> |
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | <% @roles_list.each do |role| %> |
29 | 29 | <%= labelled_radio_button role.name , :selected_role, role.id , false, :class => "selected_role" %> <br> |
30 | 30 | <% end %> |
31 | - <% button_bar do %> | |
31 | + <%= button_bar do %> | |
32 | 32 | <%= submit_button('save',_('Confirm'), :cancel => {:action => 'index'} ) %> |
33 | 33 | <% end %> |
34 | 34 | </div> | ... | ... |
app/views/profile_roles/destroy.html.erb
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <p><%= _('This role is not being currently used.')%></p> |
5 | 5 | <p><%= _('Are you sure you want to delete this role?') %></p> |
6 | 6 | |
7 | - <% button_bar do %> | |
7 | + <%= button_bar do %> | |
8 | 8 | <%= button(:remove, _('Yes, I am sure'), {:action => 'remove', :id => @role.id}, :method => :post) %> |
9 | 9 | <%= button(:cancel, _('No, I gave up'), {:action => 'index'}) %> |
10 | 10 | <% end %> |
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | <%= check_box_tag("roles[]", role.id, false ,{:id => role.key}) %> |
17 | 17 | <%= content_tag(:label, role.name, { :for => role.key }) %><br/> |
18 | 18 | <% end %> |
19 | - <% button_bar do %> | |
19 | + <%= button_bar do %> | |
20 | 20 | <%= submit_button('save',_('Delete role'), :cancel => {:action => 'index'} ) %> |
21 | 21 | <% end %> |
22 | 22 | <% end %> | ... | ... |
app/views/profile_roles/index.html.erb
app/views/profile_roles/show.html.erb
... | ... | @@ -3,11 +3,11 @@ |
3 | 3 | <h3> <%= _('Permissions') %> </h3> |
4 | 4 | <ul> |
5 | 5 | <% @role.permissions.each do |p| %> |
6 | - <li> <%= permission_name(p) %> </li> | |
6 | + <li> <%= permission_name(p) %> </li> | |
7 | 7 | <% end %> |
8 | 8 | </ul> |
9 | 9 | |
10 | -<% button_bar do %> | |
10 | +<%= button_bar do %> | |
11 | 11 | <%= button :edit, _('Edit'), :action => 'edit', :id => @role %> |
12 | 12 | <%= button :back, _('Back to roles management'), :action => 'index' %> |
13 | 13 | <% end %> | ... | ... |
app/views/profile_themes/add_css.html.erb
app/views/profile_themes/add_image.html.erb
1 | 1 | <%= form_tag({:action => 'add_image', :id => @theme.id}, :multipart => true) do %> |
2 | 2 | <%= labelled_form_field(_('Choose the image file'), file_field_tag(:image)) %> |
3 | - <% button_bar do %> | |
3 | + <%= button_bar do %> | |
4 | 4 | <%= submit_button(:add, _('Add image')) %> |
5 | 5 | <% end %> |
6 | 6 | <% end %> | ... | ... |
app/views/profile_themes/css_editor.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <%= form_tag({:action => 'update_css', :id => @theme.id }, :name => 'csscode_form') do %> |
4 | 4 | <%= hidden_field_tag('css', @css) %> |
5 | 5 | <%= text_area_tag('csscode', @code, :id => "codepressWindow", :class => 'codepress css') %> |
6 | - <% button_bar do %> | |
6 | + <%= button_bar do %> | |
7 | 7 | <%= submit_button(:save, _('Save')) %> |
8 | 8 | <% end %> |
9 | 9 | <% end %> | ... | ... |
app/views/profile_themes/edit.html.erb
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | <li><%= link_to_remote(css, :url => { :action => 'css_editor', :id => @theme.id, :css => css }, :update => { :success => 'css-code' }) %></li> |
16 | 16 | <% end %> |
17 | 17 | </ul> |
18 | - <% button_bar do %> | |
18 | + <%= button_bar do %> | |
19 | 19 | <%= modal_button :add, _('New CSS'), :action => 'add_css', :id => @theme.id %> |
20 | 20 | <% end %> |
21 | 21 | </div> |
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | <li><%= image_tag("/user_themes/#{@theme.id}/images/#{image}") %></li> |
28 | 28 | <% end %> |
29 | 29 | </ul> |
30 | - <% button_bar do %> | |
30 | + <%= button_bar do %> | |
31 | 31 | <%= modal_button :add, _('Add image'), :action => 'add_image', :id => @theme.id %> |
32 | 32 | <% end %> |
33 | 33 | </div> | ... | ... |
app/views/profile_themes/index.html.erb
app/views/profile_themes/new.html.erb
app/views/region_validators/_search.html.erb
app/views/region_validators/region.html.erb
app/views/role/_form.html.erb
app/views/role/index.html.erb
app/views/role/show.html.erb
... | ... | @@ -3,11 +3,11 @@ |
3 | 3 | <h3> <%= _('Permissions') %> </h3> |
4 | 4 | <ul> |
5 | 5 | <% @role.permissions.each do |p| %> |
6 | - <li> <%= permission_name(p) %> </li> | |
6 | + <li> <%= permission_name(p) %> </li> | |
7 | 7 | <% end %> |
8 | 8 | </ul> |
9 | 9 | |
10 | -<% button_bar do %> | |
10 | +<%= button_bar do %> | |
11 | 11 | <%= button :edit, _('Edit'), :action => 'edit', :id => @role %> |
12 | 12 | <%= button :back, _('Back to roles management'), :action => 'index' %> |
13 | 13 | <% end %> | ... | ... |
app/views/search/search_page.html.erb
1 | -<%= render :partial => 'search_form', :locals => { :hint => _("Type words about the %s you're looking for") % @asset.to_s.singularize } %> | |
1 | +<%= render :partial => 'search_form', :locals => { :hint => _("Type words about the %s you're looking for") % _(@asset.to_s.singularize) } %> | |
2 | 2 | <%= render :partial => 'search_content' %> |
3 | 3 | |
4 | 4 | <div style="clear: both"></div> | ... | ... |
app/views/search/tag.html.erb
app/views/shared/_list_groups.html.erb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <%= raw _('Description: %s') % group.description + '<br/>' if group.community? %> |
12 | 12 | <%= _('Members: %s') % group.members_count.to_s %> <br/> |
13 | 13 | <%= _('Created at: %s') % show_date(group.created_at) unless group.enterprise? %> <br/> |
14 | - <% button_bar do %> | |
14 | + <%= button_bar do %> | |
15 | 15 | <% if user.has_permission?(:edit_profile, group) %> |
16 | 16 | <%= button 'menu-ctrl-panel', _('Control panel of this group'), group.admin_url %> |
17 | 17 | <% end %> | ... | ... |
app/views/shared/access_denied.html.erb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | <p><%= _("If you are supposed to have access to this area, you'll probably want to talk to the people responsible and ask them to give you access.") %></p> |
10 | 10 | <% end %> |
11 | 11 | |
12 | - <% button_bar do %> | |
12 | + <%= button_bar do %> | |
13 | 13 | <%= button :back, _('Go back'), :back %> |
14 | 14 | <%= button :home, _('Go to the site home page'), :controller => 'home' %> |
15 | 15 | <% end %> | ... | ... |
app/views/shared/not_found.html.erb
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <%= _('You may have clicked an expired link or mistyped the address.') %> |
5 | 5 | <%= _('If you clicked a link that was in another site, or was given to you by someone else, it would be nice if you tell them that their link is not valid anymore.') %> |
6 | 6 | </p> |
7 | - <% button_bar do %> | |
7 | + <%= button_bar do %> | |
8 | 8 | <%= button :back, _('Go back'), :back %> |
9 | 9 | <%= button :home, _('Go to the home page'), '/' %> |
10 | 10 | <% end %> | ... | ... |
app/views/shared/theme_test_panel.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | |
6 | 6 | <p><small><em><%= _('You can move this window away to have a better visualization of specific parts of screen.') %></em></small></p> |
7 | 7 | |
8 | - <% button_bar do %> | |
8 | + <%= button_bar do %> | |
9 | 9 | <%= button(:ok, _('Finished testing'), :controller => 'profile_themes', :profile => theme_owner, :action => 'stop_test', :id => current_theme) %> |
10 | 10 | <%= button(:edit, _('Edit theme'), :controller => 'profile_themes', :profile => theme_owner, :action => 'edit', :id => current_theme) %> |
11 | 11 | <% end %> | ... | ... |
app/views/spam/_task.html.erb
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | |
8 | 8 | <%= yield %> <%# ??? %> |
9 | 9 | |
10 | - <% button_bar do %> | |
10 | + <%= button_bar do %> | |
11 | 11 | <%= button_to_function('new', _('Mark as NOT SPAM'), 'removeTaskBox(this, %s, "%s", "")' % [url_for(:mark_task_as_ham => task.id).to_json, "task-#{task.id}"]) %> |
12 | 12 | <%= yield :extra_buttons %> |
13 | 13 | <%= button_to_function('delete', _('Remove'), 'removeTaskBox(this, %s, "%s", %s)' % [url_for(:profile => params[:profile], :remove_task => task.id).to_json, "task-#{task.id}", _('Are you sure you want to remove this article suggestion?').to_json]) %> | ... | ... |
app/views/spam/index.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | <%= _('There are no spams to review.') if no_tabs %> |
8 | 8 | |
9 | -<% button_bar do %> | |
9 | +<%= button_bar do %> | |
10 | 10 | <%= button :back, _('Back to control panel'), :controller => :profile_editor %> |
11 | 11 | <% end %> |
12 | 12 | |
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | <%= render_tabs(tabs) %> |
21 | 21 | |
22 | 22 | <% unless no_tabs %> |
23 | - <% button_bar do %> | |
23 | + <%= button_bar do %> | |
24 | 24 | <%= button :back, _('Back to control panel'), :controller => :profile_editor %> |
25 | 25 | <% end %> |
26 | 26 | <% end %> | ... | ... |
app/views/tasks/index.html.erb
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | </p> |
42 | 42 | <% else %> |
43 | 43 | <%= form_tag tasks_url(:action => 'close') do%> |
44 | - <% button_bar(:class => 'task-actions') do %> | |
44 | + <%= button_bar(:class => 'task-actions') do %> | |
45 | 45 | <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> |
46 | 46 | <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> |
47 | 47 | <%= submit_button :save, _("Apply!") %> |
... | ... | @@ -71,7 +71,7 @@ |
71 | 71 | |
72 | 72 | <%= pagination_links(@tasks)%> |
73 | 73 | |
74 | - <% button_bar(:class => 'task-actions') do %> | |
74 | + <%= button_bar(:class => 'task-actions') do %> | |
75 | 75 | <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> |
76 | 76 | <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> |
77 | 77 | <%= submit_button :save, _("Apply!") %> | ... | ... |
app/views/tasks/list_requested.html.erb
app/views/tasks/new.html.erb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <%= f.text_field :title, :style => 'width:80%;' %> |
12 | 12 | <%= f.text_area :message, :style => 'height:200px; width:80%;' %> |
13 | 13 | |
14 | - <% button_bar do %> | |
14 | + <%= button_bar do %> | |
15 | 15 | <%= submit_button(:ok, _('Send'), :cancel => {:action => 'index'}) %> |
16 | 16 | <% end %> |
17 | 17 | <% end %> | ... | ... |
app/views/tasks/processed.html.erb
app/views/tasks/ticket_details.html.erb
app/views/templates/_create_template_form.html.erb
app/views/templates/index.html.erb
app/views/trusted_sites/edit.html.erb
app/views/trusted_sites/index.html.erb
app/views/trusted_sites/new.html.erb
app/views/users/_index_buttons.html.erb
config/application.rb
... | ... | @@ -40,7 +40,6 @@ module Noosfero |
40 | 40 | # Custom directories with classes and modules you want to be autoloadable. |
41 | 41 | config.autoload_paths << config.root.join('lib') |
42 | 42 | config.autoload_paths << config.root.join('app') |
43 | - config.autoload_paths << config.root.join('app/jobs') | |
44 | 43 | config.autoload_paths << config.root.join('app/sweepers') |
45 | 44 | config.autoload_paths.concat Dir["#{config.root}/app/controllers/**/"] |
46 | 45 | config.autoload_paths << config.root.join('test', 'mocks', Rails.env) | ... | ... |
features/edit_article.feature
... | ... | @@ -281,3 +281,16 @@ Feature: edit article |
281 | 281 | And I press "Save" |
282 | 282 | Then I should not see "Language must be choosen" |
283 | 283 | And I should be on /joaosilva/article-in-portuguese |
284 | + | |
285 | + @selenium | |
286 | + Scenario: create an article with time | |
287 | + Given I am on joaosilva's control panel | |
288 | + And I follow "Manage Content" | |
289 | + And I follow "New content" | |
290 | + When I follow "Text article with visual editor" | |
291 | + And I fill in "Title" with "My time testing Article" | |
292 | + And I fill in "Publish date" with "1980-11-15 20:37" | |
293 | + And I press "Save" | |
294 | + And I go to /joaosilva/my-time-testing-article | |
295 | + Then I should see "November 15, 1980 20:37" | |
296 | + | ... | ... |
lib/authenticated_system.rb
... | ... | @@ -1,160 +0,0 @@ |
1 | -module AuthenticatedSystem | |
2 | - | |
3 | - protected | |
4 | - | |
5 | - def self.included base | |
6 | - if base < ActionController::Base | |
7 | - base.around_filter :user_set_current | |
8 | - base.before_filter :login_from_cookie | |
9 | - end | |
10 | - | |
11 | - # Inclusion hook to make #current_user and #logged_in? | |
12 | - # available as ActionView helper methods. | |
13 | - base.helper_method :current_user, :logged_in? | |
14 | - end | |
15 | - | |
16 | - # Returns true or false if the user is logged in. | |
17 | - # Preloads @current_user with the user model if they're logged in. | |
18 | - def logged_in? | |
19 | - current_user != nil | |
20 | - end | |
21 | - | |
22 | - # Accesses the current user from the session. | |
23 | - def current_user | |
24 | - @current_user ||= begin | |
25 | - id = session[:user] | |
26 | - user = User.where(id: id).first if id | |
27 | - user.session = session if user | |
28 | - User.current = user | |
29 | - user | |
30 | - end | |
31 | - end | |
32 | - | |
33 | - # Store the given user in the session. | |
34 | - def current_user=(new_user) | |
35 | - if new_user.nil? | |
36 | - session.delete(:user) | |
37 | - else | |
38 | - session[:user] = new_user.id | |
39 | - new_user.session = session | |
40 | - new_user.register_login | |
41 | - end | |
42 | - @current_user = User.current = new_user | |
43 | - end | |
44 | - | |
45 | - # See impl. from http://stackoverflow.com/a/2513456/670229 | |
46 | - def user_set_current | |
47 | - User.current = current_user | |
48 | - yield | |
49 | - ensure | |
50 | - # to address the thread variable leak issues in Puma/Thin webserver | |
51 | - User.current = nil | |
52 | - end | |
53 | - | |
54 | - # Check if the user is authorized. | |
55 | - # | |
56 | - # Override this method in your controllers if you want to restrict access | |
57 | - # to only a few actions or if you want to check if the user | |
58 | - # has the correct rights. | |
59 | - # | |
60 | - # Example: | |
61 | - # | |
62 | - # # only allow nonbobs | |
63 | - # def authorize? | |
64 | - # current_user.login != "bob" | |
65 | - # end | |
66 | - def authorized? | |
67 | - true | |
68 | - end | |
69 | - | |
70 | - # Filter method to enforce a login requirement. | |
71 | - # | |
72 | - # To require logins for all actions, use this in your controllers: | |
73 | - # | |
74 | - # before_filter :login_required | |
75 | - # | |
76 | - # To require logins for specific actions, use this in your controllers: | |
77 | - # | |
78 | - # before_filter :login_required, :only => [ :edit, :update ] | |
79 | - # | |
80 | - # To skip this in a subclassed controller: | |
81 | - # | |
82 | - # skip_before_filter :login_required | |
83 | - # | |
84 | - def login_required | |
85 | - username, passwd = get_auth_data | |
86 | - if username && passwd | |
87 | - self.current_user ||= User.authenticate(username, passwd) || nil | |
88 | - end | |
89 | - if logged_in? && authorized? | |
90 | - true | |
91 | - else | |
92 | - if params[:require_login_popup] | |
93 | - render :json => { :require_login_popup => true } | |
94 | - else | |
95 | - access_denied | |
96 | - end | |
97 | - end | |
98 | - end | |
99 | - | |
100 | - # Redirect as appropriate when an access request fails. | |
101 | - # | |
102 | - # The default action is to redirect to the login screen. | |
103 | - # | |
104 | - # Override this method in your controllers if you want to have special | |
105 | - # behavior in case the user is not authorized | |
106 | - # to access the requested action. For example, a popup window might | |
107 | - # simply close itself. | |
108 | - def access_denied | |
109 | - respond_to do |accepts| | |
110 | - accepts.html do | |
111 | - if request.xhr? | |
112 | - render :text => _('Access denied'), :status => 401 | |
113 | - else | |
114 | - store_location | |
115 | - redirect_to :controller => '/account', :action => 'login' | |
116 | - end | |
117 | - end | |
118 | - accepts.xml do | |
119 | - headers["Status"] = "Unauthorized" | |
120 | - headers["WWW-Authenticate"] = %(Basic realm="Web Password") | |
121 | - render :text => "Could't authenticate you", :status => '401 Unauthorized' | |
122 | - end | |
123 | - end | |
124 | - false | |
125 | - end | |
126 | - | |
127 | - # Store the URI of the current request in the session. | |
128 | - # | |
129 | - # We can return to this location by calling #redirect_back_or_default. | |
130 | - def store_location(location = request.url) | |
131 | - session[:return_to] = location | |
132 | - end | |
133 | - | |
134 | - # Redirect to the URI stored by the most recent store_location call or | |
135 | - # to the passed default. | |
136 | - def redirect_back_or_default(default) | |
137 | - if session[:return_to] | |
138 | - redirect_to(session.delete(:return_to)) | |
139 | - else | |
140 | - redirect_to(default) | |
141 | - end | |
142 | - end | |
143 | - | |
144 | - # When called with before_filter :login_from_cookie will check for an :auth_token | |
145 | - # cookie and log the user back in if apropriate | |
146 | - def login_from_cookie | |
147 | - return if cookies[:auth_token].blank? or logged_in? | |
148 | - user = User.where(remember_token: cookies[:auth_token]).first | |
149 | - self.current_user = user if user and user.remember_token? | |
150 | - end | |
151 | - | |
152 | - private | |
153 | - @@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization) | |
154 | - # gets BASIC auth info | |
155 | - def get_auth_data | |
156 | - auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) } | |
157 | - auth_data = request.env[auth_key].to_s.split unless auth_key.blank? | |
158 | - return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil] | |
159 | - end | |
160 | -end |
lib/download_reported_images_job.rb
... | ... | @@ -1,27 +0,0 @@ |
1 | -class DownloadReportedImagesJob < Struct.new(:abuse_report, :article) | |
2 | - def perform | |
3 | - images_paths = article.image? ? [File.join(article.profile.environment.top_url, article.public_filename(:display))] : article.body_images_paths | |
4 | - images_paths.each do |image_path| | |
5 | - image = get_image(image_path) | |
6 | - reported_image = ReportedImage.create!( :abuse_report => abuse_report, | |
7 | - :uploaded_data => image, | |
8 | - :filename => File.basename(image_path), | |
9 | - :size => image.size ) | |
10 | - abuse_report.content = parse_content(abuse_report, image_path, reported_image) | |
11 | - end | |
12 | - abuse_report.save! | |
13 | - end | |
14 | - | |
15 | - def get_image(image_path) | |
16 | - image = ActionController::UploadedTempfile.new('reported_image') | |
17 | - image.write(Net::HTTP.get(URI.parse(image_path))) | |
18 | - image.original_path = 'tmp/' + File.basename(image_path) | |
19 | - image.content_type = 'image/' + File.extname(image_path).gsub('.','') | |
20 | - image | |
21 | - end | |
22 | - | |
23 | - def parse_content(report, old_path, image) | |
24 | - old_path = old_path.gsub(report.reporter.environment.top_url, '') | |
25 | - report.content.gsub(/#{old_path}/, image.public_filename) | |
26 | - end | |
27 | -end |
lib/extensions/active_record/reflection.rb
1 | - | |
2 | 1 | # on STI classes tike Article and Profile, plugins' extensions |
3 | 2 | # on associations should be reflected on descendants |
4 | 3 | module ActiveRecord |
5 | 4 | module Reflection |
6 | - | |
7 | - class << self | |
8 | - | |
9 | - def add_reflection_with_descendants(ar, name, reflection) | |
10 | - self.add_reflection_without_descendants ar, name, reflection | |
11 | - ar.descendants.each do |k| | |
12 | - k._reflections.merge!(name.to_s => reflection) | |
13 | - end if ar.base_class == ar | |
5 | + def self.add_reflection(ar, name, reflection) | |
6 | + (ar.descendants << ar).each do |klass| | |
7 | + klass.clear_reflections_cache | |
8 | + klass._reflections = klass._reflections.merge(name.to_s => reflection) | |
14 | 9 | end |
15 | - | |
16 | - alias_method_chain :add_reflection, :descendants | |
17 | - | |
18 | 10 | end |
19 | 11 | end |
20 | 12 | end | ... | ... |
lib/get_email_contacts_job.rb
... | ... | @@ -1,11 +0,0 @@ |
1 | -class GetEmailContactsJob < Struct.new(:import_from, :login, :password, :contact_list_id) | |
2 | - def perform | |
3 | - begin | |
4 | - Invitation.get_contacts(import_from, login, password, contact_list_id) | |
5 | - rescue Contacts::AuthenticationError => ex | |
6 | - ContactList.exists?(contact_list_id) && ContactList.find(contact_list_id).register_auth_error | |
7 | - rescue Exception => ex | |
8 | - ContactList.exists?(contact_list_id) && ContactList.find(contact_list_id).register_error | |
9 | - end | |
10 | - end | |
11 | -end |
lib/invitation_job.rb
... | ... | @@ -1,10 +0,0 @@ |
1 | -class InvitationJob < Struct.new(:person_id, :contacts_to_invite, :message, :profile_id, :contact_list_id, :locale) | |
2 | - def perform | |
3 | - Noosfero.with_locale(locale) do | |
4 | - person = Person.find(person_id) | |
5 | - profile = Profile.find(profile_id) | |
6 | - Invitation.invite(person, contacts_to_invite, message, profile) | |
7 | - ContactList.exists?(contact_list_id) && ContactList.find(contact_list_id).destroy | |
8 | - end | |
9 | - end | |
10 | -end |
lib/log_memory_consumption_job.rb
... | ... | @@ -1,22 +0,0 @@ |
1 | -class LogMemoryConsumptionJob < Struct.new(:last_stat) | |
2 | - # Number of entries do display | |
3 | - N = 20 | |
4 | - | |
5 | - def perform | |
6 | - logpath = File.join(Rails.root, 'log', "#{ENV['RAILS_ENV']}_memory_consumption.log") | |
7 | - logger = Logger.new(logpath) | |
8 | - stats = Hash.new(0) | |
9 | - ObjectSpace.each_object {|o| stats[o.class.to_s] += 1} | |
10 | - i = 1 | |
11 | - | |
12 | - logger << "[#{Time.now.strftime('%F %T %z')}]\n" | |
13 | - stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v| | |
14 | - logger << (sprintf "%-60s %10d", k, v) | |
15 | - logger << (sprintf " | delta %10d", (v - last_stat[k])) if last_stat && last_stat[k] | |
16 | - logger << "\n" | |
17 | - break if i > N | |
18 | - i += 1 | |
19 | - end | |
20 | - logger << "\n" | |
21 | - end | |
22 | -end |
lib/mailing_job.rb
lib/notify_activity_to_profiles_job.rb
... | ... | @@ -1,44 +0,0 @@ |
1 | -class NotifyActivityToProfilesJob < Struct.new(:tracked_action_id) | |
2 | - NOTIFY_ONLY_COMMUNITY = [ | |
3 | - 'add_member_in_community' | |
4 | - ] | |
5 | - | |
6 | - NOT_NOTIFY_COMMUNITY = [ | |
7 | - 'join_community' | |
8 | - ] | |
9 | - def perform | |
10 | - return unless ActionTracker::Record.exists?(tracked_action_id) | |
11 | - tracked_action = ActionTracker::Record.find(tracked_action_id) | |
12 | - return unless tracked_action.user.present? | |
13 | - target = tracked_action.target | |
14 | - if target.is_a?(Community) && ( NOTIFY_ONLY_COMMUNITY.include?(tracked_action.verb) || ! target.public_profile ) | |
15 | - ActionTrackerNotification.create(:profile_id => target.id, :action_tracker_id => tracked_action.id) | |
16 | - return | |
17 | - end | |
18 | - | |
19 | - # Notify the user | |
20 | - ActionTrackerNotification.create(:profile_id => tracked_action.user.id, :action_tracker_id => tracked_action.id) | |
21 | - | |
22 | - # Notify all friends | |
23 | - ActionTrackerNotification.connection.execute("insert into action_tracker_notifications(profile_id, action_tracker_id) select f.friend_id, #{tracked_action.id} from friendships as f where person_id=#{tracked_action.user.id} and f.friend_id not in (select atn.profile_id from action_tracker_notifications as atn where atn.action_tracker_id = #{tracked_action.id})") | |
24 | - | |
25 | - if tracked_action.user.is_a? Organization | |
26 | - ActionTrackerNotification.connection.execute "insert into action_tracker_notifications(profile_id, action_tracker_id) " + | |
27 | - "select distinct accessor_id, #{tracked_action.id} from role_assignments where resource_id = #{tracked_action.user.id} and resource_type='Profile' " + | |
28 | - if tracked_action.user.is_a? Enterprise then "union select distinct person_id, #{tracked_action.id} from favorite_enterprise_people where enterprise_id = #{tracked_action.user.id}" else "" end | |
29 | - end | |
30 | - | |
31 | - if target.is_a?(Community) | |
32 | - ActionTrackerNotification.create(:profile_id => target.id, :action_tracker_id => tracked_action.id) unless NOT_NOTIFY_COMMUNITY.include?(tracked_action.verb) | |
33 | - | |
34 | - ActionTrackerNotification.connection.execute("insert into action_tracker_notifications(profile_id, action_tracker_id) select distinct profiles.id, #{tracked_action.id} from role_assignments, profiles where profiles.type = 'Person' and profiles.id = role_assignments.accessor_id and profiles.id != #{tracked_action.user.id} and profiles.id not in (select atn.profile_id from action_tracker_notifications as atn where atn.action_tracker_id = #{tracked_action.id}) and role_assignments.resource_type = 'Profile' and role_assignments.resource_id = #{target.id}") | |
35 | - end | |
36 | - | |
37 | - if target.is_a?(Article) && target.profile.is_a?(Community) | |
38 | - ActionTrackerNotification.create(:profile_id => target.profile.id, :action_tracker_id => tracked_action.id) unless NOT_NOTIFY_COMMUNITY.include?(tracked_action.verb) | |
39 | - | |
40 | - ActionTrackerNotification.connection.execute("insert into action_tracker_notifications(profile_id, action_tracker_id) select distinct profiles.id, #{tracked_action.id} from role_assignments, profiles where profiles.type = 'Person' and profiles.id = role_assignments.accessor_id and profiles.id != #{tracked_action.user.id} and profiles.id not in (select atn.profile_id from action_tracker_notifications as atn where atn.action_tracker_id = #{tracked_action.id}) and role_assignments.resource_type = 'Profile' and role_assignments.resource_id = #{target.profile.id}") | |
41 | - end | |
42 | - | |
43 | - end | |
44 | -end |
lib/profile_suggestions_job.rb
... | ... | @@ -1,22 +0,0 @@ |
1 | -class ProfileSuggestionsJob < Struct.new(:person_id) | |
2 | - | |
3 | - def self.exists?(person_id) | |
4 | - !find(person_id).empty? | |
5 | - end | |
6 | - | |
7 | - def self.find(person_id) | |
8 | - Delayed::Job.by_handler("--- !ruby/struct:ProfileSuggestionsJob\nperson_id: #{person_id}\n") | |
9 | - end | |
10 | - | |
11 | - def perform | |
12 | - logger = Delayed::Worker.logger | |
13 | - begin | |
14 | - person = Person.find(person_id) | |
15 | - ProfileSuggestion.calculate_suggestions(person) | |
16 | - UserMailer.profiles_suggestions_email(person).deliver if person.email_suggestions | |
17 | - rescue Exception => exception | |
18 | - logger.error("Error with suggestions for person ID %d: %s" % [person_id, exception.to_s]) | |
19 | - end | |
20 | - end | |
21 | - | |
22 | -end |
lib/user_activation_job.rb
plugins/admin_notifications/controllers/admin_notifications_plugin_myprofile_controller.rb
... | ... | @@ -10,7 +10,7 @@ class AdminNotificationsPluginMyprofileController < MyProfileController |
10 | 10 | end |
11 | 11 | |
12 | 12 | def admin_required |
13 | - redirect_to :root unless target.is_admin?(current_person) | |
13 | + redirect_to :root unless (current_person.is_admin? || target.is_admin?(current_person)) | |
14 | 14 | end |
15 | 15 | |
16 | 16 | end | ... | ... |
... | ... | @@ -0,0 +1,191 @@ |
1 | +# SOME DESCRIPTIVE TITLE. | |
2 | +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |
3 | +# This file is distributed under the same license as the PACKAGE package. | |
4 | +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |
5 | +# | |
6 | +#, fuzzy | |
7 | +msgid "" | |
8 | +msgstr "" | |
9 | +"Project-Id-Version: PACKAGE VERSION\n" | |
10 | +"Report-Msgid-Bugs-To: \n" | |
11 | +"POT-Creation-Date: 2016-05-17 15:38-0300\n" | |
12 | +"PO-Revision-Date: 2016-05-17 15:38-0300\n" | |
13 | +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
14 | +"Language-Team: LANGUAGE <LL@li.org>\n" | |
15 | +"Language: \n" | |
16 | +"MIME-Version: 1.0\n" | |
17 | +"Content-Type: text/plain; charset=UTF-8\n" | |
18 | +"Content-Transfer-Encoding: 8bit\n" | |
19 | +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | |
20 | + | |
21 | +#: ../lib/admin_notifications_plugin.rb:8 | |
22 | +msgid "A plugin for notifications." | |
23 | +msgstr "" | |
24 | + | |
25 | +#: ../lib/admin_notifications_plugin.rb:29 | |
26 | +msgid "Notification Manager" | |
27 | +msgstr "" | |
28 | + | |
29 | +#: ../lib/admin_notifications_plugin.rb:35 | |
30 | +msgid "Manage Notifications" | |
31 | +msgstr "" | |
32 | + | |
33 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:14 | |
34 | +msgid "Notification successfully created" | |
35 | +msgstr "" | |
36 | + | |
37 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:17 | |
38 | +msgid "Notification couldn't be created" | |
39 | +msgstr "" | |
40 | + | |
41 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:26 | |
42 | +msgid "The notification was deleted." | |
43 | +msgstr "" | |
44 | + | |
45 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:28 | |
46 | +msgid "Could not remove the notification" | |
47 | +msgstr "" | |
48 | + | |
49 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:38 | |
50 | +msgid "The notification was edited." | |
51 | +msgstr "" | |
52 | + | |
53 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:40 | |
54 | +msgid "Could not edit the notification." | |
55 | +msgstr "" | |
56 | + | |
57 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:52 | |
58 | +msgid "The status of the notification was changed." | |
59 | +msgstr "" | |
60 | + | |
61 | +#: ../lib/admin_notifications_plugin/notification_manager.rb:54 | |
62 | +msgid "Could not change the status of the notification." | |
63 | +msgstr "" | |
64 | + | |
65 | +#: ../views/shared/_form.html.erb:5 | |
66 | +msgid "Back" | |
67 | +msgstr "" | |
68 | + | |
69 | +#: ../views/shared/_form.html.erb:11 | |
70 | +msgid "Optional Title:" | |
71 | +msgstr "" | |
72 | + | |
73 | +#: ../views/shared/_form.html.erb:13 | |
74 | +msgid "Enter your message here:" | |
75 | +msgstr "" | |
76 | + | |
77 | +#: ../views/shared/_form.html.erb:15 | |
78 | +msgid "" | |
79 | +"Obs: You can use %{name} and %{email} variables to put the user's name and ema" | |
80 | +"il in the message." | |
81 | +msgstr "" | |
82 | + | |
83 | +#: ../views/shared/_form.html.erb:18 | |
84 | +msgid "Notifications Status" | |
85 | +msgstr "" | |
86 | + | |
87 | +#: ../views/shared/_form.html.erb:18 | |
88 | +msgid "Active" | |
89 | +msgstr "" | |
90 | + | |
91 | +#: ../views/shared/_form.html.erb:18 | |
92 | +msgid "Inactive" | |
93 | +msgstr "" | |
94 | + | |
95 | +#: ../views/shared/_form.html.erb:20 | |
96 | +msgid "Notifications Color/Type" | |
97 | +msgstr "" | |
98 | + | |
99 | +#: ../views/shared/_form.html.erb:20 | |
100 | +msgid "Blue - Information" | |
101 | +msgstr "" | |
102 | + | |
103 | +#: ../views/shared/_form.html.erb:20 | |
104 | +msgid "Yellow - Warning" | |
105 | +msgstr "" | |
106 | + | |
107 | +#: ../views/shared/_form.html.erb:20 | |
108 | +msgid "Green - Success" | |
109 | +msgstr "" | |
110 | + | |
111 | +#: ../views/shared/_form.html.erb:20 | |
112 | +msgid "Red - Danger" | |
113 | +msgstr "" | |
114 | + | |
115 | +#: ../views/shared/_form.html.erb:23 | |
116 | +msgid "Display only in the profile homepage" | |
117 | +msgstr "" | |
118 | + | |
119 | +#: ../views/shared/_form.html.erb:23 | |
120 | +msgid "Display only in the homepage" | |
121 | +msgstr "" | |
122 | + | |
123 | +#: ../views/shared/_form.html.erb:27 | |
124 | +msgid "Display to not logged users too" | |
125 | +msgstr "" | |
126 | + | |
127 | +#: ../views/shared/_form.html.erb:31 | |
128 | +msgid "Display popup until user close the notification" | |
129 | +msgstr "" | |
130 | + | |
131 | +#: ../views/shared/_form.html.erb:35 | |
132 | +msgid "Save" | |
133 | +msgstr "" | |
134 | + | |
135 | +#: ../views/shared/_notifications_list.html.erb:3 | |
136 | +#: ../views/shared/_notifications_list.html.erb:16 | |
137 | +msgid "Notifications" | |
138 | +msgstr "" | |
139 | + | |
140 | +#: ../views/shared/_notifications_list.html.erb:7 | |
141 | +msgid "New Notification" | |
142 | +msgstr "" | |
143 | + | |
144 | +#: ../views/shared/_notifications_list.html.erb:10 | |
145 | +msgid "Back to control panel" | |
146 | +msgstr "" | |
147 | + | |
148 | +#: ../views/shared/_notifications_list.html.erb:19 | |
149 | +msgid "Actions" | |
150 | +msgstr "" | |
151 | + | |
152 | +#: ../views/shared/_notifications_list.html.erb:30 | |
153 | +msgid "Deactivate" | |
154 | +msgstr "" | |
155 | + | |
156 | +#: ../views/shared/_notifications_list.html.erb:30 | |
157 | +#: ../views/shared/_notifications_list.html.erb:32 | |
158 | +msgid "Do you want to change the status of this notification?" | |
159 | +msgstr "" | |
160 | + | |
161 | +#: ../views/shared/_notifications_list.html.erb:32 | |
162 | +msgid "Activate" | |
163 | +msgstr "" | |
164 | + | |
165 | +#: ../views/shared/_notifications_list.html.erb:34 | |
166 | +msgid "Edit" | |
167 | +msgstr "" | |
168 | + | |
169 | +#: ../views/shared/_notifications_list.html.erb:35 | |
170 | +msgid "Delete" | |
171 | +msgstr "" | |
172 | + | |
173 | +#: ../views/shared/_notifications_list.html.erb:35 | |
174 | +msgid "Do you want to delete this notification?" | |
175 | +msgstr "" | |
176 | + | |
177 | +#: ../views/shared/show_notification.html.erb:8 | |
178 | +msgid "There are active notifications in this environment!" | |
179 | +msgstr "" | |
180 | + | |
181 | +#: ../views/shared/show_notification.html.erb:9 | |
182 | +msgid "Manage all notifications here." | |
183 | +msgstr "" | |
184 | + | |
185 | +#: ../views/shared/show_notification.html.erb:28 | |
186 | +msgid "Do not show anymore" | |
187 | +msgstr "" | |
188 | + | |
189 | +#: ../views/shared/show_notification.html.erb:29 | |
190 | +msgid "Hide for now" | |
191 | +msgstr "" | ... | ... |
plugins/admin_notifications/po/notification.pot
... | ... | @@ -1,187 +0,0 @@ |
1 | -# SOME DESCRIPTIVE TITLE. | |
2 | -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |
3 | -# This file is distributed under the same license as the PACKAGE package. | |
4 | -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |
5 | -# | |
6 | -#, fuzzy | |
7 | -msgid "" | |
8 | -msgstr "" | |
9 | -"Project-Id-Version: PACKAGE VERSION\n" | |
10 | -"Report-Msgid-Bugs-To: \n" | |
11 | -"POT-Creation-Date: 2016-03-31 15:02-0300\n" | |
12 | -"PO-Revision-Date: 2016-03-31 15:02-0300\n" | |
13 | -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
14 | -"Language-Team: LANGUAGE <LL@li.org>\n" | |
15 | -"Language: \n" | |
16 | -"MIME-Version: 1.0\n" | |
17 | -"Content-Type: text/plain; charset=UTF-8\n" | |
18 | -"Content-Transfer-Encoding: 8bit\n" | |
19 | -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | |
20 | - | |
21 | -#: ../lib/notification_plugin.rb:8 | |
22 | -msgid "A plugin for notifications." | |
23 | -msgstr "" | |
24 | - | |
25 | -#: ../lib/notification_plugin.rb:29 | |
26 | -msgid "Notification Manager" | |
27 | -msgstr "" | |
28 | - | |
29 | -#: ../lib/notification_plugin.rb:35 | |
30 | -msgid "Manage Notifications" | |
31 | -msgstr "" | |
32 | - | |
33 | -#: ../lib/notification_plugin/notification_manager.rb:14 | |
34 | -msgid "Notification successfully created" | |
35 | -msgstr "" | |
36 | - | |
37 | -#: ../lib/notification_plugin/notification_manager.rb:17 | |
38 | -msgid "Notification couldn't be created" | |
39 | -msgstr "" | |
40 | - | |
41 | -#: ../lib/notification_plugin/notification_manager.rb:26 | |
42 | -msgid "The notification was deleted." | |
43 | -msgstr "" | |
44 | - | |
45 | -#: ../lib/notification_plugin/notification_manager.rb:28 | |
46 | -msgid "Could not remove the notification" | |
47 | -msgstr "" | |
48 | - | |
49 | -#: ../lib/notification_plugin/notification_manager.rb:38 | |
50 | -msgid "The notification was edited." | |
51 | -msgstr "" | |
52 | - | |
53 | -#: ../lib/notification_plugin/notification_manager.rb:40 | |
54 | -msgid "Could not edit the notification." | |
55 | -msgstr "" | |
56 | - | |
57 | -#: ../lib/notification_plugin/notification_manager.rb:52 | |
58 | -msgid "The status of the notification was changed." | |
59 | -msgstr "" | |
60 | - | |
61 | -#: ../lib/notification_plugin/notification_manager.rb:54 | |
62 | -msgid "Could not change the status of the notification." | |
63 | -msgstr "" | |
64 | - | |
65 | -#: ../views/shared/_form.html.erb:5 | |
66 | -msgid "Back" | |
67 | -msgstr "" | |
68 | - | |
69 | -#: ../views/shared/_form.html.erb:11 | |
70 | -msgid "Optional Title:" | |
71 | -msgstr "" | |
72 | - | |
73 | -#: ../views/shared/_form.html.erb:13 | |
74 | -msgid "Enter your message here:" | |
75 | -msgstr "" | |
76 | - | |
77 | -#: ../views/shared/_form.html.erb:15 | |
78 | -msgid "" | |
79 | -"Obs: You can use %{name} and %{email} variables to put the user's name and ema" | |
80 | -"il in the message." | |
81 | -msgstr "" | |
82 | - | |
83 | -#: ../views/shared/_form.html.erb:18 | |
84 | -msgid "Notifications Status" | |
85 | -msgstr "" | |
86 | - | |
87 | -#: ../views/shared/_form.html.erb:18 | |
88 | -msgid "Active" | |
89 | -msgstr "" | |
90 | - | |
91 | -#: ../views/shared/_form.html.erb:18 | |
92 | -msgid "Inactive" | |
93 | -msgstr "" | |
94 | - | |
95 | -#: ../views/shared/_form.html.erb:20 | |
96 | -msgid "Notifications Color/Type" | |
97 | -msgstr "" | |
98 | - | |
99 | -#: ../views/shared/_form.html.erb:20 | |
100 | -msgid "Blue - Information" | |
101 | -msgstr "" | |
102 | - | |
103 | -#: ../views/shared/_form.html.erb:20 | |
104 | -msgid "Yellow - Warning" | |
105 | -msgstr "" | |
106 | - | |
107 | -#: ../views/shared/_form.html.erb:20 | |
108 | -msgid "Green - Success" | |
109 | -msgstr "" | |
110 | - | |
111 | -#: ../views/shared/_form.html.erb:20 | |
112 | -msgid "Red - Danger" | |
113 | -msgstr "" | |
114 | - | |
115 | -#: ../views/shared/_form.html.erb:23 | |
116 | -msgid "Display only in the homepage" | |
117 | -msgstr "" | |
118 | - | |
119 | -#: ../views/shared/_form.html.erb:27 | |
120 | -msgid "Display to not logged users too" | |
121 | -msgstr "" | |
122 | - | |
123 | -#: ../views/shared/_form.html.erb:31 | |
124 | -msgid "Display popup until user close the notification" | |
125 | -msgstr "" | |
126 | - | |
127 | -#: ../views/shared/_form.html.erb:35 | |
128 | -msgid "Save" | |
129 | -msgstr "" | |
130 | - | |
131 | -#: ../views/shared/_notifications_list.html.erb:3 | |
132 | -#: ../views/shared/_notifications_list.html.erb:16 | |
133 | -msgid "Notifications" | |
134 | -msgstr "" | |
135 | - | |
136 | -#: ../views/shared/_notifications_list.html.erb:7 | |
137 | -msgid "New Notification" | |
138 | -msgstr "" | |
139 | - | |
140 | -#: ../views/shared/_notifications_list.html.erb:10 | |
141 | -msgid "Back to control panel" | |
142 | -msgstr "" | |
143 | - | |
144 | -#: ../views/shared/_notifications_list.html.erb:19 | |
145 | -msgid "Actions" | |
146 | -msgstr "" | |
147 | - | |
148 | -#: ../views/shared/_notifications_list.html.erb:30 | |
149 | -msgid "Deactivate" | |
150 | -msgstr "" | |
151 | - | |
152 | -#: ../views/shared/_notifications_list.html.erb:30 | |
153 | -#: ../views/shared/_notifications_list.html.erb:32 | |
154 | -msgid "Do you want to change the status of this notification?" | |
155 | -msgstr "" | |
156 | - | |
157 | -#: ../views/shared/_notifications_list.html.erb:32 | |
158 | -msgid "Activate" | |
159 | -msgstr "" | |
160 | - | |
161 | -#: ../views/shared/_notifications_list.html.erb:34 | |
162 | -msgid "Edit" | |
163 | -msgstr "" | |
164 | - | |
165 | -#: ../views/shared/_notifications_list.html.erb:35 | |
166 | -msgid "Delete" | |
167 | -msgstr "" | |
168 | - | |
169 | -#: ../views/shared/_notifications_list.html.erb:35 | |
170 | -msgid "Do you want to delete this notification?" | |
171 | -msgstr "" | |
172 | - | |
173 | -#: ../views/shared/show_notification.html.erb:8 | |
174 | -msgid "There are active notifications in this environment!" | |
175 | -msgstr "" | |
176 | - | |
177 | -#: ../views/shared/show_notification.html.erb:9 | |
178 | -msgid "Manage all notifications here." | |
179 | -msgstr "" | |
180 | - | |
181 | -#: ../views/shared/show_notification.html.erb:28 | |
182 | -msgid "Do not show anymore" | |
183 | -msgstr "" | |
184 | - | |
185 | -#: ../views/shared/show_notification.html.erb:29 | |
186 | -msgid "Hide for now" | |
187 | -msgstr "" |
plugins/admin_notifications/po/pt/admin_notifications.po
0 → 100644
... | ... | @@ -0,0 +1,147 @@ |
1 | +# SOME DESCRIPTIVE TITLE. | |
2 | +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | |
3 | +# This file is distributed under the same license as the PACKAGE package. | |
4 | +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | |
5 | +# | |
6 | +msgid "" | |
7 | +msgstr "" | |
8 | +"Project-Id-Version: PACKAGE VERSION\n" | |
9 | +"Report-Msgid-Bugs-To: \n" | |
10 | +"PO-Revision-Date: 2016-05-16 14:48-0300\n" | |
11 | +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
12 | +"Language-Team: LANGUAGE <LL@li.org>\n" | |
13 | +"Language: \n" | |
14 | +"MIME-Version: 1.0\n" | |
15 | +"Content-Type: text/plain; charset=UTF-8\n" | |
16 | +"Content-Transfer-Encoding: 8bit\n" | |
17 | +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | |
18 | + | |
19 | +msgid "A plugin for notifications." | |
20 | +msgstr "Plugin para notificações." | |
21 | + | |
22 | +msgid "Notification Manager" | |
23 | +msgstr "Gerenciador de Notificações" | |
24 | + | |
25 | +msgid "Manage Notifications" | |
26 | +msgstr "Gerenciar Notificações" | |
27 | + | |
28 | +msgid "Notification successfully created" | |
29 | +msgstr "Notificação criada com sucesso" | |
30 | + | |
31 | +msgid "Notification couldn't be created" | |
32 | +msgstr "Não foi possível criar notificação" | |
33 | + | |
34 | +msgid "The notification was deleted." | |
35 | +msgstr "A notificação foi removida." | |
36 | + | |
37 | +msgid "Could not remove the notification" | |
38 | +msgstr "Não foi possível remover a notificação" | |
39 | + | |
40 | +msgid "The notification was edited." | |
41 | +msgstr "A notificação foi editada." | |
42 | + | |
43 | +msgid "Could not edit the notification." | |
44 | +msgstr "Não foi possível editar a notificação." | |
45 | + | |
46 | +msgid "The status of the notification was changed." | |
47 | +msgstr "O status da notificação foi modificado." | |
48 | + | |
49 | +msgid "Could not change the status of the notification." | |
50 | +msgstr "Não foi possível alterar o status da notificação." | |
51 | + | |
52 | +msgid "Back" | |
53 | +msgstr "Voltar" | |
54 | + | |
55 | +msgid "Optional Title:" | |
56 | +msgstr "Título Opcional:" | |
57 | + | |
58 | +msgid "Enter your message here:" | |
59 | +msgstr "Entre com sua mensagem aqui:" | |
60 | + | |
61 | +msgid "" | |
62 | +"Obs: You can use %{name} and %{email} variables to put the user's name and ema" | |
63 | +"il in the message." | |
64 | +msgstr "" | |
65 | +"Obs: Você pode usar as variáveis %{name} e %{email} para inserir o nome e emai" | |
66 | +"l do usuário logado na mensagem." | |
67 | + | |
68 | +msgid "Notifications Status" | |
69 | +msgstr "Status da Notificação" | |
70 | + | |
71 | +msgid "Active" | |
72 | +msgstr "Ativa" | |
73 | + | |
74 | +msgid "Inactive" | |
75 | +msgstr "Inativa" | |
76 | + | |
77 | +msgid "Notifications Color/Type" | |
78 | +msgstr "Cor/Tipo de Notificação" | |
79 | + | |
80 | +msgid "Blue - Information" | |
81 | +msgstr "Azul - Informação" | |
82 | + | |
83 | +msgid "Yellow - Warning" | |
84 | +msgstr "Amarelo - Atenção" | |
85 | + | |
86 | +msgid "Green - Success" | |
87 | +msgstr "Verde - Sucesso" | |
88 | + | |
89 | +msgid "Red - Danger" | |
90 | +msgstr "Vermelho - Perigo" | |
91 | + | |
92 | +msgid "Display only in the profile homepage" | |
93 | +msgstr "Apresentar apenas na página inicial do perfil" | |
94 | + | |
95 | +msgid "Display only in the homepage" | |
96 | +msgstr "Apresentar apenas na página inicial" | |
97 | + | |
98 | +msgid "Display to not logged users too" | |
99 | +msgstr "Apresentar também para usuários não logados" | |
100 | + | |
101 | +msgid "Display popup until user close the notification" | |
102 | +msgstr "Apresentar popup da notificação até que o usuário a feche" | |
103 | + | |
104 | +msgid "Save" | |
105 | +msgstr "Salvar" | |
106 | + | |
107 | +msgid "Notifications" | |
108 | +msgstr "Notificações" | |
109 | + | |
110 | +msgid "New Notification" | |
111 | +msgstr "Nova Notificação" | |
112 | + | |
113 | +msgid "Back to control panel" | |
114 | +msgstr "Voltar ao painel de controle" | |
115 | + | |
116 | +msgid "Actions" | |
117 | +msgstr "Ações" | |
118 | + | |
119 | +msgid "Deactivate" | |
120 | +msgstr "Desativar" | |
121 | + | |
122 | +msgid "Do you want to change the status of this notification?" | |
123 | +msgstr "Você quer alterar o status dessa notificação?" | |
124 | + | |
125 | +msgid "Activate" | |
126 | +msgstr "Ativar" | |
127 | + | |
128 | +msgid "Edit" | |
129 | +msgstr "Editar" | |
130 | + | |
131 | +msgid "Delete" | |
132 | +msgstr "Remover" | |
133 | + | |
134 | +msgid "Do you want to delete this notification?" | |
135 | +msgstr "Você quer remover essa notificação?" | |
136 | + | |
137 | +msgid "There are active notifications in this environment!" | |
138 | +msgstr "Existem notificações ativas neste ambiente!" | |
139 | + | |
140 | +msgid "Manage all notifications here." | |
141 | +msgstr "Gerencie todas as notificações aqui." | |
142 | + | |
143 | +msgid "Do not show anymore" | |
144 | +msgstr "Não mostrar mais" | |
145 | + | |
146 | +msgid "Hide for now" | |
147 | +msgstr "Ocultar momentaneamente" | ... | ... |
plugins/admin_notifications/views/shared/_form.html.erb
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | <%= labelled_form_field(_('Notifications Color/Type'), select(:notifications, :type, options_for_select_with_title({_("Blue - Information") => "AdminNotificationsPlugin::InformationNotification", _("Yellow - Warning") => "AdminNotificationsPlugin::WarningNotification", _("Green - Success") => "AdminNotificationsPlugin::SuccessNotification", _("Red - Danger") => "AdminNotificationsPlugin::DangerNotification"}, @notification.type))) %> |
21 | 21 | |
22 | 22 | <div> |
23 | - <%= labelled_check_box(_("Display only in the homepage"), 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %> | |
23 | + <%= labelled_check_box(profile.present? ? _("Display only in the profile homepage") : _("Display only in the homepage") , 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %> | |
24 | 24 | </div> |
25 | 25 | |
26 | 26 | <div> |
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | <%= labelled_check_box(_("Display popup until user close the notification"), 'notifications[display_popup]', '1', @notification.display_popup?) %> |
32 | 32 | </div> |
33 | 33 | |
34 | - <% button_bar do %> | |
34 | + <%= button_bar do %> | |
35 | 35 | <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %> |
36 | 36 | <% end %> |
37 | 37 | ... | ... |
plugins/analytics/views/analytics_plugin/_body_ending.html.slim
1 | 1 | javascript: |
2 | - analytics.timeOnPage.baseUrl = #{url_for(controller: 'analytics_plugin/time_on_page').to_json} | |
2 | + analytics.timeOnPage.baseUrl = #{url_for(profile: profile.identifier, controller: 'analytics_plugin/time_on_page').to_json} | |
3 | 3 | analytics.timeOnPage.updateInterval = #{AnalyticsPlugin::TimeOnPageUpdateIntervalMs.to_json} |
4 | 4 | analytics.requestId = #{request.env['action_dispatch.request_id'].to_json} |
5 | 5 | analytics.init() | ... | ... |
plugins/anti_spam/views/anti_spam_plugin_admin/index.html.erb
plugins/classify_members/views/classify_members_plugin_admin/index.html.erb
plugins/comment_classification/views/comment_classification_plugin_labels/_form.html.erb
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <%= labelled_form_field(_('Color'), f.select(:color, @colors.map{|s|[s.capitalize,s]})) %> |
8 | 8 | <%= labelled_form_field(f.check_box(:enabled) + _('Enable this label?'),'') %> |
9 | 9 | |
10 | - <% button_bar do %> | |
10 | + <%= button_bar do %> | |
11 | 11 | <%= submit_button('save', c_('Save'), :cancel => {:action => 'index'} ) %> |
12 | 12 | <% end %> |
13 | 13 | <% end %> | ... | ... |
plugins/comment_classification/views/comment_classification_plugin_labels/index.html.erb
plugins/comment_classification/views/comment_classification_plugin_myprofile/_status_form.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | <%= labelled_form_field(_('Status'), f.select(:status_id, @statuses.map{|s|[s.name,s.id]})) %> |
7 | 7 | <%= labelled_form_field(_('Reason:'), f.text_area(:reason, :rows => 5)) %> |
8 | 8 | |
9 | - <% button_bar do %> | |
9 | + <%= button_bar do %> | |
10 | 10 | <%= submit_button('save', c_('Save') ) %> |
11 | 11 | <% end %> |
12 | 12 | <% end %> | ... | ... |
plugins/comment_classification/views/comment_classification_plugin_status/_form.html.erb
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <%= labelled_form_field(f.check_box(:enabled) + _('Enable this status?'),'') %> |
8 | 8 | <%#= labelled_form_field(f.check_box(:enable_reason) + _('This status allows reason?'),'') %> |
9 | 9 | |
10 | - <% button_bar do %> | |
10 | + <%= button_bar do %> | |
11 | 11 | <%= submit_button('save', c_('Save'), :cancel => {:action => 'index'} ) %> |
12 | 12 | <% end %> |
13 | 13 | <% end %> | ... | ... |
plugins/comment_classification/views/comment_classification_plugin_status/index.html.erb
plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
... | ... | @@ -59,6 +59,12 @@ class CommentParagraphPlugin < Noosfero::Plugin |
59 | 59 | [CommentParagraphPlugin::API] |
60 | 60 | end |
61 | 61 | |
62 | + def self.extra_blocks | |
63 | + { | |
64 | + CommentParagraphPlugin::DiscussionBlock => {:position => ['1','2','3'] } | |
65 | + } | |
66 | + end | |
67 | + | |
62 | 68 | def content_types |
63 | 69 | [CommentParagraphPlugin::Discussion] |
64 | 70 | end | ... | ... |
plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb
0 → 100644
... | ... | @@ -0,0 +1,59 @@ |
1 | +class CommentParagraphPlugin::DiscussionBlock < Block | |
2 | + | |
3 | + settings_items :presentation_mode, :type => String, :default => 'title_only' | |
4 | + settings_items :total_items, :type => Integer, :default => 5 | |
5 | + settings_items :discussion_status, :type => Integer | |
6 | + | |
7 | + attr_accessible :presentation_mode, :total_items, :discussion_status | |
8 | + | |
9 | + VALID_CONTENT = ['CommentParagraphPlugin::Discussion'] | |
10 | + | |
11 | + STATUS_NOT_OPENED = 0 | |
12 | + STATUS_AVAILABLE = 1 | |
13 | + STATUS_CLOSED = 2 | |
14 | + | |
15 | + def self.description | |
16 | + c_('Discussion Articles') | |
17 | + end | |
18 | + | |
19 | + def help | |
20 | + _("This block displays all profile's article discussion") | |
21 | + end | |
22 | + | |
23 | + def discussions | |
24 | + current_time = Time.now | |
25 | + discussions = holder.articles.where(type: VALID_CONTENT).order('start_date ASC, end_date DESC, created_at DESC').limit(self.total_items) | |
26 | + case discussion_status | |
27 | + when STATUS_NOT_OPENED | |
28 | + discussions = discussions.where("start_date > ?", current_time) | |
29 | + when STATUS_AVAILABLE | |
30 | + discussions = discussions.where("start_date is null or start_date <= ?", current_time) | |
31 | + discussions = discussions.where("end_date is null or end_date >= ?", current_time) | |
32 | + when STATUS_CLOSED | |
33 | + discussions = discussions.where("end_date < ?", current_time) | |
34 | + end | |
35 | + discussions | |
36 | + end | |
37 | + | |
38 | + def holder | |
39 | + return nil if self.box.nil? || self.box.owner.nil? | |
40 | + if self.box.owner.kind_of?(Environment) | |
41 | + return nil if self.box.owner.portal_community.nil? | |
42 | + self.box.owner.portal_community | |
43 | + else | |
44 | + self.box.owner | |
45 | + end | |
46 | + end | |
47 | + | |
48 | + def mode?(attr) | |
49 | + attr == self.presentation_mode | |
50 | + end | |
51 | + | |
52 | + def api_content | |
53 | + Api::Entities::ArticleBase.represent(self.discussions).as_json | |
54 | + end | |
55 | + | |
56 | + def display_api_content_by_default? | |
57 | + false | |
58 | + end | |
59 | +end | ... | ... |
plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb
... | ... | @@ -69,7 +69,7 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase |
69 | 69 | article = fast_create(Article, :profile_id => profile.id) |
70 | 70 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) |
71 | 71 | article.expects(:allow_edit?).with(user).returns(true) |
72 | - article.expects(:comment_paragraph_plugin_activated?).returns(false) | |
72 | + article.expects(:comment_paragraph_plugin_activated?).at_least_once.returns(false) | |
73 | 73 | |
74 | 74 | assert_equal 'Activate Comments', plugin.article_extra_toolbar_buttons(article)[:title] |
75 | 75 | end |
... | ... | @@ -79,7 +79,7 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase |
79 | 79 | article = fast_create(Article, :profile_id => profile.id) |
80 | 80 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) |
81 | 81 | article.expects(:allow_edit?).with(user).returns(true) |
82 | - article.expects(:comment_paragraph_plugin_activated?).returns(true) | |
82 | + article.expects(:comment_paragraph_plugin_activated?).at_least_once.returns(true) | |
83 | 83 | |
84 | 84 | assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article)[:title] |
85 | 85 | end | ... | ... |
plugins/comment_paragraph/test/unit/discussion_block_test.rb
0 → 100644
... | ... | @@ -0,0 +1,204 @@ |
1 | +require_relative '../test_helper' | |
2 | +class DiscussionBlockTest < ActiveSupport::TestCase | |
3 | + | |
4 | + def setup | |
5 | + @environment = Environment.default | |
6 | + @environment.enable_plugin(CommentParagraphPlugin) | |
7 | + end | |
8 | + | |
9 | + attr_reader :environment | |
10 | + | |
11 | + should 'describe itself' do | |
12 | + assert_not_equal Block.description, CommentParagraphPlugin::DiscussionBlock.description | |
13 | + end | |
14 | + | |
15 | + should 'holder be nil if there is no box' do | |
16 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
17 | + assert_nil b.holder | |
18 | + end | |
19 | + | |
20 | + should 'holder be nil if there is no box owner to the box' do | |
21 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
22 | + box = Box.new | |
23 | + b.box = box | |
24 | + assert_nil b.holder | |
25 | + end | |
26 | + | |
27 | + should 'holder be nil if there is no portal community in environment' do | |
28 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
29 | + environment.boxes<< Box.new | |
30 | + b.box = environment.boxes.last | |
31 | + assert_nil environment.portal_community | |
32 | + assert_nil b.holder | |
33 | + end | |
34 | + | |
35 | + should 'holder be the portal community for environments blocks' do | |
36 | + community = fast_create(Community) | |
37 | + environment.portal_community= community | |
38 | + environment.save! | |
39 | + environment.boxes<< Box.new | |
40 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
41 | + b.box = environment.boxes.last | |
42 | + assert_equal environment.portal_community, b.holder | |
43 | + end | |
44 | + | |
45 | + should 'holder be the person for people blocks' do | |
46 | + person = fast_create(Person) | |
47 | + person.boxes << Box.new | |
48 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
49 | + b.box = person.boxes.last | |
50 | + assert_equal person, b.holder | |
51 | + end | |
52 | + | |
53 | + should 'holder be the community for communities blocks' do | |
54 | + community = fast_create(Community) | |
55 | + community.boxes << Box.new | |
56 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
57 | + b.box = community.boxes.last | |
58 | + assert_equal community, b.holder | |
59 | + end | |
60 | + | |
61 | + should 'holder be the enterprise for enterprises blocks' do | |
62 | + enterprise = fast_create(Enterprise) | |
63 | + enterprise.boxes << Box.new | |
64 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
65 | + b.box = enterprise.boxes.last | |
66 | + assert_equal enterprise, b.holder | |
67 | + end | |
68 | + | |
69 | + should 'discussions return only discussion articles' do | |
70 | + community = fast_create(Community) | |
71 | + community.boxes << Box.new | |
72 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
73 | + b.box = community.boxes.last | |
74 | + b.save | |
75 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) | |
76 | + fast_create(Event, :profile_id => community.id) | |
77 | + fast_create(TinyMceArticle, :profile_id => community.id) | |
78 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) | |
79 | + assert_equivalent [a1, a2], b.discussions | |
80 | + end | |
81 | + | |
82 | + should 'return only not opened discussions if discussion status is not opened' do | |
83 | + community = fast_create(Community) | |
84 | + community.boxes << Box.new | |
85 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
86 | + b.box = community.boxes.last | |
87 | + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_NOT_OPENED | |
88 | + b.save | |
89 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now + 1.day) | |
90 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now ) | |
91 | + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now - 1.day) | |
92 | + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now - 2.day, :end_date => DateTime.now - 1.day) | |
93 | + assert_equivalent [a1], b.discussions | |
94 | + end | |
95 | + | |
96 | + should 'return only available discussions if discussion status is available' do | |
97 | + community = fast_create(Community) | |
98 | + community.boxes << Box.new | |
99 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
100 | + b.box = community.boxes.last | |
101 | + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_AVAILABLE | |
102 | + b.save | |
103 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now + 1.day) | |
104 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now ) | |
105 | + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now - 1.day) | |
106 | + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now - 2.day, :end_date => DateTime.now - 1.day) | |
107 | + a5 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :end_date => DateTime.now + 1.day) | |
108 | + assert_equivalent [a2, a3, a5], b.discussions | |
109 | + end | |
110 | + | |
111 | + should 'return only closed discussions if discussion status is closed' do | |
112 | + community = fast_create(Community) | |
113 | + community.boxes << Box.new | |
114 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
115 | + b.box = community.boxes.last | |
116 | + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_CLOSED | |
117 | + b.save | |
118 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now + 1.day) | |
119 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now ) | |
120 | + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now - 1.day) | |
121 | + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => DateTime.now - 2.day, :end_date => DateTime.now - 1.day) | |
122 | + assert_equivalent [a4], b.discussions | |
123 | + end | |
124 | + | |
125 | +end | |
126 | + | |
127 | +require 'boxes_helper' | |
128 | + | |
129 | +class DiscussionBlockViewTest < ActionView::TestCase | |
130 | + include BoxesHelper | |
131 | + | |
132 | + should 'show the title and the child titles when the block is set to title only mode' do | |
133 | + profile = create_user('testuser').person | |
134 | + | |
135 | + block = CommentParagraphPlugin::DiscussionBlock.new | |
136 | + block.stubs(:holder).returns(profile) | |
137 | + block.presentation_mode = 'title_only' | |
138 | + | |
139 | + ActionView::Base.any_instance.stubs(:block_title).returns("Block Title") | |
140 | + ActionView::Base.any_instance.stubs(:profile).returns(profile) | |
141 | + | |
142 | + content = render_block_content(block) | |
143 | + | |
144 | + assert_match /discussion-title/, content | |
145 | + assert_no_match /discussion-abstract/, content | |
146 | + end | |
147 | + | |
148 | + should 'show the title and the child titles and abstracts when the block is set to title and abstract mode' do | |
149 | + profile = create_user('testuser').person | |
150 | + | |
151 | + block = CommentParagraphPlugin::DiscussionBlock.new | |
152 | + block.stubs(:holder).returns(profile) | |
153 | + block.presentation_mode = 'title_and_abstract' | |
154 | + | |
155 | + ActionView::Base.any_instance.stubs(:block_title).returns("Block Title") | |
156 | + ActionView::Base.any_instance.stubs(:profile).returns(profile) | |
157 | + | |
158 | + content = render_block_content(block) | |
159 | + | |
160 | + assert_match /discussion-abstract/, content | |
161 | + end | |
162 | + | |
163 | + should 'show the title and the child full content when the block has no mode set' do | |
164 | + profile = create_user('testuser').person | |
165 | + | |
166 | + block = CommentParagraphPlugin::DiscussionBlock.new | |
167 | + block.stubs(:holder).returns(profile) | |
168 | + block.presentation_mode = '' | |
169 | + | |
170 | + ActionView::Base.any_instance.stubs(:block_title).returns("Block Title") | |
171 | + ActionView::Base.any_instance.stubs(:profile).returns(profile) | |
172 | + | |
173 | + content = render_block_content(block) | |
174 | + | |
175 | + assert_match /discussion-full/, content | |
176 | + end | |
177 | + | |
178 | + should 'return discussions in api_content' do | |
179 | + community = fast_create(Community) | |
180 | + community.boxes << Box.new | |
181 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
182 | + b.box = community.boxes.last | |
183 | + b.save | |
184 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) | |
185 | + fast_create(Event, :profile_id => community.id) | |
186 | + fast_create(TinyMceArticle, :profile_id => community.id) | |
187 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) | |
188 | + assert_equivalent [a2.id, a1.id], b.api_content['articles'].map {|a| a[:id]} | |
189 | + end | |
190 | + | |
191 | + should 'sort discussions by start_date, end_date and created_at' do | |
192 | + community = fast_create(Community) | |
193 | + community.boxes << Box.new | |
194 | + b = CommentParagraphPlugin::DiscussionBlock.new | |
195 | + b.box = community.boxes.last | |
196 | + b.save | |
197 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, start_date: Time.now) | |
198 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, start_date: Time.now + 1, end_date: Time.now) | |
199 | + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, start_date: Time.now + 1, end_date: Time.now + 1.day) | |
200 | + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, start_date: Time.now + 1, end_date: Time.now + 1.day) | |
201 | + assert_equal [a1.id, a2.id, a3.id, a4.id], b.discussions.map(&:id) | |
202 | + end | |
203 | + | |
204 | +end | ... | ... |
plugins/comment_paragraph/views/blocks/discussion.html.erb
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +<div id="discussion-block"> | |
2 | + <% children = block.discussions %> | |
3 | + <div class="discussion"> | |
4 | + <%= block_title(block.title.blank? ? c_("Discussions") : block.title, block.subtitle ) %> | |
5 | + </div> | |
6 | + <% if block.mode?('title_only') %> | |
7 | + <div class="discussion-title"> | |
8 | + <ul> | |
9 | + <% children.each do |item| %> | |
10 | + <li> <%= link_to(h(item.title), item.url)%></li> | |
11 | + <% end %> | |
12 | + </ul> | |
13 | + </div> | |
14 | + <% elsif block.mode?('title_and_abstract') %> | |
15 | + <div class="discussion-abstract"> | |
16 | + <% children.each do |item| %> | |
17 | + <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2> | |
18 | + <span class="post-date"><%= show_date(item.published_at, true)%></span> | |
19 | + <div class="headline"><%=item.lead%></div> | |
20 | + <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p> | |
21 | + <% end %> | |
22 | + </div> | |
23 | + <% else %> | |
24 | + <div class="discussion-full"> | |
25 | + <% children.each do |item| %> | |
26 | + <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2> | |
27 | + <span class="post-date"><%= show_date(item.published_at, true)%></span> | |
28 | + <div class="headline"><%=item.body.html_safe %></div> | |
29 | + <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p> | |
30 | + <% end %> | |
31 | + </div> | |
32 | + <% end %> | |
33 | +</div> | ... | ... |
plugins/comment_paragraph/views/box_organizer/comment_paragraph_plugin/_discussion_block.html.erb
0 → 100644
... | ... | @@ -0,0 +1,28 @@ |
1 | +<%= | |
2 | +labelled_form_field(_('Choose which blog should be displayed'), | |
3 | + select_tag( | |
4 | + 'block[discussion_status]', | |
5 | + options_for_select([[_('Not Opened Discussions'), CommentParagraphPlugin::DiscussionBlock::STATUS_NOT_OPENED],[_('Available Discussions'), CommentParagraphPlugin::DiscussionBlock::STATUS_AVAILABLE], [_('Closed Discussions'), CommentParagraphPlugin::DiscussionBlock::STATUS_CLOSED]], @block.discussion_status) | |
6 | + ) | |
7 | +) | |
8 | +%> | |
9 | +<%= | |
10 | +labelled_form_field(_('Choose how the content should be displayed'), | |
11 | + select_tag( | |
12 | + 'block[presentation_mode]', | |
13 | + options_for_select( | |
14 | + { | |
15 | + _("Title only") => "title_only", | |
16 | + _("Title and abstract") => "title_and_abstract", | |
17 | + _("Full content") => "full_content" | |
18 | + }, | |
19 | + @block.presentation_mode | |
20 | + ) | |
21 | + ) | |
22 | +) | |
23 | +%> | |
24 | +<%= labelled_form_field(_('Choose how many items will be displayed'), | |
25 | + text_field_tag('block[total_items]', | |
26 | + @block.total_items, :size => 3, :maxlength => 5) | |
27 | + ) | |
28 | +%> | ... | ... |
plugins/comment_paragraph/views/comment_paragraph_plugin_admin/index.html.erb
plugins/community_track/views/community_track_plugin_public/select_community.html.erb
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | </div> |
13 | 13 | <% end %> |
14 | 14 | |
15 | -<% button_bar do %> | |
15 | +<%= button_bar do %> | |
16 | 16 | <%= button(:add, c_('Create a new community'), :controller => 'memberships', :action => 'new_community', :profile => user.identifier, :back_to => @back_to) %> |
17 | 17 | <% end %> |
18 | 18 | ... | ... |
plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | <%= button(:add, _('Add a new select field'), '#', :onclick => "customFormsPlugin.addFields(this, 'fields', #{CGI::escapeHTML(html_for_field(f, :fields, CustomFormsPlugin::SelectField).to_json)}); return false")%> |
56 | 56 | </div> |
57 | 57 | |
58 | -<% button_bar do %> | |
58 | +<%= button_bar do %> | |
59 | 59 | <%= submit_button :save, c_('Save'), :cancel => {:action => 'index'}%> |
60 | 60 | <% end %> |
61 | 61 | ... | ... |
plugins/custom_forms/views/custom_forms_plugin_myprofile/pending.html.erb
plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb
plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | |
23 | 23 | <%= render :partial => 'shared/form_submission', :locals => {:f => f} %> |
24 | 24 | |
25 | - <% button_bar do %> | |
25 | + <%= button_bar do %> | |
26 | 26 | <% if @form.expired? %> |
27 | 27 | <%= submit_button :save, c_('Save'), :disabled => '', :class => 'disabled', :cancel => {:controller => :profile, :profile => profile.identifier} %> |
28 | 28 | <% else %> | ... | ... |
plugins/display_content/lib/display_content_block.rb
... | ... | @@ -118,69 +118,28 @@ class DisplayContentBlock < Block |
118 | 118 | holder.articles.where(type: types, parent_id: if parent.nil? then nil else parent end) |
119 | 119 | end |
120 | 120 | |
121 | - def content(args={}) | |
122 | - block = self | |
123 | - | |
121 | + def docs | |
124 | 122 | order_string = "published_at" |
125 | 123 | order_string += " DESC" if order_by_recent |
126 | 124 | |
127 | 125 | limit_final = [limit_to_show, 0].max |
128 | 126 | |
129 | - docs = owner.articles.order(order_string) | |
127 | + documents = owner.articles.order(order_string) | |
130 | 128 | .where(articles: {type: self.types}) |
131 | 129 | .includes(:profile, :image, :tags) |
132 | 130 | if nodes.present? |
133 | 131 | nodes_conditions = 'articles.id IN(:nodes)' |
134 | 132 | nodes_conditions << ' OR articles.parent_id IN(:nodes) ' if display_folder_children |
135 | - docs = docs.where nodes_conditions, nodes: nodes | |
133 | + documents = documents.where nodes_conditions, nodes: nodes | |
136 | 134 | end |
137 | - docs = docs.limit limit_final if display_folder_children | |
135 | + documents = documents.limit limit_final if display_folder_children | |
138 | 136 | |
139 | 137 | if content_with_translations |
140 | - docs = docs.native_translations | |
141 | - docs.replace docs.map{ |p| p.get_translation_to(FastGettext.locale) }.compact | |
138 | + documents = documents.native_translations | |
139 | + documents.replace documents.map{ |p| p.get_translation_to(FastGettext.locale) }.compact | |
142 | 140 | end |
143 | 141 | |
144 | - proc do | |
145 | - block.block_title(block.title, block.subtitle) + | |
146 | - content_tag('ul', docs.map {|item| | |
147 | - if !item.folder? && item.class != RssFeed | |
148 | - content_sections = '' | |
149 | - read_more_section = '' | |
150 | - tags_section = '' | |
151 | - | |
152 | - block.sections.select { |section| | |
153 | - case section[:value] | |
154 | - when 'publish_date' | |
155 | - content_sections += (block.display_section?(section) ? (content_tag('div', show_date(item.published_at, false), :class => 'published-at') ) : '') | |
156 | - when 'title' | |
157 | - content_sections += (block.display_section?(section) ? (content_tag('div', link_to(h(item.title), item.url), :class => 'title') ) : '') | |
158 | - when 'abstract' | |
159 | - content_sections += (block.display_section?(section) ? (content_tag('div', item.abstract.html_safe , :class => 'lead')) : '' ) | |
160 | - if block.display_section?(section) | |
161 | - read_more_section = content_tag('div', link_to(_('Read more'), item.url), :class => 'read_more') | |
162 | - end | |
163 | - when 'body' | |
164 | - content_sections += (block.display_section?(section) ? (content_tag('div', item.body.html_safe ,:class => 'body')) : '' ) | |
165 | - when 'image' | |
166 | - image_section = image_tag item.image.public_filename if item.image | |
167 | - if !image_section.blank? | |
168 | - content_sections += (block.display_section?(section) ? (content_tag('div', link_to( image_section, item.url ) ,:class => 'image')) : '' ) | |
169 | - end | |
170 | - when 'tags' | |
171 | - if !item.tags.empty? | |
172 | - tags_section = item.tags.map { |t| content_tag('span', t.name) }.join("") | |
173 | - content_sections += (block.display_section?(section) ? (content_tag('div', tags_section, :class => 'tags')) : '') | |
174 | - end | |
175 | - end | |
176 | - } | |
177 | - | |
178 | - content_sections += read_more_section if !read_more_section.blank? | |
179 | -#raise sections.inspect | |
180 | - content_tag('li', content_sections.html_safe) | |
181 | - end | |
182 | - }.join(" ").html_safe) | |
183 | - end | |
142 | + documents | |
184 | 143 | end |
185 | 144 | |
186 | 145 | def url_params | ... | ... |
plugins/display_content/test/unit/display_content_block_test.rb
... | ... | @@ -347,53 +347,6 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
347 | 347 | |
348 | 348 | end |
349 | 349 | |
350 | - should 'list links for all articles title defined in nodes' do | |
351 | - profile = create_user('testuser').person | |
352 | - Article.delete_all | |
353 | - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) | |
354 | - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) | |
355 | - | |
356 | - block = DisplayContentBlock.new | |
357 | - block.sections = [{:value => 'title', :checked => true}] | |
358 | - block.nodes = [a1.id, a2.id] | |
359 | - box = mock() | |
360 | - block.stubs(:box).returns(box) | |
361 | - box.stubs(:owner).returns(profile) | |
362 | - | |
363 | - assert_match /.*<a.*>#{a1.title}<\/a>/, instance_eval(&block.content) | |
364 | - assert_match /.*<a.*>#{a2.title}<\/a>/, instance_eval(&block.content) | |
365 | - end | |
366 | - | |
367 | - should 'list content for all articles lead defined in nodes' do | |
368 | - profile = create_user('testuser').person | |
369 | - Article.delete_all | |
370 | - a1 = fast_create(TinyMceArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1') | |
371 | - a2 = fast_create(TinyMceArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2') | |
372 | - | |
373 | - block = DisplayContentBlock.new | |
374 | - block.sections = [{:value => 'abstract', :checked => true}] | |
375 | - block.nodes = [a1.id, a2.id] | |
376 | - box = mock() | |
377 | - block.stubs(:box).returns(box) | |
378 | - box.stubs(:owner).returns(profile) | |
379 | - | |
380 | - assert_match /<div class="lead">#{a1.lead}<\/div>/, instance_eval(&block.content) | |
381 | - assert_match /<div class="lead">#{a2.lead}<\/div>/, instance_eval(&block.content) | |
382 | - end | |
383 | - | |
384 | - should 'not crash when referenced article is removed' do | |
385 | - profile = create_user('testuser').person | |
386 | - a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) | |
387 | - | |
388 | - block = DisplayContentBlock.new | |
389 | - block.nodes = [a1.id] | |
390 | - box = mock() | |
391 | - block.stubs(:box).returns(box) | |
392 | - box.stubs(:owner).returns(profile) | |
393 | - | |
394 | - Article.delete_all | |
395 | - assert_match /<ul><\/ul>/, instance_eval(&block.content) | |
396 | - end | |
397 | 350 | include ActionView::Helpers |
398 | 351 | include Rails.application.routes.url_helpers |
399 | 352 | |
... | ... | @@ -420,48 +373,6 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
420 | 373 | assert_equal params, block.url_params |
421 | 374 | end |
422 | 375 | |
423 | - should 'show title if defined by user' do | |
424 | - profile = create_user('testuser').person | |
425 | - a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) | |
426 | - | |
427 | - block = DisplayContentBlock.new | |
428 | - block.nodes = [a.id] | |
429 | - block.sections = [{:value => 'title', :checked => true}] | |
430 | - box = mock() | |
431 | - block.stubs(:box).returns(box) | |
432 | - box.stubs(:owner).returns(profile) | |
433 | - | |
434 | - assert_match /.*<a.*>#{a.title}<\/a>/, instance_eval(&block.content) | |
435 | - end | |
436 | - | |
437 | - should 'show abstract if defined by user' do | |
438 | - profile = create_user('testuser').person | |
439 | - a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract') | |
440 | - | |
441 | - block = DisplayContentBlock.new | |
442 | - block.nodes = [a.id] | |
443 | - block.sections = [{:value => 'abstract', :checked => true}] | |
444 | - box = mock() | |
445 | - block.stubs(:box).returns(box) | |
446 | - box.stubs(:owner).returns(profile) | |
447 | - | |
448 | - assert_match /#{a.abstract}/, instance_eval(&block.content) | |
449 | - end | |
450 | - | |
451 | - should 'show body if defined by user' do | |
452 | - profile = create_user('testuser').person | |
453 | - a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') | |
454 | - | |
455 | - block = DisplayContentBlock.new | |
456 | - block.nodes = [a.id] | |
457 | - block.sections = [{:value => 'body', :checked => true}] | |
458 | - box = mock() | |
459 | - block.stubs(:box).returns(box) | |
460 | - box.stubs(:owner).returns(profile) | |
461 | - | |
462 | - assert_match /#{a.body}/, instance_eval(&block.content) | |
463 | - end | |
464 | - | |
465 | 376 | should 'display_attribute be true for title by default' do |
466 | 377 | profile = create_user('testuser').person |
467 | 378 | |
... | ... | @@ -489,20 +400,6 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
489 | 400 | assert block.display_section?({:value => 'publish_date', :checked => true}) |
490 | 401 | end |
491 | 402 | |
492 | - should 'show publishd date if defined by user' do | |
493 | - profile = create_user('testuser').person | |
494 | - a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') | |
495 | - | |
496 | - block = DisplayContentBlock.new | |
497 | - block.nodes = [a.id] | |
498 | - block.sections = [{:value => 'publish_date', :checked => true}] | |
499 | - box = mock() | |
500 | - block.stubs(:box).returns(box) | |
501 | - box.stubs(:owner).returns(profile) | |
502 | - | |
503 | - assert_match /#{a.published_at}/, instance_eval(&block.content) | |
504 | - end | |
505 | - | |
506 | 403 | should 'do not save children if a folder is checked' do |
507 | 404 | profile = create_user('testuser').person |
508 | 405 | Article.delete_all |
... | ... | @@ -648,6 +545,117 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
648 | 545 | assert_equal [], block.parent_nodes |
649 | 546 | end |
650 | 547 | |
548 | +end | |
549 | + | |
550 | +require 'boxes_helper' | |
551 | + | |
552 | +class DisplayContentBlockViewTest < ActionView::TestCase | |
553 | + include BoxesHelper | |
554 | + | |
555 | + should 'list links for all articles title defined in nodes' do | |
556 | + profile = create_user('testuser').person | |
557 | + Article.delete_all | |
558 | + a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) | |
559 | + a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id) | |
560 | + | |
561 | + block = DisplayContentBlock.new | |
562 | + block.sections = [{:value => 'title', :checked => true}] | |
563 | + block.nodes = [a1.id, a2.id] | |
564 | + box = mock() | |
565 | + block.stubs(:box).returns(box) | |
566 | + box.stubs(:owner).returns(profile) | |
567 | + | |
568 | + assert_match /.*<a.*>#{a1.title}<\/a>/, render_block_content(block) | |
569 | + assert_match /.*<a.*>#{a2.title}<\/a>/, render_block_content(block) | |
570 | + end | |
571 | + | |
572 | + should 'list content for all articles lead defined in nodes' do | |
573 | + profile = create_user('testuser').person | |
574 | + Article.delete_all | |
575 | + a1 = fast_create(TinyMceArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'abstract article 1') | |
576 | + a2 = fast_create(TinyMceArticle, :name => 'test article 2', :profile_id => profile.id, :abstract => 'abstract article 2') | |
577 | + | |
578 | + block = DisplayContentBlock.new | |
579 | + block.sections = [{:value => 'abstract', :checked => true}] | |
580 | + block.nodes = [a1.id, a2.id] | |
581 | + box = mock() | |
582 | + block.stubs(:box).returns(box) | |
583 | + box.stubs(:owner).returns(profile) | |
584 | + | |
585 | + assert_match /<div class="lead">#{a1.lead}<\/div>/, render_block_content(block) | |
586 | + assert_match /<div class="lead">#{a2.lead}<\/div>/, render_block_content(block) | |
587 | + end | |
588 | + | |
589 | + should 'not crash when referenced article is removed' do | |
590 | + profile = create_user('testuser').person | |
591 | + a1 = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id) | |
592 | + | |
593 | + block = DisplayContentBlock.new | |
594 | + block.nodes = [a1.id] | |
595 | + box = mock() | |
596 | + block.stubs(:box).returns(box) | |
597 | + box.stubs(:owner).returns(profile) | |
598 | + | |
599 | + Article.delete_all | |
600 | + assert_match /<ul><\/ul>/, render_block_content(block) | |
601 | + end | |
602 | + | |
603 | + should 'show title if defined by user' do | |
604 | + profile = create_user('testuser').person | |
605 | + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) | |
606 | + | |
607 | + block = DisplayContentBlock.new | |
608 | + block.nodes = [a.id] | |
609 | + block.sections = [{:value => 'title', :checked => true}] | |
610 | + box = mock() | |
611 | + block.stubs(:box).returns(box) | |
612 | + box.stubs(:owner).returns(profile) | |
613 | + | |
614 | + assert_match /.*<a.*>#{a.title}<\/a>/, render_block_content(block) | |
615 | + end | |
616 | + | |
617 | + should 'show abstract if defined by user' do | |
618 | + profile = create_user('testuser').person | |
619 | + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :abstract => 'some abstract') | |
620 | + | |
621 | + block = DisplayContentBlock.new | |
622 | + block.nodes = [a.id] | |
623 | + block.sections = [{:value => 'abstract', :checked => true}] | |
624 | + box = mock() | |
625 | + block.stubs(:box).returns(box) | |
626 | + box.stubs(:owner).returns(profile) | |
627 | + | |
628 | + assert_match /#{a.abstract}/, render_block_content(block) | |
629 | + end | |
630 | + | |
631 | + should 'show body if defined by user' do | |
632 | + profile = create_user('testuser').person | |
633 | + a = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') | |
634 | + | |
635 | + block = DisplayContentBlock.new | |
636 | + block.nodes = [a.id] | |
637 | + block.sections = [{:value => 'body', :checked => true}] | |
638 | + box = mock() | |
639 | + block.stubs(:box).returns(box) | |
640 | + box.stubs(:owner).returns(profile) | |
641 | + | |
642 | + assert_match /#{a.body}/, render_block_content(block) | |
643 | + end | |
644 | + | |
645 | + should 'show publishd date if defined by user' do | |
646 | + profile = create_user('testuser').person | |
647 | + a = fast_create(TextArticle, :name => 'test article 1', :profile_id => profile.id, :body => 'some body') | |
648 | + | |
649 | + block = DisplayContentBlock.new | |
650 | + block.nodes = [a.id] | |
651 | + block.sections = [{:value => 'publish_date', :checked => true}] | |
652 | + box = mock() | |
653 | + block.stubs(:box).returns(box) | |
654 | + box.stubs(:owner).returns(profile) | |
655 | + | |
656 | + assert_match /#{a.published_at}/, render_block_content(block) | |
657 | + end | |
658 | + | |
651 | 659 | should 'show articles in recent order' do |
652 | 660 | profile = create_user('testuser').person |
653 | 661 | Article.delete_all |
... | ... | @@ -663,8 +671,8 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
663 | 671 | |
664 | 672 | block.order_by_recent = true |
665 | 673 | |
666 | - a1_index = instance_eval(&block.content).index(a1.name) | |
667 | - a2_index = instance_eval(&block.content).index(a2.name) | |
674 | + a1_index = render_block_content(block).index(a1.name) | |
675 | + a2_index = render_block_content(block).index(a2.name) | |
668 | 676 | |
669 | 677 | assert a2_index < a1_index |
670 | 678 | end |
... | ... | @@ -684,8 +692,8 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
684 | 692 | |
685 | 693 | block.order_by_recent = false |
686 | 694 | |
687 | - a1_index = instance_eval(&block.content).index(a1.name) | |
688 | - a2_index = instance_eval(&block.content).index(a2.name) | |
695 | + a1_index = render_block_content(block).index(a1.name) | |
696 | + a2_index = render_block_content(block).index(a2.name) | |
689 | 697 | |
690 | 698 | assert a1_index < a2_index |
691 | 699 | end |
... | ... | @@ -706,7 +714,7 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
706 | 714 | block.order_by_recent = true |
707 | 715 | block.limit_to_show = 1 |
708 | 716 | |
709 | - a1_index = instance_eval(&block.content).index(a1.name) | |
717 | + a1_index = render_block_content(block).index(a1.name) | |
710 | 718 | |
711 | 719 | assert a1_index.nil? |
712 | 720 | end |
... | ... | @@ -730,15 +738,15 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
730 | 738 | block.stubs(:box).returns(box) |
731 | 739 | box.stubs(:owner).returns(profile) |
732 | 740 | |
733 | - assert_nil instance_eval(&block.content).index(en_article.name) | |
734 | - assert_nil instance_eval(&block.content).index(en_article2.name) | |
735 | - assert instance_eval(&block.content).index(pt_article.name).present? | |
741 | + assert_nil render_block_content(block).index(en_article.name) | |
742 | + assert_nil render_block_content(block).index(en_article2.name) | |
743 | + assert render_block_content(block).index(pt_article.name).present? | |
736 | 744 | |
737 | 745 | FastGettext.stubs(:locale).returns('en') |
738 | 746 | |
739 | - assert instance_eval(&block.content).index(en_article.name) | |
740 | - assert instance_eval(&block.content).index(en_article2.name) | |
741 | - assert_nil instance_eval(&block.content).index(pt_article.name) | |
747 | + assert render_block_content(block).index(en_article.name) | |
748 | + assert render_block_content(block).index(en_article2.name) | |
749 | + assert_nil render_block_content(block).index(pt_article.name) | |
742 | 750 | end |
743 | 751 | |
744 | 752 | should 'replace article with its translation' do |
... | ... | @@ -758,12 +766,71 @@ class DisplayContentBlockTest < ActiveSupport::TestCase |
758 | 766 | block.stubs(:box).returns(box) |
759 | 767 | box.stubs(:owner).returns(profile) |
760 | 768 | |
761 | - assert_nil instance_eval(&block.content).index(en_article.name) | |
762 | - assert instance_eval(&block.content).index(pt_article.name).present? | |
769 | + assert_nil render_block_content(block).index(en_article.name) | |
770 | + assert render_block_content(block).index(pt_article.name).present? | |
763 | 771 | |
764 | 772 | FastGettext.stubs(:locale).returns('en') |
765 | 773 | |
766 | - assert instance_eval(&block.content).index(en_article.name).present? | |
767 | - assert_nil instance_eval(&block.content).index(pt_article.name) | |
774 | + assert render_block_content(block).index(en_article.name).present? | |
775 | + assert_nil render_block_content(block).index(pt_article.name) | |
768 | 776 | end |
777 | + | |
778 | + should 'not escape abstract html of articles' do | |
779 | + profile = create_user('testuser').person | |
780 | + a1 = fast_create(TextileArticle, abstract: "<p class='test-article-abstract'>Test</p>", name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) | |
781 | + | |
782 | + block = DisplayContentBlock.new | |
783 | + block.sections = [{:value => 'abstract', :checked => true}] | |
784 | + block.nodes = [a1.id] | |
785 | + box = mock() | |
786 | + block.stubs(:box).returns(box) | |
787 | + box.stubs(:owner).returns(profile) | |
788 | + assert_tag_in_string render_block_content(block), tag: 'p', attributes: { class: 'test-article-abstract' } | |
789 | + end | |
790 | + | |
791 | + should 'not raise if abstract of article is nil' do | |
792 | + profile = create_user('testuser').person | |
793 | + a1 = fast_create(TextileArticle, name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) | |
794 | + | |
795 | + block = DisplayContentBlock.new | |
796 | + block.sections = [{:value => 'abstract', :checked => true}] | |
797 | + block.nodes = [a1.id] | |
798 | + box = mock() | |
799 | + block.stubs(:box).returns(box) | |
800 | + box.stubs(:owner).returns(profile) | |
801 | + assert_nil a1.abstract | |
802 | + assert_nothing_raised do | |
803 | + render_block_content(block) | |
804 | + end | |
805 | + end | |
806 | + | |
807 | + should 'not escape body html of articles' do | |
808 | + profile = create_user('testuser').person | |
809 | + a1 = fast_create(TextileArticle, body: "<p class='test-article-body'>Test</p>", name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) | |
810 | + | |
811 | + block = DisplayContentBlock.new | |
812 | + block.sections = [{:value => 'body', :checked => true}] | |
813 | + block.nodes = [a1.id] | |
814 | + box = mock() | |
815 | + block.stubs(:box).returns(box) | |
816 | + box.stubs(:owner).returns(profile) | |
817 | + assert_tag_in_string render_block_content(block), tag: 'p', attributes: { class: 'test-article-body' } | |
818 | + end | |
819 | + | |
820 | + should 'not raise if body of article is nil' do | |
821 | + profile = create_user('testuser').person | |
822 | + a1 = fast_create(TextileArticle, name: 'test article 1', profile_id: profile.id, published_at: DateTime.current) | |
823 | + | |
824 | + block = DisplayContentBlock.new | |
825 | + block.sections = [{:value => 'abstract', :checked => true}] | |
826 | + block.nodes = [a1.id] | |
827 | + box = mock() | |
828 | + block.stubs(:box).returns(box) | |
829 | + box.stubs(:owner).returns(profile) | |
830 | + assert_nil a1.body | |
831 | + assert_nothing_raised do | |
832 | + render_block_content(block) | |
833 | + end | |
834 | + end | |
835 | + | |
769 | 836 | end | ... | ... |
plugins/display_content/views/blocks/display_content.slim
0 → 100644
plugins/display_content/views/blocks/display_content/_document.slim
0 → 100644
... | ... | @@ -0,0 +1,4 @@ |
1 | +li | |
2 | + - unless item.folder? || item.class == RssFeed | |
3 | + = render partial: 'blocks/display_content/section', collection: block.sections, locals: { block: block, item: item } | |
4 | + = render partial: 'blocks/display_content/read_more', locals: { item: item, abstract_section: block.sections.bsearch { |section| section[:value] == 'abstract' }, block: block } | ... | ... |
plugins/display_content/views/blocks/display_content/_read_more.slim
0 → 100644
plugins/display_content/views/blocks/display_content/_section.slim
0 → 100644
... | ... | @@ -0,0 +1,22 @@ |
1 | +- if block.display_section?(section) | |
2 | + - case section[:value] | |
3 | + - when 'publish_date' | |
4 | + div class='published-at' | |
5 | + = show_date(item.published_at, false) | |
6 | + - when 'title' | |
7 | + div class='title' | |
8 | + = link_to(h(item.title), item.url) | |
9 | + - when 'abstract' | |
10 | + div class='lead' | |
11 | + = (item.abstract || '').html_safe | |
12 | + - when 'body' | |
13 | + div class='body' | |
14 | + = (item.body || '').html_safe | |
15 | + - when 'image' | |
16 | + - unless item.image || item.image.public_filename | |
17 | + div class='image' | |
18 | + = link_to(image_tag(item.image.public_filename), item.url) | |
19 | + - when 'tags' | |
20 | + - unless item.tags.empty? | |
21 | + div class='tags' | |
22 | + = render partial: 'blocks/display_content/tag', collection: item.tags | ... | ... |
plugins/display_content/views/blocks/display_content/_tag.slim
0 → 100644
plugins/ldap/views/ldap_plugin_admin/index.html.erb
plugins/mark_comment_as_read/test/unit/mark_comment_as_read_test.rb
plugins/metadata/lib/metadata_plugin/base.rb
1 | - | |
2 | 1 | class MetadataPlugin::Base < Noosfero::Plugin |
3 | 2 | |
4 | 3 | def self.plugin_name |
... | ... | @@ -71,6 +70,6 @@ end |
71 | 70 | |
72 | 71 | ActiveSupport.run_load_hooks :metadata_plugin, MetadataPlugin |
73 | 72 | ActiveSupport.on_load :active_record do |
74 | - ApplicationRecord.extend MetadataPlugin::Specs::ClassMethods | |
73 | + ActiveRecord::Base.extend MetadataPlugin::Specs::ClassMethods | |
75 | 74 | end |
76 | 75 | ... | ... |
plugins/newsletter/test/integration/safe_strings_test.rb
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
1 | +require 'test_helper' | |
2 | + | |
3 | +class NewsletterPluginSafeStringsTest < ActionDispatch::IntegrationTest | |
4 | + | |
5 | + should 'not escape HTML from newsletter pending task' do | |
6 | + environment = Environment.default | |
7 | + environment.enable_plugin('newsletter') | |
8 | + person = create_user('john', :environment_id => environment.id, :password => 'test', :password_confirmation => 'test').person | |
9 | + person.user.activate | |
10 | + environment.add_admin(person) | |
11 | + | |
12 | + blog = fast_create(Blog, :profile_id => person.id) | |
13 | + post = fast_create(TextileArticle, :name => 'First post', :profile_id => person.id, :parent_id => blog.id, :body => 'Test') | |
14 | + newsletter = NewsletterPlugin::Newsletter.create!(:environment => environment, :person => person, :enabled => true) | |
15 | + newsletter.blog_ids = [blog.id] | |
16 | + newsletter.save! | |
17 | + task = NewsletterPlugin::ModerateNewsletter.create!( | |
18 | + :newsletter_id => newsletter.id, | |
19 | + :target => environment, | |
20 | + :post_ids => [post.id.to_s] | |
21 | + ) | |
22 | + | |
23 | + login 'john', 'test' | |
24 | + get '/myprofile/john/tasks' | |
25 | + | |
26 | + assert_tag :tag => 'input', | |
27 | + :attributes => { :type => 'checkbox', :name => "tasks[#{task.id}][task][post_ids][]" }, | |
28 | + :sibling => { :tag => 'span' } | |
29 | + end | |
30 | + | |
31 | +end | ... | ... |
plugins/newsletter/views/newsletter_plugin/unsubscribe.html.erb
... | ... | @@ -6,6 +6,6 @@ |
6 | 6 | |
7 | 7 | <%= _('Send an email to %s requesting your unsubscription or click on the button below.') % link_to(environment.contact_email, "mailto:#{environment.contact_email}?subject=#{_('Cancel newsletter subscription')}") %> |
8 | 8 | |
9 | -<% button_bar do %> | |
9 | +<%= button_bar do %> | |
10 | 10 | <%= button :ok, _('Confirm unsubscription'), {:action => 'confirm_unsubscription'}, :method => 'post' %> |
11 | 11 | <% end %> | ... | ... |
plugins/newsletter/views/newsletter_plugin_admin/index.html.erb
... | ... | @@ -85,7 +85,7 @@ |
85 | 85 | :id => 'newsletter-footer-field' |
86 | 86 | )) |
87 | 87 | %> |
88 | - <% button_bar do %> | |
88 | + <%= button_bar do %> | |
89 | 89 | <%= submit_button :save, _('Save') %> |
90 | 90 | <%= submit_button :save, _('Save and visualize'), :name => "visualize", :cancel => {:controller => 'plugins'} %> |
91 | 91 | <% end %> | ... | ... |
plugins/newsletter/views/tasks/newsletter_plugin/_moderate_newsletter_accept_details.html.erb
... | ... | @@ -9,9 +9,9 @@ |
9 | 9 | <% input_name = "tasks[#{task.id}][task][post_ids][]" %> |
10 | 10 | <% post_check_box = hidden_field_tag(input_name, '0') +check_box_tag(input_name, post.id, true) %> |
11 | 11 | |
12 | - <% newsletter_content.gsub!(/<span([^>]*?) id="#{post.id}"/, post_check_box + '<span\\1')%> | |
13 | - <% newsletter_content.gsub!(/<img([^>]*?) id="#{post.id}"/, post_check_box + '<img\\1') %> | |
12 | + <% newsletter_content.gsub!(/<span([^>]*?) id="#{post.id}"/, post_check_box + '<span\\1'.html_safe) %> | |
13 | + <% newsletter_content.gsub!(/<img([^>]*?) id="#{post.id}"/, post_check_box + '<img\\1'.html_safe) %> | |
14 | 14 | <% end %> |
15 | 15 | |
16 | - <%= newsletter_content %> | |
16 | + <%= newsletter_content.html_safe %> | |
17 | 17 | </div> | ... | ... |
plugins/oauth_client/views/oauth_client_plugin_admin/edit.html.erb
plugins/organization_ratings/controllers/organization_ratings_plugin_profile_controller.rb
... | ... | @@ -37,20 +37,17 @@ class OrganizationRatingsPluginProfileController < ProfileController |
37 | 37 | end |
38 | 38 | |
39 | 39 | def create_new_rate |
40 | - rating = OrganizationRating.new(params[:organization_rating]) | |
41 | - rating.person = current_user.person | |
42 | - rating.organization = profile | |
43 | - rating.value = params[:organization_rating_value] if params[:organization_rating_value] | |
40 | + @rating = OrganizationRating.new(params[:organization_rating]) | |
41 | + @rating.person = current_user.person | |
42 | + @rating.organization = profile | |
43 | + @rating.value = params[:organization_rating_value] if params[:organization_rating_value] | |
44 | 44 | |
45 | - if rating.save | |
46 | - @plugins.dispatch(:organization_ratings_plugin_rating_created, rating, params) | |
47 | - create_rating_comment(rating) | |
45 | + if @rating.save | |
46 | + @plugins.dispatch(:organization_ratings_plugin_rating_created, @rating, params) | |
47 | + create_rating_comment(@rating) | |
48 | 48 | session[:notice] = _("%s successfully rated!") % profile.name |
49 | - else | |
50 | - session[:notice] = _("Sorry, there were problems rating this profile.") | |
49 | + redirect_to profile.url | |
51 | 50 | end |
52 | - | |
53 | - redirect_to profile.url | |
54 | 51 | end |
55 | 52 | |
56 | 53 | def create_rating_comment(rating) | ... | ... |
plugins/organization_ratings/db/migrate/20160523193515_add_initial_page_to_organization_ratings_config.rb
0 → 100644
... | ... | @@ -0,0 +1,9 @@ |
1 | +class AddInitialPageToOrganizationRatingsConfig < ActiveRecord::Migration | |
2 | + def up | |
3 | + add_column :organization_ratings_configs, :ratings_on_initial_page, :integer, :default => 3 | |
4 | + end | |
5 | + | |
6 | + def down | |
7 | + remove_column :organization_ratings_configs, :ratings_on_initial_page | |
8 | + end | |
9 | +end | ... | ... |
plugins/organization_ratings/features/rate_community.feature
... | ... | @@ -19,7 +19,7 @@ Feature: rate_community |
19 | 19 | And I am logged in as "joaosilva" |
20 | 20 | |
21 | 21 | @selenium |
22 | - Scenario: display rate button inside average block | |
22 | + Scenario: display rate button and total ratings inside average block | |
23 | 23 | Given I am on mycommunity's homepage |
24 | 24 | Then I should see "Rate this Community" within ".average-rating-block" |
25 | 25 | And I should see "Be the first to rate" within ".average-rating-block" |
... | ... | @@ -34,3 +34,9 @@ Feature: rate_community |
34 | 34 | When I follow "Rate this Community" |
35 | 35 | Then I should see "Joao Silva" within ".star-profile-name" |
36 | 36 | And I should see Joao Silva's profile image |
37 | + | |
38 | + Scenario: display total ratings inside average block | |
39 | + Given I am on mycommunity's homepage | |
40 | + When I follow "Rate this Community" | |
41 | + Then I follow "Save" | |
42 | + Then I should see "(1)" within ".total-ratings" | ... | ... |
plugins/organization_ratings/lib/organization_rating.rb
... | ... | @@ -13,25 +13,26 @@ class OrganizationRating < ApplicationRecord |
13 | 13 | validates :organization_id, :person_id, |
14 | 14 | :presence => true |
15 | 15 | |
16 | - def display_moderation_message person | |
17 | - if person.present? | |
18 | - task_active? && (person.is_admin? || person == self.person || | |
16 | + def display_full_info_to? person | |
17 | + (person.is_admin? || person == self.person || | |
19 | 18 | self.organization.is_admin?(person)) |
20 | - end | |
21 | 19 | end |
22 | 20 | |
23 | - def task_active? | |
24 | - tasks = CreateOrganizationRatingComment.where(:target_id => self.organization.id, | |
25 | - :status => Task::Status::ACTIVE) | |
26 | - tasks.detect {|t| t.organization_rating_id == self.id}.present? | |
21 | + def task_status | |
22 | + tasks = CreateOrganizationRatingComment.where(:target_id => self.organization.id, :requestor_id => self.person.id) | |
23 | + task = tasks.detect{ |t| t.organization_rating_id == self.id } | |
24 | + task.status if task.present? | |
27 | 25 | end |
28 | 26 | |
29 | - def self.average_rating organization_id | |
30 | - average = OrganizationRating.where(organization_id: organization_id).average(:value) | |
27 | + def self.statistics_for_profile organization | |
28 | + ratings = OrganizationRating.where(organization_id: organization) | |
29 | + average = ratings.average(:value) | |
30 | + total = ratings.size | |
31 | 31 | |
32 | 32 | if average |
33 | - (average - average.truncate) >= 0.5 ? average.ceil : average.floor | |
33 | + average = (average - average.truncate) >= 0.5 ? average.ceil : average.floor | |
34 | 34 | end |
35 | + { average: average, total: total } | |
35 | 36 | end |
36 | 37 | |
37 | 38 | end | ... | ... |
plugins/organization_ratings/lib/organization_ratings_block.rb
plugins/organization_ratings/lib/organization_ratings_config.rb
... | ... | @@ -4,6 +4,7 @@ class OrganizationRatingsConfig < ApplicationRecord |
4 | 4 | |
5 | 5 | attr_accessible :cooldown, :default_rating, :order, :per_page |
6 | 6 | attr_accessible :vote_once, :are_moderated, :environment_id |
7 | + attr_accessible :ratings_on_initial_page | |
7 | 8 | |
8 | 9 | ORDER_OPTIONS = {recent: _('More Recent'), best: _('Best Ratings')} |
9 | 10 | ... | ... |
plugins/organization_ratings/lib/ratings_helper.rb
... | ... | @@ -12,4 +12,14 @@ module RatingsHelper |
12 | 12 | ratings = OrganizationRating.where(organization_id: profile_id).order("created_at DESC") |
13 | 13 | end |
14 | 14 | end |
15 | -end | |
16 | 15 | \ No newline at end of file |
16 | + | |
17 | + def status_message_for(person, rating) | |
18 | + if person.present? && rating.display_full_info_to?(person) | |
19 | + if(rating.task_status == Task::Status::ACTIVE) | |
20 | + content_tag(:p, _("Report waiting for approval"), class: "moderation-msg") | |
21 | + elsif(rating.task_status == Task::Status::CANCELLED) | |
22 | + content_tag(:p, _("Report rejected"), class: "rejected-msg") | |
23 | + end | |
24 | + end | |
25 | + end | |
26 | +end | ... | ... |
plugins/organization_ratings/public/style.css
1 | 1 | .star-container { |
2 | 2 | width: 100%; |
3 | - height: 20px; | |
3 | + height: 22px; | |
4 | 4 | } |
5 | 5 | |
6 | 6 | .star-negative, .star-positive { |
... | ... | @@ -80,7 +80,16 @@ |
80 | 80 | |
81 | 81 | .organization-average-rating-container .star-container { |
82 | 82 | float: left; |
83 | - width: 120px; | |
83 | + display: inline-flex; | |
84 | + width: auto; | |
85 | + max-width: 190px; | |
86 | + | |
87 | +} | |
88 | + | |
89 | +.total-ratings { | |
90 | + font-size: 16px; | |
91 | + margin-left: 5px; | |
92 | + margin-right: 5px; | |
84 | 93 | } |
85 | 94 | |
86 | 95 | .organization-average-rating-container .rate-this-organization { | ... | ... |
plugins/organization_ratings/test/functional/organization_ratings_plugin_profile_controller_test.rb
... | ... | @@ -46,7 +46,7 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas |
46 | 46 | test "do not create community_rating without a rate value" do |
47 | 47 | post :new_rating, profile: @community.identifier, :comments => {:body => ""}, :organization_rating_value => nil |
48 | 48 | |
49 | - assert_equal "Sorry, there were problems rating this profile.", session[:notice] | |
49 | + assert_tag :tag => 'div', :attributes => {:class => /errorExplanation/}, :content => /Value can't be blank/ | |
50 | 50 | end |
51 | 51 | |
52 | 52 | test "do not create two ratings on Community when vote once config is true" do |
... | ... | @@ -188,4 +188,24 @@ class OrganizationRatingsPluginProfileControllerTest < ActionController::TestCas |
188 | 188 | assert_no_tag :tag => 'p', :content => /Report waiting for approva/, :attributes => {:class =>/comment-rejected-msg/} |
189 | 189 | assert_tag :tag => 'p', :content => /comment accepted/, :attributes => {:class =>/comment-body/} |
190 | 190 | end |
191 | + | |
192 | + test "should display ratings count in average block" do | |
193 | + average_block = AverageRatingBlock.new | |
194 | + average_block.box = @community.boxes.find_by_position(1) | |
195 | + average_block.save! | |
196 | + | |
197 | + OrganizationRating.stubs(:statistics_for_profile).returns({:average => 5, :total => 42}) | |
198 | + get :new_rating, profile: @community.identifier | |
199 | + assert_tag :tag => 'a', :content => /\(42\)/ | |
200 | + end | |
201 | + | |
202 | + test "should display maximum ratings count in average block" do | |
203 | + average_block = AverageRatingBlock.new | |
204 | + average_block.box = @community.boxes.find_by_position(1) | |
205 | + average_block.save! | |
206 | + | |
207 | + OrganizationRating.stubs(:statistics_for_profile).returns({:average => 5, :total => 999000}) | |
208 | + get :new_rating, profile: @community.identifier | |
209 | + assert_tag :tag => 'a', :content => /\(10000\+\)/ | |
210 | + end | |
191 | 211 | end | ... | ... |
plugins/organization_ratings/test/unit/organization_rating_config_test.rb
... | ... | @@ -29,15 +29,29 @@ class OrganizationRatingConfigTest < ActiveSupport::TestCase |
29 | 29 | assert_equal "must be greater than or equal to 0", @organization_ratings_config.errors[:cooldown].first |
30 | 30 | end |
31 | 31 | |
32 | - # test "communities ratings per page validation" do | |
33 | - # environment = Environment.new :communities_ratings_per_page => 4 | |
34 | - # environment.valid? | |
32 | + test "communities ratings per page validation" do | |
33 | + @organization_ratings_config.per_page = 4 | |
35 | 34 | |
36 | - # assert_equal "must be greater than or equal to 5", environment.errors[:communities_ratings_per_page].first | |
35 | + refute @organization_ratings_config.valid? | |
37 | 36 | |
38 | - # environment.communities_ratings_per_page = 21 | |
39 | - # environment.valid? | |
37 | + assert_equal "must be greater than or equal to 5", @organization_ratings_config.errors[:per_page].first | |
40 | 38 | |
41 | - # assert_equal "must be less than or equal to 20", environment.errors[:communities_ratings_per_page].first | |
42 | - # end | |
39 | + @organization_ratings_config.per_page = 21 | |
40 | + refute @organization_ratings_config.valid? | |
41 | + | |
42 | + assert_equal "must be less than or equal to 20", @organization_ratings_config.errors[:per_page].first | |
43 | + end | |
44 | + | |
45 | + should "ratings block use initial_page config" do | |
46 | + @organization_ratings_config.ratings_on_initial_page = 4 | |
47 | + @organization_ratings_config.save! | |
48 | + block = OrganizationRatingsBlock.new | |
49 | + assert_equal block.ratings_on_initial_page, 4 | |
50 | + end | |
51 | + | |
52 | + should "ratings block show 3 ratings on initial page by default" do | |
53 | + @organization_ratings_config.save! | |
54 | + block = OrganizationRatingsBlock.new | |
55 | + assert_equal block.ratings_on_initial_page, 3 | |
56 | + end | |
43 | 57 | end | ... | ... |
plugins/organization_ratings/test/unit/organization_rating_test.rb
... | ... | @@ -35,55 +35,36 @@ class OrganizationRatingTest < ActiveSupport::TestCase |
35 | 35 | assert_equal false, organization_rating2.errors[:value].include?("must be between 1 and 5") |
36 | 36 | end |
37 | 37 | |
38 | - test "false return when no active tasks for an Organization Rating" do | |
39 | - assert_not @rating.task_active? | |
40 | - end | |
41 | - | |
42 | - test "true return when an active task exists for an Organization Rating" do | |
38 | + test "return rating task status" do | |
43 | 39 | CreateOrganizationRatingComment.create!( |
44 | 40 | :organization_rating_id => @rating.id, |
45 | 41 | :target => @community, |
46 | 42 | :requestor => @person) |
47 | 43 | |
48 | - assert_equal Task::Status::ACTIVE, CreateOrganizationRatingComment.last.status | |
49 | - assert @rating.task_active? | |
44 | + assert_equal Task::Status::ACTIVE, @rating.task_status | |
50 | 45 | end |
51 | 46 | |
52 | - test "return false when an cancelled task exists for an Organization Rating" do | |
47 | + test "return rating task status when task is cancelled" do | |
53 | 48 | CreateOrganizationRatingComment.create!( |
54 | 49 | :organization_rating_id => @rating.id, |
55 | 50 | :target => @community, |
56 | 51 | :requestor => @person) |
57 | 52 | CreateOrganizationRatingComment.last.cancel |
58 | - assert_not @rating.task_active? | |
53 | + assert_equal Task::Status::CANCELLED, @rating.task_status | |
59 | 54 | end |
60 | 55 | |
61 | - test "display report moderation message to community admin" do | |
62 | - moderator = create_user('moderator') | |
63 | - @community.add_admin(moderator.person) | |
64 | - @rating.stubs(:task_active?).returns(true) | |
65 | - assert @rating.display_moderation_message(@adminuser) | |
56 | + test "should display full info to admin" do | |
57 | + @person.stubs(:is_admin?).returns(true) | |
58 | + assert @rating.display_full_info_to?(@person) | |
66 | 59 | end |
67 | 60 | |
68 | - test "display report moderation message to owner" do | |
69 | - @rating.stubs(:task_active?).returns(true) | |
70 | - assert @rating.display_moderation_message(@person) | |
61 | + test "should display full info to owner" do | |
62 | + assert @rating.display_full_info_to?(@person) | |
71 | 63 | end |
72 | 64 | |
73 | - test "do not display report moderation message to regular user" do | |
65 | + test "should not display full info to regular user" do | |
74 | 66 | regular_person = fast_create(Person) |
75 | - @rating.stubs(:task_active?).returns(true) | |
76 | - assert_not @rating.display_moderation_message(regular_person) | |
77 | - end | |
78 | - | |
79 | - test "do not display report moderation message to not logged user" do | |
80 | - @rating.stubs(:task_active?).returns(true) | |
81 | - assert_not @rating.display_moderation_message(nil) | |
82 | - end | |
83 | - | |
84 | - test "do not display report moderation message no active task exists" do | |
85 | - @rating.stubs(:task_active?).returns(false) | |
86 | - assert_not @rating.display_moderation_message(@person) | |
67 | + assert_not @rating.display_full_info_to?(regular_person) | |
87 | 68 | end |
88 | 69 | |
89 | 70 | test "Create task for create a rating comment" do |
... | ... | @@ -109,7 +90,7 @@ class OrganizationRatingTest < ActiveSupport::TestCase |
109 | 90 | assert community.tasks.include?(create_organization_rating_comment) |
110 | 91 | end |
111 | 92 | |
112 | - test "Should calculate community's rating average" do | |
93 | + test "Should calculate community's rating statistics" do | |
113 | 94 | community = fast_create Community |
114 | 95 | p1 = fast_create Person, :name=>"Person 1" |
115 | 96 | p2 = fast_create Person, :name=>"Person 2" |
... | ... | @@ -119,11 +100,13 @@ class OrganizationRatingTest < ActiveSupport::TestCase |
119 | 100 | OrganizationRating.create! :value => 3, :organization => community, :person => p2 |
120 | 101 | OrganizationRating.create! :value => 5, :organization => community, :person => p3 |
121 | 102 | |
122 | - assert_equal 3, OrganizationRating.average_rating(community) | |
103 | + assert_equal 3, OrganizationRating.statistics_for_profile(community)[:average] | |
104 | + assert_equal 3, OrganizationRating.statistics_for_profile(community)[:total] | |
123 | 105 | |
124 | 106 | p4 = fast_create Person, :name=>"Person 4" |
125 | 107 | OrganizationRating.create! :value => 4, :organization => community, :person => p4 |
126 | 108 | |
127 | - assert_equal 4, OrganizationRating.average_rating(community) | |
109 | + assert_equal 4, OrganizationRating.statistics_for_profile(community)[:average] | |
110 | + assert_equal 4, OrganizationRating.statistics_for_profile(community)[:total] | |
128 | 111 | end |
129 | 112 | end | ... | ... |
plugins/organization_ratings/test/unit/ratings_helper_test.rb
... | ... | @@ -3,6 +3,7 @@ require 'ratings_helper' |
3 | 3 | |
4 | 4 | class RatingsHelperTest < ActiveSupport::TestCase |
5 | 5 | include RatingsHelper |
6 | + include ActionView::Helpers::TagHelper | |
6 | 7 | |
7 | 8 | def setup |
8 | 9 | |
... | ... | @@ -12,6 +13,12 @@ class RatingsHelperTest < ActiveSupport::TestCase |
12 | 13 | @person = create_user('testuser').person |
13 | 14 | @community = Community.create(:name => "TestCommunity") |
14 | 15 | @organization_ratings_config = OrganizationRatingsConfig.instance |
16 | + @rating = fast_create(OrganizationRating, {:value => 1, | |
17 | + :person_id => @person.id, | |
18 | + :organization_id => @community.id, | |
19 | + :created_at => DateTime.now, | |
20 | + :updated_at => DateTime.now, | |
21 | + }) | |
15 | 22 | end |
16 | 23 | |
17 | 24 | should "get the ratings of a community ordered by most recent ratings" do |
... | ... | @@ -32,6 +39,7 @@ class RatingsHelperTest < ActiveSupport::TestCase |
32 | 39 | |
33 | 40 | ratings_array << most_recent_rating |
34 | 41 | ratings_array << first_rating |
42 | + ratings_array << @rating | |
35 | 43 | |
36 | 44 | assert_equal @organization_ratings_config.order, "recent" |
37 | 45 | assert_equal ratings_array, get_ratings(@community.id) |
... | ... | @@ -57,7 +65,42 @@ class RatingsHelperTest < ActiveSupport::TestCase |
57 | 65 | |
58 | 66 | ratings_array << second_rating |
59 | 67 | ratings_array << first_rating |
68 | + ratings_array << @rating | |
60 | 69 | |
61 | 70 | assert_equal ratings_array, get_ratings(@community.id) |
62 | 71 | end |
72 | + | |
73 | + test "display report moderation message to community admin" do | |
74 | + @moderator = create_user('moderator').person | |
75 | + @community.add_admin(@moderator) | |
76 | + @rating.stubs(:task_status).returns(Task::Status::ACTIVE) | |
77 | + assert status_message_for(@moderator, @rating).include?("Report waiting for approval") | |
78 | + end | |
79 | + | |
80 | + test "display report moderation message to owner" do | |
81 | + @rating.stubs(:task_status).returns(Task::Status::ACTIVE) | |
82 | + assert status_message_for(@person, @rating).include?("Report waiting for approval") | |
83 | + end | |
84 | + | |
85 | + test "display report rejected message to owner" do | |
86 | + @rating.stubs(:task_status).returns(Task::Status::CANCELLED) | |
87 | + assert status_message_for(@person, @rating).include?("Report rejected") | |
88 | + end | |
89 | + | |
90 | + test "do not display report moderation message to regular user" do | |
91 | + @regular_person = fast_create(Person) | |
92 | + @rating.stubs(:task_status).returns(Task::Status::ACTIVE) | |
93 | + assert_nil status_message_for(@regular_person, @rating) | |
94 | + end | |
95 | + | |
96 | + test "return empty status message to not logged user" do | |
97 | + @rating.stubs(:task_status).returns(Task::Status::ACTIVE) | |
98 | + assert_nil status_message_for(nil, @rating) | |
99 | + end | |
100 | + | |
101 | + test "do not display status message if report task is finished" do | |
102 | + @rating.stubs(:task_status).returns(Task::Status::FINISHED) | |
103 | + assert_nil status_message_for(@person, @rating) | |
104 | + end | |
105 | + | |
63 | 106 | end | ... | ... |
plugins/organization_ratings/views/blocks/average_rating.html.erb
1 | -<% average_rating = OrganizationRating.average_rating block.owner.id %> | |
1 | +<% statistics = OrganizationRating.statistics_for_profile block.owner %> | |
2 | 2 | |
3 | 3 | <div class="organization-average-rating-container"> |
4 | - <% if average_rating %> | |
4 | + <% if statistics[:average] %> | |
5 | 5 | <div class="star-rate-text"> |
6 | 6 | <%= _("Rating: ") %> |
7 | 7 | </div> |
8 | 8 | |
9 | 9 | <div class="star-container"> |
10 | 10 | <% (1..5).each do |star_number| %> |
11 | - <% if star_number <= average_rating %> | |
11 | + <% if star_number <= statistics[:average] %> | |
12 | 12 | <div class="medium-star-positive"></div> |
13 | 13 | <% else %> |
14 | 14 | <div class="medium-star-negative"></div> |
15 | 15 | <% end %> |
16 | 16 | <% end %> |
17 | + <div class="total-ratings"> | |
18 | + <%= link_to url_for(:controller => 'organization_ratings_plugin_profile', :action => 'new_rating', :anchor => 'ratings-list') do %> | |
19 | + <% if(statistics[:total] > 10000) %> | |
20 | + <%= "(10000+)" %> | |
21 | + <% else %> | |
22 | + <%= "(#{statistics[:total]})" %> | |
23 | + <% end %> | |
24 | + <% end %> | |
25 | + </div> | |
17 | 26 | </div> |
18 | 27 | <% else %> |
19 | 28 | <div class="rating-invitation"> |
... | ... | @@ -24,4 +33,4 @@ |
24 | 33 | <div class="rate-this-organization"> |
25 | 34 | <%= link_to _("Rate this %s") % _(block.owner.class.name), url_for(:controller => "organization_ratings_plugin_profile", :action => "new_rating", :profile => block.owner.identifier) %> |
26 | 35 | </div> |
27 | -</div> | |
28 | 36 | \ No newline at end of file |
37 | +</div> | ... | ... |
plugins/organization_ratings/views/blocks/organization_ratings.html.erb
... | ... | @@ -7,14 +7,14 @@ |
7 | 7 | <% else %> |
8 | 8 | <div class="ratings-list"> |
9 | 9 | <% block.get_ratings(block.owner.id).each_with_index do |r, index| %> |
10 | - <% break if index >= block.limit_number_of_ratings %> | |
10 | + <% break if index >= block.ratings_on_initial_page %> | |
11 | 11 | <%= render :partial => "shared/user_rating_container", :locals => {:user_rate => r} %> |
12 | 12 | <% end %> |
13 | 13 | |
14 | 14 | <%= render :partial => 'shared/make_report_block' %> |
15 | 15 | |
16 | 16 | <div class="see-more"> |
17 | - <%= link_to _('See more'), url_for(:controller => 'organization_ratings_plugin_profile', :action => 'new_rating'), :class => 'icon-arrow-right-p' %> | |
17 | + <%= link_to _('See more'), url_for(:controller => 'organization_ratings_plugin_profile', :action => 'new_rating', :anchor => 'ratings-list'), :class => 'icon-arrow-right-p' %> | |
18 | 18 | </div> |
19 | 19 | </div> |
20 | 20 | <% end %> | ... | ... |
plugins/organization_ratings/views/organization_ratings_plugin_admin/index.html.erb
... | ... | @@ -43,9 +43,15 @@ |
43 | 43 | <%= c.select :per_page, 5..20 %> |
44 | 44 | </td> |
45 | 45 | </tr> |
46 | + <tr> | |
47 | + <td><%= _('Ratings amount on initial page') %></td> | |
48 | + <td> | |
49 | + <%= c.select :ratings_on_initial_page, 1..10 %> | |
50 | + </td> | |
51 | + </tr> | |
46 | 52 | </table> |
47 | 53 | <div> |
48 | - <% button_bar do %> | |
54 | + <%= button_bar do %> | |
49 | 55 | <%= submit_button('save', c_('Save changes')) %> |
50 | 56 | <%= button :back, _('Back'), :controller => 'plugins' %> |
51 | 57 | <% end %> | ... | ... |
plugins/organization_ratings/views/organization_ratings_plugin_profile/_new_rating_fields.html.erb
1 | 1 | <% min_rate = env_organization_ratings_config.minimum_ratings %> |
2 | 2 | <% default_rating = env_organization_ratings_config.default_rating %> |
3 | 3 | |
4 | -<div class="star-page-title"> | |
5 | - <%= @plugins.dispatch(:organization_ratings_title).collect { |content| instance_exec(&content) }.join("") %> | |
6 | -</div> | |
7 | - | |
8 | 4 | <div class="star-rate-data"> |
9 | 5 | |
10 | 6 | <div class="star-profile-information"> | ... | ... |
plugins/organization_ratings/views/organization_ratings_plugin_profile/new_rating.html.erb
1 | +<%= error_messages_for 'rating' %> | |
2 | + | |
1 | 3 | <% config = env_organization_ratings_config %> |
4 | +<div class="star-page-title"> | |
5 | + <%= @plugins.dispatch(:organization_ratings_title).collect { |content| instance_exec(&content) }.join("") %> | |
6 | +</div> | |
2 | 7 | <% if logged_in? %> |
3 | 8 | <%= render :partial => "new_rating_fields" %> |
4 | 9 | <% else %> |
... | ... | @@ -7,7 +12,7 @@ |
7 | 12 | </div> |
8 | 13 | <% end %> |
9 | 14 | |
10 | -<div class="ratings-list"> | |
15 | +<div class="ratings-list" id="ratings-list"> | |
11 | 16 | <% @users_ratings.each do |user_rate| %> |
12 | 17 | <%= render :partial => "shared/user_rating_container", :locals => {:user_rate => user_rate} %> |
13 | 18 | <% end %> |
... | ... | @@ -15,4 +20,4 @@ |
15 | 20 | |
16 | 21 | <div id='pagination-profiles'> |
17 | 22 | <%= pagination_links @users_ratings, :param_name => 'npage' %> |
18 | -</div> | |
19 | 23 | \ No newline at end of file |
24 | +</div> | ... | ... |
plugins/organization_ratings/views/shared/_make_report_block.html.erb
1 | 1 | <% logged_in_image = link_to profile_image(current_user.person, :portrait), current_user.person.url if current_user %> |
2 | 2 | <% logged_in_name = link_to current_user.person.name, current_user.person.url if current_user %> |
3 | -<% logged_out_image = image_tag('plugins/organization_ratings/public/images/user-not-logged.png') %> | |
3 | +<% logged_out_image = image_tag('plugins/organization_ratings/images/user-not-logged.png') %> | |
4 | 4 | |
5 | 5 | <div class="make-report-block"> |
6 | 6 | <div class="star-profile-information"> | ... | ... |
plugins/organization_ratings/views/shared/_rating_button.html.erb
plugins/organization_ratings/views/shared/_user_rating_container.html.erb
1 | +<% extend RatingsHelper %> | |
1 | 2 | <div class="user-rating-block"> |
2 | 3 | <div class="star-profile-information"> |
3 | 4 | <div class="star-profile-image"> |
... | ... | @@ -25,9 +26,7 @@ |
25 | 26 | </div> |
26 | 27 | |
27 | 28 | <div class="user-testimony"> |
28 | - <% if user_rate.display_moderation_message(user) %> | |
29 | - <p class="moderation-msg"><%= _("Report waiting for approval") %></p> | |
30 | - <% end %> | |
29 | + <%= status_message_for(user, user_rate) %> | |
31 | 30 | <% if user_rate.comment.present? %> |
32 | 31 | <p class="comment-body"> <%= user_rate.comment.body %> </p> |
33 | 32 | <% end %> | ... | ... |
plugins/piwik/views/piwik_plugin_admin/index.html.erb
plugins/products/test/unit/products_plugin/enterprise_homepage_helper_test.rb
1 | 1 | require_relative '../../test_helper' |
2 | 2 | |
3 | -class EnterpriseHomepageHelperTest < ActiveSupport::TestCase | |
3 | +class EnterpriseHomepageHelperTest < ActionView::TestCase | |
4 | 4 | |
5 | 5 | include ProductsPlugin::EnterpriseHomepageHelper |
6 | 6 | |
... | ... | @@ -57,7 +57,4 @@ class EnterpriseHomepageHelperTest < ActiveSupport::TestCase |
57 | 57 | assert_no_match /100.34/, result |
58 | 58 | end |
59 | 59 | |
60 | - protected | |
61 | - include NoosferoTestHelper | |
62 | - | |
63 | 60 | end | ... | ... |
plugins/products/test/unit/profile_test.rb
... | ... | @@ -22,9 +22,8 @@ class ProfileTest < ActiveSupport::TestCase |
22 | 22 | end |
23 | 23 | |
24 | 24 | should 'collect the highlighted products with image' do |
25 | - env = Environment.default | |
26 | 25 | e1 = fast_create(Enterprise) |
27 | - p1 = create(Product, name: 'test_prod1', product_category_id: @product_category.id, enterprise: e1) | |
26 | + create(Product, name: 'test_prod1', product_category_id: @product_category.id, enterprise: e1) | |
28 | 27 | products = [] |
29 | 28 | 3.times {|n| |
30 | 29 | products.push(create(Product, name: "product #{n}", profile_id: e1.id, |
... | ... | @@ -36,7 +35,8 @@ class ProfileTest < ActiveSupport::TestCase |
36 | 35 | create(Product, name: "product 5", profile_id: e1.id, product_category_id: @product_category.id, image_builder: { |
37 | 36 | uploaded_data: fixture_file_upload('/files/rails.png', 'image/png') |
38 | 37 | }) |
39 | - assert_equal products, e1.highlighted_products_with_image | |
38 | + | |
39 | + assert_equivalent products, e1.highlighted_products_with_image | |
40 | 40 | end |
41 | 41 | |
42 | 42 | should 'have many inputs through products' do | ... | ... |
plugins/products/views/products_plugin/page/_display_input.html.erb
1 | 1 | <div class='input-informations input-form-closed'> |
2 | 2 | <div class='input-name'> <%= input.name %> <%= input_icon(input) %> </div> |
3 | 3 | <div class='input-details'> |
4 | - <% button_bar do %> | |
4 | + <%= button_bar do %> | |
5 | 5 | <% if input.has_price_details? %> |
6 | 6 | <%= edit_button(:edit, _('Edit'), {:action => 'edit_input', :id => input}, :class => 'edit-input', :id => "edit-input-#{input.id}") %> |
7 | 7 | <% end %> | ... | ... |
plugins/products/views/products_plugin/page/_edit_description.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | html: {id: 'product-description-form', method: 'post'}) do |f| %> |
7 | 7 | |
8 | 8 | <%= labelled_form_field(_('Description:'), f.text_area(:description, rows: 15, style: 'width: 90%;', class: 'mceEditor')) %> |
9 | - <% button_bar do %> | |
9 | + <%= button_bar do %> | |
10 | 10 | <%= submit_button :save, _('Save') %> |
11 | 11 | <%= cancel_edit_product_link(@product, 'description') %> |
12 | 12 | <% end %> | ... | ... |
plugins/products/views/products_plugin/page/_edit_info.html.erb
... | ... | @@ -54,7 +54,7 @@ |
54 | 54 | |
55 | 55 | <%= hidden_field_tag 'info-bar-update-url', @product.price_composition_bar_display_url, class: 'bar-update-url' %> |
56 | 56 | |
57 | - <% button_bar do %> | |
57 | + <%= button_bar do %> | |
58 | 58 | <%= submit_button :save, _('Save') %> |
59 | 59 | <%= cancel_edit_product_link(@product, 'info') %> |
60 | 60 | <% end %> | ... | ... |
plugins/products/views/products_plugin/page/_edit_name.html.erb
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | <%= f.text_field(:name, value: @product.name, class: 'name_edition') %> |
7 | 7 | <%= select_unit(@product) %> |
8 | 8 | |
9 | - <% button_bar do %> | |
9 | + <%= button_bar do %> | |
10 | 10 | <%= submit_button :save, _('Save') %> |
11 | 11 | <%= cancel_edit_product_link(@product, 'name') %> |
12 | 12 | <% end %> | ... | ... |
plugins/products/views/products_plugin/page/_form.html.erb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <%= file_field_or_thumbnail(_('Image:'), @product.image, i) %> |
12 | 12 | <% end %> |
13 | 13 | |
14 | - <% button_bar do %> | |
14 | + <%= button_bar do %> | |
15 | 15 | <%= submit_button('save', (mode == 'new' ? _('Create product') : _('Save changes')), :cancel => {:action => 'index'} ) %> |
16 | 16 | <% end %> |
17 | 17 | <% end %> | ... | ... |
plugins/products/views/products_plugin/page/_manage_product_details.html.erb
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | <%= hidden_field(:product, :inputs_cost) %> |
22 | 22 | <%= hidden_field(:product, :price) %> |
23 | 23 | |
24 | - <% button_bar do %> | |
24 | + <%= button_bar do %> | |
25 | 25 | <%= submit_button :save, _('Save'), :disabled => '', :class => 'disabled' %> |
26 | 26 | <%= button :cancel, _('Cancel'), '#', class: 'cancel-price-details', data: {confirm: _('If you leave, you will lose all unsaved information. Are you sure you want to quit?')} %> |
27 | 27 | <%= button(:add, _('New cost'), '#', :id => 'add-new-cost') %> | ... | ... |
plugins/products/views/products_plugin/page/index.html.erb
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | |
25 | 25 | <%= pagination_links @products %> |
26 | 26 | |
27 | -<% button_bar do %> | |
27 | +<%= button_bar do %> | |
28 | 28 | <%= button :add, _('New product or service'), :action => 'new' if @profile.create_product? %> |
29 | 29 | <%= button :back, _('Back'), { :controller => 'profile_editor', :profile => @profile.identifier, :action => 'index' } %> |
30 | 30 | <% end %> | ... | ... |
plugins/products/views/products_plugin/page/show.html.erb
... | ... | @@ -68,7 +68,7 @@ |
68 | 68 | |
69 | 69 | </div> |
70 | 70 | |
71 | -<% button_bar do %> | |
71 | +<%= button_bar do %> | |
72 | 72 | <%= button :back, _('Back to the product listing'), controller: 'products_plugin/catalog', action: 'index' %> |
73 | 73 | <%= button :delete, _('Remove product or service'), {action: 'destroy', id: @product}, class: 'requires-permission-manage_products', style: 'display:none;' %> |
74 | 74 | <% end %> | ... | ... |
plugins/products/views/profile_editor/_products_profile_info_contents.html.slim
0 → 100644
plugins/products/views/profile_editor/products_profile_info_contents.html.slim
plugins/push_notification/lib/push_notification_plugin.rb
plugins/push_notification/lib/push_notification_plugin/api.rb
1 | -require_dependency 'api/helpers' | |
2 | 1 | require_relative 'api_entities' |
3 | 2 | |
4 | -class PushNotificationPlugin::Api < Grape::API | |
3 | +# Can't be called Api as will result in: | |
4 | +# warning: toplevel constant Api referenced by PushNotificationPlugin::Api | |
5 | +# To fix this PushNotificationPlugin should be a module | |
6 | +class PushNotificationPlugin::API < Grape::API | |
5 | 7 | |
6 | 8 | include Api::Helpers |
7 | 9 | ... | ... |
plugins/push_notification/views/push_notification_plugin_admin/index.html.erb
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <h3><%= t('push_notification_plugin.lib.plugin.enabled_notifications')%></h3> |
8 | 8 | <%= render partial: "notification_events_form", locals:{f: f, settings: @settings} %> |
9 | 9 | |
10 | - <% button_bar do %> | |
10 | + <%= button_bar do %> | |
11 | 11 | <%= submit_button(:save, c_('Save'), :cancel => {:controller => 'plugins'}) %> |
12 | 12 | <% end %> |
13 | 13 | ... | ... |
plugins/push_notification/views/push_notification_plugin_myprofile/index.html.erb
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | <%= form_for(:settings, :url => {:controller => "push_notification_plugin_myprofile", :action => "update_settings"}) do |f| %> |
19 | 19 | <h1><%= t('push_notification_plugin.lib.plugin.enabled_notifications') %></h1> |
20 | 20 | <%= render partial: "notification_events_form", locals: {f: f, settings: @settings} %> |
21 | - <% button_bar do %> | |
21 | + <%= button_bar do %> | |
22 | 22 | <%= submit_button(:save, _('Save')) %> |
23 | 23 | <%= button(:back, _('Back to control panel'), :controller => (profile.nil? ? 'admin_panel': 'profile_editor')) %> |
24 | 24 | <% end %> | ... | ... |
plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb
... | ... | @@ -20,45 +20,8 @@ class RelevantContentPlugin::RelevantContentBlock < Block |
20 | 20 | |
21 | 21 | attr_accessible :limit, :show_most_voted, :show_most_disliked, :show_most_liked, :show_most_commented, :show_most_read |
22 | 22 | |
23 | - include ActionView::Helpers | |
24 | - include Rails.application.routes.url_helpers | |
25 | - | |
26 | - def content(args={}) | |
27 | - | |
28 | - content = block_title(title, subtitle) | |
29 | - | |
30 | - if self.show_most_read | |
31 | - docs = Article.most_accessed(owner, self.limit) | |
32 | - content += subcontent(docs, _("Most read articles"), "mread") unless docs.blank? | |
33 | - end | |
34 | - | |
35 | - if self.show_most_commented | |
36 | - docs = Article.most_commented_relevant_content(owner, self.limit) | |
37 | - content += subcontent(docs, _("Most commented articles"), "mcommented") unless docs.blank? | |
38 | - end | |
39 | - | |
40 | - if owner.kind_of?(Environment) | |
41 | - env = owner | |
42 | - else | |
43 | - env = owner.environment | |
44 | - end | |
45 | - | |
46 | - if env.plugin_enabled?('VotePlugin') | |
47 | - if self.show_most_liked | |
48 | - docs = Article.more_positive_votes(owner, self.limit) | |
49 | - content += subcontent(docs, _("Most liked articles"), "mliked") unless docs.blank? | |
50 | - end | |
51 | - if self.show_most_disliked | |
52 | - docs = Article.more_negative_votes(owner, self.limit) | |
53 | - content += subcontent(docs, _("Most disliked articles"), "mdisliked") unless docs.blank? | |
54 | - end | |
55 | - | |
56 | - if self.show_most_voted | |
57 | - docs = Article.most_voted(owner, self.limit) | |
58 | - content += subcontent(docs, _("Most voted articles"), "mvoted") unless docs.blank? | |
59 | - end | |
60 | - end | |
61 | - return content.html_safe | |
23 | + def env | |
24 | + owner.kind_of?(Environment) ? owner : owner.environment | |
62 | 25 | end |
63 | 26 | |
64 | 27 | def timeout |
... | ... | @@ -69,14 +32,4 @@ class RelevantContentPlugin::RelevantContentBlock < Block |
69 | 32 | { :profile => [:article], :environment => [:article] } |
70 | 33 | end |
71 | 34 | |
72 | - protected | |
73 | - | |
74 | - def subcontent(docs, title, html_class) | |
75 | - subcontent = safe_join([ | |
76 | - content_tag(:span, title, class: "title #{html_class}"), | |
77 | - content_tag(:ul, safe_join(docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}, "\n")) | |
78 | - ], "\n") | |
79 | - content_tag(:div, subcontent, :class=>"block #{html_class}") | |
80 | - end | |
81 | - | |
82 | 35 | end | ... | ... |
plugins/relevant_content/test/unit/relevant_content_block_test.rb
... | ... | @@ -42,20 +42,6 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
42 | 42 | assert_equal RelevantContentPlugin::RelevantContentBlock.expire_on, {:environment=>[:article], :profile=>[:article]} |
43 | 43 | end |
44 | 44 | |
45 | - should 'not crash if vote plugin is not found' do | |
46 | - box = fast_create(Box, :owner_id => @profile.id, :owner_type => 'Profile') | |
47 | - block = RelevantContentPlugin::RelevantContentBlock.new(:box => box) | |
48 | - | |
49 | - Environment.any_instance.stubs(:enabled_plugins).returns(['RelevantContent']) | |
50 | - # When the plugin is disabled from noosfero instance, its constant name is | |
51 | - # undefined. To test this case, I have to manually undefine the constant | |
52 | - # if necessary. | |
53 | - Object.send(:remove_const, VotePlugin.to_s) if defined? VotePlugin | |
54 | - | |
55 | - assert_nothing_raised do | |
56 | - block.content | |
57 | - end | |
58 | - end | |
59 | 45 | |
60 | 46 | should 'check most voted articles from profile with relevant content block' do |
61 | 47 | community = fast_create(Community) |
... | ... | @@ -77,11 +63,41 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
77 | 63 | assert_equal false, data.empty? |
78 | 64 | end |
79 | 65 | |
66 | +end | |
67 | + | |
68 | +require 'boxes_helper' | |
69 | + | |
70 | +class RelevantContentBlockViewTest < ActionView::TestCase | |
71 | + include BoxesHelper | |
72 | + | |
73 | + def setup | |
74 | + @profile = create_user('testinguser').person | |
75 | + end | |
76 | + | |
77 | + should 'not crash if vote plugin is not found' do | |
78 | + box = fast_create(Box, :owner_id => @profile.id, :owner_type => 'Profile') | |
79 | + block = RelevantContentPlugin::RelevantContentBlock.new(:box => box) | |
80 | + | |
81 | + Environment.any_instance.stubs(:enabled_plugins).returns(['RelevantContent']) | |
82 | + ActionView::Base.any_instance.expects(:block_title).returns("") | |
83 | + # When the plugin is disabled from noosfero instance, its constant name is | |
84 | + # undefined. To test this case, I have to manually undefine the constant | |
85 | + # if necessary. | |
86 | + Object.send(:remove_const, VotePlugin.to_s) if defined? VotePlugin | |
87 | + | |
88 | + assert_nothing_raised do | |
89 | + render_block_content(block) | |
90 | + end | |
91 | + end | |
92 | + | |
80 | 93 | should 'not escape html in block content' do |
81 | - fast_create(Article, profile_id: profile.id, hits: 10) | |
82 | - box = fast_create(Box, :owner_id => profile.id, :owner_type => 'Profile') | |
94 | + fast_create(Article, profile_id: @profile.id, hits: 10) | |
95 | + box = fast_create(Box, :owner_id => @profile.id, :owner_type => 'Profile') | |
83 | 96 | block = RelevantContentPlugin::RelevantContentBlock.new(:box => box) |
97 | + | |
84 | 98 | Environment.any_instance.stubs(:enabled_plugins).returns(['RelevantContent']) |
85 | - assert_tag_in_string block.content, tag: 'span', attributes: { class: 'title mread' } | |
99 | + ActionView::Base.any_instance.expects(:block_title).returns("") | |
100 | + | |
101 | + assert_tag_in_string render_block_content(block), tag: 'span', attributes: { class: 'title mread' } | |
86 | 102 | end |
87 | 103 | end | ... | ... |
plugins/relevant_content/views/blocks/relevant_content.slim
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | += block_title(block.title, block.subtitle) | |
2 | + | |
3 | +- if block.show_most_read | |
4 | + = render partial: 'blocks/relevant_content/subcontent', locals: {docs: Article.most_accessed(block.owner, block.limit), title: _("Most read articles"), html_class: 'mread'} | |
5 | +- if block.show_most_commented | |
6 | + = render partial: 'blocks/relevant_content/subcontent', locals: {docs: Article.most_commented_relevant_content(block.owner, block.limit), title: _("Most commented articles"), html_class: 'mcommented'} | |
7 | + | |
8 | +- if block.env.plugin_enabled?('VotePlugin') | |
9 | + - if block.show_most_liked | |
10 | + = render partial: 'blocks/relevant_content/subcontent', locals: {docs: Article.more_positive_votes(block.owner, block.limit), title: _("Most liked articles"), html_class: 'mliked'} | |
11 | + - if block.show_most_disliked | |
12 | + = render partial: 'blocks/relevant_content/subcontent', locals: {docs: Article.more_negative_votes(block.owner, block.limit), title: _("Most disliked articles"), html_class: 'mdisliked'} | |
13 | + - if block.show_most_voted | |
14 | + = render partial: 'blocks/relevant_content/subcontent', locals: {docs: Article.most_voted(block.owner, block.limit), title: _("Most voted articles"), html_class: 'mvoted'} | ... | ... |
plugins/relevant_content/views/blocks/relevant_content/_doc.slim
0 → 100644
plugins/relevant_content/views/blocks/relevant_content/_subcontent.slim
0 → 100644
plugins/require_auth_to_comment/views/require_auth_to_comment_plugin_admin/index.html.erb
plugins/responsive/lib/ext/application_helper.rb
... | ... | @@ -5,7 +5,7 @@ module ApplicationHelper |
5 | 5 | protected |
6 | 6 | |
7 | 7 | module ResponsiveMethods |
8 | - FORM_CONTROL_CLASS = "form-control" | |
8 | + FORM_CONTROL_CLASS = 'form-control' | |
9 | 9 | |
10 | 10 | def button(type, label, url, html_options = {}) |
11 | 11 | return super unless theme_responsive? |
... | ... | @@ -13,15 +13,14 @@ module ApplicationHelper |
13 | 13 | option = html_options.delete(:option) || 'default' |
14 | 14 | size = html_options.delete(:size) || 'xs' |
15 | 15 | the_class = "with-text btn btn-#{size} btn-#{option} icon-#{type}" |
16 | - if html_options.has_key?(:class) | |
17 | - the_class << ' ' << html_options[:class] | |
18 | - end | |
19 | - #button_without_text type, label, url, html_options.merge(:class => the_class) | |
16 | + the_class << ' ' << html_options[:class] if html_options.has_key?(:class) | |
17 | + | |
18 | + #button_without_text type, label, url, html_options.merge(class: the_class) | |
20 | 19 | the_title = html_options[:title] || label |
21 | 20 | if html_options[:disabled] |
22 | - content_tag('a', content_tag('span', label), html_options.merge(class: the_class, title: the_title)) | |
21 | + content_tag(:a, content_tag(:span, label), html_options.merge(class: the_class, title: the_title)) | |
23 | 22 | else |
24 | - link_to(content_tag('span', label), url, html_options.merge(class: the_class, title: the_title)) | |
23 | + link_to(content_tag(:span, label), url, html_options.merge(class: the_class, title: the_title)) | |
25 | 24 | end |
26 | 25 | end |
27 | 26 | |
... | ... | @@ -36,7 +35,7 @@ module ApplicationHelper |
36 | 35 | end |
37 | 36 | the_title = html_options[:title] || label |
38 | 37 | if html_options[:disabled] |
39 | - content_tag('a', '', html_options.merge(class: the_class, title: the_title)) | |
38 | + content_tag(:a, '', html_options.merge(class: the_class, title: the_title)) | |
40 | 39 | else |
41 | 40 | link_to('', url, html_options.merge(class: the_class, title: the_title)) |
42 | 41 | end |
... | ... | @@ -91,7 +90,7 @@ module ApplicationHelper |
91 | 90 | if html_options.has_key?(:class) |
92 | 91 | the_class << ' ' << html_options[:class] |
93 | 92 | end |
94 | - content_tag('div', '', html_options.merge(class: the_class)) | |
93 | + content_tag(:div, '', html_options.merge(class: the_class)) | |
95 | 94 | end |
96 | 95 | |
97 | 96 | def icon_button(type, text, url, html_options = {}) |
... | ... | @@ -104,16 +103,21 @@ module ApplicationHelper |
104 | 103 | the_class << ' ' << html_options[:class] |
105 | 104 | end |
106 | 105 | |
107 | - link_to(content_tag('span', text), url, html_options.merge(class: the_class, title: text)) | |
106 | + link_to(content_tag(:span, text), url, html_options.merge(class: the_class, title: text)) | |
108 | 107 | end |
109 | 108 | |
110 | - def button_bar(options = {}, &block) | |
109 | + def button_bar options = {}, &block | |
111 | 110 | return super unless theme_responsive? |
112 | 111 | |
113 | - options[:class].nil? ? | |
114 | - options[:class]='button-bar' : | |
115 | - options[:class]+=' button-bar' | |
116 | - concat(content_tag('div', capture(&block).to_s + tag('br', style: 'clear: left;'), options)) | |
112 | + options[:class] ||= '' | |
113 | + options[:class] << 'button-bar' | |
114 | + | |
115 | + content_tag :div, options do | |
116 | + [ | |
117 | + capture(&block).to_s, | |
118 | + tag('br', style: 'clear: left;'), | |
119 | + ].safe_join | |
120 | + end | |
117 | 121 | end |
118 | 122 | |
119 | 123 | def expirable_button(content, action, text, url, html_options = {}) |
... | ... | @@ -128,143 +132,93 @@ module ApplicationHelper |
128 | 132 | def search_contents_menu |
129 | 133 | return super unless theme_responsive? |
130 | 134 | |
131 | - host = environment.default_hostname | |
132 | - | |
133 | - output = '<li class="dropdown">' | |
134 | - output += link_to(_('Contents'), '#', :class=>"dropdown-toggle icon-menu-articles", title: _('Contents'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown") | |
135 | - output += '<ul class="dropdown-menu" role="menu">' | |
136 | - | |
137 | - output += '<li>' + link_to(_('All contents'), {host: host, controller: "search", action: 'contents', category_path: ''}) + '</li>' | |
138 | - | |
135 | + host = environment.default_hostname | |
139 | 136 | links = [ |
140 | - {s_('contents|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_recent'})}}, | |
141 | - {s_('contents|More viewed') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_popular'})}}, | |
142 | - {s_('contents|Most commented') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_comments'})}} | |
137 | + [_('All contents'), {host: host, controller: :search, action: :contents, category_path: ''}], | |
138 | + [s_('contents|More recent'), {host: host, controller: :search, action: :contents, filter: 'more_recent'}], | |
139 | + [s_('contents|More viewed'), {host: host, controller: :search, action: :contents, filter: 'more_popular'}], | |
140 | + [s_('contents|Most commented'), {host: host, controller: :search, action: :contents, filter: 'more_comments'}], | |
143 | 141 | ] |
144 | 142 | if logged_in? |
145 | - links.push(_('New content') => modal_options({href: url_for({controller: 'cms', action: 'new', profile: current_user.login, cms: true})})) | |
143 | + links.push [_('New content'), '', modal_options({href: url_for({controller: 'cms', action: 'new', profile: current_user.login, cms: true})})] | |
146 | 144 | end |
147 | 145 | |
148 | - links.each do |link| | |
149 | - link.each do |name, options| | |
150 | - output += content_tag(:li,content_tag(:a,name,options)) | |
151 | - end | |
146 | + content_tag :li, class: 'dropdown' do | |
147 | + [ | |
148 | + link_to('#', class: 'dropdown-toggle icon-menu-articles', title: _('Contents'), data: {toggle: 'dropdown', hover: 'dropdown'}) do | |
149 | + content_tag :span, _('Contents') | |
150 | + end, | |
151 | + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do | |
152 | + links.map do |(name, url)| | |
153 | + content_tag :li do | |
154 | + link_to name, url | |
155 | + end | |
156 | + end.safe_join | |
157 | + end, | |
158 | + ].safe_join | |
152 | 159 | end |
153 | - | |
154 | - output += '</ul>' | |
155 | - output += '</li>' | |
156 | - output | |
157 | 160 | end |
158 | 161 | |
159 | 162 | def search_people_menu |
160 | 163 | return super unless theme_responsive? |
161 | 164 | |
162 | - host = environment.default_hostname | |
163 | - | |
164 | - output = '<li class="dropdown">' | |
165 | - output += link_to(_('People'), '#', :class=>"dropdown-toggle icon-menu-people", title: _('People'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown") | |
166 | - output += '<ul class="dropdown-menu" role="menu">' | |
167 | - | |
168 | - output += '<li>' + link_to(_('All people'), {host: host, controller: "search", action: 'people', category_path: ''}) + '</li>' | |
169 | - | |
165 | + host = environment.default_hostname | |
170 | 166 | links = [ |
171 | - {s_('people|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_recent'})}}, | |
172 | - {s_('people|More active') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_active'})}}, | |
173 | - {s_('people|More popular') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_popular'})}} | |
167 | + [_('All people'), {host: host, controller: :search, action: :people, category_path: ''}], | |
168 | + [s_('people|More recent'), {host: host, controller: :search, action: :people, filter: 'more_recent'}], | |
169 | + [s_('people|More active'), {host: host, controller: :search, action: :people, filter: 'more_active'}], | |
170 | + [s_('people|More popular'), {host: host, controller: :search, action: :people, filter: 'more_popular'}], | |
174 | 171 | ] |
175 | 172 | if logged_in? |
176 | - links.push(_('My friends') => {href: url_for({profile: current_user.login, controller: 'friends'})}) | |
177 | - links.push(_('Invite friends') => {href: url_for({profile: current_user.login, controller: 'invite', action: 'friends'})}) | |
173 | + links.push [_('My friends'), {profile: current_user.login, controller: 'friends'}] | |
174 | + links.push [_('Invite friends'), {profile: current_user.login, controller: 'invite', action: 'friends'}] | |
178 | 175 | end |
179 | 176 | |
180 | - links.each do |link| | |
181 | - link.each do |name, url| | |
182 | - output += '<li><a href="'+url[:href]+'">' + name + '</a></li>' | |
183 | - end | |
177 | + content_tag :li, class: 'dropdown' do | |
178 | + [ | |
179 | + link_to('#', class: "dropdown-toggle icon-menu-people", title: _('People'), data: {toggle: 'dropdown', hover: 'dropdown'}) do | |
180 | + content_tag :span, _('People') | |
181 | + end, | |
182 | + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do | |
183 | + links.map do |params| | |
184 | + content_tag :li do | |
185 | + link_to *params | |
186 | + end | |
187 | + end.safe_join | |
188 | + end | |
189 | + ].safe_join | |
184 | 190 | end |
185 | - | |
186 | - output += '</ul>' | |
187 | - output += '</li>' | |
188 | - output | |
189 | 191 | end |
190 | 192 | |
191 | 193 | def search_communities_menu |
192 | 194 | return super unless theme_responsive? |
193 | 195 | |
194 | - host = environment.default_hostname | |
195 | - | |
196 | - output = '<li class="dropdown">' | |
197 | - output += link_to(_('Communities'), '#', :class=>"dropdown-toggle icon-menu-community", title: _('Communities'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown") | |
198 | - output += '<ul class="dropdown-menu" role="menu">' | |
199 | - | |
200 | - output += '<li>' + link_to(_('All communities'), {host: host, controller: "search", action: 'communities', category_path: ''}) + '</li>' | |
201 | - | |
196 | + host = environment.default_hostname | |
202 | 197 | links = [ |
203 | - {s_('communities|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_recent'})}}, | |
204 | - {s_('communities|More active') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_active'})}}, | |
205 | - {s_('communities|More popular') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_popular'})}} | |
198 | + [_('All communities'), {host: host, controller: :search, action: :communities, category_path: ''}], | |
199 | + [s_('communities|More recent'), {host: host, controller: :search, action: :communities, filter: 'more_recent'}], | |
200 | + [s_('communities|More active'), {host: host, controller: :search, action: :communities, filter: 'more_active'}], | |
201 | + [s_('communities|More popular'), {host: host, controller: :search, action: :communities, filter: 'more_popular'}], | |
206 | 202 | ] |
207 | 203 | if logged_in? |
208 | - links.push(_('My communities') => {href: url_for({profile: current_user.login, controller: 'memberships'})}) | |
209 | - links.push(_('New community') => {href: url_for({profile: current_user.login, controller: 'memberships', action: 'new_community'})}) | |
204 | + links.push [_('My communities'), {profile: current_user.login, controller: 'memberships'}] | |
205 | + links.push [_('New community'), {profile: current_user.login, controller: 'memberships', action: 'new_community'}] | |
210 | 206 | end |
211 | 207 | |
212 | - links.each do |link| | |
213 | - link.each do |name, url| | |
214 | - output += '<li><a href="'+url[:href]+'">' + name + '</a></li>' | |
215 | - end | |
216 | - end | |
217 | - | |
218 | - output += '</ul>' | |
219 | - output += '</li>' | |
220 | - output | |
221 | - end | |
222 | - | |
223 | - def usermenu_logged_in | |
224 | - return super unless theme_responsive? | |
225 | - | |
226 | - output = '<li class="dropdown">' | |
227 | - | |
228 | - pending_tasks_count = '' | |
229 | - count = user ? Task.to(user).pending.count : -1 | |
230 | - if count > 0 | |
231 | - pending_tasks_count = "<span class=\"badge\" onclick=\"document.location='#{url_for(user.tasks_url)}'\" title=\"#{_("Manage your pending tasks")}\">" + count.to_s + '</span>' | |
208 | + content_tag :li, class: 'dropdown' do | |
209 | + [ | |
210 | + link_to('#', class: 'dropdown-toggle icon-menu-community', title: _('Communities'), data: {toggle: 'dropdown', hover: 'dropdown'}) do | |
211 | + content_tag :span, _('Communities') | |
212 | + end, | |
213 | + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do | |
214 | + links.map do |params| | |
215 | + content_tag :li do | |
216 | + link_to *params | |
217 | + end | |
218 | + end.safe_join | |
219 | + end | |
220 | + ].safe_join | |
232 | 221 | end |
233 | - | |
234 | - output += link_to("<img class=\"menu-user-gravatar\" src=\"#{user.profile_custom_icon(gravatar_default)}\"><strong>#{user.identifier}</strong> #{pending_tasks_count}", '#', id: "homepage-link", title: _('Go to your homepage'), :class=>"dropdown-toggle", :'data-toggle'=>"dropdown", :'data-target'=>"", :'data-hover'=>"dropdown") | |
235 | - | |
236 | - | |
237 | - output += '<ul class="dropdown-menu" role="menu">' | |
238 | - output += '<li>' + link_to('<span class="icon-person">'+_('Profile')+'</span>', user.public_profile_url, id: "homepage-link", title: _('Go to your homepage')) + '</li>' | |
239 | - | |
240 | - output += '<li class="divider"></li>' | |
241 | - | |
242 | - #TODO | |
243 | - #render_environment_features(:usermenu) + | |
244 | - | |
245 | - #admin_link | |
246 | - admin_link_str = admin_link | |
247 | - output += admin_link_str.present? ? '<li>' + admin_link_str + '</li>' : '' | |
248 | - | |
249 | - #control_panel link | |
250 | - output += '<li>' + link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', user.admin_url, class: 'ctrl-panel', title: _("Configure your personal account and content")) + '</li>' | |
251 | - | |
252 | - output += chat_user_status_menu('icon-menu-offline', _('Offline')) | |
253 | - | |
254 | - #manage_enterprises | |
255 | - manage_enterprises_str = manage_enterprises | |
256 | - output += manage_enterprises_str.present? ? '<li>' + manage_enterprises_str + '</li>' : '' | |
257 | - | |
258 | - #manage_communities | |
259 | - manage_communities_str = manage_communities | |
260 | - output += manage_communities_str.present? ? '<li>' + manage_communities_str + '</li>' : '' | |
261 | - | |
262 | - output += '<li class="divider"></li>' | |
263 | - | |
264 | - output += '<li>' + link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { controller: 'account', action: 'logout'} , id: "logout", title: _("Leave the system")) + '</li>' | |
265 | - | |
266 | - output += '</ul>' | |
267 | - output | |
268 | 222 | end |
269 | 223 | |
270 | 224 | def manage_link(list, kind, title) |
... | ... | @@ -274,17 +228,22 @@ module ApplicationHelper |
274 | 228 | link_to_all = nil |
275 | 229 | if list.count > 5 |
276 | 230 | list = list.first(5) |
277 | - link_to_all = link_to(content_tag('strong', _('See all')), :controller => 'memberships', :profile => user.identifier) | |
231 | + link_to_all = link_to(content_tag(:strong, _('See all')), controller: 'memberships', profile: user.identifier) | |
278 | 232 | end |
279 | 233 | link = list.map do |element| |
280 | - link_to(content_tag('strong', element.short_name(25)), element.admin_url, :class => "icon-menu-"+element.class.identification.underscore, :title => _('Manage %s') % element.short_name) | |
234 | + link_to(content_tag(:strong, element.short_name(25)), element.admin_url, class: "icon-menu-"+element.class.identification.underscore, title: _('Manage %s') % element.short_name) | |
281 | 235 | end |
282 | 236 | if link_to_all |
283 | 237 | link << link_to_all |
284 | 238 | end |
285 | - content_tag('li', nil, class: 'divider') + | |
286 | - content_tag('li', title, class: 'dropdown-header') + | |
287 | - link.map{ |l| content_tag 'li', l }.join | |
239 | + | |
240 | + [ | |
241 | + content_tag(:li, nil, class: 'divider'), | |
242 | + content_tag(:li, title, class: 'dropdown-header'), | |
243 | + link.map do |l| | |
244 | + content_tag :li, l | |
245 | + end.safe_join | |
246 | + ].safe_join | |
288 | 247 | end |
289 | 248 | end |
290 | 249 | |
... | ... | @@ -301,15 +260,24 @@ module ApplicationHelper |
301 | 260 | unless html_options[:style].present? and html_options[:style] =~ /display *: *none/ |
302 | 261 | menu_content << '<br/>' unless first |
303 | 262 | first = false |
304 | - menu_content << content_tag(:a,link_label,html_options) | |
263 | + menu_content << content_tag(:a, link_label,html_options) | |
305 | 264 | end |
306 | 265 | end |
307 | 266 | end |
308 | 267 | end |
309 | 268 | |
310 | 269 | option = html_options.delete(:option) || 'default' |
311 | - size = html_options.delete(:size) || 'xs' | |
312 | - "<button class='btn btn-#{size} btn-#{option} btn-popover-menu icon-parent-folder' data-toggle='popover' data-html='true' data-placement='top' data-trigger='focus' data-content=\""+CGI::escapeHTML(menu_content)+'" data-title="'+menu_title+'"></button>' | |
270 | + size = html_options.delete(:size) || 'xs' | |
271 | + button_tag '', | |
272 | + class: "btn btn-#{size} btn-#{option} btn-popover-menu icon-parent-folder", | |
273 | + data: { | |
274 | + html: 'true', | |
275 | + toggle: 'popover', | |
276 | + placement: 'top', | |
277 | + trigger: 'focus', | |
278 | + content: menu_content, | |
279 | + title: menu_title, | |
280 | + } | |
313 | 281 | end |
314 | 282 | |
315 | 283 | |
... | ... | @@ -406,12 +374,7 @@ module ApplicationHelper |
406 | 374 | end |
407 | 375 | |
408 | 376 | include ResponsiveChecks |
409 | - if RUBY_VERSION >= '2.0.0' | |
410 | - prepend ResponsiveMethods | |
411 | - else | |
412 | - extend ActiveSupport::Concern | |
413 | - included { include ResponsiveMethods } | |
414 | - end | |
377 | + prepend ResponsiveMethods | |
415 | 378 | |
416 | 379 | # TODO: apply theme_responsive? condition |
417 | 380 | class NoosferoFormBuilder |
... | ... | @@ -440,13 +403,16 @@ module ApplicationHelper |
440 | 403 | |
441 | 404 | if options[:horizontal] |
442 | 405 | label_html = content_tag :label, gettext(text), class: 'control-label col-sm-3 col-md-2 col-lg-2', for: field_id |
443 | - result = content_tag :div, label_html + content_tag('div',field_html, class: 'col-sm-9 col-md-6 col-lg-6'), class: 'form-group' | |
406 | + content = [ | |
407 | + label_html, | |
408 | + content_tag(:div, field_html.html_safe, class: 'col-sm-9 col-md-6 col-lg-6'), | |
409 | + ].safe_join | |
410 | + content_tag :div, content, class: 'form-group' | |
444 | 411 | else |
445 | 412 | label_html = content_tag :label, gettext(text), class: 'control-label', for: field_id |
446 | - result = content_tag :div, label_html + field_html, class: 'form-group' | |
413 | + content = [label_html, field_html.html_safe].safe_join | |
414 | + content_tag :div, content, class: 'form-group' | |
447 | 415 | end |
448 | - | |
449 | - result | |
450 | 416 | end |
451 | 417 | end |
452 | 418 | ... | ... |
plugins/responsive/lib/ext/boxes_helper.rb
... | ... | @@ -62,12 +62,7 @@ module BoxesHelper |
62 | 62 | end |
63 | 63 | |
64 | 64 | include ResponsiveChecks |
65 | - if RUBY_VERSION >= '2.0.0' | |
66 | - prepend ResponsiveMethods | |
67 | - else | |
68 | - extend ActiveSupport::Concern | |
69 | - included { include ResponsiveMethods } | |
70 | - end | |
65 | + prepend ResponsiveMethods | |
71 | 66 | |
72 | 67 | end |
73 | 68 | ... | ... |
plugins/responsive/lib/ext/chat_helper.rb
... | ... | @@ -23,12 +23,7 @@ module ChatHelper |
23 | 23 | end |
24 | 24 | |
25 | 25 | include ResponsiveChecks |
26 | - if RUBY_VERSION >= '2.0.0' | |
27 | - prepend ResponsiveMethods | |
28 | - else | |
29 | - extend ActiveSupport::Concern | |
30 | - included { include ResponsiveMethods } | |
31 | - end | |
26 | + prepend ResponsiveMethods | |
32 | 27 | |
33 | 28 | end |
34 | 29 | ... | ... |
plugins/responsive/lib/ext/forms_helper.rb
... | ... | @@ -11,8 +11,15 @@ module FormsHelper |
11 | 11 | return super unless theme_responsive? |
12 | 12 | |
13 | 13 | options[:id] ||= 'radio-' + FormsHelper.next_id_number |
14 | - content_tag( 'label', radio_button_tag( name, value, checked, options ) + ' ' + | |
15 | - human_name, for: options[:id], class: 'radio-inline' ) | |
14 | + content_tag :div, class:'radio-inline' do | |
15 | + content_tag :label, for: options[:id] do | |
16 | + [ | |
17 | + radio_button_tag(name, value, checked, options), | |
18 | + ' ', | |
19 | + human_name, | |
20 | + ].safe_join | |
21 | + end | |
22 | + end | |
16 | 23 | end |
17 | 24 | |
18 | 25 | # add -inline class |
... | ... | @@ -20,8 +27,18 @@ module FormsHelper |
20 | 27 | return super unless theme_responsive? |
21 | 28 | |
22 | 29 | options[:id] ||= 'checkbox-' + FormsHelper.next_id_number |
23 | - hidden_field_tag(name, '0') + | |
24 | - content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline') | |
30 | + [ | |
31 | + hidden_field_tag(name, '0'), | |
32 | + content_tag(:div, class:'checkbox-inline') do | |
33 | + content_tag :label, for: options[:id] do | |
34 | + [ | |
35 | + check_box_tag(name, value, checked, options), | |
36 | + ' ', | |
37 | + human_name, | |
38 | + ].safe_join | |
39 | + end | |
40 | + end | |
41 | + ].safe_join | |
25 | 42 | end |
26 | 43 | |
27 | 44 | def submit_button(type, label, html_options = {}) |
... | ... | @@ -43,42 +60,34 @@ module FormsHelper |
43 | 60 | html_options.delete(:cancel) |
44 | 61 | bt_submit = button_tag(label, html_options.merge(class: the_class)) |
45 | 62 | |
46 | - bt_submit + bt_cancel | |
63 | + [bt_submit + bt_cancel].safe_join | |
47 | 64 | end |
48 | 65 | |
49 | - %w[select select_tag text_field_tag number_field_tag password_field_tag].each do |method| | |
50 | - define_method method do |*args, &block| | |
51 | - #return super(*args, &block) unless theme_responsive? | |
66 | + bt_submit + bt_cancel | |
67 | + end | |
52 | 68 | |
53 | - options = args.extract_options! | |
54 | - if options['class'] | |
55 | - options['class'] = "#{options['class']} form-control" | |
56 | - else | |
57 | - options[:class] = "#{options[:class]} form-control" | |
58 | - end | |
59 | - super(*(args << options), &block) | |
69 | + %w[ | |
70 | + select_tag | |
71 | + text_field_tag text_area_tag | |
72 | + number_field_tag password_field_tag url_field_tag email_field_tag | |
73 | + month_field_tag date_field_tag | |
74 | + ].each do |method| | |
75 | + define_method method do |name, value=nil, options={}, &block| | |
76 | + responsive_add_field_class! options | |
77 | + super(name, value, options, &block).html_safe | |
60 | 78 | end |
61 | 79 | end |
62 | 80 | %w[select_month select_year].each do |method| |
63 | 81 | define_method method do |date, options={}, html_options={}| |
64 | - if html_options['class'] | |
65 | - html_options['class'] = "#{html_options['class']} form-control" | |
66 | - else | |
67 | - html_options[:class] = "#{html_options[:class]} form-control" | |
68 | - end | |
69 | - super date, options, html_options | |
82 | + responsive_add_field_class! html_options | |
83 | + super(date, options, html_options).html_safe | |
70 | 84 | end |
71 | 85 | end |
72 | 86 | |
73 | 87 | end |
74 | 88 | |
75 | 89 | include ResponsiveChecks |
76 | - if RUBY_VERSION >= '2.0.0' | |
77 | - prepend ResponsiveMethods | |
78 | - else | |
79 | - extend ActiveSupport::Concern | |
80 | - included { include ResponsiveMethods } | |
81 | - end | |
90 | + prepend ResponsiveMethods | |
82 | 91 | |
83 | 92 | end |
84 | 93 | ... | ... |
plugins/responsive/lib/ext/input_helper.rb
... | ... | @@ -4,16 +4,15 @@ module InputHelper |
4 | 4 | protected |
5 | 5 | |
6 | 6 | def input_group_addon addon, options = {}, &block |
7 | - content_tag :div, | |
8 | - content_tag(:span, addon, class: 'input-group-addon') + yield, | |
9 | - class: 'input-group' | |
7 | + content_tag :div, class: 'input-group' do | |
8 | + [ | |
9 | + content_tag(:span, addon, class: 'input-group-addon'), | |
10 | + capture(&block), | |
11 | + ].safe_join | |
12 | + end | |
10 | 13 | end |
11 | 14 | |
12 | 15 | end |
13 | 16 | |
14 | -module ApplicationHelper | |
15 | - | |
16 | - include InputHelper | |
17 | - | |
18 | -end | |
17 | +ApplicationHelper.include InputHelper | |
19 | 18 | ... | ... |
plugins/responsive/lib/responsive_plugin.rb
... | ... | @@ -13,7 +13,7 @@ class ResponsivePlugin < Noosfero::Plugin |
13 | 13 | end |
14 | 14 | |
15 | 15 | def head_ending |
16 | - '<meta name="viewport" content="width=device-width, initial-scale=1">' | |
16 | + '<meta name="viewport" content="width=device-width, initial-scale=1">'.html_safe | |
17 | 17 | end |
18 | 18 | |
19 | 19 | def body_ending | ... | ... |
plugins/responsive/views/invite/select_friends.html.erb
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | <%= labelled_form_field(_('Invitation text:'), text_area_tag(:mail_template, @mail_template, :cols => 72, :rows => 8)) %> |
40 | 40 | </div> |
41 | 41 | |
42 | - <% button_bar do %> | |
42 | + <%= button_bar do %> | |
43 | 43 | <%= submit_button(:ok, _("Invite my friends!")) %> |
44 | 44 | <% end %> |
45 | 45 | <% end %> | ... | ... |
plugins/responsive/views/layouts/_menu_responsive.html.erb
... | ... | @@ -1,71 +0,0 @@ |
1 | -<div> | |
2 | -<nav id="top-bar" class="navbar navbar-default" role="navigation"> | |
3 | - <div class="container"> | |
4 | - <!-- Brand and toggle get grouped for better mobile display --> | |
5 | - <div class="navbar-header"> | |
6 | - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-user-collapse"> | |
7 | - <span class="sr-only"><%= _('User menu') %></span> | |
8 | - <span class="fa fa-user navbar-toggle-icon"></span> | |
9 | - </button> | |
10 | - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-search-collapse"> | |
11 | - <span class="sr-only"><%= _('Search') %></span> | |
12 | - <span class="fa fa-search navbar-toggle-icon"></span> | |
13 | - </button> | |
14 | - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-navigation-collapse"> | |
15 | - <span class="sr-only"><%= _('Navigation') %></span> | |
16 | - <span class="icon-bar"></span> | |
17 | - <span class="icon-bar"></span> | |
18 | - <span class="icon-bar"></span> | |
19 | - </button> | |
20 | - | |
21 | - </div> | |
22 | - | |
23 | - <!-- Collect the nav links, forms, and other content for toggling --> | |
24 | - <div class="collapse navbar-collapse" id="navbar-navigation-collapse"> | |
25 | - <ul class="nav navbar-nav menu-navigation"> | |
26 | - <%= theme_extra_navigation %> | |
27 | - <li class="dropdown" id="search-dropdown-menu"> | |
28 | - <a href="#" class="dropdown-toggle icon-search" data-hover="dropdown" data-toggle="dropdown" title="<%= _('Search') %>"><span><%= _('Search') %></span></a> | |
29 | - <ul class="dropdown-menu" role="menu"> | |
30 | - <li> | |
31 | - <form action="/search" id="top-search" method="get" role="search"> | |
32 | - <div class="form-group col-lg-12 col-md-12 col-sm-12"> | |
33 | - <input name="query" title="<%=_('Search...')%>" placeholder="<%=_('Search...')%>" type="text" class="form-control input-sm"/> | |
34 | - </div> | |
35 | - </form> | |
36 | - </li> | |
37 | - </ul> | |
38 | - </li> | |
39 | - </ul> | |
40 | - </div> | |
41 | - <div class="collapse navbar-collapse" id="navbar-search-collapse"> | |
42 | - <form action="/search" id="top-search" class="navbar-form navbar-left" method="get" role="search"> | |
43 | - <div class="form-group"> | |
44 | - <input name="query" title="<%=_('Search...')%>" placeholder="<%=_('Search...')%>" type="text" class="form-control"/> | |
45 | - </div> | |
46 | - </form> | |
47 | - </div> | |
48 | - <div class="collapse navbar-collapse" id="navbar-user-collapse"> | |
49 | - <ul class="nav navbar-nav pull-right"> | |
50 | - <% if user.present? %> | |
51 | - <%= usermenu_logged_in %> | |
52 | - <% else %> | |
53 | - <li> | |
54 | - <%= modal_inline_link_to('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, '#inlineLoginBox', :id => 'link_login') %> | |
55 | - <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_exec(&content) }.join("") #TODO review this | |
56 | - %> | |
57 | - </li> | |
58 | - <% unless @plugins.dispatch(:allow_user_registration).include?(false) %> | |
59 | - <li> | |
60 | - <%= link_to('<strong>' + _('Sign up') + '</strong>', :controller => 'account', :action => 'signup')%> | |
61 | - </li> | |
62 | - <% end %> | |
63 | - <% end %> | |
64 | - </ul> | |
65 | - </div><!-- /.navbar-collapse --> | |
66 | - </div><!-- /.container-fluid --> | |
67 | -</nav> | |
68 | -</div> | |
69 | -<div id='inlineLoginBox' style='display: none;'> | |
70 | - <%= render :file => 'account/login', :locals => { :is_thickbox => true } %> | |
71 | -</div> |
plugins/responsive/views/layouts/_menu_responsive.html.slim
0 → 100644
... | ... | @@ -0,0 +1,54 @@ |
1 | +div | |
2 | + nav#top-bar.navbar.navbar-default.navbar-static-top role="navigation" | |
3 | + .container | |
4 | + /! Brand and toggle get grouped for better mobile display | |
5 | + .navbar-header | |
6 | + button.navbar-toggle data-target="#navbar-user-collapse" data-toggle="collapse" type="button" | |
7 | + span.sr-only= _('User menu') | |
8 | + span.fa.fa-user.navbar-toggle-icon | |
9 | + | |
10 | + button.navbar-toggle data-target="#navbar-search-collapse" data-toggle="collapse" type="button" | |
11 | + span.sr-only= _('Search') | |
12 | + span.fa.fa-search.navbar-toggle-icon | |
13 | + | |
14 | + button.navbar-toggle data-target="#navbar-navigation-collapse" data-toggle="collapse" type="button" | |
15 | + span.sr-only= _('Navigation') | |
16 | + span.icon-bar | |
17 | + span.icon-bar | |
18 | + span.icon-bar | |
19 | + a.navbar-brand href="#{environment.top_url}" | |
20 | + = theme_site_title | |
21 | + span#navbar-brand-site-title | |
22 | + = h @environment.name | |
23 | + | |
24 | + /! Collect the nav links, forms, and other content for toggling | |
25 | + #navbar-navigation-collapse.collapse.navbar-collapse | |
26 | + ul.nav.navbar-nav.menu-navigation | |
27 | + = theme_extra_navigation | |
28 | + li#search-dropdown-menu.dropdown | |
29 | + a.dropdown-toggle.icon-search data-hover="dropdown" data-toggle="dropdown" href="#" title="#{_('Search')}" | |
30 | + span= _('Search') | |
31 | + ul.dropdown-menu role="menu" | |
32 | + li | |
33 | + form#top-search action="/search" method="get" role="search" | |
34 | + .form-group.col-lg-12.col-md-12.col-sm-12 | |
35 | + input.form-control.input-sm name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" / | |
36 | + | |
37 | + #navbar-search-collapse.collapse.navbar-collapse | |
38 | + form#top-search.navbar-form.navbar-left action="/search" method="get" role="search" | |
39 | + .form-group | |
40 | + input.form-control name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" / | |
41 | + | |
42 | + #navbar-user-collapse.collapse.navbar-collapse | |
43 | + ul.nav.navbar-nav.pull-right | |
44 | + - if user.present? | |
45 | + = render 'layouts/usermenu_logged_in' | |
46 | + - else | |
47 | + li | |
48 | + = modal_inline_link_to "<i class='icon-menu-login'></i><strong>#{_('Login')}</strong>".html_safe, login_url, '#inlineLoginBox', id: 'link_login' | |
49 | + = @plugins.dispatch(:alternative_authentication_link).collect{ |content| instance_exec(&content) }.safe_join | |
50 | + - unless @plugins.dispatch(:allow_user_registration).include? false | |
51 | + li= link_to content_tag(:strong, _('Sign up')), controller: :account, action: :signup | |
52 | + | |
53 | +#inlineLoginBox style="display: none;" | |
54 | + = render file: 'account/login', locals: {is_thickbox: true} | ... | ... |
plugins/responsive/views/layouts/_usermenu_logged_in.html.slim
0 → 100644
... | ... | @@ -0,0 +1,39 @@ |
1 | +- pending_tasks_count = Task.to(user).pending.count if user | |
2 | + | |
3 | +li.dropdown | |
4 | + = link_to '#', id: "homepage-link", title: _('Go to your homepage'), class: 'dropdown-toggle', data: {toggle: 'dropdown', hover: 'dropdown'} | |
5 | + = image_tag user.profile_custom_icon(gravatar_default), class: 'menu-user-gravatar' | |
6 | + = content_tag :strong, user.identifier | |
7 | + - if pending_tasks_count | |
8 | + span class='badge' onclick="document.location='#{url_for(user.tasks_url)}'" title="#{_("Manage your pending tasks")}" | |
9 | + count | |
10 | + | |
11 | + ul class='dropdown-menu' role='menu' | |
12 | + li | |
13 | + = link_to user.public_profile_url, id: "homepage-link", title: _('Go to your homepage') | |
14 | + span class='icon-person' = _('Profile') | |
15 | + li.divider | |
16 | + | |
17 | + /TODO | |
18 | + /= render_environment_features(:usermenu) | |
19 | + | |
20 | + li = admin_link | |
21 | + | |
22 | + li | |
23 | + = link_to user.admin_url, class: 'ctrl-panel', title: _("Configure your personal account and content") | |
24 | + i class='icon-menu-ctrl-panel' | |
25 | + strong = _('Control panel') | |
26 | + | |
27 | + - if environment.enabled? 'xmpp_chat' | |
28 | + = responsive_chat_user_status_menu 'icon-menu-offline', _('Offline') | |
29 | + | |
30 | + li = manage_enterprises | |
31 | + li = manage_communities | |
32 | + | |
33 | + li.divider | |
34 | + | |
35 | + li | |
36 | + = link_to({controller: 'account', action: 'logout'}, id: "logout", title: _("Leave the system")) | |
37 | + i class='icon-menu-logout' | |
38 | + strong = _('Logout') | |
39 | + | ... | ... |
plugins/responsive/views/layouts/application-responsive.html.erb
1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
2 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>" class="<%= h html_tag_classes %>"> |
3 | 3 | <head> |
4 | - <title><%= h page_title %></title> | |
4 | + <title><%= h page_title.html_safe %></title> | |
5 | 5 | <%= yield(:feeds) %> |
6 | 6 | <!--<meta http-equiv="refresh" content="1"/>--> |
7 | 7 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | <%= |
23 | 23 | @plugins.dispatch(:head_ending).map do |content| |
24 | 24 | if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end |
25 | - end.join("\n") | |
25 | + end.safe_join | |
26 | 26 | %> |
27 | 27 | |
28 | 28 | <script type="text/javascript"> |
... | ... | @@ -68,7 +68,7 @@ |
68 | 68 | <%= |
69 | 69 | @plugins.dispatch(:body_ending).map do |content| |
70 | 70 | if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end |
71 | - end.join("\n") | |
71 | + end.safe_join | |
72 | 72 | %> |
73 | 73 | </body> |
74 | 74 | </html> | ... | ... |
plugins/responsive/views/manage_products/_edit_name.html.erb
plugins/send_email/views/send_email_plugin_admin/index.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <%= form_for :environment, :url => {:action => 'index'}, :html => {:method => 'post'} do |f| %> |
4 | 4 | <%= labelled_form_field(_("E-Mail addresses you want to allow to send"), f.text_area(:send_email_plugin_allow_to, :rows => 8)) %> |
5 | 5 | <small><%= _('(list of email addresses separated by comma)') %></small> |
6 | - <% button_bar do %> | |
6 | + <%= button_bar do %> | |
7 | 7 | <%= submit_button 'save', c_('Save'), :cancel => {:controller => 'plugins'} %> |
8 | 8 | <% end %> |
9 | 9 | <% end %> | ... | ... |
plugins/site_tour/views/site_tour_plugin_admin/index.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= labelled_form_field _('Tooltips (CSV format: language, group name, selector, description)'), f.text_area(:actions_csv, :style => 'width: 100%', :class => 'actions-csv') %> |
6 | 6 | <%= labelled_form_field _('Group Triggers (CSV format: group name, selector, event (e.g. mouseenter, click))'), f.text_area(:group_triggers_csv, :style => 'width: 100%', :class => 'groups-csv', :rows => 7) %> |
7 | 7 | |
8 | - <% button_bar do %> | |
8 | + <%= button_bar do %> | |
9 | 9 | <%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> |
10 | 10 | <% end %> |
11 | 11 | ... | ... |
plugins/sniffer/views/sniffer_plugin_myprofile/edit.html.erb
plugins/social_share_privacy/test/unit/social_share_privacy_test.rb
plugins/social_share_privacy/views/social_share_privacy_plugin_admin/index.html.erb
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | <%= _('The same order in which you arrange the social networks here will be used for arranging the share buttons.') %> |
39 | 39 | </p> |
40 | 40 | |
41 | - <% button_bar do %> | |
41 | + <%= button_bar do %> | |
42 | 42 | <%= submit_button 'save', _('Save'), :cancel => {:controller => 'plugins', :action => 'index'} %> |
43 | 43 | <% end %> |
44 | 44 | <% end %> | ... | ... |
plugins/spaminator/views/spaminator_plugin_admin/index.html.erb
... | ... | @@ -30,7 +30,7 @@ |
30 | 30 | <%= button(:cancel, _('Withhold'), {:action => 'withhold'}, :title => _('Cancel next scheduled scans')) if @settings.deployed %> |
31 | 31 | <% end %> |
32 | 32 | |
33 | - <% button_bar do %> | |
33 | + <%= button_bar do %> | |
34 | 34 | <%= submit_button(:save, c_('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> |
35 | 35 | <% end %> |
36 | 36 | </div> | ... | ... |
plugins/spaminator/views/spaminator_plugin_admin/reports.html.erb
plugins/statistics/lib/statistics_block.rb
... | ... | @@ -93,6 +93,7 @@ class StatisticsBlock < Block |
93 | 93 | end |
94 | 94 | |
95 | 95 | def products |
96 | + return [] unless environment.plugin_enabled?('ProductsPlugin') | |
96 | 97 | if owner.kind_of?(Environment) |
97 | 98 | owner.products.where("profiles.enabled = true and profiles.visible = true").count |
98 | 99 | elsif owner.kind_of?(Enterprise) | ... | ... |
plugins/statistics/test/unit/statistics_block_test.rb
... | ... | @@ -145,6 +145,7 @@ class StatisticsBlockTest < ActiveSupport::TestCase |
145 | 145 | |
146 | 146 | b = StatisticsBlock.new |
147 | 147 | e = fast_create(Environment) |
148 | + e.enable_plugin('ProductsPlugin') | |
148 | 149 | |
149 | 150 | e1 = fast_create(Enterprise, :visible => true, :enabled => true, :environment_id => e.id) |
150 | 151 | e2 = fast_create(Enterprise, :visible => true, :enabled => false, :environment_id => e.id) |
... | ... | @@ -168,6 +169,8 @@ class StatisticsBlockTest < ActiveSupport::TestCase |
168 | 169 | b = StatisticsBlock.new |
169 | 170 | |
170 | 171 | e = fast_create(Enterprise) |
172 | + environment = e.environment | |
173 | + environment.enable_plugin('ProductsPlugin') | |
171 | 174 | |
172 | 175 | fast_create(Product, :profile_id => e.id) |
173 | 176 | fast_create(Product, :profile_id => e.id) | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_myprofile/index.html.erb
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | <% end %> |
11 | 11 | |
12 | 12 | <%= form_tag do %> |
13 | - <% button_bar do %> | |
13 | + <%= button_bar do %> | |
14 | 14 | <%= button(:add, _('Create a new sub-community'), :controller => 'memberships', :action => 'new_community', :profile => user.identifier, :sub_organizations_plugin_parent_to_be => profile.id) %> |
15 | 15 | <%= button :add, _('Register a new sub-enterprise'), :controller => 'enterprise_registration', :sub_organizations_plugin_parent_to_be => profile.id if environment.enabled?('enterprise_registration') %> |
16 | 16 | <% end %> |
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | :hint_text => _('Type in a search term for a group'), |
22 | 22 | :pre_populate => @tokenized_children}) %> |
23 | 23 | |
24 | - <% button_bar do %> | |
24 | + <%= button_bar do %> | |
25 | 25 | <%= submit_button('save', c_('Save'))%> |
26 | 26 | <%= button('cancel', c_('Cancel'), {:controller => 'profile_editor'})%> |
27 | 27 | <% end %> | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 | <%= pagination_links(organizations, {:param_name => 'npage', :page_links => true}) %> |
52 | 52 | </div> |
53 | 53 | |
54 | - <% button_bar(:class => "related-organizations-button-bar") do %> | |
54 | + <%= button_bar(:class => "related-organizations-button-bar") do %> | |
55 | 55 | <%= button :back, c_('Go back'), { :controller => 'profile' } %> |
56 | 56 | <%= button :add, _("Add a new %s") % organization_type, :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> |
57 | 57 | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_related_organizations.html.erb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | <% if organizations.length == 0 %> |
10 | 10 | <li><%= _("There are no sub-%s yet.") % organization_type.pluralize %></li> |
11 | 11 | <% end %> |
12 | - <% button_bar(:class => "related-organizations-button-bar") do %> | |
12 | + <%= button_bar(:class => "related-organizations-button-bar") do %> | |
13 | 13 | <%= button :back, c_('Go back'), { :controller => 'profile' } %> |
14 | 14 | <%= button :add, _("Add a new %s") % organization_type, :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> |
15 | 15 | ... | ... |
plugins/suppliers/views/suppliers_plugin/manage_products/_distribution_tab.html.slim
plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb
... | ... | @@ -11,13 +11,13 @@ |
11 | 11 | f.text_field(:content_tolerance, :size => 2, :style => 'font-size: 14px; text-align: right') + |
12 | 12 | select_tag(:content_tolerance_unit, options_for_select(time_units, @content_default_unit) )) %> |
13 | 13 | <% end %> |
14 | - <%= labelled_form_field(_('Comment edition tolerance time'), | |
15 | - f.text_field(:comment_tolerance, :size => 2, :style => 'font-size: 14px; text-align: right') + | |
14 | + <%= labelled_form_field(_('Comment edition tolerance time'), | |
15 | + f.text_field(:comment_tolerance, :size => 2, :style => 'font-size: 14px; text-align: right') + | |
16 | 16 | select_tag(:comment_tolerance_unit, options_for_select(time_units, @comment_default_unit) )) %> |
17 | 17 | |
18 | 18 | <%= content_tag( 'small', _('Empty means unlimited and zero means right away.') ) %> |
19 | 19 | |
20 | - <% button_bar do %> | |
20 | + <%= button_bar do %> | |
21 | 21 | <%= submit_button('save', c_('Save'))%> |
22 | 22 | <%= button('back', c_('Back'), {:controller => 'profile_editor'})%> |
23 | 23 | <% end %> | ... | ... |
plugins/vote/views/vote_plugin_admin/index.html.erb
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | <%= labelled_form_field _('Limit of voters to display:'), f.text_field(:voters_limit, :size => 3) %> |
14 | 14 | </strong> |
15 | 15 | |
16 | - <% button_bar do %> | |
16 | + <%= button_bar do %> | |
17 | 17 | <%= submit_button(:save, c_('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> |
18 | 18 | <% end %> |
19 | 19 | ... | ... |
plugins/work_assignment/views/work_assignment_plugin_myprofile/edit_visibility.html.erb
test/api/activities_test.rb
... | ... | @@ -27,8 +27,8 @@ class ActivitiesTest < ActiveSupport::TestCase |
27 | 27 | assert_equal 403, last_response.status |
28 | 28 | end |
29 | 29 | |
30 | - should 'not get community activities if not member' do | |
31 | - community = fast_create(Community) | |
30 | + should 'not get community activities if not member and community is private' do | |
31 | + community = fast_create(Community, public_profile: false) | |
32 | 32 | other_person = fast_create(Person) |
33 | 33 | community.add_member(other_person) # so there is an activity in community |
34 | 34 | |
... | ... | @@ -68,6 +68,15 @@ class ActivitiesTest < ActiveSupport::TestCase |
68 | 68 | assert_equivalent other_person.activities.map(&:activity).map(&:id), json["activities"].map{|c| c["id"]} |
69 | 69 | end |
70 | 70 | |
71 | + should 'get activities for non logged user in a public community' do | |
72 | + community = fast_create(Community) | |
73 | + create_activity(community) | |
74 | + community.add_member(person) | |
75 | + get "/api/v1/profiles/#{community.id}/activities?#{params.to_query}" | |
76 | + json = JSON.parse(last_response.body) | |
77 | + assert_equivalent community.activities.map(&:activity).map(&:id), json["activities"].map{|c| c["id"]} | |
78 | + end | |
79 | + | |
71 | 80 | def create_activity(target) |
72 | 81 | activity = ActionTracker::Record.create! :verb => :leave_scrap, :user => person, :target => target |
73 | 82 | ProfileActivity.create! profile_id: target.id, activity: activity | ... | ... |
test/api/articles_test.rb
... | ... | @@ -7,6 +7,26 @@ class ArticlesTest < ActiveSupport::TestCase |
7 | 7 | login_api |
8 | 8 | end |
9 | 9 | |
10 | + should 'remove article' do | |
11 | + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | |
12 | + delete "/api/v1/articles/#{article.id}?#{params.to_query}" | |
13 | + json = JSON.parse(last_response.body) | |
14 | + | |
15 | + assert_not_equal 401, last_response.status | |
16 | + assert_equal true, json['success'] | |
17 | + | |
18 | + assert !Article.exists?(article.id) | |
19 | + end | |
20 | + | |
21 | + should 'not remove article without permission' do | |
22 | + otherPerson = fast_create(Person, :name => "Other Person") | |
23 | + article = fast_create(Article, :profile_id => otherPerson.id, :name => "Some thing") | |
24 | + delete "/api/v1/articles/#{article.id}?#{params.to_query}" | |
25 | + json = JSON.parse(last_response.body) | |
26 | + assert_equal 403, last_response.status | |
27 | + assert Article.exists?(article.id) | |
28 | + end | |
29 | + | |
10 | 30 | should 'list articles' do |
11 | 31 | article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") |
12 | 32 | get "/api/v1/articles/?#{params.to_query}" |
... | ... | @@ -14,6 +34,17 @@ class ArticlesTest < ActiveSupport::TestCase |
14 | 34 | assert_includes json["articles"].map { |a| a["id"] }, article.id |
15 | 35 | end |
16 | 36 | |
37 | + should 'list all text articles' do | |
38 | + profile = Community.create(identifier: 'my-community', name: 'name-my-community') | |
39 | + a1 = fast_create(TextArticle, :profile_id => profile.id) | |
40 | + a2 = fast_create(TextileArticle, :profile_id => profile.id) | |
41 | + a3 = fast_create(TinyMceArticle, :profile_id => profile.id) | |
42 | + params['content_type']='TextArticle' | |
43 | + get "api/v1/communities/#{profile.id}/articles?#{params.to_query}" | |
44 | + json = JSON.parse(last_response.body) | |
45 | + assert_equal 3, json['articles'].count | |
46 | + end | |
47 | + | |
17 | 48 | should 'get profile homepage' do |
18 | 49 | article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") |
19 | 50 | person.home_page=article |
... | ... | @@ -104,6 +135,17 @@ class ArticlesTest < ActiveSupport::TestCase |
104 | 135 | assert_equivalent [child1.id, child2.id], json["articles"].map { |a| a["id"] } |
105 | 136 | end |
106 | 137 | |
138 | + should 'list all text articles of children' do | |
139 | + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | |
140 | + child1 = fast_create(TextArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 1") | |
141 | + child2 = fast_create(TextileArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 2") | |
142 | + child3 = fast_create(TinyMceArticle, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing 3") | |
143 | + get "/api/v1/articles/#{article.id}/children?#{params.to_query}" | |
144 | + json = JSON.parse(last_response.body) | |
145 | + assert_equivalent [child1.id, child2.id, child3.id], json["articles"].map { |a| a["id"] } | |
146 | + end | |
147 | + | |
148 | + | |
107 | 149 | should 'list public article children for not logged in access' do |
108 | 150 | article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") |
109 | 151 | child1 = fast_create(Article, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing") |
... | ... | @@ -744,4 +786,12 @@ class ArticlesTest < ActiveSupport::TestCase |
744 | 786 | assert_not_includes json['article']['children'].map {|a| a['id']}, child.id |
745 | 787 | end |
746 | 788 | |
789 | + should 'list article permissions when get an article' do | |
790 | + community = fast_create(Community) | |
791 | + give_permission(person, 'post_content', community) | |
792 | + article = fast_create(Article, :profile_id => community.id) | |
793 | + get "/api/v1/articles/#{article.id}?#{params.to_query}" | |
794 | + json = JSON.parse(last_response.body) | |
795 | + assert_includes json["article"]["permissions"], 'allow_post_content' | |
796 | + end | |
747 | 797 | end | ... | ... |
test/api/boxes_test.rb
... | ... | @@ -47,4 +47,46 @@ class BoxesTest < ActiveSupport::TestCase |
47 | 47 | json = JSON.parse(last_response.body) |
48 | 48 | assert !json["boxes"].first["blocks"].first.key?('api_content') |
49 | 49 | end |
50 | + | |
51 | + should 'get blocks from boxes' do | |
52 | + Environment.delete_all | |
53 | + environment = fast_create(Environment, :is_default => true) | |
54 | + box = fast_create(Box, :owner_id => environment.id, :owner_type => 'Environment') | |
55 | + block = fast_create(Block, box_id: box.id) | |
56 | + get "/api/v1/environments/default/boxes?#{params.to_query}" | |
57 | + json = JSON.parse(last_response.body) | |
58 | + assert_equal [block.id], json["boxes"].first["blocks"].map {|b| b['id']} | |
59 | + end | |
60 | + | |
61 | + should 'not list a block for not logged users' do | |
62 | + logout_api | |
63 | + profile = fast_create(Profile) | |
64 | + box = fast_create(Box, :owner_id => profile.id, :owner_type => Profile.name) | |
65 | + block = fast_create(Block, box_id: box.id) | |
66 | + block.display = 'never' | |
67 | + block.save! | |
68 | + get "/api/v1/profiles/#{profile.id}/boxes?#{params.to_query}" | |
69 | + json = JSON.parse(last_response.body) | |
70 | + assert_equal [], json["boxes"].first["blocks"].map {|b| b['id']} | |
71 | + end | |
72 | + | |
73 | + should 'list a block with logged in display_user for a logged user' do | |
74 | + profile = fast_create(Profile) | |
75 | + box = fast_create(Box, :owner_id => profile.id, :owner_type => Profile.name) | |
76 | + block = fast_create(Block, box_id: box.id) | |
77 | + block.display_user = 'logged' | |
78 | + block.save! | |
79 | + get "/api/v1/profiles/#{profile.id}/boxes?#{params.to_query}" | |
80 | + json = JSON.parse(last_response.body) | |
81 | + assert_equal [block.id], json["boxes"].first["blocks"].map {|b| b['id']} | |
82 | + end | |
83 | + | |
84 | + should 'not list boxes for user without permission' do | |
85 | + profile = fast_create(Profile, public_profile: false) | |
86 | + box = fast_create(Box, :owner_id => profile.id, :owner_type => Profile.name) | |
87 | + block = fast_create(Block, box_id: box.id) | |
88 | + get "/api/v1/profiles/#{profile.id}/boxes?#{params.to_query}" | |
89 | + json = JSON.parse(last_response.body) | |
90 | + assert_equal 403, last_response.status | |
91 | + end | |
50 | 92 | end | ... | ... |
test/api/comments_test.rb
... | ... | @@ -70,6 +70,16 @@ class CommentsTest < ActiveSupport::TestCase |
70 | 70 | assert_equal body, json['comment']['body'] |
71 | 71 | end |
72 | 72 | |
73 | + should 'not create comment when an article does not accept comments' do | |
74 | + login_api | |
75 | + article = fast_create(Article, :profile_id => @local_person.id, :name => "Some thing", accept_comments: false) | |
76 | + body = 'My comment' | |
77 | + params.merge!({:body => body}) | |
78 | + post "/api/v1/articles/#{article.id}/comments?#{params.to_query}" | |
79 | + json = JSON.parse(last_response.body) | |
80 | + assert_equal 403, last_response.status | |
81 | + end | |
82 | + | |
73 | 83 | should 'logged user not comment an archived article' do |
74 | 84 | login_api |
75 | 85 | article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing", :archived => true) |
... | ... | @@ -186,4 +196,53 @@ class CommentsTest < ActiveSupport::TestCase |
186 | 196 | assert_equal [comment1.id], json["comments"].map { |c| c['id'] } |
187 | 197 | end |
188 | 198 | |
199 | + should 'delete comment successfully' do | |
200 | + login_api | |
201 | + article = fast_create(Article, profile_id: person.id, name: "Some thing") | |
202 | + comment = article.comments.create!(body: "some comment", author: person) | |
203 | + delete "api/v1/articles/#{article.id}/comments/#{comment.id}?#{params.to_query}" | |
204 | + json = JSON.parse(last_response.body) | |
205 | + assert_equal 200, last_response.status | |
206 | + assert_equal comment.id, json['comment']['id'] | |
207 | + assert_not_includes article.comments, comment | |
208 | + end | |
209 | + | |
210 | + should 'not delete a comment when user is not logged' do | |
211 | + article = fast_create(Article, profile_id: person.id, name: "Some thing") | |
212 | + comment = article.comments.create!(body: "some comment", author: person) | |
213 | + delete "api/v1/articles/#{article.id}/comments/#{comment.id}?#{params.to_query}" | |
214 | + json = JSON.parse(last_response.body) | |
215 | + assert_equal 403, last_response.status | |
216 | + assert_includes article.comments, comment | |
217 | + end | |
218 | + | |
219 | + should 'not delete a comment when user does not have permission' do | |
220 | + login_api | |
221 | + article = fast_create(Article, profile_id: @local_person.id, name: "Some thing") | |
222 | + comment = article.comments.create!(body: "some comment", author: @local_person) | |
223 | + delete "api/v1/articles/#{article.id}/comments/#{comment.id}?#{params.to_query}" | |
224 | + json = JSON.parse(last_response.body) | |
225 | + assert_equal 403, last_response.status | |
226 | + assert_includes article.comments, comment | |
227 | + end | |
228 | + | |
229 | + should 'return not found when delete a inexistent comment' do | |
230 | + article = fast_create(Article, profile_id: person.id, name: "Some thing") | |
231 | + comment = article.comments.create!(body: "some comment", author: person) | |
232 | + delete "api/v1/articles/#{article.id}/comments/0?#{params.to_query}" | |
233 | + json = JSON.parse(last_response.body) | |
234 | + assert_equal 404, last_response.status | |
235 | + assert_includes article.comments, comment | |
236 | + end | |
237 | + | |
238 | + should 'return error when failed to delete comment' do | |
239 | + login_api | |
240 | + article = fast_create(Article, profile_id: person.id, name: "Some thing") | |
241 | + comment = article.comments.create!(body: "some comment", author: person) | |
242 | + Comment.any_instance.expects(:destroy).raises(StandardError) | |
243 | + delete "api/v1/articles/#{article.id}/comments/#{comment.id}?#{params.to_query}" | |
244 | + json = JSON.parse(last_response.body) | |
245 | + assert_equal 500, last_response.status | |
246 | + assert_includes article.comments, comment | |
247 | + end | |
189 | 248 | end | ... | ... |
test/api/helpers_test.rb
... | ... | @@ -99,7 +99,7 @@ class Api::HelpersTest < ActiveSupport::TestCase |
99 | 99 | end |
100 | 100 | |
101 | 101 | should 'parse_content_type return all content types as an array' do |
102 | - assert_equivalent ['TextArticle','TinyMceArticle'], parse_content_type("TextArticle,TinyMceArticle") | |
102 | + assert_equivalent ['TextileArticle','TinyMceArticle'], parse_content_type("TextileArticle,TinyMceArticle") | |
103 | 103 | end |
104 | 104 | |
105 | 105 | should 'find_article return article by id in list passed for user with permission' do | ... | ... |
test/api/profiles_test.rb
... | ... | @@ -146,4 +146,49 @@ class ProfilesTest < ActiveSupport::TestCase |
146 | 146 | refute json.has_key?('Rating') |
147 | 147 | end |
148 | 148 | |
149 | + [Community, Enterprise].each do |klass| | |
150 | + should "update #{klass.name}" do | |
151 | + login_api | |
152 | + profile = fast_create(klass) | |
153 | + profile.add_admin(person) | |
154 | + params[:profile] = {} | |
155 | + params[:profile][:custom_header] = "Another Header" | |
156 | + post "/api/v1/profiles/#{profile.id}?#{params.to_query}" | |
157 | + assert_equal "Another Header", profile.reload.custom_header | |
158 | + end | |
159 | + | |
160 | + should "not update a #{klass.name} if user does not have permission" do | |
161 | + login_api | |
162 | + profile = fast_create(klass) | |
163 | + params[:profile] = {} | |
164 | + params[:profile][:custom_header] = "Another Header" | |
165 | + post "/api/v1/profiles/#{profile.id}?#{params.to_query}" | |
166 | + assert_equal 403, last_response.status | |
167 | + end | |
168 | + | |
169 | + should "not update a #{klass.name} if user is not logged in" do | |
170 | + profile = fast_create(klass) | |
171 | + params[:profile] = {} | |
172 | + params[:profile][:custom_header] = "Another Header" | |
173 | + post "/api/v1/profiles/#{profile.id}?#{params.to_query}" | |
174 | + assert_equal 401, last_response.status | |
175 | + end | |
176 | + end | |
177 | + | |
178 | + should 'update person' do | |
179 | + login_api | |
180 | + params[:profile] = {} | |
181 | + params[:profile][:custom_header] = "Another Header" | |
182 | + post "/api/v1/profiles/#{person.id}?#{params.to_query}" | |
183 | + assert_equal "Another Header", person.reload.custom_header | |
184 | + end | |
185 | + | |
186 | + should 'not update person information if user does not have permission' do | |
187 | + login_api | |
188 | + profile = fast_create(Person) | |
189 | + params[:profile] = {} | |
190 | + params[:profile][:custom_header] = "Another Header" | |
191 | + post "/api/v1/profiles/#{profile.id}?#{params.to_query}" | |
192 | + assert_equal 403, last_response.status | |
193 | + end | |
149 | 194 | end | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -224,7 +224,7 @@ class ApplicationControllerTest < ActionController::TestCase |
224 | 224 | end |
225 | 225 | |
226 | 226 | should 'display theme test panel when testing theme' do |
227 | - @request.session[:theme] = 'my-test-theme' | |
227 | + @request.session[:user_theme] = 'my-test-theme' | |
228 | 228 | theme = mock |
229 | 229 | profile = mock |
230 | 230 | theme.expects(:owner).returns(profile).at_least_once |
... | ... | @@ -506,6 +506,21 @@ class ApplicationControllerTest < ActionController::TestCase |
506 | 506 | assert_redirected_to :controller => 'account', :action => 'login' |
507 | 507 | end |
508 | 508 | |
509 | + should 'override user when current is an admin' do | |
510 | + user = create_user | |
511 | + other_user = create_user | |
512 | + environment = Environment.default | |
513 | + login_as user.login | |
514 | + @controller.stubs(:environment).returns(environment) | |
515 | + | |
516 | + get :index, override_user: other_user.id | |
517 | + assert_equal user, assigns(:current_user) | |
518 | + | |
519 | + environment.add_admin user.person | |
520 | + get :index, override_user: other_user.id | |
521 | + assert_equal other_user, assigns(:current_user) | |
522 | + end | |
523 | + | |
509 | 524 | should 'do not allow member not included in whitelist to access an restricted environment' do |
510 | 525 | user = create_user |
511 | 526 | e = Environment.default |
... | ... | @@ -576,4 +591,36 @@ class ApplicationControllerTest < ActionController::TestCase |
576 | 591 | assert_redirected_to :controller => 'test', :action => 'index', :profile => profile.identifier |
577 | 592 | end |
578 | 593 | |
594 | + should 'set session theme if a params theme is passed as parameter' do | |
595 | + current_theme = 'my-test-theme' | |
596 | + environment = Environment.default | |
597 | + Theme.stubs(:system_themes).returns([Theme.new(current_theme)]) | |
598 | + environment.themes = [current_theme] | |
599 | + environment.save! | |
600 | + assert_nil @request.session[:theme] | |
601 | + get :index, :theme => current_theme | |
602 | + assert_equal current_theme, @request.session[:theme] | |
603 | + end | |
604 | + | |
605 | + should 'set session theme only in environment available themes' do | |
606 | + environment = Environment.default | |
607 | + assert_nil @request.session[:theme] | |
608 | + environment.stubs(:theme_ids).returns(['another_theme']) | |
609 | + get :index, :theme => 'my-test-theme' | |
610 | + assert_nil @request.session[:theme] | |
611 | + end | |
612 | + | |
613 | + should 'unset session theme if not environment available themes is defined' do | |
614 | + environment = Environment.default | |
615 | + current_theme = 'my-test-theme' | |
616 | + Theme.stubs(:system_themes).returns([Theme.new(current_theme)]) | |
617 | + environment.themes = [current_theme] | |
618 | + environment.save! | |
619 | + get :index, :theme => current_theme | |
620 | + assert_equal current_theme, @request.session[:theme] | |
621 | + | |
622 | + get :index, :theme => 'another_theme' | |
623 | + assert_nil @request.session[:theme] | |
624 | + end | |
625 | + | |
579 | 626 | end | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -528,7 +528,7 @@ class CmsControllerTest < ActionController::TestCase |
528 | 528 | post :new, :type => TextileArticle.name, :profile => profile.identifier, :article => { :name => 'adding-categories-test', :category_ids => [ c1.id, c3.id, c3.id ] } |
529 | 529 | |
530 | 530 | saved = profile.articles.find_by(name: 'adding-categories-test') |
531 | - assert_equal [c1, c3], saved.categories.all | |
531 | + assert_equivalent [c1, c3], saved.categories.all | |
532 | 532 | end |
533 | 533 | |
534 | 534 | should 'filter html with white_list from tiny mce article name' do | ... | ... |
test/functional/profile_themes_controller_test.rb
... | ... | @@ -231,7 +231,7 @@ class ProfileThemesControllerTest < ActionController::TestCase |
231 | 231 | theme = Theme.create('theme-under-test', :owner => profile) |
232 | 232 | post :start_test, :profile => 'testinguser', :id => 'theme-under-test' |
233 | 233 | |
234 | - assert_equal 'theme-under-test', session[:theme] | |
234 | + assert_equal 'theme-under-test', session[:user_theme] | |
235 | 235 | assert_redirected_to :controller => 'content_viewer', :profile => 'testinguser', :action => 'view_page' |
236 | 236 | end |
237 | 237 | |
... | ... | @@ -239,7 +239,7 @@ class ProfileThemesControllerTest < ActionController::TestCase |
239 | 239 | theme = Theme.create('theme-under-test', :owner => profile) |
240 | 240 | post :stop_test, :profile => 'testinguser', :id => 'theme-under-test' |
241 | 241 | |
242 | - assert_nil session[:theme] | |
242 | + assert_nil session[:user_theme] | |
243 | 243 | assert_redirected_to :action => 'index' |
244 | 244 | end |
245 | 245 | ... | ... |
test/integration/blocks_test.rb
... | ... | @@ -1,46 +0,0 @@ |
1 | -require_relative "../test_helper" | |
2 | - | |
3 | -class BlocksTest < ActionDispatch::IntegrationTest | |
4 | - | |
5 | - def blog_on_article_block_bootstrap | |
6 | - profile = fast_create(Profile) | |
7 | - blog = fast_create(Blog, :name => 'Blog', :profile_id => profile.id) | |
8 | - fast_create(TinyMceArticle, :name => "First Post", :profile_id => profile.id, :parent_id => blog.id, :body => '<p> Wasserstoffbombe </p>') | |
9 | - fast_create(TinyMceArticle, :name => "A Post", :profile_id => profile.id, :parent_id => blog.id, :body => '<p>Lorem ipsum dolor sit amet</p> <p>Second paragraph</p>') | |
10 | - block = ArticleBlock.new | |
11 | - block.article = blog | |
12 | - profile.boxes << Box.new | |
13 | - profile.boxes.first.blocks << block | |
14 | - return block | |
15 | - end | |
16 | - | |
17 | - should 'allow blog as article block content' do | |
18 | - block = blog_on_article_block_bootstrap | |
19 | - get "/profile/#{block.owner.identifier}" | |
20 | - assert_match(/Lorem ipsum dolor sit amet/, @response.body) | |
21 | - end | |
22 | - | |
23 | - should 'display short version for block posts on article block' do | |
24 | - block = blog_on_article_block_bootstrap | |
25 | - get "/profile/#{block.owner.identifier}" | |
26 | - assert_no_match(/Second paragraph/, @response.body) | |
27 | - end | |
28 | - | |
29 | - should 'display full version for block posts on article block' do | |
30 | - block = blog_on_article_block_bootstrap | |
31 | - block.visualization_format = 'full' | |
32 | - block.save! | |
33 | - get "/profile/#{block.owner.identifier}" | |
34 | - assert_match(/Second paragraph/, @response.body) | |
35 | - end | |
36 | - | |
37 | - should 'display configured number of blog posts on article block' do | |
38 | - block = blog_on_article_block_bootstrap | |
39 | - block.posts_per_page = 2 | |
40 | - block.save! | |
41 | - get "/profile/#{block.owner.identifier}" | |
42 | - assert_match(/Lorem ipsum dolor sit amet/, @response.body) | |
43 | - assert_match(/Wasserstoffbombe/, @response.body) | |
44 | - end | |
45 | - | |
46 | -end |
... | ... | @@ -0,0 +1,46 @@ |
1 | +require_relative "../test_helper" | |
2 | + | |
3 | +class ProfileBlocksTest < ActionDispatch::IntegrationTest | |
4 | + | |
5 | + def blog_on_article_block_bootstrap | |
6 | + profile = fast_create(Profile) | |
7 | + blog = fast_create(Blog, :name => 'Blog', :profile_id => profile.id) | |
8 | + fast_create(TinyMceArticle, :name => "First Post", :profile_id => profile.id, :parent_id => blog.id, :body => '<p> Wasserstoffbombe </p>') | |
9 | + fast_create(TinyMceArticle, :name => "A Post", :profile_id => profile.id, :parent_id => blog.id, :body => '<p>Lorem ipsum dolor sit amet</p> <p>Second paragraph</p>') | |
10 | + block = ArticleBlock.new | |
11 | + block.article = blog | |
12 | + profile.boxes << Box.new | |
13 | + profile.boxes.first.blocks << block | |
14 | + return block | |
15 | + end | |
16 | + | |
17 | + should 'allow blog as article block content' do | |
18 | + block = blog_on_article_block_bootstrap | |
19 | + get "/profile/#{block.owner.identifier}" | |
20 | + assert_match(/Lorem ipsum dolor sit amet/, @response.body) | |
21 | + end | |
22 | + | |
23 | + should 'display short version for block posts on article block' do | |
24 | + block = blog_on_article_block_bootstrap | |
25 | + get "/profile/#{block.owner.identifier}" | |
26 | + assert_no_match(/Second paragraph/, @response.body) | |
27 | + end | |
28 | + | |
29 | + should 'display full version for block posts on article block' do | |
30 | + block = blog_on_article_block_bootstrap | |
31 | + block.visualization_format = 'full' | |
32 | + block.save! | |
33 | + get "/profile/#{block.owner.identifier}" | |
34 | + assert_match(/Second paragraph/, @response.body) | |
35 | + end | |
36 | + | |
37 | + should 'display configured number of blog posts on article block' do | |
38 | + block = blog_on_article_block_bootstrap | |
39 | + block.posts_per_page = 2 | |
40 | + block.save! | |
41 | + get "/profile/#{block.owner.identifier}" | |
42 | + assert_match(/Lorem ipsum dolor sit amet/, @response.body) | |
43 | + assert_match(/Wasserstoffbombe/, @response.body) | |
44 | + end | |
45 | + | |
46 | +end | ... | ... |
test/integration/safe_strings_test.rb
... | ... | @@ -163,4 +163,16 @@ class SafeStringsTest < ActionDispatch::IntegrationTest |
163 | 163 | get url_for(action: :edit, controller: :profile_design, profile: person.identifier, id: block.id) |
164 | 164 | assert_select '.block-config-options .image-data-line' |
165 | 165 | end |
166 | + | |
167 | + should 'not escape icons options editing link_list block' do | |
168 | + create_user('jimi', :password => 'test', :password_confirmation => 'test').activate | |
169 | + profile = Person['jimi'] | |
170 | + login 'jimi', 'test' | |
171 | + profile.blocks.each(&:destroy) | |
172 | + profile.boxes.first.blocks << LinkListBlock.new | |
173 | + block = profile.boxes.first.blocks.first | |
174 | + get "/myprofile/#{profile.identifier}/profile_design/edit/#{block.id}" | |
175 | + assert_select '.icon-selector .icon-edit' | |
176 | + end | |
177 | + | |
166 | 178 | end | ... | ... |
test/support/noosfero_test_helper.rb
1 | +## | |
2 | +# DEPRECATED ActionView::TestCase already provide all needed | |
3 | +# | |
1 | 4 | module NoosferoTestHelper |
2 | 5 | |
3 | - def link_to(content, url, options = {}) | |
4 | - "<a href='#{url.inspect}'>#{content}</a>" | |
5 | - end | |
6 | - | |
7 | - def content_tag(tag, content, options = {}) | |
8 | - tag_attr = options.blank? ? '' : ' ' + options.collect{ |o| "#{o[0]}=\"#{o[1]}\"" }.join(' ') | |
9 | - "<#{tag}#{tag_attr}>#{content}</#{tag}>" | |
10 | - end | |
11 | 6 | |
12 | 7 | def submit_tag(content, options = {}) |
13 | 8 | content |
... | ... | @@ -17,11 +12,6 @@ module NoosferoTestHelper |
17 | 12 | '' |
18 | 13 | end |
19 | 14 | |
20 | - def tag(tag, args = {}) | |
21 | - attrs = args.map{|k,v| "#{k}='#{v}'"}.join(' ') | |
22 | - "<#{tag} #{attrs} />" | |
23 | - end | |
24 | - | |
25 | 15 | def options_from_collection_for_select(collection, value_method, content_method) |
26 | 16 | "<option value='fake value'>fake content</option>" |
27 | 17 | end | ... | ... |
test/unit/add_member_test.rb
... | ... | @@ -149,4 +149,11 @@ class AddMemberTest < ActiveSupport::TestCase |
149 | 149 | |
150 | 150 | assert_no_match(/\(#{task.requestor.email}\)/, task.target_notification_description) |
151 | 151 | end |
152 | + | |
153 | + should 'have cancel notification message with explanation' do | |
154 | + explanation_message = 'some explanation' | |
155 | + task = AddMember.new(:person => person, :organization => community, | |
156 | + :reject_explanation => explanation_message) | |
157 | + assert_match(/#{explanation_message}/, task.task_cancelled_message) | |
158 | + end | |
152 | 159 | end | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -466,7 +466,7 @@ class ApplicationHelperTest < ActionView::TestCase |
466 | 466 | should 'use theme passed via param when in development mode' do |
467 | 467 | stubs(:environment).returns(build(Environment, :theme => 'environment-theme')) |
468 | 468 | Rails.env.stubs(:development?).returns(true) |
469 | - self.stubs(:params).returns({:theme => 'skyblue'}) | |
469 | + self.stubs(:params).returns({:user_theme => 'skyblue'}) | |
470 | 470 | assert_equal 'skyblue', current_theme |
471 | 471 | end |
472 | 472 | |
... | ... | @@ -682,29 +682,6 @@ class ApplicationHelperTest < ActionView::TestCase |
682 | 682 | assert_nil default_folder_for_image_upload(profile) |
683 | 683 | end |
684 | 684 | |
685 | - should 'envelop a html with button-bar div' do | |
686 | - result = button_bar { '<b>foo</b>' } | |
687 | - assert_equal '<div class="button-bar"><b>foo</b>'+ | |
688 | - '<br style=\'clear: left;\' /></div>', result | |
689 | - end | |
690 | - | |
691 | - should 'add more classes to button-bar envelope' do | |
692 | - result = button_bar :class=>'test' do | |
693 | - '<b>foo</b>' | |
694 | - end | |
695 | - assert_equal '<div class="test button-bar"><b>foo</b>'+ | |
696 | - '<br style=\'clear: left;\' /></div>', result | |
697 | - end | |
698 | - | |
699 | - should 'add more attributes to button-bar envelope' do | |
700 | - result = button_bar :id=>'bt1' do | |
701 | - '<b>foo</b>' | |
702 | - end | |
703 | - assert_tag_in_string result, :tag =>'div', :attributes => {:class => 'button-bar', :id => 'bt1'} | |
704 | - assert_tag_in_string result, :tag =>'b', :content => 'foo', :parent => {:tag => 'div', :attributes => {:id => 'bt1'}} | |
705 | - assert_tag_in_string result, :tag =>'br', :parent => {:tag => 'div', :attributes => {:id => 'bt1'}} | |
706 | - end | |
707 | - | |
708 | 685 | should 'not filter html if source does not have macros' do |
709 | 686 | class Plugin1 < Noosfero::Plugin |
710 | 687 | end |
... | ... | @@ -871,7 +848,7 @@ class ApplicationHelperTest < ActionView::TestCase |
871 | 848 | html = fullscreen_buttons("#article") |
872 | 849 | assert html.include?("<script>fullscreenPageLoad('#article')</script>") |
873 | 850 | assert html.include?("class=\"button with-text icon-fullscreen\"") |
874 | - assert html.include?("onClick=\"toggle_fullwidth('#article')\"") | |
851 | + assert html.include?("onClick=\"toggle_fullwidth('#article')\"") | |
875 | 852 | end |
876 | 853 | |
877 | 854 | should "return the related class string" do | ... | ... |
test/unit/block_test.rb
... | ... | @@ -23,10 +23,6 @@ class BlockTest < ActiveSupport::TestCase |
23 | 23 | assert_nil Block.new.owner |
24 | 24 | end |
25 | 25 | |
26 | - should 'provide no footer by default' do | |
27 | - assert_nil Block.new.footer | |
28 | - end | |
29 | - | |
30 | 26 | should 'provide an empty default title' do |
31 | 27 | assert_equal '', Block.new.default_title |
32 | 28 | end | ... | ... |
test/unit/buttons_helper_test.rb
1 | -# encoding: UTF-8 | |
2 | 1 | require_relative "../test_helper" |
3 | 2 | |
4 | 3 | class ButtonsHelperTest < ActionView::TestCase |
4 | + | |
5 | 5 | include ButtonsHelper |
6 | 6 | |
7 | 7 | should 'append with-text class and keep existing classes' do |
8 | 8 | expects(:button_without_text).with('type', 'label', 'url', { :class => 'with-text class1'}) |
9 | 9 | button('type', 'label', 'url', { :class => 'class1' }) |
10 | 10 | end |
11 | -end | |
12 | 11 | \ No newline at end of file |
12 | + | |
13 | + should 'envelop a html with button-bar div' do | |
14 | + result = button_bar { content_tag :b, 'foo' } | |
15 | + assert_equal '<div class=" button-bar"><b>foo</b>'+ | |
16 | + '<br style="clear: left;" /></div>', result | |
17 | + end | |
18 | + | |
19 | + should 'add more classes to button-bar envelope' do | |
20 | + result = button_bar :class=>'test' do | |
21 | + content_tag :b, 'foo' | |
22 | + end | |
23 | + assert_equal '<div class="test button-bar"><b>foo</b>'+ | |
24 | + '<br style="clear: left;" /></div>', result | |
25 | + end | |
26 | + | |
27 | + should 'add more attributes to button-bar envelope' do | |
28 | + result = button_bar :id=>'bt1' do | |
29 | + content_tag :b, 'foo' | |
30 | + end | |
31 | + assert_tag_in_string result, :tag =>'div', :attributes => {:class => ' button-bar', :id => 'bt1'} | |
32 | + assert_tag_in_string result, :tag =>'b', :content => 'foo', :parent => {:tag => 'div', :attributes => {:id => 'bt1'}} | |
33 | + assert_tag_in_string result, :tag =>'br', :parent => {:tag => 'div', :attributes => {:id => 'bt1'}} | |
34 | + end | |
35 | + | |
36 | +end | ... | ... |
test/unit/comment_handler_test.rb
... | ... | @@ -21,4 +21,14 @@ class CommentHandlerTest < ActiveSupport::TestCase |
21 | 21 | handler.perform |
22 | 22 | end |
23 | 23 | |
24 | + should 'save locale from creation context and not change current locale' do | |
25 | + FastGettext.stubs(:locale).returns("pt") | |
26 | + handler = CommentHandler.new(5, :whatever_method) | |
27 | + | |
28 | + FastGettext.stubs(:locale).returns("en") | |
29 | + assert_equal "pt", handler.locale | |
30 | + | |
31 | + handler.perform | |
32 | + assert_equal "en", FastGettext.locale | |
33 | + end | |
24 | 34 | end | ... | ... |
test/unit/comment_helper_test.rb
1 | 1 | require_relative "../test_helper" |
2 | 2 | |
3 | -class CommentHelperTest < ActiveSupport::TestCase | |
3 | +class CommentHelperTest < ActionView::TestCase | |
4 | 4 | |
5 | 5 | include CommentHelper |
6 | - include ActionView::Helpers::TagHelper | |
7 | - include NoosferoTestHelper | |
6 | + | |
7 | + helper ApplicationHelper | |
8 | 8 | |
9 | 9 | def setup |
10 | 10 | @user = create_user('usertest').person |
... | ... | @@ -12,6 +12,7 @@ class CommentHelperTest < ActiveSupport::TestCase |
12 | 12 | self.stubs(:logged_in?).returns(true) |
13 | 13 | self.stubs(:report_abuse).returns('<a href="#">link</a>') |
14 | 14 | self.stubs(:expirable_comment_link).returns('<a href="#">link</a>') |
15 | + self.stubs(:url_for) | |
15 | 16 | @plugins = mock |
16 | 17 | @plugins.stubs(:dispatch).returns([]) |
17 | 18 | end |
... | ... | @@ -140,9 +141,5 @@ class CommentHelperTest < ActiveSupport::TestCase |
140 | 141 | assert_match /plugin_action/, Nokogiri::HTML.fragment(html).css('.comments-action-bar').to_html |
141 | 142 | end |
142 | 143 | |
143 | - def link_to_function(content, url, options = {}) | |
144 | - link_to(content, url, options) | |
145 | - end | |
146 | - | |
147 | 144 | end |
148 | 145 | ... | ... |
test/unit/content_viewer_helper_test.rb
... | ... | @@ -3,6 +3,8 @@ require_relative "../test_helper" |
3 | 3 | class ContentViewerHelperTest < ActionView::TestCase |
4 | 4 | |
5 | 5 | include ActionView::Helpers::TagHelper |
6 | + include ActionView::Helpers::TextHelper | |
7 | + | |
6 | 8 | include ContentViewerHelper |
7 | 9 | include DatesHelper |
8 | 10 | include ApplicationHelper |
... | ... | @@ -99,14 +101,14 @@ class ContentViewerHelperTest < ActionView::TestCase |
99 | 101 | end |
100 | 102 | |
101 | 103 | should 'theme provides addthis custom icon' do |
102 | - stubs(:session).returns({:theme => 'base'}) | |
104 | + stubs(:session).returns({:user_theme => 'base'}) | |
103 | 105 | File.expects(:exists?).with(anything).returns(true) |
104 | 106 | Environment.any_instance.stubs(:default_hostname).returns('noosfero.org') |
105 | 107 | assert_match 'addthis.gif', addthis_image_tag |
106 | 108 | end |
107 | 109 | |
108 | 110 | should 'use default addthis icon if theme has no addthis.gif image' do |
109 | - stubs(:session).returns({:theme => 'base'}) | |
111 | + stubs(:session).returns({:user_theme => 'base'}) | |
110 | 112 | File.expects(:exists?).with(anything).returns(false) |
111 | 113 | Environment.any_instance.stubs(:default_hostname).returns('noosfero.org') |
112 | 114 | assert_match 'bt-bookmark.gif', addthis_image_tag |
... | ... | @@ -148,11 +150,4 @@ class ContentViewerHelperTest < ActionView::TestCase |
148 | 150 | assert_match /February 1, 2007/, result |
149 | 151 | end |
150 | 152 | |
151 | - protected | |
152 | - include NoosferoTestHelper | |
153 | - include ActionView::Helpers::TextHelper | |
154 | - def url_for(args = {}) | |
155 | - ['http:/', args[:host], args[:profile], args[:page]].join('/') | |
156 | - end | |
157 | - | |
158 | 153 | end | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -457,6 +457,22 @@ class EnvironmentTest < ActiveSupport::TestCase |
457 | 457 | assert_equal ['new-theme', 'other-theme'], Environment.default.themes.map(&:id) |
458 | 458 | end |
459 | 459 | |
460 | + should 'return the theme ids' do | |
461 | + env = Environment.default | |
462 | + t1 = 'theme_1' | |
463 | + t2 = 'theme_2' | |
464 | + Theme.stubs(:system_themes).returns([Theme.new(t1), Theme.new(t2)]) | |
465 | + env.themes = [t1, t2] | |
466 | + env.save! | |
467 | + assert_equivalent [t1, t2], Environment.default.theme_ids | |
468 | + end | |
469 | + should 'theme_ids be an empty array if there is no settings themes defined' do | |
470 | + env = Environment.default | |
471 | + env.settings[:themes] = nil | |
472 | + env.save! | |
473 | + assert Environment.default.theme_ids.empty? | |
474 | + end | |
475 | + | |
460 | 476 | should 'create templates' do |
461 | 477 | e = create(Environment, :name => 'test_env') |
462 | 478 | e.reload | ... | ... |
test/unit/events_helper_test.rb
test/unit/forum_helper_test.rb
1 | 1 | require_relative "../test_helper" |
2 | 2 | |
3 | -class ForumHelperTest < ActiveSupport::TestCase | |
3 | +class ForumHelperTest < ActionView::TestCase | |
4 | 4 | |
5 | 5 | include BlogHelper |
6 | 6 | include ForumHelper |
... | ... | @@ -58,7 +58,7 @@ class ForumHelperTest < ActiveSupport::TestCase |
58 | 58 | assert_match result, out |
59 | 59 | assert_match 'a2', out |
60 | 60 | |
61 | - assert_match(/#{result} by <a href='[^']+'>a2<\/a>/, last_topic_update(some_post)) | |
61 | + assert_match(/#{result} by <a href="[^"]+">a2<\/a>/, last_topic_update(some_post)) | |
62 | 62 | end |
63 | 63 | |
64 | 64 | should "return last comment author's name from unauthenticated user" do | ... | ... |
test/unit/link_list_block_test.rb
... | ... | @@ -79,13 +79,6 @@ class LinkListBlockTest < ActiveSupport::TestCase |
79 | 79 | assert_tag_in_string render_block_content(l), :tag => 'a', :attributes => { :href => '/prefix/bar' } |
80 | 80 | end |
81 | 81 | |
82 | - should 'display options for icons' do | |
83 | - l = LinkListBlock.new | |
84 | - l.icons_options.each do |option| | |
85 | - assert_match(/<span title=\".+\" class=\"icon-.+\" onclick=\"changeIcon\(this, '.+'\)\"><\/span>/, option) | |
86 | - end | |
87 | - end | |
88 | - | |
89 | 82 | should 'link with icon' do |
90 | 83 | l = LinkListBlock.new(:links => [{:icon => 'save', :name => 'test', :address => 'test.com'}]) |
91 | 84 | assert_match /a class="icon-[^"]+"/, render_block_content(l) | ... | ... |
test/unit/organization_test.rb
... | ... | @@ -567,4 +567,24 @@ class OrganizationTest < ActiveSupport::TestCase |
567 | 567 | assert_not_includes person_orgs, o7 |
568 | 568 | assert_includes env_admin_orgs, o7 |
569 | 569 | end |
570 | + | |
571 | + should 'return true at display_private_info_to? when profile is public and user is nil' do | |
572 | + organization = fast_create(Organization, public_profile: true) | |
573 | + assert organization.display_private_info_to?(nil) | |
574 | + end | |
575 | + | |
576 | + should 'return false at display_private_info_to? when profile is public and secret' do | |
577 | + organization = fast_create(Organization, public_profile: true, secret: true) | |
578 | + assert !organization.display_private_info_to?(nil) | |
579 | + end | |
580 | + | |
581 | + should 'return false at display_private_info_to? when profile is public and not visible' do | |
582 | + organization = fast_create(Organization, public_profile: true, visible: false) | |
583 | + assert !organization.display_private_info_to?(nil) | |
584 | + end | |
585 | + | |
586 | + should 'return false at display_private_info_to? when profile is private and user is nil' do | |
587 | + organization = fast_create(Organization, public_profile: false) | |
588 | + assert !organization.display_private_info_to?(nil) | |
589 | + end | |
570 | 590 | end | ... | ... |
test/unit/theme_loader_helper_test.rb
... | ... | @@ -20,7 +20,7 @@ class ThemeLoaderHelperTest < ActionView::TestCase |
20 | 20 | end |
21 | 21 | |
22 | 22 | should 'override theme with testing theme from session' do |
23 | - stubs(:session).returns(:theme => 'theme-under-test') | |
23 | + stubs(:session).returns(:user_theme => 'theme-under-test') | |
24 | 24 | assert_equal 'theme-under-test', current_theme |
25 | 25 | end |
26 | 26 | |
... | ... | @@ -30,7 +30,17 @@ class ThemeLoaderHelperTest < ActionView::TestCase |
30 | 30 | end |
31 | 31 | |
32 | 32 | should 'point to user theme path when testing theme' do |
33 | - stubs(:session).returns({:theme => 'theme-under-test'}) | |
33 | + stubs(:session).returns({:user_theme => 'theme-under-test'}) | |
34 | 34 | assert_equal '/user_themes/theme-under-test', theme_path |
35 | 35 | end |
36 | -end | |
37 | 36 | \ No newline at end of file |
37 | + | |
38 | + should 'point to session theme is defined' do | |
39 | + session = mock | |
40 | + stubs(:session).returns(session) | |
41 | + my_session_theme = 'session_theme' | |
42 | + session.stubs(:[]).with(:user_theme).returns(nil) | |
43 | + session.stubs(:[]).with(:theme).returns(my_session_theme) | |
44 | + assert_equal '/designs/themes/' + my_session_theme, theme_path | |
45 | + end | |
46 | + | |
47 | +end | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +require 'test_helper' | |
2 | + | |
3 | +class UrlHelperTest < ActionView::TestCase | |
4 | + | |
5 | + include UrlHelper | |
6 | + | |
7 | + def setup | |
8 | + end | |
9 | + | |
10 | + should 'preserve override_user if present' do | |
11 | + params[:override_user] = 1 | |
12 | + assert_equal default_url_options[:override_user], params[:override_user] | |
13 | + end | |
14 | + | |
15 | +end | ... | ... |