Skip to content

Commit

Permalink
Dev: Add BIT user attributes to MS User table
Browse files Browse the repository at this point in the history
remove BIT attrributes from being returned in _repr_(self)

remove unnecessary brackets

Fix description

add bit branch to github action

fix black linting error

Remove alembic auto-generated comments
  • Loading branch information
mtreacy002 committed May 2, 2021
1 parent ca4728a commit 81f739c
Show file tree
Hide file tree
Showing 5 changed files with 1,248 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Lint Code and Run Tests

on:
pull_request:
branches: [develop]
branches: [develop, bit]
push:
branches: [develop]
branches: [develop, bit]

jobs:
lint:
Expand Down
14 changes: 14 additions & 0 deletions app/database/models/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from werkzeug.security import generate_password_hash, check_password_hash
import time
from app.database.sqlalchemy_extension import db
from app.database.db_types.JsonCustomType import JsonCustomType
from app.utils.bitschema_utils import Timezone


class UserModel(db.Model):
Expand All @@ -12,6 +14,9 @@ class UserModel(db.Model):
password: A string for storing the user's password.
email: A string for storing user email.
terms_and_conditions_checked: A boolean indicating if user has agreed to terms and conditions or not.
is_organization_rep: A boolean indicating that user is a organization representative.
additional_info: A json object for storing other information of the user.
timezone: A string for storing user timezone information.
"""

# Specifying database table used for UserModel
Expand Down Expand Up @@ -56,6 +61,9 @@ class UserModel(db.Model):

need_mentoring = db.Column(db.Boolean)
available_to_mentor = db.Column(db.Boolean)
is_organization_rep = db.Column(db.Boolean)
additional_info = db.Column(JsonCustomType)
timezone = db.Column(db.Enum(Timezone))

def __init__(self, name, username, password, email, terms_and_conditions_checked):
"""Initialises userModel class with name, username, password, email, and terms_and_conditions_checked."""
Expand All @@ -73,11 +81,14 @@ def __init__(self, name, username, password, email, terms_and_conditions_checked
self.is_admin = True if self.is_empty() else False # first user is admin
self.is_email_verified = False
self.registration_date = time.time()
self.is_organization_rep = False

## optional fields

self.need_mentoring = False
self.available_to_mentor = False
self.additional_info = None
self.timezone = Timezone.GMT0

def json(self):
"""Returns Usermodel object in json format."""
Expand Down Expand Up @@ -106,6 +117,9 @@ def json(self):
"photo_url": self.photo_url,
"need_mentoring": self.need_mentoring,
"available_to_mentor": self.available_to_mentor,
"is_organization_rep": self.is_organization_rep,
"additional_info": self.additional_info,
"timezone": self.timezone,
}

def __repr__(self):
Expand Down
Loading

0 comments on commit 81f739c

Please sign in to comment.