From 419a48ac3a788255530847f5f9adc517cb09ba67 Mon Sep 17 00:00:00 2001 From: tleb Date: Mon, 21 Oct 2019 17:01:21 +0200 Subject: [PATCH] /pedagogy/uv/create put urls in settings --- api/views/uv.py | 6 +++--- sith/settings.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/views/uv.py b/api/views/uv.py index 24e72dd2..9cf46a2b 100644 --- a/api/views/uv.py +++ b/api/views/uv.py @@ -2,6 +2,7 @@ from rest_framework.response import Response from rest_framework.decorators import api_view, renderer_classes from rest_framework.renderers import JSONRenderer from django.core.exceptions import PermissionDenied +from django.conf import settings from rest_framework import serializers import urllib.request import json @@ -34,7 +35,7 @@ def find_uv(lang, year, code): full_uv is the detailed representation of an UV. """ # 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)) uvs = json.loads(response.read().decode("utf-8")) @@ -45,9 +46,8 @@ def find_uv(lang, year, code): return (None, None) # get detailed information about the UV - uv_url = "https://extranet1.utbm.fr/gpedago/api/guide/uv/{lang}/{year}/{code}/{formation}" 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"] ) ) diff --git a/sith/settings.py b/sith/settings.py index 3fe4e826..68250b47 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -445,6 +445,9 @@ SITH_PEDAGOGY_UV_RESULT_GRADE = [ ("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_DECO = 1151