Skip to content

Commit

Permalink
feat(json): use sqlalchemy_json lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
teleyinex committed Dec 13, 2020
1 parent b1d2ed3 commit 2141f67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 3 additions & 6 deletions pybossa/model/user.py
Expand Up @@ -20,7 +20,7 @@
from sqlalchemy.schema import Column
from sqlalchemy.orm import relationship
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.ext.mutable import MutableDict
from sqlalchemy_json import mutable_json_type
from flask_login import UserMixin
from flask import current_app

Expand Down Expand Up @@ -64,25 +64,22 @@ class User(db.Model, DomainObject, UserMixin):
confirmation_email_sent = Column(Boolean, default=False)
subscribed = Column(Boolean, default=False)
consent = Column(Boolean, default=False)
info = Column(MutableDict.as_mutable(JSONB), default=dict())
info = Column(mutable_json_type(dbtype=JSONB, nested=True), default=dict())
user_pref = Column(JSONB)
notified_at = Column(Date, default=None)

## Relationships
# Relationships
task_runs = relationship(TaskRun, backref='user')
projects = relationship(Project, backref='owner')
blogposts = relationship(Blogpost, backref='owner')


def get_id(self):
'''id for login system. equates to name'''
return self.name


def set_password(self, password):
self.passwd_hash = signer.generate_password_hash(password)


def check_password(self, password):
# OAuth users do not have a password
if self.passwd_hash:
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Expand Up @@ -123,6 +123,7 @@
"soupsieve==1.6.1",
"speaklater==1.3",
"SQLAlchemy>=1.3.0",
"sqlalchemy-json==0.4.0",
"stevedore>=1.30.0",
"termstyle==0.1.11",
"text-unidecode==1.2",
Expand All @@ -141,10 +142,10 @@
]

setup(
name = 'pybossa',
version = __version__,
packages = find_packages(),
install_requires = requirements,
name='pybossa',
version=__version__,
packages=find_packages(),
install_requires=requirements,
# only needed when installing directly from setup.py (PyPi, eggs?) and pointing to e.g. a git repo.
# Keep in mind that dependency_links are not used when installing with requirements.txt
# and need to be added redundant to requirements.txt in this case!
Expand Down

0 comments on commit 2141f67

Please sign in to comment.