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

chore:improved github actions to use a matrix #1079

Merged
merged 5 commits into from
May 1, 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
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ jobs:
build:
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.9]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to use latest for a matrix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK it only accepts numerical values but giving a try with latest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epicadk it isn't possible , will revert the changes


steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
22 changes: 11 additions & 11 deletions app/database/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class UserModel(db.Model):
available_to_mentor = db.Column(db.Boolean)

def __init__(self, name, username, password, email, terms_and_conditions_checked):
"""Initialises userModel class with name, username, password, email, and terms_and_conditions_checked. """
"""Initialises userModel class with name, username, password, email, and terms_and_conditions_checked."""
## required fields

self.name = name
Expand Down Expand Up @@ -109,49 +109,49 @@ def json(self):
}

def __repr__(self):
"""Returns the user's name and username. """
"""Returns the user's name and username."""
return f"User name {self.name} . Username is {self.username} ."

@classmethod
def find_by_username(cls, username: str) -> "UserModel":
"""Returns the user that has the username we searched for. """
"""Returns the user that has the username we searched for."""
return cls.query.filter_by(username=username).first()

@classmethod
def find_by_email(cls, email: str) -> "UserModel":
"""Returns the user that has the email we searched for. """
"""Returns the user that has the email we searched for."""
return cls.query.filter_by(email=email).first()

@classmethod
def find_by_id(cls, _id: int) -> "UserModel":
"""Returns the user that has the id we searched for. """
"""Returns the user that has the id we searched for."""
return cls.query.filter_by(id=_id).first()

@classmethod
def get_all_admins(cls, is_admin=True):
"""Returns all the admins. """
"""Returns all the admins."""
return cls.query.filter_by(is_admin=is_admin).all()

@classmethod
def is_empty(cls) -> bool:
"""Returns a boolean if the Usermodel is empty or not. """
"""Returns a boolean if the Usermodel is empty or not."""
return cls.query.first() is None

def set_password(self, password_plain_text: str) -> None:
"""Sets user password when they create an account or when they are changing their password. """
"""Sets user password when they create an account or when they are changing their password."""
self.password_hash = generate_password_hash(password_plain_text)

# checks if password is the same, using its hash
def check_password(self, password_plain_text: str) -> bool:
"""Returns a boolean if password is the same as it hash or not. """
"""Returns a boolean if password is the same as it hash or not."""
return check_password_hash(self.password_hash, password_plain_text)

def save_to_db(self) -> None:
"""Adds a user to the database. """
"""Adds a user to the database."""
db.session.add(self)
db.session.commit()

def delete_from_db(self) -> None:
"""Deletes a user from the database. """
"""Deletes a user from the database."""
db.session.delete(self)
db.session.commit()