Commit 59c3792a authored by delanoe's avatar delanoe

[ADMIN] Init accounts for mass creation with group.

parent 06b4cdd5
## Version 3.0.6.2
## TODO
* Guided Tour
* Sources form highlighting crawlers
## 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
## Version 3.0.6
......
......@@ -6,7 +6,6 @@ from datetime import datetime
from .users import User
__all__ = ['Node', 'NodeNode']
class NodeType(TypeDecorator):
......
......@@ -3,11 +3,9 @@ from gargantext.util.db import *
from datetime import datetime
__all__ = ['User']
__all__ = ['User', 'Contact']
class User(Base):
# The properties below are a reflection of Django's auth module's models.
__tablename__ = models.User._meta.db_table
id = Column(Integer, primary_key=True)
......@@ -48,6 +46,7 @@ class User(Base):
return query
def contacts_nodes(self, typename=None):
from .nodes import Node
for contact in self.contacts():
contact_nodes = (session
.query(Node)
......@@ -61,15 +60,16 @@ class User(Base):
"""check if a given node is owned by the user"""
return (node.user_id == self.id) or \
node.id in (contact.id for contact in self.contacts())
def get_params(self, username=None):
print(self.__dict__.items())
return self.hyperdata
class Contact(Base):
__tablename__ = 'contacts'
id = Column(Integer, primary_key=True)
user1_id = Column(Integer, primary_key=True)
user2_id = Column(Integer, primary_key=True)
id = Column(Integer, primary_key=True, autoincrement=True)
user1_id = Column(Integer, ForeignKey(User.id, ondelete='CASCADE'))
user2_id = Column(Integer, ForeignKey(User.id, ondelete='CASCADE'))
is_blocked = Column(Boolean(), default=False)
date_creation = Column(DateTime(timezone=False))
......
......@@ -2,7 +2,9 @@ from gargantext import settings
from gargantext.util.json import json_dumps
########################################################################
# get engine, session, etc.
########################################################################
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import delete
......@@ -25,21 +27,24 @@ Base = declarative_base()
session = scoped_session(sessionmaker(bind=engine))
########################################################################
# tools to build models
########################################################################
from sqlalchemy.types import *
from sqlalchemy.schema import Column, ForeignKey, UniqueConstraint
from sqlalchemy.dialects.postgresql import JSONB, DOUBLE_PRECISION
from sqlalchemy.ext.mutable import MutableDict, MutableList
Double = DOUBLE_PRECISION
########################################################################
# useful for queries
########################################################################
from sqlalchemy.orm import aliased
from sqlalchemy import func, desc
########################################################################
# bulk insertions
########################################################################
import psycopg2
def get_cursor():
......@@ -54,7 +59,6 @@ def get_cursor():
return db, db.cursor()
class bulk_insert:
def __init__(self, table, fields, data, cursor=None):
# prepare the iterator
self.iter = iter(data)
......@@ -85,7 +89,6 @@ class bulk_insert:
readline = read
def bulk_insert_ifnotexists(model, uniquekey, fields, data, cursor=None, do_stats=False):
"""
Inserts bulk data with an intermediate check on a uniquekey
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment