Skip to content

Commit

Permalink
Merge pull request #125 from numerique-gouv/main
Browse files Browse the repository at this point in the history
Prepare new release
  • Loading branch information
LoanR authored Apr 22, 2024
2 parents f9d08d9 + 6934e8f commit 9c391fc
Show file tree
Hide file tree
Showing 21 changed files with 509 additions and 549 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Check_local_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
strategy:
matrix:
python:
- '3.12'
- '3.11'
- '3.10'
- '3.9'
- '3.8'

steps:
- name: Setup git
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ web-local.env
*.swp

messages.mo
.tox
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ repos:
rev: v3.15.2
hooks:
- id: pyupgrade
args: ["--py38-plus"]
args: ["--py39-plus"]
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Le projet est organisé de la façon suivante :

- Les modification sont faites sur une `branche` de votre **fork**.
- Lorsque le développement est prêt, une *pull request* vers la branche `main` du projet d'*origine* est réalisée
- Une fois ce {doc}`développement validé <../maintainers/pullRequestValidation>`, les mainteneurs du projet vont *merger* ces modifications sur `main`
- Une fois ce {doc}`développement validé <../maintainers/codeReview>`, les mainteneurs du projet vont *merger* ces modifications sur `main`
- Lorsque suffisamment de modifications sont faites dans `main`, les mainteneurs peuvent décider de créer une nouvelle version du projet
- La branche `main` est *mergée* dans la branche `production`, référente pour les déploiements du projet B3Desk

Expand Down
468 changes: 203 additions & 265 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "b3desk"
version = "1.2.1"
version = "1.2.2dev"
description = "Outil de visioconférence pour les agents de l'Education Nationale et de l'Etat en général."
authors = ["Your Name <you@example.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
python = ">=3.9,<4.0"
celery = "^5.2.7"
filetype = "^1.2.0"
flask = "^3.0.0"
Expand Down Expand Up @@ -82,10 +82,10 @@ isolated_build = true
skipsdist = true
envlist =
style
py38
py39
py310
py311
py312
coverage
doc
Expand All @@ -109,7 +109,7 @@ commands =
[testenv:doc]
commands =
poetry install --with doc
poetry run sphinx-build documentation build/sphinx/html
poetry run sphinx-build -W --keep-going documentation build/sphinx/html
"""

[tool.coverage.run]
Expand Down
3 changes: 2 additions & 1 deletion web/b3desk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .utils import enum_converter
from .utils import model_converter

__version__ = "1.2.1"
__version__ = "1.2.2dev"

LANGUAGES = ["en", "fr"]

Expand Down Expand Up @@ -134,6 +134,7 @@ def global_processor():
return {
"config": app.config,
"beta": app.config["BETA"],
"development_version": __version__ == "0.0.0" or "dev" in __version__,
"documentation_link": app.config["DOCUMENTATION_LINK"],
"is_rie": is_rie(),
"version": __version__,
Expand Down
20 changes: 12 additions & 8 deletions web/b3desk/endpoints/meeting_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ def download_meeting_files(meeting: Meeting, owner: User, file_id=None):
def insertDocuments(meeting: Meeting):
from flask import request

files_title = request.get_json()
filenames = request.get_json()
secret_key = current_app.config["SECRET_KEY"]

xml_beg = "<?xml version='1.0' encoding='UTF-8'?> <modules> <module name='presentation'> "
xml_end = " </module></modules>"
xml_mid = ""
# @FIX We ONLY send the documents that have been uploaded NOW, not ALL of them for this meetingid ;)
for cur_file in files_title:
id = add_external_meeting_file_nextcloud(cur_file, meeting.id)
for filename in filenames:
id = add_external_meeting_file_nextcloud(filename, meeting.id)
filehash = hashlib.sha1(
f"{secret_key}-1-{id}-{secret_key}".encode()
).hexdigest()
Expand All @@ -174,9 +174,10 @@ def insertDocuments(meeting: Meeting):
isexternal=1,
mfid=id,
mftoken=filehash,
filename=filename,
_external=True,
)
xml_mid += f"<document url='{url}' filename='{cur_file}' />"
xml_mid += f"<document url='{url}' filename='{filename}' />"

bbb_endpoint = current_app.config["BIGBLUEBUTTON_ENDPOINT"]
xml = xml_beg + xml_mid + xml_end
Expand Down Expand Up @@ -392,7 +393,7 @@ def add_meeting_file_nextcloud(path, meeting_id, is_default):
)

meeting_file = MeetingFiles(
title=path,
title=path.split("/")[-1],
created_at=date.today(),
meeting_id=meeting_id,
nc_path=path,
Expand Down Expand Up @@ -546,6 +547,7 @@ def insertDoc(token):
isexternal=0,
mfid=meeting_file.id,
mftoken=meeting_file.download_hash,
filename=meeting_file.title,
_external=True,
)
xml = f"<?xml version='1.0' encoding='UTF-8'?> <modules> <module name='presentation'><document url='{url}' filename='{meeting_file.title}' /> </module></modules>"
Expand All @@ -561,8 +563,8 @@ def insertDoc(token):


@bp.route("/ncdownload/<int:isexternal>/<mfid>/<mftoken>")
# @auth.token_auth(provider_name="default") - must be accessible by BBB server, so no auth
def ncdownload(isexternal, mfid, mftoken):
@bp.route("/ncdownload/<int:isexternal>/<mfid>/<mftoken>/<filename>")
def ncdownload(isexternal, mfid, mftoken, filename=None):
secret_key = current_app.config["SECRET_KEY"]
# select good file from token
# get file through NC credentials - HOW POSSIBLE ?
Expand Down Expand Up @@ -607,4 +609,6 @@ def ncdownload(isexternal, mfid, mftoken):
return jsonify(status=500, msg="La connexion avec Nextcloud semble rompue")

# send the downloaded file to the BBB:
return send_from_directory(TMP_DOWNLOAD_DIR, uniqfile)
return send_from_directory(
TMP_DOWNLOAD_DIR, uniqfile, download_name=meeting_file.title
)
14 changes: 12 additions & 2 deletions web/b3desk/models/bbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ def bbb_request(self, action, method="GET", **kwargs):
)
def bbb_response(self, request):
session = requests.Session()
current_app.logger.debug("BBB API request %s: %s", request.method, request.url)
current_app.logger.debug(
"BBB API request method:%s url:%s data:%s",
request.method,
request.url,
request.body,
)
response = session.send(request)
current_app.logger.debug("BBB API response %s", response.text)
return {c.tag: c.text for c in ElementTree.fromstring(response.content)}

bbb_response.make_cache_key = cache_key
Expand Down Expand Up @@ -221,7 +227,9 @@ def get_recordings(self):
request = self.bbb_request(
"getRecordings", params={"meetingID": self.meeting.meetingID}
)
current_app.logger.debug("BBB API request %s: %s", request.method, request.url)
current_app.logger.debug(
"BBB API request method:%s url:%s", request.method, request.url
)
response = requests.Session().send(request)

root = ElementTree.fromstring(response.content)
Expand Down Expand Up @@ -316,7 +324,9 @@ def meeting_file_addition_xml(self, meeting_files):
isexternal=0,
mfid=meeting_file.id,
mftoken=filehash,
filename=meeting_file.title,
_external=True,
_scheme=current_app.config["PREFERRED_URL_SCHEME"],
)
xml_mid += f"<document downloadable='{'true' if meeting_file.is_downloadable else 'false'}' url='{url}' filename='{meeting_file.title}' />"

Expand Down
18 changes: 8 additions & 10 deletions web/b3desk/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import json
from typing import Annotated
from typing import Any
from typing import Dict
from typing import List
from typing import Optional

from flask_babel import lazy_gettext as _
Expand All @@ -24,7 +22,7 @@ def split_comma_separated_strings(value):
return map(str.strip, value.split(","))


ListOfStrings = Annotated[List[str], BeforeValidator(split_comma_separated_strings)]
ListOfStrings = Annotated[list[str], BeforeValidator(split_comma_separated_strings)]


AVAILABLE_WORDINGS = {
Expand Down Expand Up @@ -231,7 +229,7 @@ class MainSettings(BaseSettings):
MAX_MEETINGS_PER_USER: int = 50
"""Le nombre maximum de séminaires que peut créer un utilisateur."""

ALLOWED_MIME_TYPES_SERVER_SIDE: Optional[List[str]] = [
ALLOWED_MIME_TYPES_SERVER_SIDE: Optional[list[str]] = [
"application/pdf",
"image/vnd.dwg",
"image/x-xcf",
Expand Down Expand Up @@ -268,9 +266,9 @@ class MainSettings(BaseSettings):
@field_validator("ALLOWED_MIME_TYPES_SERVER_SIDE", mode="before")
def get_allowed_mime_types_server_side(
cls,
allowed_mime_types_server_side: Optional[List[str]],
allowed_mime_types_server_side: Optional[list[str]],
info: ValidationInfo,
) -> List[str]:
) -> list[str]:
if not allowed_mime_types_server_side:
return []

Expand Down Expand Up @@ -318,7 +316,7 @@ def get_allowed_mime_types_server_side(
https://flask-pyoidc.readthedocs.io/en/latest/api.html?highlight=userinfo_http_method#flask_pyoidc.provider_configuration.ProviderConfiguration
"""

OIDC_INFO_REQUESTED_FIELDS: List[str] = ["email", "given_name", "family_name"]
OIDC_INFO_REQUESTED_FIELDS: list[str] = ["email", "given_name", "family_name"]
"""Probablement un relicat de flask-oidc, semble inutilisé."""

OIDC_ISSUER: Optional[str] = None
Expand Down Expand Up @@ -492,7 +490,7 @@ def get_attendee_attendee_scopes(
"""Semble inutilisé."""

@computed_field
def DOCUMENTATION_LINK(self) -> Dict[str, Any]:
def DOCUMENTATION_LINK(self) -> dict[str, Any]:
return {
"url": self.DOCUMENTATION_LINK_URL,
"label": self.DOCUMENTATION_LINK_LABEL,
Expand Down Expand Up @@ -821,7 +819,7 @@ def get_meeting_mail_subject(
"""Sous-titre de la page de documentation."""

@computed_field
def WORDINGS(self) -> Dict[str, Any]:
def WORDINGS(self) -> dict[str, Any]:
return {
"a_meeting": self.WORDING_A_MEETING,
"the_meeting": self.WORDING_THE_MEETING,
Expand Down Expand Up @@ -960,7 +958,7 @@ def get_moderator_welcome_message(

@field_validator("EMAIL_WHITELIST")
def get_email_whitelist(
cls, email_whitelist: List[str], info: ValidationInfo
cls, email_whitelist: list[str], info: ValidationInfo
) -> str:
if not email_whitelist:
return DEFAULT_EMAIL_WHITELIST
Expand Down
10 changes: 2 additions & 8 deletions web/b3desk/static/js/meeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,9 @@ function add_URL_file(name, from) {
return ;
}
// si pas de https:// renseigné, on le force en préfixe, si c'est du http, la personne devra corriger d'elle-même
if (!name.match(/^http/)) name = `https://${name}`;
//simple copy as we are fetch in asynchronous mode
var URL_to_fetch = name;
// gestion if name > 50 char, reduce its printing
if (name.length > 80 ) {
var splitted = name.split(['/']);
name = splitted[2] + '/' + splitted[3] + '.../' + splitted.slice(-1).slice(-20);
if (!name.match(/^http/)) {
name = `https://${name}`;
}

link_file_to_meeting(name, 'URL');

}
Expand Down
5 changes: 3 additions & 2 deletions web/b3desk/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

@celery.task(name="background_upload")
def background_upload(endpoint, xml):
requests.post(
response = requests.post(
endpoint,
headers={"Content-Type": "application/xml"},
data=xml,
)
logger.info(f"adding background files endpoint:{endpoint} xml:{xml}")
logger.info("BBB API request %s: xml:%s", endpoint, xml)
logger.info("BBB API response %s", response.text)
return True
6 changes: 5 additions & 1 deletion web/b3desk/templates/brand.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
<p class="fr-header__service-title">
{% trans %}{{ service_title }}{% endtrans %}
{% if config.get("BETA") %}
<span class="fr-badge fr-badge--sm fr-badge--green-emeraude">BETA</span>
{% if development_version %}
<span class="fr-badge fr-badge--sm fr-badge--warning">DEV</span>
{% else %}
<span class="fr-badge fr-badge--sm fr-badge--green-emeraude">BETA</span>
{% endif %}
{% endif %}
</p>
</a>
Expand Down
2 changes: 1 addition & 1 deletion web/b3desk/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% trans %}Le code source est ouvert et les contributions sont bienvenues.{% endtrans %}
<a title="{% trans %}Voir le code source - nouvelle fenêtre{% endtrans %}" href="https://github.com/numerique-gouv/b3desk" target="_blank" rel="noopener">{% trans %}Voir le code source{% endtrans %}</a>
{% if version %}
{% if version == "0.0.0" %}
{% if development_version %}
<span class="fr-badge fr-badge--sm fr-badge--warning" title="{% trans %}Ceci est une version de développement et ne doit en aucun cas être déployée dans des environnements de production.{% endtrans %}">DEV</span>
{% else %}
v{{ version }}
Expand Down
Loading

0 comments on commit 9c391fc

Please sign in to comment.