Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: Add BIT user attributes to MS User #1074

Merged
merged 1 commit into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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