Merge branch 'jmplace-api_logos'

This commit is contained in:
Emmanuel Viennet 2021-12-22 00:36:24 +01:00
commit 5422124d68
3 changed files with 27 additions and 6 deletions

View File

@ -2,8 +2,25 @@
""" """
from flask import Blueprint from flask import Blueprint
from flask import request
bp = Blueprint("api", __name__) bp = Blueprint("api", __name__)
from app.api import sco_api
def requested_format(default_format="json", allowed_formats=None):
"""Extract required format from query string.
* default value is json. A list of allowed formats may be provided
(['json'] considered if not provided).
* if the required format is not in allowed list, returns None.
NB: if json in not in allowed_formats, format specification is mandatory.
"""
format_type = request.args.get("format", default_format)
if format_type in (allowed_formats or ["json"]):
return format_type
return None
from app.api import tokens from app.api import tokens
from app.api import sco_api
from app.api import logos

View File

@ -38,16 +38,15 @@
# Scolarite/Notes/groups_view # Scolarite/Notes/groups_view
# Scolarite/Notes/moduleimpl_status # Scolarite/Notes/moduleimpl_status
# Scolarite/setGroups # Scolarite/setGroups
from datetime import datetime
from flask import jsonify, request, url_for, abort, g from flask import jsonify, request, g, send_file
from flask_login import current_user
from sqlalchemy.sql import func from sqlalchemy.sql import func
from app import db, log from app import db, log
from app.api import bp from app.api import bp, requested_format
from app.api.auth import token_auth from app.api.auth import token_auth
from app.api.errors import bad_request, error_response from app.api.errors import error_response
from app.decorators import permission_required
from app import models from app import models
from app.models import FormSemestre, FormSemestreInscription, Identite from app.models import FormSemestre, FormSemestreInscription, Identite
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission

View File

@ -42,3 +42,8 @@ class Departement(db.Model):
"date_creation": self.date_creation, "date_creation": self.date_creation,
} }
return data return data
@classmethod
def from_acronym(cls, acronym):
dept = cls.query.filter_by(acronym=acronym).first_or_404()
return dept