Skip to content

Commit

Permalink
Add access to user.announcements_email
Browse files Browse the repository at this point in the history
Closes #27.
  • Loading branch information
ezwelty committed Jul 10, 2023
1 parent 481524b commit 9ed7467
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions db/repos/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Users {
name: null,
bio: null,
range: null,
announcements_email: true,
...req.body
}
// Store encrypted password
Expand Down
8 changes: 6 additions & 2 deletions db/sql/users/add.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ INSERT INTO users (
encrypted_password,
name,
bio,
range
range,
announcements_email
)
VALUES (
${email},
${password},
${name},
${bio},
ST_GeomFromGeoJson(${range:json})
ST_GeomFromGeoJson(${range:json}),
${announcements_email}
)
RETURNING
id,
email,
name,
bio,
ST_AsGeoJson(range) as range,
announcements_email,
roles,
created_at,
updated_at,
Expand Down
5 changes: 4 additions & 1 deletion db/sql/users/edit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ SET (
name,
bio,
range,
announcements_email,
updated_at
) = (
${name},
${bio},
ST_GeomFromGeoJson(${range:json}),
${announcements_email},
NOW()
)
WHERE id = ${id}
Expand All @@ -16,8 +18,9 @@ RETURNING
email,
name,
bio,
roles,
ST_AsGeoJson(range) as range,
announcements_email,
roles,
created_at,
updated_at,
confirmed_at,
Expand Down
5 changes: 4 additions & 1 deletion db/sql/users/edit_password.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ SET (
bio,
encrypted_password,
range,
announcements_email,
updated_at
) = (
${name},
${bio},
${password},
ST_GeomFromGeoJson(${range:json}),
${announcements_email},
NOW()
)
WHERE id = ${id}
Expand All @@ -18,8 +20,9 @@ RETURNING
email,
name,
bio,
roles,
ST_AsGeoJson(range) as range,
announcements_email,
roles,
created_at,
updated_at,
confirmed_at,
Expand Down
3 changes: 2 additions & 1 deletion db/sql/users/show.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ SELECT
email,
name,
bio,
roles,
ST_AsGeoJson(range) as range,
announcements_email,
roles,
created_at,
updated_at,
confirmed_at
Expand Down
6 changes: 6 additions & 0 deletions docs/components/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ EditUser:
- name
- bio
- range
- announcements_email
properties:
email:
$ref: properties.yml#/email
Expand All @@ -567,6 +568,11 @@ EditUser:
- type: object
description: Foraging range.
nullable: true
announcements_email:
description: Whether user woud like to receive announcements by email.
type: boolean
example: true
default: true
PublicUser:
title: User (public)
allOf:
Expand Down
6 changes: 6 additions & 0 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,7 @@ components:
- name
- bio
- range
- announcements_email
properties:
email:
description: Email.
Expand Down Expand Up @@ -1754,6 +1755,11 @@ components:
- type: object
description: Foraging range.
nullable: true
announcements_email:
description: Whether user woud like to receive announcements by email.
type: boolean
example: true
default: true
PublicUser:
title: User (public)
allOf:
Expand Down

0 comments on commit 9ed7467

Please sign in to comment.