Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
3d3724d1
Commit
3d3724d1
authored
Apr 10, 2017
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Improving backend needs more features.
parent
0c367b99
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
nodes.py
gargantext/models/nodes.py
+3
-0
users.py
gargantext/models/users.py
+16
-0
rightManagement.py
gargantext/util/rightManagement.py
+48
-0
No files found.
gargantext/models/nodes.py
View file @
3d3724d1
...
...
@@ -216,14 +216,17 @@ class NodeUser(Base):
Example:
A user only node: 700 == rwx --- ---
A user sharing read mode to his group: 740 == rwx r-- ---
A user sharing all rights to his group: 770 == rwx rwx ---
A user sharing to the public (read mode only): 744 == rwx r-- r--
A user sharing rights with group and publc: 774 == rwx rwx r--
"""
__tablename__
=
'node_user'
node_id
=
Column
(
Integer
,
ForeignKey
(
Node
.
id
,
ondelete
=
'CASCADE'
),
primary_key
=
True
)
user_id
=
Column
(
Integer
,
ForeignKey
(
User
.
id
,
ondelete
=
'CASCADE'
))
group_id
=
Column
(
Integer
,
ForeignKey
(
User
.
id
,
ondelete
=
'CASCADE'
))
rules_user
=
Column
(
Integer
)
rules_group
=
Column
(
Integer
)
rules_others
=
Column
(
Integer
)
...
...
gargantext/models/users.py
View file @
3d3724d1
...
...
@@ -177,4 +177,20 @@ class Contact(Base):
__table_args__
=
(
UniqueConstraint
(
'user1_id'
,
'user2_id'
),
)
class
Group
(
Base
):
__tablename__
=
'groups'
id
=
Column
(
Integer
,
primary_key
=
True
)
name
=
Column
(
String
(
60
))
is_active
=
Column
(
Boolean
(),
default
=
True
)
class
GroupUser
(
Base
):
__tablename__
=
'group_user'
id
=
Column
(
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
group_id
=
Column
(
Integer
,
ForeignKey
(
Group
.
id
,
ondelete
=
'CASCADE'
))
user_id
=
Column
(
Integer
,
ForeignKey
(
User
.
id
,
ondelete
=
'CASCADE'
))
__table_args__
=
(
UniqueConstraint
(
'group_id'
,
'user_id'
),
)
gargantext/util/rightManagement.py
0 → 100644
View file @
3d3724d1
from
gargantext.util.db
import
*
#from gargantext.util.db_cache import cache
from
gargantext.models
import
*
def
set_rights_pure
(
nodeUser
,
user
=
None
,
group
=
None
,
others
=
None
):
"""
set_rights :: NodeUser
-> Maybe (Int, Int)
-> Maybe (Int, Int)
-> Maybe Int
-> NodeUser
"""
if
user
is
not
None
:
user_id
,
mode_user
=
user
nodeUser
.
user_id
=
user_id
nodeUser
.
mode_user
=
mode_user
if
group
is
not
None
:
group_id
,
mode_group
=
group
nodeUser
.
group_id
=
group_id
nodeUser
.
mode_group
=
mode_group
if
others
is
not
None
:
nodeUser
.
mode_others
=
others
return
nodeUser
def
set_rights
(
node_id
,
user_id
=
None
,
group_id
=
None
,
rights
=
(
7
,
0
,
0
)):
"""
Set rights of a node
"""
nodeUser
=
session
.
query
(
NodeUser
)
.
filter
(
NodeUser
.
node_id
==
node_id
)
.
first
()
if
nodeUser
is
None
:
nodeUser
=
NodeUser
()
nodeUser
def
share_node
(
node_id
,
user_id
=
None
)
def
share_corpus
(
corpus_id
,
user_id
=
None
,
)
def
share_project
()
def
share_document
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment