Skip to content

Commit

Permalink
Merge branch 'production' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jhagberg authored Jan 2, 2025
2 parents 1377427 + f9a8554 commit 21a9e5e
Show file tree
Hide file tree
Showing 22 changed files with 386 additions and 57 deletions.
11 changes: 8 additions & 3 deletions .docker/main
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ FROM python:3.8-buster
ENV TZ='Europe/Stockholm'
RUN mkdir -p /code

COPY app/ /code/
WORKDIR /code

RUN apt-get update && apt-get -y upgrade &&\
apt-get install -y supervisor nginx inotify-tools rsync swig python3-pykcs11

RUN usermod -u 1000 www-data
RUN groupmod -g 1000 www-data

COPY --chown=www-data:www-data app/ /code/
WORKDIR /code

RUN pip3 install -r /code/requirements.txt && chown -R www-data:www-data /code/
RUN pip3 install uwsgi

Expand All @@ -37,4 +40,6 @@ COPY system/herdbook.standalone.nginx /etc/nginx/herdbook.standalone

COPY system/entrypoint.sh /

RUN chown -R www-data:www-data /code /api_src

CMD /entrypoint.sh
20 changes: 12 additions & 8 deletions app/herdbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,10 @@ def external_login_handler(service):

user = da.authenticate_with_credentials(service, persistent_id)

if user:
if user and not user.validated:
return "Du behöver gå en kurs och bli validerad först kontakta [email protected]"

if user and user.validated:
APP.logger.info(
"Logging in user %s (%s - #%d) by persistent id %s for service %s, refferrer is %s"
% (
Expand Down Expand Up @@ -538,7 +541,7 @@ def external_login_handler(service):
accountdetails["email"],
None,
username=accountdetails["username"],
validated=True,
validated=False,
fullname=accountdetails["fullname"] if "fullname" in accountdetails else None,
privileges=[
{"level": "viewer", "genebank": 1},
Expand Down Expand Up @@ -567,9 +570,6 @@ def external_login_handler(service):
% (persistent_id, accountdetails["email"], service)
)

# FIXME: this is how we "really" log in the user
session["user_id"] = user.uuid

# If we got a herd from external, setup ownership
if "herd" in accountdetails:
for h in ["G", "M"]:
Expand All @@ -586,9 +586,13 @@ def external_login_handler(service):
else:
APP.logger.warning("Could not find herd id for herd %s" % h.strip())

login_user(user)

return redirect("/start")
# FIXME: this is how we "really" log in the user
if user.validated:
session["user_id"] = user.uuid
login_user(user)
return redirect("/start")
else:
return "Du behöver gå en kurs och bli validerad först kontakta [email protected]"


@APP.route("/api/link/<string:service>", methods=["GET", "POST"])
Expand Down
11 changes: 11 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"react": "^17.0.2",
"react-cookie-consent": "^8.0.1",
"react-dom": "^17.0.2",
"react-hotjar": "^5.3.0",
"react-icons": "^4.2.0",
"react-is": "^17.0.2",
"react-number-format": "^4.6.3",
Expand Down
31 changes: 31 additions & 0 deletions frontend/src/breeding_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,11 @@ export function BreedingForm({
label="Född tidigast"
format={dateFormat}
value={fromDate}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand Down Expand Up @@ -661,6 +666,11 @@ export function BreedingForm({
format={dateFormat}
className="wideControl"
value={formState.breed_date ?? null}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand Down Expand Up @@ -688,6 +698,12 @@ export function BreedingForm({
className="wideControl"
variant={inputVariant}
margin="normal"
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
// jscpd:ignore-end
Expand Down Expand Up @@ -716,6 +732,12 @@ export function BreedingForm({
className="wideControl"
variant={inputVariant}
margin="normal"
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
// jscpd:ignore-end
Expand All @@ -730,6 +752,7 @@ export function BreedingForm({
className="wideControl"
multiline
minRows={2}
inputProps={{ className: "data-hj-allow" }}
value={formState.breed_notes ?? ""}
onChange={(e: any) => {
setFormField("breed_notes", e.target.value);
Expand Down Expand Up @@ -759,6 +782,11 @@ export function BreedingForm({
format={dateFormat}
className="controlFull"
value={formState.birth_date ?? null}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand All @@ -772,6 +800,7 @@ export function BreedingForm({
value={formState.litter_size ?? ""}
type="number"
className="control controlWidth"
inputProps={{ className: "data-hj-allow" }}
variant={inputVariant}
InputLabelProps={{
shrink: true,
Expand All @@ -786,6 +815,7 @@ export function BreedingForm({
type="number"
className="controlWidth"
variant={inputVariant}
inputProps={{ className: "data-hj-allow" }}
InputLabelProps={{
shrink: true,
}}
Expand All @@ -800,6 +830,7 @@ export function BreedingForm({
className="controlFull"
multiline
minRows={2}
inputProps={{ className: "data-hj-allow" }}
value={formState.birth_notes ?? ""}
onChange={(e: any) => {
setFormField("birth_notes", e.target.value);
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/cert_autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export const CertAutocomplete = ({
className="control"
variant={inputVariant}
margin="normal"
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
onChange={(event: any, newValue: OptionType) => {
Expand All @@ -100,6 +106,7 @@ export const CertAutocomplete = ({
className="control controlWidth"
variant={inputVariant}
value={individual.certificate ?? ""}
inputProps={{ className: "data-hj-allow" }}
onChange={(event) => {
updateIndividual("certificate", event.currentTarget.value);
}}
Expand All @@ -122,6 +129,7 @@ export const CertAutocomplete = ({
className="control controlWidth"
variant={inputVariant}
value={individual.digital_certificate ?? ""}
inputProps={{ className: "data-hj-allow" }}
onChange={(event) => {
updateIndividual(
"digital_certificate",
Expand All @@ -148,6 +156,7 @@ export const CertAutocomplete = ({
label="Lägg till intyg senare"
disabled
className="control controlWidth"
inputProps={{ className: "data-hj-allow" }}
variant={inputVariant}
value=""
onChange={() => {}}
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/filter_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,17 @@ export function FilterTable({
option.value == value.value
}
renderInput={(params) => (
<TextField {...params} variant={inputVariant} margin="normal" />
<TextField
{...params}
variant={inputVariant}
margin="normal"
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
onChange={(event: any, newValues: OptionType[] | null) => {
newValues && updateColumns(newValues);
Expand Down Expand Up @@ -521,6 +531,7 @@ export function FilterTable({
className="search"
label="Sök"
variant={inputVariant}
inputProps={{ className: "data-hj-allow" }}
onChange={(e) => setSearch(e.currentTarget.value)}
/>
<TableContainer>
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/individual_add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,11 @@ export function IndividualAdd({
label="Född tidigast"
format={dateFormat}
value={fromDate}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand Down Expand Up @@ -895,6 +900,12 @@ export function IndividualAdd({
{...params}
label="Välj mor"
variant={inputVariant}
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
/>
Expand All @@ -914,6 +925,12 @@ export function IndividualAdd({
{...params}
label="Välj far"
variant={inputVariant}
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
/>
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/individual_breeding_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ export function IndividualBreedingForm({
label="Född tidigast"
format={dateFormat}
value={fromDate}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand Down Expand Up @@ -469,6 +474,12 @@ export function IndividualBreedingForm({
label="Välj mor"
variant={inputVariant}
className="controlFull"
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
/>
Expand Down Expand Up @@ -498,6 +509,12 @@ export function IndividualBreedingForm({
label="Välj far"
variant={inputVariant}
className="controlFull"
InputProps={{
...params.InputProps,
classes: {
input: "data-hj-allow",
},
}}
/>
)}
/>
Expand All @@ -515,6 +532,11 @@ export function IndividualBreedingForm({
format={dateFormat}
className="controlFull"
value={formState?.birth_date ?? null}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand All @@ -530,6 +552,11 @@ export function IndividualBreedingForm({
type="number"
className="control controlWidth"
variant={inputVariant}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand All @@ -543,6 +570,11 @@ export function IndividualBreedingForm({
type="number"
className="controlWidth"
variant={inputVariant}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
InputLabelProps={{
shrink: true,
}}
Expand All @@ -562,6 +594,11 @@ export function IndividualBreedingForm({
onChange={(e: any) => {
setFormField("birth_notes", e.target.value);
}}
InputProps={{
classes: {
input: "data-hj-allow",
},
}}
/>
</div>
</div>
Expand Down
Loading

0 comments on commit 21a9e5e

Please sign in to comment.