Skip to content
Snippets Groups Projects
Commit 7161b5df authored by geant-release-service's avatar geant-release-service
Browse files

Finished release 0.44.

parents eb0d49f2 30f80aa2
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
## [0.44] - 2023-12-07
- COMP-329: User getting redirected with wrong year of survey
## [0.43] - 2023-12-07
- COMP-306: Renamed PIONEER to PSNC
- COMP-268: Renamed ANAS to AzScienceNet
......
......@@ -46,6 +46,42 @@ LIST_SURVEYS_RESPONSE_SCHEMA = {
'items': {'$ref': '#/definitions/survey'}
}
SURVEY_ACTIVE_YEAR_RESPONSE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"year": {
"type": "string"
}
},
"required": ["year"],
"additionalProperties": False
}
@routes.route('/active/year', methods=['GET'])
@common.require_accepts_json
@login_required
def get_active_survey_year() -> Any:
"""
retrieve a year of latest active survey
response will be formatted as:
.. asjson::
compendium_v2.routes.survey.SURVEY_ACTIVE_YEAR_RESPONSE_SCHEMA
"""
survey_record = db.session.query(Survey.year).filter(
Survey.status == SurveyStatus.open
).order_by(Survey.year.desc()).first()
if survey_record:
year = survey_record.year
return {'year': year}
else:
return {'message': 'No open survey found.'}, 404
@routes.route('/list', methods=['GET'])
@common.require_accepts_json
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='compendium-v2',
version="0.43",
version="0.44",
author='GEANT',
author_email='swd@geant.org',
description='Flask and React project for displaying '
......
......@@ -2,7 +2,7 @@ import React, { ReactElement, useContext, useState, useEffect } from "react";
import { useNavigate, Link } from "react-router-dom";
import { Table, Container, Row } from "react-bootstrap";
import { userContext } from "./providers/UserProvider";
import { fetchSurveys } from "./api/survey";
import { fetchSurveys, fetchActiveSurveyYear } from "./api/survey";
import { Survey } from "./api/types";
......@@ -16,9 +16,14 @@ function Landing(): ReactElement {
const isAdmin = loggedIn ? user.permissions.admin : false;
const isObserver = loggedIn ? user.role === 'observer' : false;
const moveToSurvey = () => {
const currentYear = new Date().getFullYear();
navigate(`/survey/response/${currentYear}/${activeNren}`);
const moveToSurvey = () => {
const [activeSurveyYear, setActiveSurveyYear] = useState<string>()
useEffect(() => {
fetchActiveSurveyYear().then((year) => {
setActiveSurveyYear(year);
});
}, []);
navigate(`/survey/response/${activeSurveyYear}/${activeNren}`);
return <></>
}
......
......@@ -9,4 +9,21 @@ export async function fetchSurveys(): Promise<Survey[]> {
console.log('failed fetching survey list..');
return [];
}
}
\ No newline at end of file
}
export async function fetchActiveSurveyYear(): Promise<string> {
try {
const response = await fetch('/api/survey/active/year');
const data = await response.json();
if ('year' in data) {
const year = data.year;
return year.toString();
} else {
console.log('Invalid response format: Failed fetching active survey year.');
return "";
}
} catch (error) {
console.error('Failed fetching active survey year:', error);
return "";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment