diff --git a/app/controllers/api/v0/statistics_controller.rb b/app/controllers/api/v0/statistics_controller.rb
index 57c2e43..761cf26 100644
--- a/app/controllers/api/v0/statistics_controller.rb
+++ b/app/controllers/api/v0/statistics_controller.rb
@@ -12,11 +12,10 @@
def users_joined
raise Pundit::NotAuthorizedError unless Api::V0::StatisticsPolicy.new(@user, :statistics).users_joined?
- scoped = User.unscoped.where.not(confirmed_at: nil)
if @user.can_super_admin? && params[:org_id].present?
- scoped = scoped.where(org_id: params[:org_id])
+ scoped = User.unscoped.where(org_id: params[:org_id])
else
- scoped = scoped.where(org_id: @user.org_id)
+ scoped = User.unscoped.where(org_id: @user.org_id)
end
if params[:range_dates].present?
@@ -28,13 +27,13 @@
end
respond_to do |format|
format.json { render(json: r.to_json) }
- format.csv {
+ format.csv {
send_data(CSV.generate do |csv|
csv << [_('Month'), _('No. Users joined')]
total = 0
r.each_pair{ |k,v| csv << [k,v]; total+=v }
csv << [_('Total'), total]
- end, filename: "#{_('users_joined')}.csv") }
+ end, filename: "#{_('users_joined')}.csv") }
end
else
scoped = scoped.where('created_at >= ?', Date.parse(params[:start_date])) if params[:start_date].present?
@@ -80,7 +79,7 @@
plans = plans.where('plans.updated_at >= ?', Date.parse(params[:start_date])) if params[:start_date].present?
plans = plans.where('plans.updated_at <= ?', Date.parse(params[:end_date])) if params[:end_date].present?
count = roles.joins(:user, :plan).merge(users).merge(plans).select(:plan_id).distinct.count
- render(json: { completed_plans: count })
+ render(json: { completed_plans: count })
end
end
@@ -88,7 +87,7 @@
# Returns the number of created plans within the user's org for the data start_date and end_date specified
def created_plans
raise Pundit::NotAuthorizedError unless Api::V0::StatisticsPolicy.new(@user, :statistics).plans?
-
+
roles = Role.where("#{Role.creator_condition} OR #{Role.administrator_condition}")
users = User.unscoped
@@ -232,4 +231,4 @@
end
end
end
-end
\ No newline at end of file
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index ecf5dcf..cc42075 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -49,16 +49,17 @@
end
def after_sign_in_path_for(resource)
- if from_external_domain? || request.referer.eql?(new_user_session_url(:protocol => 'https')) || request.referer.eql?(new_user_registration_url(:protocol => 'https'))
+ referer_path = URI(request.referer).path unless request.referer.nil? or nil
+ if from_external_domain? || referer_path.eql?(new_user_session_path) || referer_path.eql?(new_user_registration_path) || referer_path.nil?
root_path
else
- return request.referer unless request.referer.nil?
- root_path
+ request.referer
end
end
def after_sign_up_path_for(resource)
- if from_external_domain? or request.referer.eql?(new_user_session_url(:protocol => 'https'))
+ referer_path = URI(request.referer).path unless request.referer.nil? or nil
+ if from_external_domain? || referer_path.eql?(new_user_session_path) || referer_path.nil?
root_path
else
request.referer
@@ -85,11 +86,11 @@
def failed_update_error(obj, obj_name)
"#{_('Could not update your %{o}.') % {o: obj_name}} #{errors_to_s(obj)}"
end
-
+
def failed_destroy_error(obj, obj_name)
"#{_('Could not delete the %{o}.') % {o: obj_name}} #{errors_to_s(obj)}"
end
-
+
def success_message(obj_name, action)
"#{_('Successfully %{action} your %{object}.') % {object: obj_name, action: action}}"
end
@@ -108,7 +109,7 @@
private
# Override rails default render action to look for a branded version of a
- # template instead of using the default one. If no override exists, the
+ # template instead of using the default one. If no override exists, the
# default version in ./app/views/[:controller]/[:action] will be used
#
# The path in the app/views/branded/ directory must match the the file it is
@@ -117,7 +118,7 @@
def prepend_view_paths
prepend_view_path "app/views/branded"
end
-
+
def errors_to_s(obj)
if obj.errors.count > 0
msg = "
"
@@ -126,7 +127,7 @@
msg += "#{_(e)} - #{_(m)}
"
else
msg += "'#{obj[e]}' - #{_(m)}
"
- end
+ end
end
msg
end
diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb
index 45bf21d..872733e 100644
--- a/app/controllers/contacts_controller.rb
+++ b/app/controllers/contacts_controller.rb
@@ -3,12 +3,17 @@
def create
@contact = ContactUs::Contact.new(params[:contact_us_contact])
- if verify_recaptcha(model: @contact) && @contact.save
+ if !user_signed_in?
+ unless verify_recaptcha(model: @contact) && @contact.save
+ flash[:alert] = _('Captcha verification failed, please retry.')
+ render_new_page and return
+ end
+ end
+ if @contact.save
redirect_to(ContactUs.success_redirect || '/', :notice => _('Contact email was successfully sent.'))
else
- flash[:alert] = _('Captcha verification failed, please retry.')
- redirect_to request.referrer
- #render_new_page
+ flash[:alert] = _('Unable to submit your request')
+ render_new_page
end
end
diff --git a/app/views/plans/index.html.erb b/app/views/plans/index.html.erb
index a00ec53..9d05e58 100644
--- a/app/views/plans/index.html.erb
+++ b/app/views/plans/index.html.erb
@@ -20,7 +20,7 @@
controller: 'paginable/plans',
action: 'privately_visible',
scope: @plans,
- query_params: { sort_field: 'plans.updated_at', sort_direction: :desc }) %>
+ query_params: { sort_field: 'plans.updated_at', sort_direction: 'desc' }) %>