Skip to content

Commit

Permalink
Merge pull request #719 from NBISweden/hotfix/productions-bugs
Browse files Browse the repository at this point in the history
Hotfix/productions bugs
  • Loading branch information
jhagberg authored Jan 14, 2025
2 parents b7a4e13 + be929a7 commit c2a0ede
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
8 changes: 6 additions & 2 deletions app/utils/data_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,12 @@ def add_herd(form, user_uuid):
user = fetch_user_info(user_uuid)
if user is None:
return {"status": "error", "message": "Not logged in"}
if not (user.is_admin or (user.is_manager and form["genebank"] in user.is_manager)):
return {"status": "error", "message": "Forbidden"}
try:
genebank_id = int(form["genebank"])
if not (user.is_admin or (user.is_manager and genebank_id in user.is_manager)):
return {"status": "error", "message": "Forbidden"}
except (ValueError, KeyError):
return {"status": "error", "message": "Invalid genebank ID"}

with DATABASE.atomic():
try:
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/breeding_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ export const WithBreedingContext = (props: { children: React.ReactNode }) => {
if (!breeding.litter_size6w) {
return Math.min(breedingUpdates.litter_size6w, 9);
}
if (breeding.litter_size6w < breedingUpdates.litter_size6w) {
if (
Number(breeding.litter_size6w) < Number(breedingUpdates.litter_size6w)
) {
return (
Math.min(breedingUpdates.litter_size6w, 9) -
Math.min(breeding.litter_size6w, 9)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/breeding_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export function BreedingForm({
return false;
}

if (userInput?.litter_size6w > userInput?.litter_size) {
if (Number(userInput?.litter_size6w) > Number(userInput?.litter_size)) {
userMessage(
"Kullstorleken efter 6 veckor får inte vara större än kullstorleken vid födseln.",
"warning"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/individual_add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export function IndividualAdd({
);
return false;
}
if (individual.litter_size6w > individual.litter_size) {
if (Number(individual.litter_size6w) > Number(individual.litter_size)) {
userMessage(
"Kullstorleken efter 6 veckor får inte vara större än kullstorleken vid födseln.",
"warning"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/individual_breeding_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export function IndividualBreedingForm({

if (
(userInput.birth_date, userInput.litter_size) !== null &&
!(userInput.litter_size > 0)
!(Number(userInput.litter_size) > 0)
) {
userMessage("Ange en kullstorlek större än 0", "warning");
return false;
Expand Down Expand Up @@ -365,7 +365,7 @@ export function IndividualBreedingForm({
const newBirthData: Birth = {
date: breeding.birth_date,
litter_size: breeding.litter_size,
litter_size6w: breeding.litter_size,
litter_size6w: breeding.litter_size6w,
notes: breeding.birth_notes !== "" ? breeding.birth_notes : undefined,
id: newBreeding.breeding_id,
};
Expand Down

0 comments on commit c2a0ede

Please sign in to comment.