Skip to content

Commit

Permalink
Merge branch 'dev' for release 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainbx committed Jun 28, 2016
2 parents 4bb555f + 7126843 commit 59efdcf
Show file tree
Hide file tree
Showing 96 changed files with 1,689 additions and 154 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

/public/uploads
/public/assets
/public/api

# Ignore application configurations
/config/application.yml
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog Fab Manager

## v2.3.0 2016 June 28

- Public API with access management and online documentation
- Add json cache for machines, events, trainings
- Optimise sql query, avoid to N+1
- Projects URL are always composed with slug instead of ID
- Confirmation on project deletion
- Fix a bug: unable to deploy 2.2.0+ when PostgreSQL 'unaccent' extension was already active
- Fix a bug: some reservations was referencing reservables not present in database (#patch)
- [TODO DEPLOY] `bundle exec rake fablab:fix:reservations_not_existing_reservable` to apply #patch
- [TODO DEPLOY] `bundle install` and `rake db:migrate`

## 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
Expand Down Expand Up @@ -41,4 +53,4 @@
- Fix a bug: custom asset favicon-file favicon file is not set
- Fix a security issue: stripe card token is now checked on server side on new/renew subscription
- Translated notification e-mails into english language
- Subscription extension logic has been extracted into a microservice
- Subscription extension logic has been extracted into a microservice
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ gem 'therubyracer', '= 0.12.0', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
gem 'jbuilder', '~> 2.5'
gem 'jbuilder_cache_multi'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc #TODO remove unused ?

Expand Down Expand Up @@ -139,3 +140,7 @@ gem 'protected_attributes'
gem 'message_format'

gem 'openlab_ruby'

gem 'api-pagination'
gem 'has_secure_token'
gem 'apipie-rails'
23 changes: 17 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ GEM
tzinfo (~> 1.1)
addressable (2.3.8)
ansi (1.5.0)
api-pagination (4.3.0)
apipie-rails (0.3.6)
json
arel (6.0.3)
autoprefixer-rails (5.1.8)
execjs
Expand Down Expand Up @@ -164,6 +167,8 @@ GEM
activerecord (>= 4.0.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
has_secure_token (1.0.0)
activerecord (>= 3.0)
hashdiff (0.3.0)
hashie (3.4.2)
highline (1.7.1)
Expand All @@ -179,9 +184,11 @@ GEM
multi_xml (>= 0.5.2)
i18n (0.7.0)
ice_nine (0.11.1)
jbuilder (2.2.12)
activesupport (>= 3.0.0, < 5)
jbuilder (2.5.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jbuilder_cache_multi (0.0.3)
jbuilder (>= 1.5.0, < 3)
jquery-rails (4.0.3)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
Expand All @@ -208,13 +215,13 @@ GEM
mime-types (2.99)
mini_magick (4.2.0)
mini_portile2 (2.0.0)
minitest (5.8.4)
minitest (5.9.0)
minitest-reporters (1.1.8)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.11.2)
multi_json (1.12.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
naught (1.0.0)
Expand Down Expand Up @@ -430,6 +437,8 @@ DEPENDENCIES
aasm
actionpack-page_caching
active_record_query_trace
api-pagination
apipie-rails
awesome_print
bootstrap-sass
byebug
Expand All @@ -452,7 +461,9 @@ DEPENDENCIES
foreman
forgery
friendly_id (~> 5.1.0)
jbuilder (~> 2.0)
has_secure_token
jbuilder (~> 2.5)
jbuilder_cache_multi
jquery-rails
kaminari
letter_opener
Expand Down Expand Up @@ -497,4 +508,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.11.2
1.12.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Application.Controllers.controller "OpenAPIClientsController", ["$scope", 'clientsPromise', 'growl', 'OpenAPIClient', 'dialogs', '_t'
, ($scope, clientsPromise, growl, OpenAPIClient, dialogs, _t) ->



### PUBLIC SCOPE ###

## clients list
$scope.clients = clientsPromise
$scope.order = null
$scope.clientFormVisible = false
$scope.client = {}

$scope.toggleForm = ->
$scope.clientFormVisible = !$scope.clientFormVisible


# Change the order criterion to the one provided
# @param orderBy {string} ordering criterion
##
$scope.setOrder = (orderBy)->
if $scope.order == orderBy
$scope.order = '-'+orderBy
else
$scope.order = orderBy

$scope.saveClient = (client)->
if client.id?
OpenAPIClient.update { id: client.id }, open_api_client: client, (clientResp)->
client = clientResp
growl.success(_t('client_successfully_updated'))
else
OpenAPIClient.save open_api_client: client, (client)->
$scope.clients.push client
growl.success(_t('client_successfully_created'))


$scope.clientFormVisible = false
$scope.clientForm.$setPristine()
$scope.client = {}

$scope.editClient = (client)->
$scope.clientFormVisible = true
$scope.client = client

$scope.deleteClient = (index)->
dialogs.confirm
resolve:
object: ->
title: _t('confirmation_required')
msg: _t('do_you_really_want_to_delete_this_open_api_client')
, ->
OpenAPIClient.delete { id: $scope.clients[index].id }, ->
$scope.clients.splice(index, 1)
growl.success(_t('client_successfully_deleted'))

$scope.resetToken = (client)->
dialogs.confirm
resolve:
object: ->
title: _t('confirmation_required')
msg: _t('do_you_really_want_to_revoke_this_open_api_access')
, ->
OpenAPIClient.resetToken { id: client.id }, {}, (clientResp)->
client.token = clientResp.token
growl.success(_t('access_successfully_revoked'))


]
19 changes: 10 additions & 9 deletions app/assets/javascripts/controllers/admin/plans.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ Application.Controllers.controller 'NewPlanController', ['$scope', '$uibModal',
##
# Controller used in the plan edition form
##
Application.Controllers.controller 'EditPlanController', ['$scope', 'groups', 'plans', 'planPromise', 'machines', 'prices', 'partners', 'CSRF', '$state', '$stateParams', 'growl', '$filter', '_t', '$locale'
, ($scope, groups, plans, planPromise, machines, prices, partners, CSRF, $state, $stateParams, growl, $filter, _t, $locale) ->
Application.Controllers.controller 'EditPlanController', ['$scope', 'groups', 'plans', 'planPromise', 'machines', 'prices', 'partners', 'CSRF', '$state', '$stateParams', 'growl', '$filter', '_t', '$locale', 'Plan'
, ($scope, groups, plans, planPromise, machines, prices, partners, CSRF, $state, $stateParams, growl, $filter, _t, $locale, Plan) ->



Expand Down Expand Up @@ -207,12 +207,13 @@ Application.Controllers.controller 'EditPlanController', ['$scope', 'groups', 'p
##
$scope.copyPricesFromPlan = ->
if $scope.plan.parent
parentPlan = $scope.getPlanFromId($scope.plan.parent)
for parentPrice in parentPlan.prices
for childKey, childPrice of $scope.plan.prices
if childPrice.priceable_type == parentPrice.priceable_type and childPrice.priceable_id == parentPrice.priceable_id
$scope.plan.prices[childKey].amount = parentPrice.amount
break
Plan.get {id: $scope.plan.parent}, (parentPlan) ->
for parentPrice in parentPlan.prices
for childKey, childPrice of $scope.plan.prices
if childPrice.priceable_type == parentPrice.priceable_type and childPrice.priceable_id == parentPrice.priceable_id
$scope.plan.prices[childKey].amount = parentPrice.amount
break

# if no plan were selected, unset every prices
else
for key, price of $scope.plan.prices
Expand Down Expand Up @@ -257,4 +258,4 @@ Application.Controllers.controller 'EditPlanController', ['$scope', 'groups', 'p

## !!! MUST BE CALLED AT THE END of the controller
initialize()
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Application.Controllers.controller "EditPricingController", ["$scope", "$state",

### PUBLIC SCOPE ###
## List of machines prices (not considering any plan)
$scope.machinesPrices = machinesPricesPromise.prices
$scope.machinesPrices = machinesPricesPromise

## List of trainings pricing
$scope.trainingsPricings = trainingsPricingsPromise
Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/controllers/main_nav.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location",
linkText: 'customization'
linkIcon: 'gear'
}
{
state: 'app.admin.open_api_clients'
linkText: 'open_api_clients'
linkIcon: 'cloud'
}
].concat(Fablab.adminNavLinks)

$scope.adminNavLinks = Fablab.adminNavLinks
Expand Down
16 changes: 11 additions & 5 deletions app/assets/javascripts/controllers/projects.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ProjectsController
$('section[ui-view=main]').scrollTop(0, 200)
return
else
$state.go('app.public.projects_show', {id: content.id})
$state.go('app.public.projects_show', {id: content.slug})



Expand Down Expand Up @@ -338,8 +338,8 @@ Application.Controllers.controller "EditProjectController", ["$scope", "$state",
##
# Controller used in the public project's details page
##
Application.Controllers.controller "ShowProjectController", ["$scope", "$state", "projectPromise", '$location', '$uibModal', '_t'
, ($scope, $state, projectPromise, $location, $uibModal, _t) ->
Application.Controllers.controller "ShowProjectController", ["$scope", "$state", "projectPromise", '$location', '$uibModal', 'dialogs', '_t'
, ($scope, $state, projectPromise, $location, $uibModal, dialogs, _t) ->

### PUBLIC SCOPE ###

Expand Down Expand Up @@ -383,8 +383,14 @@ Application.Controllers.controller "ShowProjectController", ["$scope", "$state",
# check the permissions
if $scope.currentUser.role is 'admin' or $scope.projectDeletableBy($scope.currentUser)
# delete the project then refresh the projects list
$scope.project.$delete ->
$state.go('app.public.projects_list', {}, {reload: true})
dialogs.confirm
resolve:
object: ->
title: _t('confirmation_required')
msg: _t('do_you_really_want_to_delete_this_project')
, -> # cancel confirmed
$scope.project.$delete ->
$state.go('app.public.projects_list', {}, {reload: true})
else
console.error _t('unauthorized_operation')

Expand Down
21 changes: 17 additions & 4 deletions app/assets/javascripts/router.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ angular.module('application.router', ['ui.router']).
controller: 'ReserveMachineController'
resolve:
plansPromise: ['Plan', (Plan)->
Plan.query(attributes_requested: "['machines_credits']").$promise
Plan.query().$promise
]
groupsPromise: ['Group', (Group)->
Group.query().$promise
Expand Down Expand Up @@ -362,7 +362,6 @@ angular.module('application.router', ['ui.router']).
translations: [ 'Translations', (Translations) ->
Translations.query(['app.admin.machines_edit', 'app.shared.machine']).$promise
]

# trainings
.state 'app.logged.trainings_reserve',
url: '/trainings/reserve'
Expand All @@ -375,7 +374,7 @@ angular.module('application.router', ['ui.router']).
Setting.get(name: 'training_explications_alert').$promise
]
plansPromise: ['Plan', (Plan)->
Plan.query(attributes_requested: "['trainings_credits']").$promise
Plan.query().$promise
]
groupsPromise: ['Group', (Group)->
Group.query().$promise
Expand Down Expand Up @@ -423,7 +422,7 @@ angular.module('application.router', ['ui.router']).
Setting.get(name: 'subscription_explications_alert').$promise
]
plansPromise: ['Plan', (Plan)->
Plan.query(shallow: true).$promise
Plan.query().$promise
]
groupsPromise: ['Group', (Group)->
Group.query().$promise
Expand Down Expand Up @@ -876,5 +875,19 @@ angular.module('application.router', ['ui.router']).
Translations.query('app.admin.settings').$promise
]

# OpenAPI Clients
.state 'app.admin.open_api_clients',
url: '/open_api_clients'
views:
'main@':
templateUrl: '<%= asset_path "admin/open_api_clients/index.html" %>'
controller: 'OpenAPIClientsController'
resolve:
clientsPromise: ['OpenAPIClient', (OpenAPIClient)->
OpenAPIClient.query().$promise
]
translations: [ 'Translations', (Translations) ->
Translations.query('app.admin.open_api_clients').$promise
]

]
11 changes: 11 additions & 0 deletions app/assets/javascripts/services/open_api_client.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'

Application.Services.factory 'OpenAPIClient', ["$resource", ($resource)->
$resource "/api/open_api_clients/:id",
{id: "@id"},
resetToken:
method: 'PATCH'
url: "/api/open_api_clients/:id/reset_token"
update:
method: 'PUT'
]
2 changes: 1 addition & 1 deletion app/assets/javascripts/services/price.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Application.Services.factory 'Price', ["$resource", ($resource)->
$resource "/api/prices/:id",
{},
query:
isArray: false
isArray: true
update:
method: 'PUT'
compute:
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/app.utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ p, .widget p {
}
}

.exponent {
font-size: 0.7em;
vertical-align: super
}

@media screen and (min-width: $screen-lg-min) {
.b-r-lg {border-right: 1px solid $border-color; }
}
Expand Down
Loading

0 comments on commit 59efdcf

Please sign in to comment.