Skip to content

Commit

Permalink
Merge branch 'dev' for release 6.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed Sep 6, 2023
2 parents 5e6e4b8 + 48d76fa commit 60a99e4
Show file tree
Hide file tree
Showing 47 changed files with 287 additions and 107 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog Fab-manager

## next deploy

## v6.0.14 2023 September 6

- Fix a bug: for project categories, if there is no category : do not show categories panel in show view, do not show categories input field in edit view
- Fix a bug: unable to update status to paid for latest payment schedule item
- Fix a bug: unable to generate statistic
- Fix a bug: unable to update user profile by admin
- Feature: add a filter in members list (admin) to show only "not validated" members
- Concerning statistics:
- removes age and type column from all statistics tabs (only in web, not in xlsx export file)
- index:
- renames user column header for projects tab and projects xlsx export
- adds group name of user for every tab except projects tab
- adds status and project users names for projects tab
- [TODO DEPLOY] `rails db:seed`
- [TODO DEPLOY] `rails fablab:es:build_stats`
- [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2014,1]`

## v6.0.13 2023 August 28

- Fix a bug: unable to cancel a payment schedule
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/api/notification_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ class API::NotificationTypesController < API::APIController

def index
@notification_types = if params[:is_configurable] == 'true'
NotificationType.where(is_configurable: true)
role = 'admin' if current_user.admin?
role ||= 'manager' if current_user.manager?
NotificationType.where(is_configurable: true).for_role(role)
else
NotificationType.all
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { IApplication } from '../../models/application';
import { Loader } from '../base/loader';
import { react2angular } from 'react2angular';
import { FabButton } from '../base/fab-button';
import { SettingValue } from '../../models/setting';

declare const Application: IApplication;
Expand All @@ -17,15 +16,12 @@ interface EditorialBlockProps {
* Display a editorial text block with an optional cta button
*/
export const EditorialBlock: React.FC<EditorialBlockProps> = ({ text, cta, url }) => {
/** Link to url from props */
const linkTo = (): void => {
window.location.href = url as string;
};

return (
<div className={`editorial-block ${(cta as string)?.length > 25 ? 'long-cta' : ''}`}>
<div dangerouslySetInnerHTML={{ __html: text as string }}></div>
{cta && <FabButton className='is-main' onClick={linkTo}>{cta}</FabButton>}
{cta &&
<a href={url as string} target="_blank" rel="noopener noreferrer" className='fab-button is-main cta'>{cta}</a>
}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const NotificationsCenter: React.FC<NotificationsCenterProps> = ({ onErro

return (
<>
{role === 'admin' && <FabTabs defaultTab='notifications-list' tabs={[
{(role === 'admin' || role === 'manager') && <FabTabs defaultTab='notifications-list' tabs={[
{
id: 'notifications_settings',
title: t('app.logged.notifications_center.notifications_settings'),
Expand All @@ -42,7 +42,7 @@ export const NotificationsCenter: React.FC<NotificationsCenterProps> = ({ onErro
content: <NotificationsList onError={onError}/>
}
]} />}
{role !== 'admin' && <NotificationsList onError={onError}/>}
{role === 'member' && <NotificationsList onError={onError}/>}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
}

return handleSubmit((data: User) => {
['events_reservations', 'space_reservations', 'training_reservations', 'machine_reservations', 'all_projects', 'invoices', 'subscribed_plan', 'subscription'].forEach(key => delete data[key]);
MemberAPI[action](data)
.then(res => {
reset(res);
Expand Down
2 changes: 2 additions & 0 deletions app/frontend/src/javascript/controllers/admin/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
// is user validation required
$scope.enableUserValidationRequired = (settingsPromise.user_validation_required === 'true');

if ($scope.enableUserValidationRequired) { $scope.member.memberFilters.push('not_validated'); }

// should we display the username in the list?
$scope.displayUsername = (settingsPromise.show_username_in_admin_list === 'true');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
border: 1px solid var(--gray-soft-dark);
border-radius: var(--border-radius);
@include editor;
button { white-space: normal; }
.cta {
white-space: normal;
text-decoration: none;
}

@media (min-width: 540px) {
flex-direction: row;
justify-content: space-between;
align-items: flex-end;
button { white-space: nowrap; }
.cta { white-space: nowrap; }
&.long-cta {
flex-direction: column;
align-items: flex-start;
button { margin-left: auto; }
.cta { margin-left: auto; }
}
}
@media (min-width: 1200px) {
Expand Down
10 changes: 2 additions & 8 deletions app/frontend/templates/admin/statistics/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,11 @@ <h1 translate>{{ 'app.admin.statistics.statistics' }}</h1>
<tr>
<th ng-if="['booking', 'hour'].includes(type.active.key)" translate>{{ 'app.admin.statistics.reservation_date' }}</th>
<th ng-if="!['booking', 'hour'].includes(type.active.key)" translate>{{ 'app.admin.statistics.date' }}</th>
<th translate>{{ 'app.admin.statistics.user' }}</th>
<th ng-if="['project'].includes(type.active.key)" translate>{{ 'app.admin.statistics.project_author' }}</th>
<th ng-if="!['project'].includes(type.active.key)" translate>{{ 'app.admin.statistics.user' }}</th>
<th ng-if="reservationContextFeatureEnabled && reservationContextIsApplicable(selectedIndex.es_type_key)">
{{ 'app.admin.statistics.reservation_context' | translate }}
</th>
<th translate>{{ 'app.admin.statistics.age' }}</th>
<th translate>{{ 'app.admin.statistics.type' }}</th>
<th ng-if="!type.active.simple">{{type.active.label}}</th>
<th ng-repeat="field in selectedIndex.additional_fields">{{field.label}}</th>
<th ng-if="selectedIndex.ca">{{ 'app.admin.statistics.revenue' | translate }}
Expand All @@ -285,11 +284,6 @@ <h1 translate>{{ 'app.admin.statistics.statistics' }}</h1>
<td ng-if="reservationContextFeatureEnabled && reservationContextIsApplicable(selectedIndex.es_type_key)">
{{ formatReservationContext(datum._source.reservationContextId) }}
</td>
<td>
<span ng-if="datum._source.age">{{datum._source.age}} {{ 'app.admin.statistics.years_old' | translate }}</span>
<span ng-if="!datum._source.age" translate>{{ 'app.admin.statistics.unknown' }}</span>
</td>
<td>{{formatSubtype(datum._source.subType)}}</td>
<td ng-if="!type.active.simple">{{datum._source.stat}}</td>
<td ng-repeat="field in selectedIndex.additional_fields">
<ng-switch on="field.data_type">
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/templates/projects/_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ <h3 translate>{{ 'app.shared.project.tags' }}</h3>
</div>
</div>

<div class="widget panel b-a m m-t-lg">
<div class="widget panel b-a m m-t-lg" ng-if="projectCategories.length">
<div class="panel-heading b-b small">
<h3 translate>{{ projectCategoriesWording }}</h3>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/templates/projects/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ <h3 translate>{{ 'app.shared.project.tags' }}</h3>
</div>
</section>

<section class="widget panel b-a m" ng-if="project.project_categories">
<section class="widget panel b-a m" ng-if="project.project_categories.length">
<div class="panel-heading b-b">
<h3 translate>{{ projectCategoriesWording }}</h3>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/stat_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module StatConcern
attribute :gender, String
attribute :age, Integer
attribute :group, String
attribute :groupName, String

# has include Elasticsearch::Persistence::Model
index_name 'stats'
Expand Down
10 changes: 10 additions & 0 deletions app/models/notification_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ class NotificationType < ApplicationRecord
validates :category, presence: true, inclusion: { in: %w[subscriptions user projects deprecated exports agenda trainings accountings
app_management wallet payments users_accounts supporting_documents shop] }
validates :is_configurable, inclusion: { in: [true, false] }

validate :validate_roles

scope :for_role, ->(role) { where("roles @> ?", "{#{role}}") }

private

def validate_roles
errors.add(:roles, :invalid) if roles.any? { |r| !r.in?(%w(admin manager)) }
end
end
2 changes: 2 additions & 0 deletions app/models/stats/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ class Stats::Project
attribute :components, Array
attribute :machines, Array
attribute :users, Integer
attribute :status, String
attribute :projectUserNames, Array
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class User < ApplicationRecord
scope :with_subscription, -> { joins(statistic_profile: [:subscriptions]) }
scope :not_confirmed, -> { where(confirmed_at: nil) }
scope :inactive_for_3_years, -> { where('users.last_sign_in_at < ?', 3.years.ago) }
scope :not_validated, -> { where(validated_at: nil) }

def to_json(*)
ApplicationController.new.view_context.render(
Expand Down
4 changes: 2 additions & 2 deletions app/policies/notification_preference_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Check the access policies for API::NotificationPreferencesController
class NotificationPreferencePolicy < ApplicationPolicy
def update?
user.admin?
user.admin? || user.manager?
end

def bulk_update?
user.admin?
user.admin? || user.manager?
end
end
2 changes: 1 addition & 1 deletion app/services/members/list_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def list(params)
'plans.base_name ILIKE :search', search: "%#{params[:search]}%")
end

filter = params[:filter].presence_in(%w[inactive_for_3_years not_confirmed]) || nil
filter = params[:filter].presence_in(%w[inactive_for_3_years not_confirmed not_validated]) || nil
@query = @query.send(filter) if filter

@query
Expand Down
6 changes: 4 additions & 2 deletions app/services/statistics/builders/members_builder_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ def build(options = default_options)
Stats::Account.create({ date: format_date(m[:date]),
type: 'member',
subType: 'created',
stat: 1 }.merge(user_info_stat(m)))
stat: 1,
groupName: m[:groupName] }.merge(user_info_stat(m)))
end

# member ca list
Statistics::FetcherService.members_ca_list(options).each do |m|
Stats::User.create({ date: format_date(m[:date]),
type: 'revenue',
subType: m[:group],
stat: m[:ca] }.merge(user_info_stat(m)))
stat: m[:ca],
groupName: m[:groupName] }.merge(user_info_stat(m)))
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def build(options = default_options)
name: r["#{category}_name".to_sym],
reservationId: r[:reservation_id],
reservationContextId: r[:reservation_context_id],
coupon: r[:coupon]
coupon: r[:coupon],
groupName: r[:groupName],
}.merge(user_info_stat(r)))
stat[:stat] = (type == 'booking' ? 1 : r[:nb_hours])
stat["#{category}Id".to_sym] = r["#{category}_id".to_sym]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def build(options = default_options)
orderId: o[:order_id],
state: o[:order_state],
coupon: o[:coupon],
groupName: o[:groupName],
stat: 1 }.merge(user_info_stat(o)))
end
end
Expand Down
14 changes: 12 additions & 2 deletions app/services/statistics/concerns/projects_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def get_project_users(project)
sum
end

def get_project_user_names(project)
project.project_users.map do |project_user|
{ id: project_user.user.id, name: project_user.user.profile.full_name }
end
end

def project_info(project)
{
project_id: project.id,
Expand All @@ -41,7 +47,9 @@ def project_info(project)
project_themes: get_project_themes(project),
project_components: get_projects_components(project),
project_machines: get_projects_machines(project),
project_users: get_project_users(project)
project_users: get_project_users(project),
project_status: project.status&.name,
project_user_names: get_project_user_names(project),
}
end

Expand All @@ -53,7 +61,9 @@ def project_info_stat(project)
themes: project[:project_themes],
components: project[:project_components],
machines: project[:project_machines],
users: project[:project_users]
users: project[:project_users],
status: project[:project_status],
projectUserNames: project[:project_user_names],
}
end
end
Expand Down
Loading

0 comments on commit 60a99e4

Please sign in to comment.