Skip to content

Commit

Permalink
Merge pull request #84 from Bilgecrank/fe-dev-boards
Browse files Browse the repository at this point in the history
Final update for release.
  • Loading branch information
Bilgecrank authored Mar 4, 2024
2 parents a693d16 + 0a407d2 commit 0919218
Show file tree
Hide file tree
Showing 25 changed files with 564 additions and 236 deletions.
2 changes: 0 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import secrets
from dotenv import load_dotenv

load_dotenv()
Expand All @@ -25,5 +24,4 @@ class Config: # pylint: disable=too-few-public-methods
DEBUG = False
TESTING = False
SECRET_KEY = os.getenv('SECRET_KEY')
# SECRET_KEY = secrets.token_hex(32)
SQLALCHEMY_DATABASE_URI = database_uri
8 changes: 4 additions & 4 deletions app/hindsite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def create_app():
app.register_blueprint(auth)

# pylint: disable=wrong-import-position,import-outside-toplevel
from app.hindsite.history.history import history
# from app.hindsite.history.history import history
# pylint: enable=wrong-import-position,import-outside-toplevel
app.register_blueprint(history)
# app.register_blueprint(history)

# pylint: disable=wrong-import-position,import-outside-toplevel
from app.hindsite.home.home import home
# pylint: enable=wrong-import-position,import-outside-toplevel
app.register_blueprint(home)

# pylint: disable=wrong-import-position,import-outside-toplevel
from app.hindsite.group.group import group
from app.hindsite.group.group import grp
# pylint: enable=wrong-import-position,import-outside-toplevel
app.register_blueprint(group)
app.register_blueprint(grp)

# pylint: disable=wrong-import-position,import-outside-toplevel
from app.hindsite.settings.settings import settings
Expand Down
4 changes: 2 additions & 2 deletions app/hindsite/auth/authenticate_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re # For serverside validation of secrets.

import bcrypt
from flask import flash, make_response, redirect, render_template, session, url_for
from flask import flash, make_response, render_template, session, url_for
import flask_login
from app.hindsite.extensions import login_manager, db
from app.hindsite.tables import User, Password
Expand Down Expand Up @@ -213,4 +213,4 @@ def is_users_password(email: str, password):
:return:
"""
stored_password = get_user(email).password.password.encode('utf-8')
return bcrypt.checkpw(password.encode('utf-8'), stored_password)
return bcrypt.checkpw(password.encode('utf-8'), stored_password)
2 changes: 1 addition & 1 deletion app/hindsite/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
from datetime import datetime

from flask import Blueprint, render_template, make_response, session
from flask import Blueprint, render_template, session
from flask_login import login_required, current_user

from app.hindsite.common_model import get_boards
Expand Down
28 changes: 19 additions & 9 deletions app/hindsite/common_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def get_groups(email: str):
return groups

def get_ownership(email: str, group_id: int):
"""
Checks for group ownership
:param email: **str** Email to find the user
:param group_id: **int** Group id to check for ownership in
:returns: **bool** True or False
"""
user = get_user(email)
groups = []
ownership = False
Expand All @@ -78,20 +85,21 @@ def get_group(group_id: int):
return None

def authorized_routes(route_1: Callable, route_2: Callable):
"""
Calls routes based on the value of the facilitator session variable
:route_1: **Callable** route to call if true
:route_2: **Callable** route to call if false
:returns: **Callable** returns the selected route
"""
facilitator = False
if 'facilitator' in session:
facilitator = session.get('facilitator')
if facilitator == True:
if facilitator is True:
return route_1
return route_2

def authorized():
facilitator = False
if 'facilitator' in session:
facilitator = session.get('facilitator')
return facilitator


class BoardError(Exception):
"""
Definition for errors raised by board function
Expand Down Expand Up @@ -182,7 +190,7 @@ def add_card(field: Field, author: 'User', card_message: str):

# READ

def get_board(group_id: int, board_id: int, archive_status=False):
def get_board(group_id: int, board_id: int):
"""
Retrieves the most recent board attached to a group
Expand Down Expand Up @@ -271,6 +279,7 @@ def get_cards(field: Field, archive_status=False):

def get_card(card_id: int, field: Field):
"""
Returns a single card based on the card_id and field
"""
rtn_card = None
for card in field.cards:
Expand Down Expand Up @@ -408,6 +417,7 @@ def toggle_archive_field(field: Field):
db.session.commit()
return field


def toggle_archive_card(card: Card):
"""
Toggles the archive status of a card
Expand Down
11 changes: 5 additions & 6 deletions app/hindsite/group/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from app.hindsite.group.group_model import UserSearchError, get_uninvited_users, get_invited_users

static_dir = os.path.abspath('static')
group = Blueprint('group',
grp = Blueprint('grp',
__name__,
template_folder='templates', # relative route to templates dir
static_folder=static_dir)


@group.route('/group', methods=['GET', 'POST'])
@grp.route('/group', methods=['GET', 'POST'])
@login_required
def group_page():
"""
Expand All @@ -29,7 +29,7 @@ def group_page():
return render_template('group.html', title='Group', users=users)


@group.route('/search-users', methods=['GET', 'POST'])
@grp.route('/search-users', methods=['GET', 'POST'])
@login_required
def search_users():
"""
Expand All @@ -56,7 +56,7 @@ def search_users():
return render_template('partials/search-results.html', users=users, term=search)


@group.route('/send-invite', methods=['GET', 'POST'])
@grp.route('/send-invite', methods=['GET', 'POST'])
@login_required
def send_invite():
"""
Expand All @@ -82,15 +82,14 @@ def send_invite():
return render_template('partials/search-results.html')


@group.route('/invites', methods=['POST', 'GET'])
@grp.route('/invites', methods=['POST', 'GET'])
@login_required
def invites():
"""
Loads all the invite codes to be accepted or rejected
TODO: Put the invite codes into a modal, add decline button, create
notification bell to open the modal.
"""
error = None
if request.method == 'GET':
invitations = get_invitations(current_user.id)
return render_template('partials/invites.html', invitations=invitations)
Expand Down
Loading

0 comments on commit 0919218

Please sign in to comment.