Skip to content
Snippets Groups Projects
Commit f58e978e authored by Victor Löfgren's avatar Victor Löfgren
Browse files

Fix some bugs

parent bacdd393
No related branches found
No related tags found
1 merge request!161Resolve "replace-restx-with-smorest"
......@@ -15,15 +15,13 @@ export const getCities = () => async (dispatch: AppDispatch) => {
type: Types.SET_CITIES,
payload: res.data,
})
const pagination = JSON.parse(res.headers.pagination)
dispatch({
type: Types.SET_CITIES_TOTAL,
payload: pagination.total,
payload: res.data.length,
})
dispatch({
type: Types.SET_CITIES_COUNT,
payload: pagination.total <= pagination.page_size ? pagination.total : pagination.page_size,
payload: res.data.length,
})
})
.catch((err) => console.log(err))
......
......@@ -161,7 +161,7 @@ const CompetitionManager: React.FC = (props: any) => {
await axios
.get(`/api/competitions/${id}/codes`)
.then((response) => {
setCodes(response.data.items)
setCodes(response.data)
})
.catch(console.log)
}
......@@ -171,8 +171,7 @@ const CompetitionManager: React.FC = (props: any) => {
await axios
.get(`/api/competitions/${id}/teams`)
.then((response) => {
// console.log(response.data.items)
setTeams(response.data.items)
setTeams(response.data)
})
.catch((err) => {
console.log(err)
......
......@@ -152,7 +152,7 @@ const OperatorViewPage: React.FC = () => {
await axios
.get(`/api/competitions/${activeId}/codes`)
.then((response) => {
setCodes(response.data.items)
setCodes(response.data)
})
.catch(console.log)
}
......
......@@ -21,13 +21,13 @@ export const CheckAuthenticationCompetition = async (role: 'Judge' | 'Operator'
store.dispatch({
type: Types.SET_COMPETITION_LOGIN_DATA,
payload: {
competition_id: decodedToken.user_claims.competition_id,
team_id: decodedToken.user_claims.team_id,
view: decodedToken.user_claims.view,
competition_id: decodedToken.competition_id,
team_id: decodedToken.team_id,
view: decodedToken.view,
},
})
getPresentationCompetition(decodedToken.user_claims.competition_id)(store.dispatch, store.getState)
setPresentationCode(decodedToken.user_claims.code)(store.dispatch)
getPresentationCompetition(decodedToken.competition_id)(store.dispatch, store.getState)
setPresentationCode(decodedToken.code)(store.dispatch)
})
.catch((error) => {
console.log(error)
......
......@@ -46,7 +46,7 @@ class CompetitionSearchArgsSchema(BaseSchema):
@blp.route("")
class CompetitionsList(MethodView):
class Competitions(MethodView):
@protect_route(allowed_roles=["*"])
@blp.arguments(CompetitionAddArgsSchema)
@blp.response(http_codes.OK, CompetitionSchema)
......@@ -57,7 +57,7 @@ class CompetitionsList(MethodView):
@blp.route("/<competition_id>")
class Competitions(MethodView):
class CompetitionById(MethodView):
@protect_route(allowed_roles=["*"], allowed_views=["*"])
@blp.response(http_codes.OK, CompetitionSchemaRich)
@blp.alt_response(http_codes.NOT_FOUND, None, description="Competition not found")
......
......@@ -102,8 +102,7 @@ def component(type_id, slide_id, view_type_id, x=0, y=0, w=0, h=0, copy=False, *
)
item.question_id = data.get("question_id")
else:
pass
# abort(codes.BAD_REQUEST, f"Invalid type_id{type_id}")
abort(http_codes.BAD_REQUEST, f"Ogiltigt typ_id '{type_id}'")
item = dbc.utils.commit_and_refresh(item)
return item
......
......@@ -2,9 +2,11 @@
This file contains some miscellaneous functionality.
"""
from app.apis import http_codes
from app.core import db
from app.core.codes import generate_code_string
from app.database.models import Code
from flask_smorest import abort
# from flask_restx import abort
......@@ -106,8 +108,7 @@ def refresh(item):
try:
db.session.refresh(item)
except Exception as e:
pass
# abort(codes.INTERNAL_SERVER_ERROR, f"Refresh failed!\n{str(e)}")
abort(http_codes.INTERNAL_SERVER_ERROR, f"Refresh failed!\n{str(e)}")
return item
......@@ -119,8 +120,7 @@ def commit():
db.session.commit()
except Exception as e:
db.session.rollback()
pass
# abort(codes.INTERNAL_SERVER_ERROR, f"Commit failed!\n{str(e)}")
abort(http_codes.INTERNAL_SERVER_ERROR, f"Commit failed!\n{str(e)}")
def commit_and_refresh(item):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment