/pedagogy/uv/create put urls in settings

This commit is contained in:
tleb 2019-10-21 17:01:21 +02:00
parent 6fce27113a
commit 419a48ac3a
2 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,7 @@ from rest_framework.response import Response
from rest_framework.decorators import api_view, renderer_classes from rest_framework.decorators import api_view, renderer_classes
from rest_framework.renderers import JSONRenderer from rest_framework.renderers import JSONRenderer
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.conf import settings
from rest_framework import serializers from rest_framework import serializers
import urllib.request import urllib.request
import json import json
@ -34,7 +35,7 @@ def find_uv(lang, year, code):
full_uv is the detailed representation of an UV. full_uv is the detailed representation of an UV.
""" """
# query the UV list # query the UV list
uvs_url = "https://extranet1.utbm.fr/gpedago/api/guide/uvs/{lang}/{year}" uvs_url = settings.SITH_PEDAGOGY_UTBM_API_UVS_URL
response = urllib.request.urlopen(uvs_url.format(lang=lang, year=year)) response = urllib.request.urlopen(uvs_url.format(lang=lang, year=year))
uvs = json.loads(response.read().decode("utf-8")) uvs = json.loads(response.read().decode("utf-8"))
@ -45,9 +46,8 @@ def find_uv(lang, year, code):
return (None, None) return (None, None)
# get detailed information about the UV # get detailed information about the UV
uv_url = "https://extranet1.utbm.fr/gpedago/api/guide/uv/{lang}/{year}/{code}/{formation}"
response = urllib.request.urlopen( response = urllib.request.urlopen(
uv_url.format( settings.SITH_PEDAGOGY_UTBM_API_UV_URL.format(
lang=lang, year=year, code=code, formation=short_uv["codeFormation"] lang=lang, year=year, code=code, formation=short_uv["codeFormation"]
) )
) )

View File

@ -445,6 +445,9 @@ SITH_PEDAGOGY_UV_RESULT_GRADE = [
("ABS", _("Abs")), ("ABS", _("Abs")),
] ]
SITH_PEDAGOGY_UTBM_API_UVS_URL = "https://extranet1.utbm.fr/gpedago/api/guide/uvs/{lang}/{year}"
SITH_PEDAGOGY_UTBM_API_UV_URL = "https://extranet1.utbm.fr/gpedago/api/guide/uv/{lang}/{year}/{code}/{formation}"
SITH_ECOCUP_CONS = 1152 SITH_ECOCUP_CONS = 1152
SITH_ECOCUP_DECO = 1151 SITH_ECOCUP_DECO = 1151