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
59c3792a
Commit
59c3792a
authored
Nov 15, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADMIN] Init accounts for mass creation with group.
parent
06b4cdd5
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
235 additions
and
68 deletions
+235
-68
CHANGELOG.md
CHANGELOG.md
+7
-3
nodes.py
gargantext/models/nodes.py
+0
-1
users.py
gargantext/models/users.py
+6
-6
db.py
gargantext/util/db.py
+8
-5
init_accounts.py
init_accounts.py
+214
-53
No files found.
CHANGELOG.md
View file @
59c3792a
## TODO
## Version 3.0.6.2
*
Guided Tour
*
Guided Tour
*
Sources form highlighting crawlers
## Version 3.0.6.1
## Version 3.0.6.1
*
Sources form highlighting crawlers
*
SQL Table change. Update:
*
psql gargandb
*
drop table contacts
*
./manage.py dbmigrate.py
*
Init accounts with ISC-PIF partner group
*
Link to Licence
*
Link to Licence
## Version 3.0.6
## Version 3.0.6
...
...
gargantext/models/nodes.py
View file @
59c3792a
...
@@ -6,7 +6,6 @@ from datetime import datetime
...
@@ -6,7 +6,6 @@ from datetime import datetime
from
.users
import
User
from
.users
import
User
__all__
=
[
'Node'
,
'NodeNode'
]
__all__
=
[
'Node'
,
'NodeNode'
]
class
NodeType
(
TypeDecorator
):
class
NodeType
(
TypeDecorator
):
...
...
gargantext/models/users.py
View file @
59c3792a
...
@@ -3,11 +3,9 @@ from gargantext.util.db import *
...
@@ -3,11 +3,9 @@ from gargantext.util.db import *
from
datetime
import
datetime
from
datetime
import
datetime
__all__
=
[
'User'
]
__all__
=
[
'User'
,
'Contact'
]
class
User
(
Base
):
class
User
(
Base
):
# The properties below are a reflection of Django's auth module's models.
# The properties below are a reflection of Django's auth module's models.
__tablename__
=
models
.
User
.
_meta
.
db_table
__tablename__
=
models
.
User
.
_meta
.
db_table
id
=
Column
(
Integer
,
primary_key
=
True
)
id
=
Column
(
Integer
,
primary_key
=
True
)
...
@@ -48,6 +46,7 @@ class User(Base):
...
@@ -48,6 +46,7 @@ class User(Base):
return
query
return
query
def
contacts_nodes
(
self
,
typename
=
None
):
def
contacts_nodes
(
self
,
typename
=
None
):
from
.nodes
import
Node
for
contact
in
self
.
contacts
():
for
contact
in
self
.
contacts
():
contact_nodes
=
(
session
contact_nodes
=
(
session
.
query
(
Node
)
.
query
(
Node
)
...
@@ -61,15 +60,16 @@ class User(Base):
...
@@ -61,15 +60,16 @@ class User(Base):
"""check if a given node is owned by the user"""
"""check if a given node is owned by the user"""
return
(
node
.
user_id
==
self
.
id
)
or
\
return
(
node
.
user_id
==
self
.
id
)
or
\
node
.
id
in
(
contact
.
id
for
contact
in
self
.
contacts
())
node
.
id
in
(
contact
.
id
for
contact
in
self
.
contacts
())
def
get_params
(
self
,
username
=
None
):
def
get_params
(
self
,
username
=
None
):
print
(
self
.
__dict__
.
items
())
print
(
self
.
__dict__
.
items
())
return
self
.
hyperdata
return
self
.
hyperdata
class
Contact
(
Base
):
class
Contact
(
Base
):
__tablename__
=
'contacts'
__tablename__
=
'contacts'
id
=
Column
(
Integer
,
primary_key
=
True
)
id
=
Column
(
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
user1_id
=
Column
(
Integer
,
primary_key
=
True
)
user1_id
=
Column
(
Integer
,
ForeignKey
(
User
.
id
,
ondelete
=
'CASCADE'
)
)
user2_id
=
Column
(
Integer
,
primary_key
=
True
)
user2_id
=
Column
(
Integer
,
ForeignKey
(
User
.
id
,
ondelete
=
'CASCADE'
)
)
is_blocked
=
Column
(
Boolean
(),
default
=
False
)
is_blocked
=
Column
(
Boolean
(),
default
=
False
)
date_creation
=
Column
(
DateTime
(
timezone
=
False
))
date_creation
=
Column
(
DateTime
(
timezone
=
False
))
...
...
gargantext/util/db.py
View file @
59c3792a
...
@@ -2,7 +2,9 @@ from gargantext import settings
...
@@ -2,7 +2,9 @@ from gargantext import settings
from
gargantext.util.json
import
json_dumps
from
gargantext.util.json
import
json_dumps
########################################################################
# get engine, session, etc.
# get engine, session, etc.
########################################################################
from
sqlalchemy.orm
import
sessionmaker
,
scoped_session
from
sqlalchemy.orm
import
sessionmaker
,
scoped_session
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy
import
delete
from
sqlalchemy
import
delete
...
@@ -25,21 +27,24 @@ Base = declarative_base()
...
@@ -25,21 +27,24 @@ Base = declarative_base()
session
=
scoped_session
(
sessionmaker
(
bind
=
engine
))
session
=
scoped_session
(
sessionmaker
(
bind
=
engine
))
########################################################################
# tools to build models
# tools to build models
########################################################################
from
sqlalchemy.types
import
*
from
sqlalchemy.types
import
*
from
sqlalchemy.schema
import
Column
,
ForeignKey
,
UniqueConstraint
from
sqlalchemy.schema
import
Column
,
ForeignKey
,
UniqueConstraint
from
sqlalchemy.dialects.postgresql
import
JSONB
,
DOUBLE_PRECISION
from
sqlalchemy.dialects.postgresql
import
JSONB
,
DOUBLE_PRECISION
from
sqlalchemy.ext.mutable
import
MutableDict
,
MutableList
from
sqlalchemy.ext.mutable
import
MutableDict
,
MutableList
Double
=
DOUBLE_PRECISION
Double
=
DOUBLE_PRECISION
########################################################################
# useful for queries
# useful for queries
########################################################################
from
sqlalchemy.orm
import
aliased
from
sqlalchemy.orm
import
aliased
from
sqlalchemy
import
func
,
desc
from
sqlalchemy
import
func
,
desc
########################################################################
# bulk insertions
# bulk insertions
########################################################################
import
psycopg2
import
psycopg2
def
get_cursor
():
def
get_cursor
():
...
@@ -54,7 +59,6 @@ def get_cursor():
...
@@ -54,7 +59,6 @@ def get_cursor():
return
db
,
db
.
cursor
()
return
db
,
db
.
cursor
()
class
bulk_insert
:
class
bulk_insert
:
def
__init__
(
self
,
table
,
fields
,
data
,
cursor
=
None
):
def
__init__
(
self
,
table
,
fields
,
data
,
cursor
=
None
):
# prepare the iterator
# prepare the iterator
self
.
iter
=
iter
(
data
)
self
.
iter
=
iter
(
data
)
...
@@ -85,7 +89,6 @@ class bulk_insert:
...
@@ -85,7 +89,6 @@ class bulk_insert:
readline
=
read
readline
=
read
def
bulk_insert_ifnotexists
(
model
,
uniquekey
,
fields
,
data
,
cursor
=
None
,
do_stats
=
False
):
def
bulk_insert_ifnotexists
(
model
,
uniquekey
,
fields
,
data
,
cursor
=
None
,
do_stats
=
False
):
"""
"""
Inserts bulk data with an intermediate check on a uniquekey
Inserts bulk data with an intermediate check on a uniquekey
...
...
init_accounts.py
View file @
59c3792a
This diff is collapsed.
Click to expand it.
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