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/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' }) %>