Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainbx committed Jun 23, 2016
2 parents ef9907a + 98edd34 commit 4bb555f
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog Fab Manager

## v2.2.2 2016 June 23
- Fix some bugs: users with uncompleted account (sso imported) won't appear in statistics, in listings and in searches. Moreover, they won't block statistics generation
- Fix a bug: unable to display next results in statistics tables
- Admin: Category is mandatory when creating a course/workshop (event)

## v2.2.1 2016 June 22
- Fix a bug: field User.merged_at should not be allowed to be mapped in SSO
- Fix a bug: integration test "user reservation without plan"
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/controllers/admin/events.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ Application.Controllers.controller "NewEventController", ["$scope", "$state", "$
end_time: new Date()
all_day: 'false'
recurrence: 'none'
category_ids: []

## Possible types of recurrences for an event
$scope.recurrenceTypes = [
Expand Down
2 changes: 1 addition & 1 deletion app/assets/templates/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

</div> <!-- ./panel-body -->
<div class="panel-footer no-padder">
<input type="submit" ng-value="submitName" class="r-b btn-valid btn btn-warning btn-block p-lg btn-lg text-u-c" ng-disabled="eventForm.$invalid"/>
<input type="submit" ng-value="submitName" class="r-b btn-valid btn btn-warning btn-block p-lg btn-lg text-u-c" ng-disabled="eventForm.$invalid || event.category_ids.length === 0"/>
</div>
</section>

Expand Down
27 changes: 22 additions & 5 deletions app/controllers/api/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ class API::MembersController < API::ApiController

def index
@requested_attributes = params[:requested_attributes]
@members = policy_scope(User)
@query = policy_scope(User)

unless params[:page].nil? and params[:size].nil?
@members = @members.page(params[:page].to_i).per(params[:size].to_i)
@query = @query.page(params[:page].to_i).per(params[:size].to_i)
end

# remove unmerged profiles from list
@members = @query.to_a
@members.delete_if { |u| u.need_completion? }
end

def last_subscribed
@members = User.active.with_role(:member).includes(:profile).where('is_allow_contact = true AND confirmed_at IS NOT NULL').order('created_at desc').limit(params[:last])
@query = User.active.with_role(:member).includes(:profile).where('is_allow_contact = true AND confirmed_at IS NOT NULL').order('created_at desc').limit(params[:last])

# remove unmerged profiles from list
@members = @query.to_a
@members.delete_if { |u| u.need_completion? }

@requested_attributes = ['profile']
render :index
end
Expand Down Expand Up @@ -169,15 +178,19 @@ def list
order_key = 'users.id'
end

@members = User.includes(:profile, :group)
@query = User.includes(:profile, :group)
.joins(:profile, :group, :roles, 'LEFT JOIN "subscriptions" ON "subscriptions"."user_id" = "users"."id" LEFT JOIN "plans" ON "plans"."id" = "subscriptions"."plan_id"')
.where("users.is_active = 'true' AND roles.name = 'member'")
.order("#{order_key} #{direction}")
.page(p[:page])
.per(p[:size])

# ILIKE => PostgreSQL case-insensitive LIKE
@members = @members.where('profiles.first_name ILIKE :search OR profiles.last_name ILIKE :search OR profiles.phone ILIKE :search OR email ILIKE :search OR groups.name ILIKE :search OR plans.base_name ILIKE :search', search: "%#{p[:search]}%") if p[:search].size > 0
@query = @query.where('profiles.first_name ILIKE :search OR profiles.last_name ILIKE :search OR profiles.phone ILIKE :search OR email ILIKE :search OR groups.name ILIKE :search OR plans.base_name ILIKE :search', search: "%#{p[:search]}%") if p[:search].size > 0

# remove unmerged profiles from list
@members = @query.to_a
@members.delete_if { |u| u.need_completion? }

@members

Expand All @@ -201,6 +214,10 @@ def search
end
end

# remove unmerged profiles from list
@members = @members.to_a
@members.delete_if { |u| u.need_completion? }

@members
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/statistics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def #{path}
def scroll
authorize :statistic, :scroll?

results = Elasticsearch::Client.new.scroll scroll: params[:scroll], scroll_id: params[:scrollId]
results = Elasticsearch::Model.client.scroll scroll: params[:scroll], scroll_id: params[:scrollId]
render json: results
end

Expand Down
1 change: 1 addition & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Event < ActiveRecord::Base
has_many :event_files, as: :viewable, dependent: :destroy
accepts_nested_attributes_for :event_files, allow_destroy: true, reject_if: :all_blank
has_and_belongs_to_many :categories, join_table: :events_categories
validates :categories, presence: true

belongs_to :availability, dependent: :destroy
accepts_nested_attributes_for :availability
Expand Down
10 changes: 6 additions & 4 deletions app/services/statistic_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,12 @@ def members_ca_list(options = default_options)

def members_list(options = default_options)
result = []
User.with_role(:member).where('users.created_at >= :start_date AND users.created_at <= :end_date', options).each do |u|
result.push OpenStruct.new({
date: options[:start_date].to_date
}.merge(user_info(u)))
User.with_role(:member).includes(:profile).where('users.created_at >= :start_date AND users.created_at <= :end_date', options).each do |u|
if !u.need_completion?
result.push OpenStruct.new({
date: options[:start_date].to_date
}.merge(user_info(u)))
end
end
result
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/members/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
user_is_admin = (current_user and current_user.is_admin?)
maxMembers = @members.except(:offset, :limit, :order).count
maxMembers = @query.except(:offset, :limit, :order).count

json.array!(@members) do |member|
json.maxMembers maxMembers
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/members/list.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
maxMembers = @members.except(:offset, :limit, :order).count
maxMembers = @query.except(:offset, :limit, :order).count

json.array!(@members) do |member|
json.maxMembers maxMembers
Expand Down

0 comments on commit 4bb555f

Please sign in to comment.