Add the User model
This commit is contained in:
parent
4b1272c65a
commit
6be1915955
1
Pipfile
1
Pipfile
@ -8,6 +8,7 @@ flask = "*"
|
||||
flask-sqlalchemy = "*"
|
||||
flask-security = "*"
|
||||
gunicorn = "*"
|
||||
sqlalchemy-utils = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
|
16
Pipfile.lock
generated
16
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "11e0c3bf9031ac561ba1a3392c1a5458ca8ea23c37b21b151921835666171bfa"
|
||||
"sha256": "38fdaedc7c799c04d4612be2649872d71228c1c3f4cd2ca8872b6b0e02d71fc1"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@ -132,6 +132,13 @@
|
||||
],
|
||||
"version": "==2018.4"
|
||||
},
|
||||
"six": {
|
||||
"hashes": [
|
||||
"sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
|
||||
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
|
||||
],
|
||||
"version": "==1.11.0"
|
||||
},
|
||||
"speaklater": {
|
||||
"hashes": [
|
||||
"sha256:59fea336d0eed38c1f0bf3181ee1222d0ef45f3a9dd34ebe65e6bfffdd6a65a9"
|
||||
@ -144,6 +151,13 @@
|
||||
],
|
||||
"version": "==1.2.8"
|
||||
},
|
||||
"sqlalchemy-utils": {
|
||||
"hashes": [
|
||||
"sha256:4119204ff302906015516992b7481e5aabeeaa61c7b04329f9113e42c097b855"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.33.3"
|
||||
},
|
||||
"werkzeug": {
|
||||
"hashes": [
|
||||
"sha256:c3fd7a7d41976d9f44db327260e263132466836cef6f91512889ed60ad26557c",
|
||||
|
69
app/models.py
Normal file
69
app/models.py
Normal file
@ -0,0 +1,69 @@
|
||||
# Albums.social
|
||||
# Copyright (C) 2018 Gergely Polonkai
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from flask_security import UserMixin
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from sqlalchemy_utils.types.choice import ChoiceType
|
||||
|
||||
db = SQLAlchemy()
|
||||
|
||||
|
||||
class User(db.Model, UserMixin):
|
||||
"""Model for the User accounts
|
||||
"""
|
||||
|
||||
__tablename__ = 'users'
|
||||
|
||||
#: Email address is visible only to site administrators, eg. to contact the user
|
||||
EMAIL_ADMIN = 'admin'
|
||||
#: Email address is visible to friends (ie. mutual follows)
|
||||
EMAIL_FRIENDS = 'friends'
|
||||
#: Email address is publicly available
|
||||
EMAIL_PUBLIC = 'public'
|
||||
|
||||
EMAIL_VISIBILITY = (
|
||||
(EMAIL_ADMIN, EMAIL_ADMIN),
|
||||
(EMAIL_FRIENDS, EMAIL_FRIENDS),
|
||||
(EMAIL_PUBLIC, EMAIL_PUBLIC),
|
||||
)
|
||||
|
||||
#: The ID of the user. Generated automatically
|
||||
id = db.Column(db.Integer(), primary_key=True)
|
||||
|
||||
#: The handle of the user. This will be used in the global account name
|
||||
handle = db.Column(db.String(length=255), unique=True)
|
||||
|
||||
#: The hashed password of the user
|
||||
password = db.Column(db.String(length=255))
|
||||
|
||||
#: The email address of the user. It may be hashed in which case it can only be used for
|
||||
#: logging in
|
||||
email = db.Column(db.String(length=255))
|
||||
|
||||
#: Visibility of the user’s email address
|
||||
email_visibility = db.Column(ChoiceType(EMAIL_VISIBILITY), default=EMAIL_ADMIN)
|
||||
|
||||
#: Active flag. If this is ``False``, the user is disabled and cannot use the API in any way
|
||||
active = db.Column(db.Boolean())
|
||||
|
||||
#: The timestamp of the user’s registration
|
||||
registered_at = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||
|
||||
#: The timestamp when the user confirmed the registration. While this field is ``None``, the
|
||||
#: user cannot use the API.
|
||||
confirmed_at = db.Column(db.DateTime())
|
Loading…
Reference in New Issue
Block a user