Skip to content

Commit

Permalink
refactor: role has its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Mar 27, 2024
1 parent f5f7293 commit e965577
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions web/b3desk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def setup_database(app):


def setup_jinja(app):
from b3desk.models.meetings import Role
from b3desk.models.roles import Role
from b3desk.session import get_current_user
from b3desk.session import has_user_session

Expand Down Expand Up @@ -147,7 +147,7 @@ def global_processor():
def setup_flask(app):
with app.app_context():
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import Role
from b3desk.models.roles import Role
from b3desk.models.users import User

for model in (Meeting, User):
Expand Down
2 changes: 1 addition & 1 deletion web/b3desk/endpoints/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import Blueprint
from flask import request

from b3desk.models.meetings import Role
from b3desk.models.roles import Role
from b3desk.models.users import get_or_create_user

from .. import auth
Expand Down
2 changes: 1 addition & 1 deletion web/b3desk/endpoints/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from b3desk.forms import JoinMeetingForm
from b3desk.models import db
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import Role
from b3desk.models.meetings import get_mail_meeting
from b3desk.models.meetings import get_meeting_from_meeting_id_and_user_id
from b3desk.models.roles import Role

from .. import auth
from ..session import get_authenticated_attendee_fullname
Expand Down
2 changes: 1 addition & 1 deletion web/b3desk/endpoints/meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from b3desk.forms import ShowMeetingForm
from b3desk.models import db
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import Role
from b3desk.models.meetings import get_quick_meeting_from_user_and_random_string
from b3desk.models.roles import Role
from b3desk.models.users import User

from .. import auth
Expand Down
4 changes: 1 addition & 3 deletions web/b3desk/models/bbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from b3desk.tasks import background_upload

from .. import cache
from .roles import Role


def cache_key(func, caller, prepped, *args, **kwargs):
Expand Down Expand Up @@ -86,7 +87,6 @@ def is_meeting_running(self):

def create(self):
"""https://docs.bigbluebutton.org/development/api/#create"""
from .meetings import Role

params = {
"meetingID": self.meeting.meetingID,
Expand Down Expand Up @@ -270,8 +270,6 @@ def update_recordings(self, recording_ids, metadata):
def prepare_request_to_join_bbb(self, meeting_role, fullname):
"""https://docs.bigbluebutton.org/dev/api.html#join"""

from .meetings import Role

params = {
"fullName": fullname,
"meetingID": self.meeting.meetingID,
Expand Down
8 changes: 1 addition & 7 deletions web/b3desk/models/meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import hashlib
from datetime import datetime
from datetime import timedelta
from enum import StrEnum

from flask import current_app
from flask import url_for
Expand All @@ -21,17 +20,12 @@
from b3desk.utils import secret_key

from . import db
from .roles import Role
from .users import User

MODERATOR_ONLY_MESSAGE_MAXLENGTH = 150


class Role(StrEnum):
attendee = "attendee"
moderator = "moderator"
authenticated = "authenticated"


class MeetingFiles(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.Unicode(4096))
Expand Down
7 changes: 7 additions & 0 deletions web/b3desk/models/roles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from enum import StrEnum


class Role(StrEnum):
attendee = "attendee"
moderator = "moderator"
authenticated = "authenticated"
3 changes: 1 addition & 2 deletions web/b3desk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from werkzeug.routing import BaseConverter

from b3desk.models import db
from b3desk.models.roles import Role


def secret_key():
Expand Down Expand Up @@ -57,8 +58,6 @@ def get_random_alphanumeric_string(length):


def send_quick_meeting_mail(meeting, to_email):
from b3desk.models.meetings import Role

smtp_from = current_app.config["SMTP_FROM"]
smtp_host = current_app.config["SMTP_HOST"]
smtp_port = current_app.config["SMTP_PORT"]
Expand Down
2 changes: 1 addition & 1 deletion web/tests/meeting/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from flask import url_for

from b3desk.models.meetings import Role
from b3desk.models.roles import Role


def test_signin_meeting(client_app, meeting, user, bbb_response):
Expand Down
3 changes: 1 addition & 2 deletions web/tests/meeting/test_meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from b3desk.models.meetings import MODERATOR_ONLY_MESSAGE_MAXLENGTH
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import MeetingFiles
from b3desk.models.meetings import Role
from b3desk.models.roles import Role


@pytest.fixture()
Expand Down Expand Up @@ -536,7 +536,6 @@ def test_create_without_logout_url_gets_default(

def test_create_quick_meeting(client_app, monkeypatch, user, mocker, bbb_response):
from b3desk.endpoints.meetings import get_quick_meeting_from_user_and_random_string
from b3desk.models.meetings import Role

mocker.patch("b3desk.tasks.background_upload.delay", return_value=True)
monkeypatch.setattr("b3desk.models.users.User.id", 1)
Expand Down

0 comments on commit e965577

Please sign in to comment.