Allow group name change (#795)

* fix bug on email separator

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

* allow group name change

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

---------

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
Denis Barbaron
2024-07-15 17:03:33 +02:00
committed by GitHub
parent 875730886d
commit cf56911e9f
8 changed files with 99 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019,2023 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var r = require('rethinkdb')
@@ -826,6 +826,31 @@ dbapi.updateDefaultUserGroupsQuotas = function(email, duration, number, repetiti
}}}, {returnChanges: true}))
}
dbapi.updateDeviceGroupName = function(serial, group) {
return db.run(r.table('devices').get(serial).update({group: {
name:
r.branch(
r.expr(apiutil.isOriginGroup(group.class)).eq(false)
, r.branch(
r.expr(group.isActive).eq(true)
, group.name
, r.row('group')('name')
)
, r.branch(
r.row('group')('origin').eq(r.row('group')('id'))
, group.name
, r.row('group')('name')
)
)
, originName:
r.branch(
r.expr(apiutil.isOriginGroup(group.class)).eq(true)
, group.name
, r.row('group')('originName')
)
}}))
}
dbapi.updateDeviceCurrentGroupFromOrigin = function(serial) {
return db.run(r.table('devices').get(serial)).then(function(device) {
return db.run(r.table('groups').get(device.group.origin)).then(function(group) {