1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-02 13:24:20 +01:00

Merge branch 'dev'

This commit is contained in:
Sylvain 2016-06-23 11:50:15 +02:00
commit 4bb555f624
9 changed files with 39 additions and 13 deletions

View File

@ -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"

View File

@ -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 = [

View File

@ -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>

View File

@ -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
@ -169,7 +178,7 @@ class API::MembersController < API::ApiController
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}")
@ -177,7 +186,11 @@ class API::MembersController < API::ApiController
.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
@ -201,6 +214,10 @@ class API::MembersController < API::ApiController
end
end
# remove unmerged profiles from list
@members = @members.to_a
@members.delete_if { |u| u.need_completion? }
@members
end

View File

@ -20,7 +20,7 @@ class API::StatisticsController < API::ApiController
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

View File

@ -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

View File

@ -252,10 +252,12 @@ class StatisticService
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

View File

@ -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

View File

@ -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