forked from ScoDoc/ScoDoc
Merge branch 'jmplace-api_logos'
This commit is contained in:
commit
5422124d68
@ -2,8 +2,25 @@
|
||||
"""
|
||||
|
||||
from flask import Blueprint
|
||||
from flask import request
|
||||
|
||||
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 sco_api
|
||||
from app.api import logos
|
||||
|
@ -38,16 +38,15 @@
|
||||
# Scolarite/Notes/groups_view
|
||||
# Scolarite/Notes/moduleimpl_status
|
||||
# Scolarite/setGroups
|
||||
from datetime import datetime
|
||||
|
||||
from flask import jsonify, request, url_for, abort, g
|
||||
from flask_login import current_user
|
||||
from flask import jsonify, request, g, send_file
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
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.errors import bad_request, error_response
|
||||
from app.decorators import permission_required
|
||||
from app.api.errors import error_response
|
||||
from app import models
|
||||
from app.models import FormSemestre, FormSemestreInscription, Identite
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
|
@ -42,3 +42,8 @@ class Departement(db.Model):
|
||||
"date_creation": self.date_creation,
|
||||
}
|
||||
return data
|
||||
|
||||
@classmethod
|
||||
def from_acronym(cls, acronym):
|
||||
dept = cls.query.filter_by(acronym=acronym).first_or_404()
|
||||
return dept
|
||||
|
Loading…
Reference in New Issue
Block a user