Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gdd-sigma-poc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume WANG
gdd-sigma-poc
Commits
e56df0d6
Commit
e56df0d6
authored
7 years ago
by
Anatole ROMON
Browse files
Options
Downloads
Patches
Plain Diff
travail sur les membres
parent
d291a0e0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
db/seeds/01_create_groups.js
+7
-0
7 additions, 0 deletions
db/seeds/01_create_groups.js
src/graphql/connectors/connectors.js
+57
-5
57 additions, 5 deletions
src/graphql/connectors/connectors.js
src/graphql/resolvers.js
+6
-2
6 additions, 2 deletions
src/graphql/resolvers.js
with
70 additions
and
7 deletions
db/seeds/01_create_groups.js
+
7
−
0
View file @
e56df0d6
...
@@ -21,6 +21,13 @@ exports.seed = function(knex, Promise) {
...
@@ -21,6 +21,13 @@ exports.seed = function(knex, Promise) {
school
:
'
polytechnique
'
,
school
:
'
polytechnique
'
,
parentuid
:
'
kes
'
,
parentuid
:
'
kes
'
,
type
:
'
simple
'
type
:
'
simple
'
},{
name
:
'
Faërix
'
,
uid
:
'
faerix
'
,
website
:
'
faerix.net
'
,
school
:
'
polytechnique
'
,
parentuid
:
'
kes
'
,
type
:
'
simple
'
},{
},{
name
:
'
Bôbar
'
,
name
:
'
Bôbar
'
,
uid
:
'
bob
'
,
uid
:
'
bob
'
,
...
...
This diff is collapsed.
Click to expand it.
src/graphql/connectors/connectors.js
+
57
−
5
View file @
e56df0d6
...
@@ -264,8 +264,9 @@ export async function getAllVisibleGroups(user){
...
@@ -264,8 +264,9 @@ export async function getAllVisibleGroups(user){
* @return {Promise(Boolean)} Boolean indiquant si l'utilisateur est membre du groupe.
* @return {Promise(Boolean)} Boolean indiquant si l'utilisateur est membre du groupe.
* @rights user
* @rights user
*/
*/
export
const
isMember
=
(
user
,
groupUID
)
=>
{
export
async
function
isMember
(
user
,
groupUID
){
return
listerGroupes
(
user
,
user
.
uid
).
then
(
group_ids
=>
group_ids
&&
group_ids
.
indexOf
(
groupUID
)
!=
-
1
);
let
member_list
=
await
getGroupMemberUsers
(
user
,
groupUID
);
return
member_list
&&
member_list
.
indexOf
(
groupUID
)
!=
-
1
;
};
};
/**
/**
...
@@ -462,8 +463,7 @@ export const getMetaGroupAdminMembers = (user, metaGroupUID) => {
...
@@ -462,8 +463,7 @@ export const getMetaGroupAdminMembers = (user, metaGroupUID) => {
};
};
/**
/**
* @function getMetaGroupMembers
* @summary Renvoie un callback qui génère tous les membres d'un meta-groupe.
* @summary Renvoie tous les membres d'un meta-groupe.
* @param {Object} user - Utilisateur effectuant la requête.
* @param {Object} user - Utilisateur effectuant la requête.
* @param {String} metaGroupUID - Identifiant unique du groupe.
* @param {String} metaGroupUID - Identifiant unique du groupe.
* @return {Promise(callback)} a callback to build a query for the members of a group
* @return {Promise(callback)} a callback to build a query for the members of a group
...
@@ -478,4 +478,56 @@ export async function getMetaGroupMembersCallback(user, metaGroupUID){
...
@@ -478,4 +478,56 @@ export async function getMetaGroupMembersCallback(user, metaGroupUID){
.
innerJoin
(
'
meta_group_membership
'
,
'
groups.uid
'
,
'
meta_group_membership.member_uid
'
)
.
innerJoin
(
'
meta_group_membership
'
,
'
groups.uid
'
,
'
meta_group_membership.member_uid
'
)
.
where
(
'
meta_group_membership.union_uid
'
,
'
=
'
,
metaGroupUID
);
.
where
(
'
meta_group_membership.union_uid
'
,
'
=
'
,
metaGroupUID
);
};
};
};
};
\ No newline at end of file
/**
* @summary Renvoie un callback qui génère tous les membres admin d'un meta-groupe.
* @param {Object} user - Utilisateur effectuant la requête.
* @param {String} metaGroupUID - Identifiant unique du groupe.
* @return {Promise(callback)} a callback to build a query for the admin members of a group
* @author akka vodol
* @rights member(metaGroupUID)
*/
export
async
function
getMetaGroupAdminMembersCallback
(
user
,
metaGroupUID
){
return
function
(
query_builder
){
return
query_builder
.
distinct
().
select
().
from
(
'
groups
'
)
.
innerJoin
(
'
meta_group_membership
'
,
'
groups.uid
'
,
'
meta_group_membership.member_uid
'
)
.
where
(
'
meta_group_membership.union_uid
'
,
'
=
'
,
metaGroupUID
)
.
where
(
'
meta_group_membership.status
'
,
'
=
'
,
'
admin
'
);
};
};
/**
* @summary Renvoie les membres d'un groupe quelquonque.
* @param {Object} user - Utilisateur effectuant la requête.
* @param {String} metaGroupUID - Identifiant unique du groupe.
* @return {Promise(List)} Une liste des uid de tous les membres du groupe
* @author akka vodol
* @rights member(metaGroupUID)
*/
export
async
function
getGroupMemberUsers
(
user
,
GroupUID
){
switch
(
await
getGroupType
(
user
,
GroupUID
)
){
case
"
simple
"
:
return
listerMembres
(
user
,
GroupUID
);
case
"
meta
"
:
return
getMetaGroupMemberUsers
(
user
,
GroupUID
);
default
:
return
undefined
;
}
};
/**
* @summary Renvoie les membres d'un meta groupe.
* @param {Object} user - Utilisateur effectuant la requête.
* @param {String} metaGroupUID - Identifiant unique du groupe.
* @return {Promise(List)} Une liste des uid de tous les membres du groupe
* @author akka vodol
* @rights member(metaGroupUID)
*/
export
async
function
getMetaGroupMemberUsers
(
user
,
metaGroupUID
){
let
member_group_list
=
await
getMetaGroupMembersCallback
(
user
,
metaGroupUID
).
then
(
cb
=>
cb
(
knex
));
let
members
=
[];
for
(
memberGroup
of
await
member_group_list
){
members
=
members
.
concat
(
getGroupMemberUsers
(
user
,
metaGroupUID
));
}
};
This diff is collapsed.
Click to expand it.
src/graphql/resolvers.js
+
6
−
2
View file @
e56df0d6
...
@@ -23,8 +23,12 @@ export const resolvers = {
...
@@ -23,8 +23,12 @@ export const resolvers = {
throw
"
You do not have admin rights over this group
"
;
throw
"
You do not have admin rights over this group
"
;
},
},
asMember
:
function
(
obj
,
args
,
context
){
asMember
:
async
function
(
obj
,
args
,
context
){
return
{
groupUID
:
args
.
groupUID
};
if
(
await
connectors
.
isMember
(
context
.
user
,
args
.
groupUID
)
||
connectors
.
hasAdminRights
(
context
.
user
,
args
.
groupUID
))
return
{
groupUID
:
args
.
groupUID
};
else
throw
"
You do not have member rights over this group
"
;
},
},
accessGroups
:
(
obj
,
args
,
context
)
=>
{
accessGroups
:
(
obj
,
args
,
context
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment