Add gender, address, and emergency contact to the user row
Browse files at this commitf151345d92f9caf95fb6eb05049cf31dbf89dc9fParent: 5d43523- feat
- add gender, address, and emergency contact to the user row
22 changed files +889 -106
- .sqlx/query-e30a05b019f2834851c819abde37d928f6a02f051e99bc877168f48d142bff8b.json → .sqlx/query-11efb8f095f9c3a25f15e81c63f7c8ce6060d4a07381e18af874156b5a9355a2.json +59 -11
- .sqlx/query-ac0befbd1b4398d79d2bbe2d8923bde69dfbe93bbb60dadc632ce93bbe18f8a6.json → .sqlx/query-285553fed5434ba6d2dc0b5f8cfca643533fc704888da822bda102b292a59a58.json +59 -11
- .sqlx/query-0887ff018a2ecdc9bf29472dd59b5e7f76610c2a39de92e7b30ad8be5a5966f8.json → .sqlx/query-2e30b1574b30eeea4de6f677fffa01a753f85e8940e85c30a65367bab6a85472.json +59 -11
- .sqlx/query-09f4fca0c1cf695324fd71baec63fd30baa3cfff04429798e9e8784ffb611ede.json → .sqlx/query-3570903f9c3efa997ab946792400987bf2ba4f6c0a0121812e08abe12d495f0d.json +59 -11
- .sqlx/query-c8eeec6b17943f913ed919e8663e44fc9d0e85ac9eaa6a7f2c9b012237381d5c.json → .sqlx/query-56cb33247c6d8b90a8f8adbf74020e68e743aafd2373a5ba08d2340edfea70f6.json +59 -11
- .sqlx/query-fb4bc5f405406b6b5f6a41705b65ceb78cd496905d3da3669ab659e57b0ed7fc.json → .sqlx/query-584815529fd2220312415393ca0fe9036201139d948c2fdcd17da489b473161c.json +59 -11
- .sqlx/query-7496e13f38da77b1fc311a687f1996651f4d8ce46c0ee401f63d2a5f80334ab2.json → .sqlx/query-7d46215022acf66ec30b62b6022443ef169dd0b12bb3e3824cf706b6245045fc.json +59 -11
- README.md +14 -5
- migrations/school/20260923000003_person_extra.sql +9 -0
- src/constant.rs +3 -2
- src/db/user.rs +73 -17
- src/domain/profile.rs +93 -1
- src/domain/user.rs +30 -1
- src/service/user.rs +11 -1
- src/web/dto.rs +22 -0
- src/web/limits.rs +8 -0
- src/web/users.rs +27 -1
- tests/integration.rs +105 -0
- tests/limits_completeness.rs +1 -0
- tests/partial_patch_users.rs +58 -0
- tests/regress_profile.rs +13 -1
- tests/spec_bounds.rs +9 -0
.sqlx/query-e30a05b019f2834851c819abde37d928f6a02f051e99bc877168f48d142bff8b.json → .sqlx/query-11efb8f095f9c3a25f15e81c63f7c8ce6060d4a07381e18af874156b5a9355a2.jsonrenamed+59 -11
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "db_name": "PostgreSQL", | 2 | "db_name": "PostgreSQL", |
| 3 | - "query": "INSERT INTO app_user (id, username, person, role, student_number, created_at)\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size", | 3 | + "query": "INSERT INTO app_user (id, username, person, role, student_number, created_at)\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size", |
| 4 | "describe": { | 4 | "describe": { |
| 5 | "columns": [ | 5 | "columns": [ |
| 6 | { | 6 | { |
| @@ -104,6 +104,50 @@ | |||
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | "ordinal": 9, | 106 | "ordinal": 9, |
| 107 | + "name": "gender: Gender", | ||
| 108 | + "type_info": "Text", | ||
| 109 | + "origin": { | ||
| 110 | + "Table": { | ||
| 111 | + "table": "app_user", | ||
| 112 | + "name": "gender" | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ordinal": 10, | ||
| 118 | + "name": "address: Address", | ||
| 119 | + "type_info": "Text", | ||
| 120 | + "origin": { | ||
| 121 | + "Table": { | ||
| 122 | + "table": "app_user", | ||
| 123 | + "name": "address" | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "ordinal": 11, | ||
| 129 | + "name": "emergency_contact_name: PersonName", | ||
| 130 | + "type_info": "Text", | ||
| 131 | + "origin": { | ||
| 132 | + "Table": { | ||
| 133 | + "table": "app_user", | ||
| 134 | + "name": "emergency_contact_name" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }, | ||
| 138 | + { | ||
| 139 | + "ordinal": 12, | ||
| 140 | + "name": "emergency_contact_phone: Phone", | ||
| 141 | + "type_info": "Text", | ||
| 142 | + "origin": { | ||
| 143 | + "Table": { | ||
| 144 | + "table": "app_user", | ||
| 145 | + "name": "emergency_contact_phone" | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + "ordinal": 13, | ||
| 107 | "name": "theme: Theme", | 151 | "name": "theme: Theme", |
| 108 | "type_info": "Text", | 152 | "type_info": "Text", |
| 109 | "origin": { | 153 | "origin": { |
| @@ -114,7 +158,7 @@ | |||
| 114 | } | 158 | } |
| 115 | }, | 159 | }, |
| 116 | { | 160 | { |
| 117 | - "ordinal": 10, | 161 | + "ordinal": 14, |
| 118 | "name": "language: Language", | 162 | "name": "language: Language", |
| 119 | "type_info": "Text", | 163 | "type_info": "Text", |
| 120 | "origin": { | 164 | "origin": { |
| @@ -125,7 +169,7 @@ | |||
| 125 | } | 169 | } |
| 126 | }, | 170 | }, |
| 127 | { | 171 | { |
| 128 | - "ordinal": 11, | 172 | + "ordinal": 15, |
| 129 | "name": "palette_color: PaletteColor", | 173 | "name": "palette_color: PaletteColor", |
| 130 | "type_info": "Text", | 174 | "type_info": "Text", |
| 131 | "origin": { | 175 | "origin": { |
| @@ -136,7 +180,7 @@ | |||
| 136 | } | 180 | } |
| 137 | }, | 181 | }, |
| 138 | { | 182 | { |
| 139 | - "ordinal": 12, | 183 | + "ordinal": 16, |
| 140 | "name": "display_name: DisplayName", | 184 | "name": "display_name: DisplayName", |
| 141 | "type_info": "Text", | 185 | "type_info": "Text", |
| 142 | "origin": { | 186 | "origin": { |
| @@ -147,7 +191,7 @@ | |||
| 147 | } | 191 | } |
| 148 | }, | 192 | }, |
| 149 | { | 193 | { |
| 150 | - "ordinal": 13, | 194 | + "ordinal": 17, |
| 151 | "name": "bio: Bio", | 195 | "name": "bio: Bio", |
| 152 | "type_info": "Text", | 196 | "type_info": "Text", |
| 153 | "origin": { | 197 | "origin": { |
| @@ -158,7 +202,7 @@ | |||
| 158 | } | 202 | } |
| 159 | }, | 203 | }, |
| 160 | { | 204 | { |
| 161 | - "ordinal": 14, | 205 | + "ordinal": 18, |
| 162 | "name": "avatar_file", | 206 | "name": "avatar_file", |
| 163 | "type_info": "Text", | 207 | "type_info": "Text", |
| 164 | "origin": { | 208 | "origin": { |
| @@ -169,7 +213,7 @@ | |||
| 169 | } | 213 | } |
| 170 | }, | 214 | }, |
| 171 | { | 215 | { |
| 172 | - "ordinal": 15, | 216 | + "ordinal": 19, |
| 173 | "name": "avatar_content_type: FileContentType", | 217 | "name": "avatar_content_type: FileContentType", |
| 174 | "type_info": "Text", | 218 | "type_info": "Text", |
| 175 | "origin": { | 219 | "origin": { |
| @@ -180,7 +224,7 @@ | |||
| 180 | } | 224 | } |
| 181 | }, | 225 | }, |
| 182 | { | 226 | { |
| 183 | - "ordinal": 16, | 227 | + "ordinal": 20, |
| 184 | "name": "branch", | 228 | "name": "branch", |
| 185 | "type_info": "Text", | 229 | "type_info": "Text", |
| 186 | "origin": { | 230 | "origin": { |
| @@ -191,7 +235,7 @@ | |||
| 191 | } | 235 | } |
| 192 | }, | 236 | }, |
| 193 | { | 237 | { |
| 194 | - "ordinal": 17, | 238 | + "ordinal": 21, |
| 195 | "name": "student_number: StudentNumber", | 239 | "name": "student_number: StudentNumber", |
| 196 | "type_info": "Text", | 240 | "type_info": "Text", |
| 197 | "origin": { | 241 | "origin": { |
| @@ -202,7 +246,7 @@ | |||
| 202 | } | 246 | } |
| 203 | }, | 247 | }, |
| 204 | { | 248 | { |
| 205 | - "ordinal": 18, | 249 | + "ordinal": 22, |
| 206 | "name": "avatar_size", | 250 | "name": "avatar_size", |
| 207 | "type_info": "Int8", | 251 | "type_info": "Int8", |
| 208 | "origin": { | 252 | "origin": { |
| @@ -242,8 +286,12 @@ | |||
| 242 | true, | 286 | true, |
| 243 | true, | 287 | true, |
| 244 | true, | 288 | true, |
| 289 | + true, | ||
| 290 | + true, | ||
| 291 | + true, | ||
| 292 | + true, | ||
| 245 | true | 293 | true |
| 246 | ] | 294 | ] |
| 247 | }, | 295 | }, |
| 248 | - "hash": "e30a05b019f2834851c819abde37d928f6a02f051e99bc877168f48d142bff8b" | 296 | + "hash": "11efb8f095f9c3a25f15e81c63f7c8ce6060d4a07381e18af874156b5a9355a2" |
| 249 | } | 297 | } |
.sqlx/query-ac0befbd1b4398d79d2bbe2d8923bde69dfbe93bbb60dadc632ce93bbe18f8a6.json → .sqlx/query-285553fed5434ba6d2dc0b5f8cfca643533fc704888da822bda102b292a59a58.jsonrenamed+59 -11
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "db_name": "PostgreSQL", | 2 | "db_name": "PostgreSQL", |
| 3 | - "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1", | 3 | + "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1", |
| 4 | "describe": { | 4 | "describe": { |
| 5 | "columns": [ | 5 | "columns": [ |
| 6 | { | 6 | { |
| @@ -104,6 +104,50 @@ | |||
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | "ordinal": 9, | 106 | "ordinal": 9, |
| 107 | + "name": "gender: Gender", | ||
| 108 | + "type_info": "Text", | ||
| 109 | + "origin": { | ||
| 110 | + "Table": { | ||
| 111 | + "table": "app_user", | ||
| 112 | + "name": "gender" | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ordinal": 10, | ||
| 118 | + "name": "address: Address", | ||
| 119 | + "type_info": "Text", | ||
| 120 | + "origin": { | ||
| 121 | + "Table": { | ||
| 122 | + "table": "app_user", | ||
| 123 | + "name": "address" | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "ordinal": 11, | ||
| 129 | + "name": "emergency_contact_name: PersonName", | ||
| 130 | + "type_info": "Text", | ||
| 131 | + "origin": { | ||
| 132 | + "Table": { | ||
| 133 | + "table": "app_user", | ||
| 134 | + "name": "emergency_contact_name" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }, | ||
| 138 | + { | ||
| 139 | + "ordinal": 12, | ||
| 140 | + "name": "emergency_contact_phone: Phone", | ||
| 141 | + "type_info": "Text", | ||
| 142 | + "origin": { | ||
| 143 | + "Table": { | ||
| 144 | + "table": "app_user", | ||
| 145 | + "name": "emergency_contact_phone" | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + "ordinal": 13, | ||
| 107 | "name": "theme: Theme", | 151 | "name": "theme: Theme", |
| 108 | "type_info": "Text", | 152 | "type_info": "Text", |
| 109 | "origin": { | 153 | "origin": { |
| @@ -114,7 +158,7 @@ | |||
| 114 | } | 158 | } |
| 115 | }, | 159 | }, |
| 116 | { | 160 | { |
| 117 | - "ordinal": 10, | 161 | + "ordinal": 14, |
| 118 | "name": "language: Language", | 162 | "name": "language: Language", |
| 119 | "type_info": "Text", | 163 | "type_info": "Text", |
| 120 | "origin": { | 164 | "origin": { |
| @@ -125,7 +169,7 @@ | |||
| 125 | } | 169 | } |
| 126 | }, | 170 | }, |
| 127 | { | 171 | { |
| 128 | - "ordinal": 11, | 172 | + "ordinal": 15, |
| 129 | "name": "palette_color: PaletteColor", | 173 | "name": "palette_color: PaletteColor", |
| 130 | "type_info": "Text", | 174 | "type_info": "Text", |
| 131 | "origin": { | 175 | "origin": { |
| @@ -136,7 +180,7 @@ | |||
| 136 | } | 180 | } |
| 137 | }, | 181 | }, |
| 138 | { | 182 | { |
| 139 | - "ordinal": 12, | 183 | + "ordinal": 16, |
| 140 | "name": "display_name: DisplayName", | 184 | "name": "display_name: DisplayName", |
| 141 | "type_info": "Text", | 185 | "type_info": "Text", |
| 142 | "origin": { | 186 | "origin": { |
| @@ -147,7 +191,7 @@ | |||
| 147 | } | 191 | } |
| 148 | }, | 192 | }, |
| 149 | { | 193 | { |
| 150 | - "ordinal": 13, | 194 | + "ordinal": 17, |
| 151 | "name": "bio: Bio", | 195 | "name": "bio: Bio", |
| 152 | "type_info": "Text", | 196 | "type_info": "Text", |
| 153 | "origin": { | 197 | "origin": { |
| @@ -158,7 +202,7 @@ | |||
| 158 | } | 202 | } |
| 159 | }, | 203 | }, |
| 160 | { | 204 | { |
| 161 | - "ordinal": 14, | 205 | + "ordinal": 18, |
| 162 | "name": "avatar_file", | 206 | "name": "avatar_file", |
| 163 | "type_info": "Text", | 207 | "type_info": "Text", |
| 164 | "origin": { | 208 | "origin": { |
| @@ -169,7 +213,7 @@ | |||
| 169 | } | 213 | } |
| 170 | }, | 214 | }, |
| 171 | { | 215 | { |
| 172 | - "ordinal": 15, | 216 | + "ordinal": 19, |
| 173 | "name": "avatar_content_type: FileContentType", | 217 | "name": "avatar_content_type: FileContentType", |
| 174 | "type_info": "Text", | 218 | "type_info": "Text", |
| 175 | "origin": { | 219 | "origin": { |
| @@ -180,7 +224,7 @@ | |||
| 180 | } | 224 | } |
| 181 | }, | 225 | }, |
| 182 | { | 226 | { |
| 183 | - "ordinal": 16, | 227 | + "ordinal": 20, |
| 184 | "name": "branch", | 228 | "name": "branch", |
| 185 | "type_info": "Text", | 229 | "type_info": "Text", |
| 186 | "origin": { | 230 | "origin": { |
| @@ -191,7 +235,7 @@ | |||
| 191 | } | 235 | } |
| 192 | }, | 236 | }, |
| 193 | { | 237 | { |
| 194 | - "ordinal": 17, | 238 | + "ordinal": 21, |
| 195 | "name": "student_number: StudentNumber", | 239 | "name": "student_number: StudentNumber", |
| 196 | "type_info": "Text", | 240 | "type_info": "Text", |
| 197 | "origin": { | 241 | "origin": { |
| @@ -202,7 +246,7 @@ | |||
| 202 | } | 246 | } |
| 203 | }, | 247 | }, |
| 204 | { | 248 | { |
| 205 | - "ordinal": 18, | 249 | + "ordinal": 22, |
| 206 | "name": "avatar_size", | 250 | "name": "avatar_size", |
| 207 | "type_info": "Int8", | 251 | "type_info": "Int8", |
| 208 | "origin": { | 252 | "origin": { |
| @@ -237,8 +281,12 @@ | |||
| 237 | true, | 281 | true, |
| 238 | true, | 282 | true, |
| 239 | true, | 283 | true, |
| 284 | + true, | ||
| 285 | + true, | ||
| 286 | + true, | ||
| 287 | + true, | ||
| 240 | true | 288 | true |
| 241 | ] | 289 | ] |
| 242 | }, | 290 | }, |
| 243 | - "hash": "ac0befbd1b4398d79d2bbe2d8923bde69dfbe93bbb60dadc632ce93bbe18f8a6" | 291 | + "hash": "285553fed5434ba6d2dc0b5f8cfca643533fc704888da822bda102b292a59a58" |
| 244 | } | 292 | } |
.sqlx/query-0887ff018a2ecdc9bf29472dd59b5e7f76610c2a39de92e7b30ad8be5a5966f8.json → .sqlx/query-2e30b1574b30eeea4de6f677fffa01a753f85e8940e85c30a65367bab6a85472.jsonrenamed+59 -11
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "db_name": "PostgreSQL", | 2 | "db_name": "PostgreSQL", |
| 3 | - "query": "UPDATE app_user\n SET role = $2,\n student_number = CASE WHEN $2 = 'student' THEN student_number ELSE NULL END\n WHERE id = $1\n AND NOT (role = 'admin'\n AND $2 <> 'admin'\n AND (SELECT count(*) FROM app_user\n WHERE role = 'admin' AND id <> $1) = 0)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size", | 3 | + "query": "UPDATE app_user\n SET role = $2,\n student_number = CASE WHEN $2 = 'student' THEN student_number ELSE NULL END\n WHERE id = $1\n AND NOT (role = 'admin'\n AND $2 <> 'admin'\n AND (SELECT count(*) FROM app_user\n WHERE role = 'admin' AND id <> $1) = 0)\n RETURNING id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size", |
| 4 | "describe": { | 4 | "describe": { |
| 5 | "columns": [ | 5 | "columns": [ |
| 6 | { | 6 | { |
| @@ -104,6 +104,50 @@ | |||
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | "ordinal": 9, | 106 | "ordinal": 9, |
| 107 | + "name": "gender: Gender", | ||
| 108 | + "type_info": "Text", | ||
| 109 | + "origin": { | ||
| 110 | + "Table": { | ||
| 111 | + "table": "app_user", | ||
| 112 | + "name": "gender" | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ordinal": 10, | ||
| 118 | + "name": "address: Address", | ||
| 119 | + "type_info": "Text", | ||
| 120 | + "origin": { | ||
| 121 | + "Table": { | ||
| 122 | + "table": "app_user", | ||
| 123 | + "name": "address" | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "ordinal": 11, | ||
| 129 | + "name": "emergency_contact_name: PersonName", | ||
| 130 | + "type_info": "Text", | ||
| 131 | + "origin": { | ||
| 132 | + "Table": { | ||
| 133 | + "table": "app_user", | ||
| 134 | + "name": "emergency_contact_name" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }, | ||
| 138 | + { | ||
| 139 | + "ordinal": 12, | ||
| 140 | + "name": "emergency_contact_phone: Phone", | ||
| 141 | + "type_info": "Text", | ||
| 142 | + "origin": { | ||
| 143 | + "Table": { | ||
| 144 | + "table": "app_user", | ||
| 145 | + "name": "emergency_contact_phone" | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + "ordinal": 13, | ||
| 107 | "name": "theme: Theme", | 151 | "name": "theme: Theme", |
| 108 | "type_info": "Text", | 152 | "type_info": "Text", |
| 109 | "origin": { | 153 | "origin": { |
| @@ -114,7 +158,7 @@ | |||
| 114 | } | 158 | } |
| 115 | }, | 159 | }, |
| 116 | { | 160 | { |
| 117 | - "ordinal": 10, | 161 | + "ordinal": 14, |
| 118 | "name": "language: Language", | 162 | "name": "language: Language", |
| 119 | "type_info": "Text", | 163 | "type_info": "Text", |
| 120 | "origin": { | 164 | "origin": { |
| @@ -125,7 +169,7 @@ | |||
| 125 | } | 169 | } |
| 126 | }, | 170 | }, |
| 127 | { | 171 | { |
| 128 | - "ordinal": 11, | 172 | + "ordinal": 15, |
| 129 | "name": "palette_color: PaletteColor", | 173 | "name": "palette_color: PaletteColor", |
| 130 | "type_info": "Text", | 174 | "type_info": "Text", |
| 131 | "origin": { | 175 | "origin": { |
| @@ -136,7 +180,7 @@ | |||
| 136 | } | 180 | } |
| 137 | }, | 181 | }, |
| 138 | { | 182 | { |
| 139 | - "ordinal": 12, | 183 | + "ordinal": 16, |
| 140 | "name": "display_name: DisplayName", | 184 | "name": "display_name: DisplayName", |
| 141 | "type_info": "Text", | 185 | "type_info": "Text", |
| 142 | "origin": { | 186 | "origin": { |
| @@ -147,7 +191,7 @@ | |||
| 147 | } | 191 | } |
| 148 | }, | 192 | }, |
| 149 | { | 193 | { |
| 150 | - "ordinal": 13, | 194 | + "ordinal": 17, |
| 151 | "name": "bio: Bio", | 195 | "name": "bio: Bio", |
| 152 | "type_info": "Text", | 196 | "type_info": "Text", |
| 153 | "origin": { | 197 | "origin": { |
| @@ -158,7 +202,7 @@ | |||
| 158 | } | 202 | } |
| 159 | }, | 203 | }, |
| 160 | { | 204 | { |
| 161 | - "ordinal": 14, | 205 | + "ordinal": 18, |
| 162 | "name": "avatar_file", | 206 | "name": "avatar_file", |
| 163 | "type_info": "Text", | 207 | "type_info": "Text", |
| 164 | "origin": { | 208 | "origin": { |
| @@ -169,7 +213,7 @@ | |||
| 169 | } | 213 | } |
| 170 | }, | 214 | }, |
| 171 | { | 215 | { |
| 172 | - "ordinal": 15, | 216 | + "ordinal": 19, |
| 173 | "name": "avatar_content_type: FileContentType", | 217 | "name": "avatar_content_type: FileContentType", |
| 174 | "type_info": "Text", | 218 | "type_info": "Text", |
| 175 | "origin": { | 219 | "origin": { |
| @@ -180,7 +224,7 @@ | |||
| 180 | } | 224 | } |
| 181 | }, | 225 | }, |
| 182 | { | 226 | { |
| 183 | - "ordinal": 16, | 227 | + "ordinal": 20, |
| 184 | "name": "branch", | 228 | "name": "branch", |
| 185 | "type_info": "Text", | 229 | "type_info": "Text", |
| 186 | "origin": { | 230 | "origin": { |
| @@ -191,7 +235,7 @@ | |||
| 191 | } | 235 | } |
| 192 | }, | 236 | }, |
| 193 | { | 237 | { |
| 194 | - "ordinal": 17, | 238 | + "ordinal": 21, |
| 195 | "name": "student_number: StudentNumber", | 239 | "name": "student_number: StudentNumber", |
| 196 | "type_info": "Text", | 240 | "type_info": "Text", |
| 197 | "origin": { | 241 | "origin": { |
| @@ -202,7 +246,7 @@ | |||
| 202 | } | 246 | } |
| 203 | }, | 247 | }, |
| 204 | { | 248 | { |
| 205 | - "ordinal": 18, | 249 | + "ordinal": 22, |
| 206 | "name": "avatar_size", | 250 | "name": "avatar_size", |
| 207 | "type_info": "Int8", | 251 | "type_info": "Int8", |
| 208 | "origin": { | 252 | "origin": { |
| @@ -238,8 +282,12 @@ | |||
| 238 | true, | 282 | true, |
| 239 | true, | 283 | true, |
| 240 | true, | 284 | true, |
| 285 | + true, | ||
| 286 | + true, | ||
| 287 | + true, | ||
| 288 | + true, | ||
| 241 | true | 289 | true |
| 242 | ] | 290 | ] |
| 243 | }, | 291 | }, |
| 244 | - "hash": "0887ff018a2ecdc9bf29472dd59b5e7f76610c2a39de92e7b30ad8be5a5966f8" | 292 | + "hash": "2e30b1574b30eeea4de6f677fffa01a753f85e8940e85c30a65367bab6a85472" |
| 245 | } | 293 | } |
.sqlx/query-09f4fca0c1cf695324fd71baec63fd30baa3cfff04429798e9e8784ffb611ede.json → .sqlx/query-3570903f9c3efa997ab946792400987bf2ba4f6c0a0121812e08abe12d495f0d.jsonrenamed+59 -11
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "db_name": "PostgreSQL", | 2 | "db_name": "PostgreSQL", |
| 3 | - "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = ANY($1)", | 3 | + "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = ANY($1)", |
| 4 | "describe": { | 4 | "describe": { |
| 5 | "columns": [ | 5 | "columns": [ |
| 6 | { | 6 | { |
| @@ -104,6 +104,50 @@ | |||
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | "ordinal": 9, | 106 | "ordinal": 9, |
| 107 | + "name": "gender: Gender", | ||
| 108 | + "type_info": "Text", | ||
| 109 | + "origin": { | ||
| 110 | + "Table": { | ||
| 111 | + "table": "app_user", | ||
| 112 | + "name": "gender" | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ordinal": 10, | ||
| 118 | + "name": "address: Address", | ||
| 119 | + "type_info": "Text", | ||
| 120 | + "origin": { | ||
| 121 | + "Table": { | ||
| 122 | + "table": "app_user", | ||
| 123 | + "name": "address" | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "ordinal": 11, | ||
| 129 | + "name": "emergency_contact_name: PersonName", | ||
| 130 | + "type_info": "Text", | ||
| 131 | + "origin": { | ||
| 132 | + "Table": { | ||
| 133 | + "table": "app_user", | ||
| 134 | + "name": "emergency_contact_name" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }, | ||
| 138 | + { | ||
| 139 | + "ordinal": 12, | ||
| 140 | + "name": "emergency_contact_phone: Phone", | ||
| 141 | + "type_info": "Text", | ||
| 142 | + "origin": { | ||
| 143 | + "Table": { | ||
| 144 | + "table": "app_user", | ||
| 145 | + "name": "emergency_contact_phone" | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + "ordinal": 13, | ||
| 107 | "name": "theme: Theme", | 151 | "name": "theme: Theme", |
| 108 | "type_info": "Text", | 152 | "type_info": "Text", |
| 109 | "origin": { | 153 | "origin": { |
| @@ -114,7 +158,7 @@ | |||
| 114 | } | 158 | } |
| 115 | }, | 159 | }, |
| 116 | { | 160 | { |
| 117 | - "ordinal": 10, | 161 | + "ordinal": 14, |
| 118 | "name": "language: Language", | 162 | "name": "language: Language", |
| 119 | "type_info": "Text", | 163 | "type_info": "Text", |
| 120 | "origin": { | 164 | "origin": { |
| @@ -125,7 +169,7 @@ | |||
| 125 | } | 169 | } |
| 126 | }, | 170 | }, |
| 127 | { | 171 | { |
| 128 | - "ordinal": 11, | 172 | + "ordinal": 15, |
| 129 | "name": "palette_color: PaletteColor", | 173 | "name": "palette_color: PaletteColor", |
| 130 | "type_info": "Text", | 174 | "type_info": "Text", |
| 131 | "origin": { | 175 | "origin": { |
| @@ -136,7 +180,7 @@ | |||
| 136 | } | 180 | } |
| 137 | }, | 181 | }, |
| 138 | { | 182 | { |
| 139 | - "ordinal": 12, | 183 | + "ordinal": 16, |
| 140 | "name": "display_name: DisplayName", | 184 | "name": "display_name: DisplayName", |
| 141 | "type_info": "Text", | 185 | "type_info": "Text", |
| 142 | "origin": { | 186 | "origin": { |
| @@ -147,7 +191,7 @@ | |||
| 147 | } | 191 | } |
| 148 | }, | 192 | }, |
| 149 | { | 193 | { |
| 150 | - "ordinal": 13, | 194 | + "ordinal": 17, |
| 151 | "name": "bio: Bio", | 195 | "name": "bio: Bio", |
| 152 | "type_info": "Text", | 196 | "type_info": "Text", |
| 153 | "origin": { | 197 | "origin": { |
| @@ -158,7 +202,7 @@ | |||
| 158 | } | 202 | } |
| 159 | }, | 203 | }, |
| 160 | { | 204 | { |
| 161 | - "ordinal": 14, | 205 | + "ordinal": 18, |
| 162 | "name": "avatar_file", | 206 | "name": "avatar_file", |
| 163 | "type_info": "Text", | 207 | "type_info": "Text", |
| 164 | "origin": { | 208 | "origin": { |
| @@ -169,7 +213,7 @@ | |||
| 169 | } | 213 | } |
| 170 | }, | 214 | }, |
| 171 | { | 215 | { |
| 172 | - "ordinal": 15, | 216 | + "ordinal": 19, |
| 173 | "name": "avatar_content_type: FileContentType", | 217 | "name": "avatar_content_type: FileContentType", |
| 174 | "type_info": "Text", | 218 | "type_info": "Text", |
| 175 | "origin": { | 219 | "origin": { |
| @@ -180,7 +224,7 @@ | |||
| 180 | } | 224 | } |
| 181 | }, | 225 | }, |
| 182 | { | 226 | { |
| 183 | - "ordinal": 16, | 227 | + "ordinal": 20, |
| 184 | "name": "branch", | 228 | "name": "branch", |
| 185 | "type_info": "Text", | 229 | "type_info": "Text", |
| 186 | "origin": { | 230 | "origin": { |
| @@ -191,7 +235,7 @@ | |||
| 191 | } | 235 | } |
| 192 | }, | 236 | }, |
| 193 | { | 237 | { |
| 194 | - "ordinal": 17, | 238 | + "ordinal": 21, |
| 195 | "name": "student_number: StudentNumber", | 239 | "name": "student_number: StudentNumber", |
| 196 | "type_info": "Text", | 240 | "type_info": "Text", |
| 197 | "origin": { | 241 | "origin": { |
| @@ -202,7 +246,7 @@ | |||
| 202 | } | 246 | } |
| 203 | }, | 247 | }, |
| 204 | { | 248 | { |
| 205 | - "ordinal": 18, | 249 | + "ordinal": 22, |
| 206 | "name": "avatar_size", | 250 | "name": "avatar_size", |
| 207 | "type_info": "Int8", | 251 | "type_info": "Int8", |
| 208 | "origin": { | 252 | "origin": { |
| @@ -237,8 +281,12 @@ | |||
| 237 | true, | 281 | true, |
| 238 | true, | 282 | true, |
| 239 | true, | 283 | true, |
| 284 | + true, | ||
| 285 | + true, | ||
| 286 | + true, | ||
| 287 | + true, | ||
| 240 | true | 288 | true |
| 241 | ] | 289 | ] |
| 242 | }, | 290 | }, |
| 243 | - "hash": "09f4fca0c1cf695324fd71baec63fd30baa3cfff04429798e9e8784ffb611ede" | 291 | + "hash": "3570903f9c3efa997ab946792400987bf2ba4f6c0a0121812e08abe12d495f0d" |
| 244 | } | 292 | } |
.sqlx/query-c8eeec6b17943f913ed919e8663e44fc9d0e85ac9eaa6a7f2c9b012237381d5c.json → .sqlx/query-56cb33247c6d8b90a8f8adbf74020e68e743aafd2373a5ba08d2340edfea70f6.jsonrenamed+59 -11
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "db_name": "PostgreSQL", | 2 | "db_name": "PostgreSQL", |
| 3 | - "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE role = $1 ORDER BY id DESC", | 3 | + "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE role = $1 ORDER BY id DESC", |
| 4 | "describe": { | 4 | "describe": { |
| 5 | "columns": [ | 5 | "columns": [ |
| 6 | { | 6 | { |
| @@ -104,6 +104,50 @@ | |||
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | "ordinal": 9, | 106 | "ordinal": 9, |
| 107 | + "name": "gender: Gender", | ||
| 108 | + "type_info": "Text", | ||
| 109 | + "origin": { | ||
| 110 | + "Table": { | ||
| 111 | + "table": "app_user", | ||
| 112 | + "name": "gender" | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ordinal": 10, | ||
| 118 | + "name": "address: Address", | ||
| 119 | + "type_info": "Text", | ||
| 120 | + "origin": { | ||
| 121 | + "Table": { | ||
| 122 | + "table": "app_user", | ||
| 123 | + "name": "address" | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "ordinal": 11, | ||
| 129 | + "name": "emergency_contact_name: PersonName", | ||
| 130 | + "type_info": "Text", | ||
| 131 | + "origin": { | ||
| 132 | + "Table": { | ||
| 133 | + "table": "app_user", | ||
| 134 | + "name": "emergency_contact_name" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }, | ||
| 138 | + { | ||
| 139 | + "ordinal": 12, | ||
| 140 | + "name": "emergency_contact_phone: Phone", | ||
| 141 | + "type_info": "Text", | ||
| 142 | + "origin": { | ||
| 143 | + "Table": { | ||
| 144 | + "table": "app_user", | ||
| 145 | + "name": "emergency_contact_phone" | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + "ordinal": 13, | ||
| 107 | "name": "theme: Theme", | 151 | "name": "theme: Theme", |
| 108 | "type_info": "Text", | 152 | "type_info": "Text", |
| 109 | "origin": { | 153 | "origin": { |
| @@ -114,7 +158,7 @@ | |||
| 114 | } | 158 | } |
| 115 | }, | 159 | }, |
| 116 | { | 160 | { |
| 117 | - "ordinal": 10, | 161 | + "ordinal": 14, |
| 118 | "name": "language: Language", | 162 | "name": "language: Language", |
| 119 | "type_info": "Text", | 163 | "type_info": "Text", |
| 120 | "origin": { | 164 | "origin": { |
| @@ -125,7 +169,7 @@ | |||
| 125 | } | 169 | } |
| 126 | }, | 170 | }, |
| 127 | { | 171 | { |
| 128 | - "ordinal": 11, | 172 | + "ordinal": 15, |
| 129 | "name": "palette_color: PaletteColor", | 173 | "name": "palette_color: PaletteColor", |
| 130 | "type_info": "Text", | 174 | "type_info": "Text", |
| 131 | "origin": { | 175 | "origin": { |
| @@ -136,7 +180,7 @@ | |||
| 136 | } | 180 | } |
| 137 | }, | 181 | }, |
| 138 | { | 182 | { |
| 139 | - "ordinal": 12, | 183 | + "ordinal": 16, |
| 140 | "name": "display_name: DisplayName", | 184 | "name": "display_name: DisplayName", |
| 141 | "type_info": "Text", | 185 | "type_info": "Text", |
| 142 | "origin": { | 186 | "origin": { |
| @@ -147,7 +191,7 @@ | |||
| 147 | } | 191 | } |
| 148 | }, | 192 | }, |
| 149 | { | 193 | { |
| 150 | - "ordinal": 13, | 194 | + "ordinal": 17, |
| 151 | "name": "bio: Bio", | 195 | "name": "bio: Bio", |
| 152 | "type_info": "Text", | 196 | "type_info": "Text", |
| 153 | "origin": { | 197 | "origin": { |
| @@ -158,7 +202,7 @@ | |||
| 158 | } | 202 | } |
| 159 | }, | 203 | }, |
| 160 | { | 204 | { |
| 161 | - "ordinal": 14, | 205 | + "ordinal": 18, |
| 162 | "name": "avatar_file", | 206 | "name": "avatar_file", |
| 163 | "type_info": "Text", | 207 | "type_info": "Text", |
| 164 | "origin": { | 208 | "origin": { |
| @@ -169,7 +213,7 @@ | |||
| 169 | } | 213 | } |
| 170 | }, | 214 | }, |
| 171 | { | 215 | { |
| 172 | - "ordinal": 15, | 216 | + "ordinal": 19, |
| 173 | "name": "avatar_content_type: FileContentType", | 217 | "name": "avatar_content_type: FileContentType", |
| 174 | "type_info": "Text", | 218 | "type_info": "Text", |
| 175 | "origin": { | 219 | "origin": { |
| @@ -180,7 +224,7 @@ | |||
| 180 | } | 224 | } |
| 181 | }, | 225 | }, |
| 182 | { | 226 | { |
| 183 | - "ordinal": 16, | 227 | + "ordinal": 20, |
| 184 | "name": "branch", | 228 | "name": "branch", |
| 185 | "type_info": "Text", | 229 | "type_info": "Text", |
| 186 | "origin": { | 230 | "origin": { |
| @@ -191,7 +235,7 @@ | |||
| 191 | } | 235 | } |
| 192 | }, | 236 | }, |
| 193 | { | 237 | { |
| 194 | - "ordinal": 17, | 238 | + "ordinal": 21, |
| 195 | "name": "student_number: StudentNumber", | 239 | "name": "student_number: StudentNumber", |
| 196 | "type_info": "Text", | 240 | "type_info": "Text", |
| 197 | "origin": { | 241 | "origin": { |
| @@ -202,7 +246,7 @@ | |||
| 202 | } | 246 | } |
| 203 | }, | 247 | }, |
| 204 | { | 248 | { |
| 205 | - "ordinal": 18, | 249 | + "ordinal": 22, |
| 206 | "name": "avatar_size", | 250 | "name": "avatar_size", |
| 207 | "type_info": "Int8", | 251 | "type_info": "Int8", |
| 208 | "origin": { | 252 | "origin": { |
| @@ -237,8 +281,12 @@ | |||
| 237 | true, | 281 | true, |
| 238 | true, | 282 | true, |
| 239 | true, | 283 | true, |
| 284 | + true, | ||
| 285 | + true, | ||
| 286 | + true, | ||
| 287 | + true, | ||
| 240 | true | 288 | true |
| 241 | ] | 289 | ] |
| 242 | }, | 290 | }, |
| 243 | - "hash": "c8eeec6b17943f913ed919e8663e44fc9d0e85ac9eaa6a7f2c9b012237381d5c" | 291 | + "hash": "56cb33247c6d8b90a8f8adbf74020e68e743aafd2373a5ba08d2340edfea70f6" |
| 244 | } | 292 | } |
.sqlx/query-fb4bc5f405406b6b5f6a41705b65ceb78cd496905d3da3669ab659e57b0ed7fc.json → .sqlx/query-584815529fd2220312415393ca0fe9036201139d948c2fdcd17da489b473161c.jsonrenamed+59 -11
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "db_name": "PostgreSQL", | 2 | "db_name": "PostgreSQL", |
| 3 | - "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE username = $1", | 3 | + "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE username = $1", |
| 4 | "describe": { | 4 | "describe": { |
| 5 | "columns": [ | 5 | "columns": [ |
| 6 | { | 6 | { |
| @@ -104,6 +104,50 @@ | |||
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | "ordinal": 9, | 106 | "ordinal": 9, |
| 107 | + "name": "gender: Gender", | ||
| 108 | + "type_info": "Text", | ||
| 109 | + "origin": { | ||
| 110 | + "Table": { | ||
| 111 | + "table": "app_user", | ||
| 112 | + "name": "gender" | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ordinal": 10, | ||
| 118 | + "name": "address: Address", | ||
| 119 | + "type_info": "Text", | ||
| 120 | + "origin": { | ||
| 121 | + "Table": { | ||
| 122 | + "table": "app_user", | ||
| 123 | + "name": "address" | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "ordinal": 11, | ||
| 129 | + "name": "emergency_contact_name: PersonName", | ||
| 130 | + "type_info": "Text", | ||
| 131 | + "origin": { | ||
| 132 | + "Table": { | ||
| 133 | + "table": "app_user", | ||
| 134 | + "name": "emergency_contact_name" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }, | ||
| 138 | + { | ||
| 139 | + "ordinal": 12, | ||
| 140 | + "name": "emergency_contact_phone: Phone", | ||
| 141 | + "type_info": "Text", | ||
| 142 | + "origin": { | ||
| 143 | + "Table": { | ||
| 144 | + "table": "app_user", | ||
| 145 | + "name": "emergency_contact_phone" | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + "ordinal": 13, | ||
| 107 | "name": "theme: Theme", | 151 | "name": "theme: Theme", |
| 108 | "type_info": "Text", | 152 | "type_info": "Text", |
| 109 | "origin": { | 153 | "origin": { |
| @@ -114,7 +158,7 @@ | |||
| 114 | } | 158 | } |
| 115 | }, | 159 | }, |
| 116 | { | 160 | { |
| 117 | - "ordinal": 10, | 161 | + "ordinal": 14, |
| 118 | "name": "language: Language", | 162 | "name": "language: Language", |
| 119 | "type_info": "Text", | 163 | "type_info": "Text", |
| 120 | "origin": { | 164 | "origin": { |
| @@ -125,7 +169,7 @@ | |||
| 125 | } | 169 | } |
| 126 | }, | 170 | }, |
| 127 | { | 171 | { |
| 128 | - "ordinal": 11, | 172 | + "ordinal": 15, |
| 129 | "name": "palette_color: PaletteColor", | 173 | "name": "palette_color: PaletteColor", |
| 130 | "type_info": "Text", | 174 | "type_info": "Text", |
| 131 | "origin": { | 175 | "origin": { |
| @@ -136,7 +180,7 @@ | |||
| 136 | } | 180 | } |
| 137 | }, | 181 | }, |
| 138 | { | 182 | { |
| 139 | - "ordinal": 12, | 183 | + "ordinal": 16, |
| 140 | "name": "display_name: DisplayName", | 184 | "name": "display_name: DisplayName", |
| 141 | "type_info": "Text", | 185 | "type_info": "Text", |
| 142 | "origin": { | 186 | "origin": { |
| @@ -147,7 +191,7 @@ | |||
| 147 | } | 191 | } |
| 148 | }, | 192 | }, |
| 149 | { | 193 | { |
| 150 | - "ordinal": 13, | 194 | + "ordinal": 17, |
| 151 | "name": "bio: Bio", | 195 | "name": "bio: Bio", |
| 152 | "type_info": "Text", | 196 | "type_info": "Text", |
| 153 | "origin": { | 197 | "origin": { |
| @@ -158,7 +202,7 @@ | |||
| 158 | } | 202 | } |
| 159 | }, | 203 | }, |
| 160 | { | 204 | { |
| 161 | - "ordinal": 14, | 205 | + "ordinal": 18, |
| 162 | "name": "avatar_file", | 206 | "name": "avatar_file", |
| 163 | "type_info": "Text", | 207 | "type_info": "Text", |
| 164 | "origin": { | 208 | "origin": { |
| @@ -169,7 +213,7 @@ | |||
| 169 | } | 213 | } |
| 170 | }, | 214 | }, |
| 171 | { | 215 | { |
| 172 | - "ordinal": 15, | 216 | + "ordinal": 19, |
| 173 | "name": "avatar_content_type: FileContentType", | 217 | "name": "avatar_content_type: FileContentType", |
| 174 | "type_info": "Text", | 218 | "type_info": "Text", |
| 175 | "origin": { | 219 | "origin": { |
| @@ -180,7 +224,7 @@ | |||
| 180 | } | 224 | } |
| 181 | }, | 225 | }, |
| 182 | { | 226 | { |
| 183 | - "ordinal": 16, | 227 | + "ordinal": 20, |
| 184 | "name": "branch", | 228 | "name": "branch", |
| 185 | "type_info": "Text", | 229 | "type_info": "Text", |
| 186 | "origin": { | 230 | "origin": { |
| @@ -191,7 +235,7 @@ | |||
| 191 | } | 235 | } |
| 192 | }, | 236 | }, |
| 193 | { | 237 | { |
| 194 | - "ordinal": 17, | 238 | + "ordinal": 21, |
| 195 | "name": "student_number: StudentNumber", | 239 | "name": "student_number: StudentNumber", |
| 196 | "type_info": "Text", | 240 | "type_info": "Text", |
| 197 | "origin": { | 241 | "origin": { |
| @@ -202,7 +246,7 @@ | |||
| 202 | } | 246 | } |
| 203 | }, | 247 | }, |
| 204 | { | 248 | { |
| 205 | - "ordinal": 18, | 249 | + "ordinal": 22, |
| 206 | "name": "avatar_size", | 250 | "name": "avatar_size", |
| 207 | "type_info": "Int8", | 251 | "type_info": "Int8", |
| 208 | "origin": { | 252 | "origin": { |
| @@ -237,8 +281,12 @@ | |||
| 237 | true, | 281 | true, |
| 238 | true, | 282 | true, |
| 239 | true, | 283 | true, |
| 284 | + true, | ||
| 285 | + true, | ||
| 286 | + true, | ||
| 287 | + true, | ||
| 240 | true | 288 | true |
| 241 | ] | 289 | ] |
| 242 | }, | 290 | }, |
| 243 | - "hash": "fb4bc5f405406b6b5f6a41705b65ceb78cd496905d3da3669ab659e57b0ed7fc" | 291 | + "hash": "584815529fd2220312415393ca0fe9036201139d948c2fdcd17da489b473161c" |
| 244 | } | 292 | } |
.sqlx/query-7496e13f38da77b1fc311a687f1996651f4d8ce46c0ee401f63d2a5f80334ab2.json → .sqlx/query-7d46215022acf66ec30b62b6022443ef169dd0b12bb3e3824cf706b6245045fc.jsonrenamed+59 -11
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "db_name": "PostgreSQL", | 2 | "db_name": "PostgreSQL", |
| 3 | - "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1 FOR UPDATE", | 3 | + "query": "SELECT id AS \"id: UserId\",\n username AS \"username: Username\",\n person AS \"person: PersonId\",\n role AS \"role: Role\",\n name AS \"name: PersonName\",\n surname AS \"surname: PersonName\",\n email AS \"email: Email\",\n phone AS \"phone: Phone\",\n birth_date AS \"birth_date: BirthDate\",\n gender AS \"gender: Gender\",\n address AS \"address: Address\",\n emergency_contact_name AS \"emergency_contact_name: PersonName\",\n emergency_contact_phone AS \"emergency_contact_phone: Phone\",\n theme AS \"theme: Theme\",\n language AS \"language: Language\",\n palette_color AS \"palette_color: PaletteColor\",\n display_name AS \"display_name: DisplayName\",\n bio AS \"bio: Bio\",\n avatar_file,\n avatar_content_type AS \"avatar_content_type: FileContentType\",\n branch,\n student_number AS \"student_number: StudentNumber\",\n avatar_size\n FROM app_user WHERE id = $1 FOR UPDATE", |
| 4 | "describe": { | 4 | "describe": { |
| 5 | "columns": [ | 5 | "columns": [ |
| 6 | { | 6 | { |
| @@ -104,6 +104,50 @@ | |||
| 104 | }, | 104 | }, |
| 105 | { | 105 | { |
| 106 | "ordinal": 9, | 106 | "ordinal": 9, |
| 107 | + "name": "gender: Gender", | ||
| 108 | + "type_info": "Text", | ||
| 109 | + "origin": { | ||
| 110 | + "Table": { | ||
| 111 | + "table": "app_user", | ||
| 112 | + "name": "gender" | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ordinal": 10, | ||
| 118 | + "name": "address: Address", | ||
| 119 | + "type_info": "Text", | ||
| 120 | + "origin": { | ||
| 121 | + "Table": { | ||
| 122 | + "table": "app_user", | ||
| 123 | + "name": "address" | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "ordinal": 11, | ||
| 129 | + "name": "emergency_contact_name: PersonName", | ||
| 130 | + "type_info": "Text", | ||
| 131 | + "origin": { | ||
| 132 | + "Table": { | ||
| 133 | + "table": "app_user", | ||
| 134 | + "name": "emergency_contact_name" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }, | ||
| 138 | + { | ||
| 139 | + "ordinal": 12, | ||
| 140 | + "name": "emergency_contact_phone: Phone", | ||
| 141 | + "type_info": "Text", | ||
| 142 | + "origin": { | ||
| 143 | + "Table": { | ||
| 144 | + "table": "app_user", | ||
| 145 | + "name": "emergency_contact_phone" | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + "ordinal": 13, | ||
| 107 | "name": "theme: Theme", | 151 | "name": "theme: Theme", |
| 108 | "type_info": "Text", | 152 | "type_info": "Text", |
| 109 | "origin": { | 153 | "origin": { |
| @@ -114,7 +158,7 @@ | |||
| 114 | } | 158 | } |
| 115 | }, | 159 | }, |
| 116 | { | 160 | { |
| 117 | - "ordinal": 10, | 161 | + "ordinal": 14, |
| 118 | "name": "language: Language", | 162 | "name": "language: Language", |
| 119 | "type_info": "Text", | 163 | "type_info": "Text", |
| 120 | "origin": { | 164 | "origin": { |
| @@ -125,7 +169,7 @@ | |||
| 125 | } | 169 | } |
| 126 | }, | 170 | }, |
| 127 | { | 171 | { |
| 128 | - "ordinal": 11, | 172 | + "ordinal": 15, |
| 129 | "name": "palette_color: PaletteColor", | 173 | "name": "palette_color: PaletteColor", |
| 130 | "type_info": "Text", | 174 | "type_info": "Text", |
| 131 | "origin": { | 175 | "origin": { |
| @@ -136,7 +180,7 @@ | |||
| 136 | } | 180 | } |
| 137 | }, | 181 | }, |
| 138 | { | 182 | { |
| 139 | - "ordinal": 12, | 183 | + "ordinal": 16, |
| 140 | "name": "display_name: DisplayName", | 184 | "name": "display_name: DisplayName", |
| 141 | "type_info": "Text", | 185 | "type_info": "Text", |
| 142 | "origin": { | 186 | "origin": { |
| @@ -147,7 +191,7 @@ | |||
| 147 | } | 191 | } |
| 148 | }, | 192 | }, |
| 149 | { | 193 | { |
| 150 | - "ordinal": 13, | 194 | + "ordinal": 17, |
| 151 | "name": "bio: Bio", | 195 | "name": "bio: Bio", |
| 152 | "type_info": "Text", | 196 | "type_info": "Text", |
| 153 | "origin": { | 197 | "origin": { |
| @@ -158,7 +202,7 @@ | |||
| 158 | } | 202 | } |
| 159 | }, | 203 | }, |
| 160 | { | 204 | { |
| 161 | - "ordinal": 14, | 205 | + "ordinal": 18, |
| 162 | "name": "avatar_file", | 206 | "name": "avatar_file", |
| 163 | "type_info": "Text", | 207 | "type_info": "Text", |
| 164 | "origin": { | 208 | "origin": { |
| @@ -169,7 +213,7 @@ | |||
| 169 | } | 213 | } |
| 170 | }, | 214 | }, |
| 171 | { | 215 | { |
| 172 | - "ordinal": 15, | 216 | + "ordinal": 19, |
| 173 | "name": "avatar_content_type: FileContentType", | 217 | "name": "avatar_content_type: FileContentType", |
| 174 | "type_info": "Text", | 218 | "type_info": "Text", |
| 175 | "origin": { | 219 | "origin": { |
| @@ -180,7 +224,7 @@ | |||
| 180 | } | 224 | } |
| 181 | }, | 225 | }, |
| 182 | { | 226 | { |
| 183 | - "ordinal": 16, | 227 | + "ordinal": 20, |
| 184 | "name": "branch", | 228 | "name": "branch", |
| 185 | "type_info": "Text", | 229 | "type_info": "Text", |
| 186 | "origin": { | 230 | "origin": { |
| @@ -191,7 +235,7 @@ | |||
| 191 | } | 235 | } |
| 192 | }, | 236 | }, |
| 193 | { | 237 | { |
| 194 | - "ordinal": 17, | 238 | + "ordinal": 21, |
| 195 | "name": "student_number: StudentNumber", | 239 | "name": "student_number: StudentNumber", |
| 196 | "type_info": "Text", | 240 | "type_info": "Text", |
| 197 | "origin": { | 241 | "origin": { |
| @@ -202,7 +246,7 @@ | |||
| 202 | } | 246 | } |
| 203 | }, | 247 | }, |
| 204 | { | 248 | { |
| 205 | - "ordinal": 18, | 249 | + "ordinal": 22, |
| 206 | "name": "avatar_size", | 250 | "name": "avatar_size", |
| 207 | "type_info": "Int8", | 251 | "type_info": "Int8", |
| 208 | "origin": { | 252 | "origin": { |
| @@ -237,8 +281,12 @@ | |||
| 237 | true, | 281 | true, |
| 238 | true, | 282 | true, |
| 239 | true, | 283 | true, |
| 284 | + true, | ||
| 285 | + true, | ||
| 286 | + true, | ||
| 287 | + true, | ||
| 240 | true | 288 | true |
| 241 | ] | 289 | ] |
| 242 | }, | 290 | }, |
| 243 | - "hash": "7496e13f38da77b1fc311a687f1996651f4d8ce46c0ee401f63d2a5f80334ab2" | 291 | + "hash": "7d46215022acf66ec30b62b6022443ef169dd0b12bb3e3824cf706b6245045fc" |
| 244 | } | 292 | } |
README.mdmodified+14 -5
| @@ -645,12 +645,13 @@ response in the same commit. | |||
| 645 | "reserved_usernames": ["admin", "…"], | 645 | "reserved_usernames": ["admin", "…"], |
| 646 | "min_password_len": 6, "max_password_len": 128, | 646 | "min_password_len": 6, "max_password_len": 128, |
| 647 | "max_name_len": 100, "max_display_name_len": 50, | 647 | "max_name_len": 100, "max_display_name_len": 50, |
| 648 | - "max_bio_len": 500, | 648 | + "max_bio_len": 500, "max_address_len": 500, |
| 649 | "max_profile_courses": 20, "max_profile_classes": 5, | 649 | "max_profile_courses": 20, "max_profile_classes": 5, |
| 650 | "max_email_len": 254, | 650 | "max_email_len": 254, |
| 651 | "min_phone_digits": 7, "max_phone_digits": 15, | 651 | "min_phone_digits": 7, "max_phone_digits": 15, |
| 652 | "roles": ["parent", "student", "teacher", "manager", "admin"], | 652 | "roles": ["parent", "student", "teacher", "manager", "admin"], |
| 653 | "themes": ["light", "dark"], "languages": ["tr", "en"], | 653 | "themes": ["light", "dark"], "languages": ["tr", "en"], |
| 654 | + "genders": ["female", "male", "other", "undisclosed"], | ||
| 654 | "palette_color_pattern": "^#[0-9a-fA-F]{6}$", "palette_color_len": 7, | 655 | "palette_color_pattern": "^#[0-9a-fA-F]{6}$", "palette_color_len": 7, |
| 655 | "session_duration_days": 7 }, | 656 | "session_duration_days": 7 }, |
| 656 | "badges": { "catalog": [ { "id": "homework_submitted_10", | 657 | "badges": { "catalog": [ { "id": "homework_submitted_10", |
| @@ -722,7 +723,7 @@ drift from it**, which is enforced rather than asked for: | |||
| 722 | and fails unless each one is either referenced by `src/web/limits.rs` or | 723 | and fails unless each one is either referenced by `src/web/limits.rs` or |
| 723 | listed as a deliberate exclusion *with a reason*. A new constant breaks the | 724 | listed as a deliberate exclusion *with a reason*. A new constant breaks the |
| 724 | suite until someone decides, consciously, whether clients need it. | 725 | suite until someone decides, consciously, whether clients need it. |
| 725 | -- `tests/spec_bounds.rs` builds the OpenAPI document, reads all 218 published | 726 | +- `tests/spec_bounds.rs` builds the OpenAPI document, reads all 220 published |
| 726 | bounds back out of the emitted JSON, and asserts each equals its constant. | 727 | bounds back out of the emitted JSON, and asserts each equals its constant. |
| 727 | This exists because utoipa's `#[schema(max_length = …)]` accepts a **literal | 728 | This exists because utoipa's `#[schema(max_length = …)]` accepts a **literal |
| 728 | only** — a `const` there does not compile — so the annotations are | 729 | only** — a `const` there does not compile — so the annotations are |
| @@ -1601,7 +1602,12 @@ is independent: omitted (or `null`) keeps the current value, an empty string | |||
| 1601 | `""` clears it, anything else is validated — email must look like | 1602 | `""` clears it, anything else is validated — email must look like |
| 1602 | `name@example.com`, phone is 7–15 digits with an optional `+` and cosmetic | 1603 | `name@example.com`, phone is 7–15 digits with an optional `+` and cosmetic |
| 1603 | separators, `birth_date` is a real `YYYY-MM-DD` calendar date not in the | 1604 | separators, `birth_date` is a real `YYYY-MM-DD` calendar date not in the |
| 1604 | -future. Names allow unicode; usernames are strict: lowercase letters and | 1605 | +future. The profile extras ride the same patch with the same semantics: |
| 1606 | +`gender` is one of the four fixed words `female`/`male`/`other`/`undisclosed` | ||
| 1607 | +(a closed vocabulary — anything else is a `400`), `address` is free text up to | ||
| 1608 | +`max_address_len` (500), and `emergency_contact_name` / | ||
| 1609 | +`emergency_contact_phone` follow the `name` and `phone` rules respectively. | ||
| 1610 | +Names allow unicode; usernames are strict: lowercase letters and | ||
| 1605 | digits plus non-consecutive interior `.`, `_`, `-` separators, starting and | 1611 | digits plus non-consecutive interior `.`, `_`, `-` separators, starting and |
| 1606 | ending with a letter or digit (3–32 chars). Staff-looking names (`admin`, | 1612 | ending with a letter or digit (3–32 chars). Staff-looking names (`admin`, |
| 1607 | `administrator`, `root`, `support`, `system`, `moderator`, `staff`) are | 1613 | `administrator`, `root`, `support`, `system`, `moderator`, `staff`) are |
| @@ -1650,8 +1656,11 @@ the school. `GET /users/me/profile` is the caller's own copy of it, | |||
| 1650 | ``` | 1656 | ``` |
| 1651 | 1657 | ||
| 1652 | **Contact fields are absent by design.** `email`, `phone` and `birth_date` are | 1658 | **Contact fields are absent by design.** `email`, `phone` and `birth_date` are |
| 1653 | -not on this document at any role — they keep exactly the gate they have today | 1659 | +not on this document at any role, and neither are the profile extras that say |
| 1654 | -(`GET /auth/me` for oneself, `GET /users/{id}` for an admin). A school-wide | 1660 | +where a person lives or who to call for them (`gender`, `address`, |
| 1661 | +`emergency_contact_name`, `emergency_contact_phone`) — they keep exactly the | ||
| 1662 | +gate the other contact fields have (`GET /auth/me` for oneself, | ||
| 1663 | +`GET /users/{id}` for an admin). A school-wide | ||
| 1655 | read surface is not the place to widen where a phone number is reachable. | 1664 | read surface is not the place to widen where a phone number is reachable. |
| 1656 | 1665 | ||
| 1657 | **Visibility** is every authenticated account reading every profile, with one | 1666 | **Visibility** is every authenticated account reading every profile, with one |
migrations/school/20260923000003_person_extra.sqladded+9 -0
| @@ -0,0 +1,9 @@ | |||
| 1 | +-- Profile extras on app_user: gender, postal address, and an emergency | ||
| 2 | +-- contact (name + phone). All NULL until filled in; every column rides the | ||
| 3 | +-- three-state PATCH (omitted keeps, "" clears, a value validates), exactly | ||
| 4 | +-- like phone and birth_date before them. | ||
| 5 | +ALTER TABLE app_user | ||
| 6 | + ADD COLUMN gender TEXT NULL CHECK (gender IN ('female', 'male', 'other', 'undisclosed')), | ||
| 7 | + ADD COLUMN address TEXT NULL, | ||
| 8 | + ADD COLUMN emergency_contact_name TEXT NULL, | ||
| 9 | + ADD COLUMN emergency_contact_phone TEXT NULL; | ||
src/constant.rsmodified+3 -2
| @@ -35,10 +35,11 @@ pub const MAX_PASSWORD_LEN: usize = 128; | |||
| 35 | 35 | ||
| 36 | pub const MAX_NAME_LEN: usize = 100; | 36 | pub const MAX_NAME_LEN: usize = 100; |
| 37 | 37 | ||
| 38 | -/// Profile fields: the self-chosen name a user is shown under, and the free | 38 | +/// Profile fields: the self-chosen name a user is shown under, the free |
| 39 | -/// text under it. | 39 | +/// text under it, and the postal address. |
| 40 | pub const MAX_DISPLAY_NAME_LEN: usize = 50; | 40 | pub const MAX_DISPLAY_NAME_LEN: usize = 50; |
| 41 | pub const MAX_BIO_LEN: usize = 500; | 41 | pub const MAX_BIO_LEN: usize = 500; |
| 42 | +pub const MAX_ADDRESS_LEN: usize = 500; | ||
| 42 | 43 | ||
| 43 | /// How many course and class references one profile read embeds. A cap on the | 44 | /// How many course and class references one profile read embeds. A cap on the |
| 44 | /// response, not on membership — the full lists stay at `/courses/me` and | 45 | /// response, not on membership — the full lists stay at `/courses/me` and |
src/db/user.rsmodified+73 -17
| @@ -15,7 +15,7 @@ use crate::domain::board::{Board, BoardId, BoardTitle}; | |||
| 15 | use crate::domain::note_file::FileContentType; | 15 | use crate::domain::note_file::FileContentType; |
| 16 | use crate::domain::person::PersonId; | 16 | use crate::domain::person::PersonId; |
| 17 | use crate::domain::preferences::{Language, PaletteColor, Theme}; | 17 | use crate::domain::preferences::{Language, PaletteColor, Theme}; |
| 18 | -use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone}; | 18 | +use crate::domain::profile::{Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone}; |
| 19 | use crate::domain::role::Role; | 19 | use crate::domain::role::Role; |
| 20 | use crate::domain::text_fold::{search_fold, search_fold_sql}; | 20 | use crate::domain::text_fold::{search_fold, search_fold_sql}; |
| 21 | use crate::domain::timestamp::Timestamp; | 21 | use crate::domain::timestamp::Timestamp; |
| @@ -92,6 +92,10 @@ pub async fn create_with_role( | |||
| 92 | email AS "email: Email", | 92 | email AS "email: Email", |
| 93 | phone AS "phone: Phone", | 93 | phone AS "phone: Phone", |
| 94 | birth_date AS "birth_date: BirthDate", | 94 | birth_date AS "birth_date: BirthDate", |
| 95 | + gender AS "gender: Gender", | ||
| 96 | + address AS "address: Address", | ||
| 97 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 98 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 95 | theme AS "theme: Theme", | 99 | theme AS "theme: Theme", |
| 96 | language AS "language: Language", | 100 | language AS "language: Language", |
| 97 | palette_color AS "palette_color: PaletteColor", | 101 | palette_color AS "palette_color: PaletteColor", |
| @@ -146,6 +150,10 @@ pub async fn read(db: &Database, id: &UserId) -> Result<Option<User>, AppError> | |||
| 146 | email AS "email: Email", | 150 | email AS "email: Email", |
| 147 | phone AS "phone: Phone", | 151 | phone AS "phone: Phone", |
| 148 | birth_date AS "birth_date: BirthDate", | 152 | birth_date AS "birth_date: BirthDate", |
| 153 | + gender AS "gender: Gender", | ||
| 154 | + address AS "address: Address", | ||
| 155 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 156 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 149 | theme AS "theme: Theme", | 157 | theme AS "theme: Theme", |
| 150 | language AS "language: Language", | 158 | language AS "language: Language", |
| 151 | palette_color AS "palette_color: PaletteColor", | 159 | palette_color AS "palette_color: PaletteColor", |
| @@ -192,6 +200,10 @@ pub async fn list_by_ids(db: &Database, ids: &[UserId]) -> Result<Vec<User>, App | |||
| 192 | email AS "email: Email", | 200 | email AS "email: Email", |
| 193 | phone AS "phone: Phone", | 201 | phone AS "phone: Phone", |
| 194 | birth_date AS "birth_date: BirthDate", | 202 | birth_date AS "birth_date: BirthDate", |
| 203 | + gender AS "gender: Gender", | ||
| 204 | + address AS "address: Address", | ||
| 205 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 206 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 195 | theme AS "theme: Theme", | 207 | theme AS "theme: Theme", |
| 196 | language AS "language: Language", | 208 | language AS "language: Language", |
| 197 | palette_color AS "palette_color: PaletteColor", | 209 | palette_color AS "palette_color: PaletteColor", |
| @@ -225,6 +237,10 @@ pub async fn list_by_role(db: &Database, role: Role) -> Result<Vec<User>, AppErr | |||
| 225 | email AS "email: Email", | 237 | email AS "email: Email", |
| 226 | phone AS "phone: Phone", | 238 | phone AS "phone: Phone", |
| 227 | birth_date AS "birth_date: BirthDate", | 239 | birth_date AS "birth_date: BirthDate", |
| 240 | + gender AS "gender: Gender", | ||
| 241 | + address AS "address: Address", | ||
| 242 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 243 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 228 | theme AS "theme: Theme", | 244 | theme AS "theme: Theme", |
| 229 | language AS "language: Language", | 245 | language AS "language: Language", |
| 230 | palette_color AS "palette_color: PaletteColor", | 246 | palette_color AS "palette_color: PaletteColor", |
| @@ -456,6 +472,10 @@ pub async fn set_role_cascade( | |||
| 456 | email AS "email: Email", | 472 | email AS "email: Email", |
| 457 | phone AS "phone: Phone", | 473 | phone AS "phone: Phone", |
| 458 | birth_date AS "birth_date: BirthDate", | 474 | birth_date AS "birth_date: BirthDate", |
| 475 | + gender AS "gender: Gender", | ||
| 476 | + address AS "address: Address", | ||
| 477 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 478 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 459 | theme AS "theme: Theme", | 479 | theme AS "theme: Theme", |
| 460 | language AS "language: Language", | 480 | language AS "language: Language", |
| 461 | palette_color AS "palette_color: PaletteColor", | 481 | palette_color AS "palette_color: PaletteColor", |
| @@ -722,6 +742,10 @@ pub async fn set_profile( | |||
| 722 | birth_date: Option<Option<BirthDate>>, | 742 | birth_date: Option<Option<BirthDate>>, |
| 723 | display_name: Option<Option<DisplayName>>, | 743 | display_name: Option<Option<DisplayName>>, |
| 724 | bio: Option<Option<Bio>>, | 744 | bio: Option<Option<Bio>>, |
| 745 | + gender: Option<Option<Gender>>, | ||
| 746 | + address: Option<Option<Address>>, | ||
| 747 | + emergency_contact_name: Option<Option<PersonName>>, | ||
| 748 | + emergency_contact_phone: Option<Option<Phone>>, | ||
| 725 | branch: Option<Option<String>>, | 749 | branch: Option<Option<String>>, |
| 726 | student_number: Option<Option<StudentNumber>>, | 750 | student_number: Option<Option<StudentNumber>>, |
| 727 | ) -> Result<User, AppError> { | 751 | ) -> Result<User, AppError> { |
| @@ -763,6 +787,30 @@ pub async fn set_profile( | |||
| 763 | "bio", | 787 | "bio", |
| 764 | text(bio.as_ref().map(|n| n.as_ref().map(|x| x.as_str()))), | 788 | text(bio.as_ref().map(|n| n.as_ref().map(|x| x.as_str()))), |
| 765 | ) | 789 | ) |
| 790 | + .set( | ||
| 791 | + "gender", | ||
| 792 | + text(gender.as_ref().map(|n| n.as_ref().map(|x| x.as_str()))), | ||
| 793 | + ) | ||
| 794 | + .set( | ||
| 795 | + "address", | ||
| 796 | + text(address.as_ref().map(|n| n.as_ref().map(|x| x.as_str()))), | ||
| 797 | + ) | ||
| 798 | + .set( | ||
| 799 | + "emergency_contact_name", | ||
| 800 | + text( | ||
| 801 | + emergency_contact_name | ||
| 802 | + .as_ref() | ||
| 803 | + .map(|n| n.as_ref().map(|x| x.as_str())), | ||
| 804 | + ), | ||
| 805 | + ) | ||
| 806 | + .set( | ||
| 807 | + "emergency_contact_phone", | ||
| 808 | + text( | ||
| 809 | + emergency_contact_phone | ||
| 810 | + .as_ref() | ||
| 811 | + .map(|n| n.as_ref().map(|x| x.as_str())), | ||
| 812 | + ), | ||
| 813 | + ) | ||
| 766 | // The subject area is plain text, not a newtype: the school's own list is | 814 | // The subject area is plain text, not a newtype: the school's own list is |
| 767 | // settings data, so its membership check belongs to the write path | 815 | // settings data, so its membership check belongs to the write path |
| 768 | // that holds that list (the web layer), not to a row type. | 816 | // that holds that list (the web layer), not to a row type. |
| @@ -840,6 +888,10 @@ pub async fn set_avatar( | |||
| 840 | email AS "email: Email", | 888 | email AS "email: Email", |
| 841 | phone AS "phone: Phone", | 889 | phone AS "phone: Phone", |
| 842 | birth_date AS "birth_date: BirthDate", | 890 | birth_date AS "birth_date: BirthDate", |
| 891 | + gender AS "gender: Gender", | ||
| 892 | + address AS "address: Address", | ||
| 893 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 894 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 843 | theme AS "theme: Theme", | 895 | theme AS "theme: Theme", |
| 844 | language AS "language: Language", | 896 | language AS "language: Language", |
| 845 | palette_color AS "palette_color: PaletteColor", | 897 | palette_color AS "palette_color: PaletteColor", |
| @@ -890,6 +942,10 @@ pub async fn clear_avatar(db: &Database, id: &UserId) -> Result<Option<User>, Ap | |||
| 890 | email AS "email: Email", | 942 | email AS "email: Email", |
| 891 | phone AS "phone: Phone", | 943 | phone AS "phone: Phone", |
| 892 | birth_date AS "birth_date: BirthDate", | 944 | birth_date AS "birth_date: BirthDate", |
| 945 | + gender AS "gender: Gender", | ||
| 946 | + address AS "address: Address", | ||
| 947 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 948 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 893 | theme AS "theme: Theme", | 949 | theme AS "theme: Theme", |
| 894 | language AS "language: Language", | 950 | language AS "language: Language", |
| 895 | palette_color AS "palette_color: PaletteColor", | 951 | palette_color AS "palette_color: PaletteColor", |
| @@ -954,6 +1010,10 @@ pub async fn find_by_username(db: &Database, username: &str) -> Result<Option<Us | |||
| 954 | email AS "email: Email", | 1010 | email AS "email: Email", |
| 955 | phone AS "phone: Phone", | 1011 | phone AS "phone: Phone", |
| 956 | birth_date AS "birth_date: BirthDate", | 1012 | birth_date AS "birth_date: BirthDate", |
| 1013 | + gender AS "gender: Gender", | ||
| 1014 | + address AS "address: Address", | ||
| 1015 | + emergency_contact_name AS "emergency_contact_name: PersonName", | ||
| 1016 | + emergency_contact_phone AS "emergency_contact_phone: Phone", | ||
| 957 | theme AS "theme: Theme", | 1017 | theme AS "theme: Theme", |
| 958 | language AS "language: Language", | 1018 | language AS "language: Language", |
| 959 | palette_color AS "palette_color: PaletteColor", | 1019 | palette_color AS "palette_color: PaletteColor", |
| @@ -1016,6 +1076,10 @@ mod tests { | |||
| 1016 | None, | 1076 | None, |
| 1017 | None, | 1077 | None, |
| 1018 | None, | 1078 | None, |
| 1079 | + None, | ||
| 1080 | + None, | ||
| 1081 | + None, | ||
| 1082 | + None, | ||
| 1019 | ) | 1083 | ) |
| 1020 | .await | 1084 | .await |
| 1021 | .unwrap(); | 1085 | .unwrap(); |
| @@ -1048,14 +1112,8 @@ mod tests { | |||
| 1048 | set_profile( | 1112 | set_profile( |
| 1049 | &db, | 1113 | &db, |
| 1050 | user.get_id(), | 1114 | user.get_id(), |
| 1051 | - None, | 1115 | + None, None, None, None, None, None, None, None, // name..bio |
| 1052 | - None, | 1116 | + None, None, None, None, // gender..emergency_contact_phone |
| 1053 | - None, | ||
| 1054 | - None, | ||
| 1055 | - None, | ||
| 1056 | - None, | ||
| 1057 | - None, | ||
| 1058 | - None, | ||
| 1059 | Some(Some(number.clone())), | 1117 | Some(Some(number.clone())), |
| 1060 | ) | 1118 | ) |
| 1061 | .await | 1119 | .await |
| @@ -1071,14 +1129,8 @@ mod tests { | |||
| 1071 | let refused = set_profile( | 1129 | let refused = set_profile( |
| 1072 | &db, | 1130 | &db, |
| 1073 | stale.get_id(), | 1131 | stale.get_id(), |
| 1074 | - None, | 1132 | + None, None, None, None, None, None, None, None, // name..bio |
| 1075 | - None, | 1133 | + None, None, None, None, // gender..emergency_contact_phone |
| 1076 | - None, | ||
| 1077 | - None, | ||
| 1078 | - None, | ||
| 1079 | - None, | ||
| 1080 | - None, | ||
| 1081 | - None, | ||
| 1082 | Some(Some(number)), | 1134 | Some(Some(number)), |
| 1083 | ) | 1135 | ) |
| 1084 | .await; | 1136 | .await; |
| @@ -1123,6 +1175,10 @@ mod tests { | |||
| 1123 | None, | 1175 | None, |
| 1124 | None, | 1176 | None, |
| 1125 | None, | 1177 | None, |
| 1178 | + None, | ||
| 1179 | + None, | ||
| 1180 | + None, | ||
| 1181 | + None, | ||
| 1126 | ) | 1182 | ) |
| 1127 | .await | 1183 | .await |
| 1128 | .unwrap(); | 1184 | .unwrap(); |
src/domain/profile.rsmodified+93 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | //! Personal-info newtypes shared by every account role — student, teacher, | 1 | //! Personal-info newtypes shared by every account role — student, teacher, |
| 2 | //! manager, and admin records all carry the same optional contact fields. | 2 | //! manager, and admin records all carry the same optional contact fields. |
| 3 | 3 | ||
| 4 | -use crate::constant::{MAX_BIO_LEN, MAX_DISPLAY_NAME_LEN, MAX_NAME_LEN}; | 4 | +use crate::constant::{MAX_ADDRESS_LEN, MAX_BIO_LEN, MAX_DISPLAY_NAME_LEN, MAX_NAME_LEN}; |
| 5 | use crate::domain::badge::BadgeStats; | 5 | use crate::domain::badge::BadgeStats; |
| 6 | use crate::domain::timestamp::Timestamp; | 6 | use crate::domain::timestamp::Timestamp; |
| 7 | use crate::error::ValidationError; | 7 | use crate::error::ValidationError; |
| @@ -131,6 +131,69 @@ impl Bio { | |||
| 131 | } | 131 | } |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | +/// A person's gender, self-declared and deliberately coarse — the school | ||
| 135 | +/// office needs a word for a form, not an identity system. One of four fixed | ||
| 136 | +/// wire values (`female`, `male`, `other`, `undisclosed`), stored as the same | ||
| 137 | +/// string; `NULL` (never chosen) is a row state, not a fifth value. | ||
| 138 | +#[derive(Debug, Clone, Copy, PartialEq, Eq, sqlx::Type)] | ||
| 139 | +#[sqlx(type_name = "TEXT", rename_all = "lowercase")] | ||
| 140 | +pub enum Gender { | ||
| 141 | + Female, | ||
| 142 | + Male, | ||
| 143 | + Other, | ||
| 144 | + Undisclosed, | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +impl Gender { | ||
| 148 | + /// The wire/storage form. Must stay in lockstep with `rename_all = "lowercase"`. | ||
| 149 | + pub fn as_str(self) -> &'static str { | ||
| 150 | + match self { | ||
| 151 | + Gender::Female => "female", | ||
| 152 | + Gender::Male => "male", | ||
| 153 | + Gender::Other => "other", | ||
| 154 | + Gender::Undisclosed => "undisclosed", | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + /// Parse a wire string into a gender — the inverse of [`Gender::as_str`]. | ||
| 159 | + /// The vocabulary is closed, so an unknown value is a plain 400, the same | ||
| 160 | + /// refusal an out-of-vocabulary `theme` gets. | ||
| 161 | + pub fn try_from_str(value: &str) -> Result<Self, ValidationError> { | ||
| 162 | + GENDERS | ||
| 163 | + .into_iter() | ||
| 164 | + .find(|gender| gender.as_str() == value) | ||
| 165 | + .ok_or(ValidationError::Invalid { | ||
| 166 | + field: "gender", | ||
| 167 | + reason: "must be one of: female, male, other, undisclosed", | ||
| 168 | + }) | ||
| 169 | + } | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +pub const GENDERS: [Gender; 4] = [ | ||
| 173 | + Gender::Female, | ||
| 174 | + Gender::Male, | ||
| 175 | + Gender::Other, | ||
| 176 | + Gender::Undisclosed, | ||
| 177 | +]; | ||
| 178 | + | ||
| 179 | +/// A postal address, [`MAX_ADDRESS_LEN`] characters at most. Free text on | ||
| 180 | +/// purpose — addresses do not fit a shape the way a phone number does, and | ||
| 181 | +/// enforcing one would only reject real ones. Stored trimmed. | ||
| 182 | +#[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)] | ||
| 183 | +#[sqlx(transparent)] | ||
| 184 | +pub struct Address(String); | ||
| 185 | + | ||
| 186 | +impl Address { | ||
| 187 | + pub fn try_new(value: &str) -> Result<Self, ValidationError> { | ||
| 188 | + validate_required("address", value, MAX_ADDRESS_LEN)?; | ||
| 189 | + Ok(Self(value.trim().to_string())) | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + pub fn as_str(&self) -> &str { | ||
| 193 | + &self.0 | ||
| 194 | + } | ||
| 195 | +} | ||
| 196 | + | ||
| 134 | /// The motivational counters on a public profile. Every field is a derived | 197 | /// The motivational counters on a public profile. Every field is a derived |
| 135 | /// count, never a settable one: zero rows is a true zero, so these are `i64` | 198 | /// count, never a settable one: zero rows is a true zero, so these are `i64` |
| 136 | /// and never `Option` — a `null` in this API means "never chose", which a | 199 | /// and never `Option` — a `null` in this API means "never chose", which a |
| @@ -259,4 +322,33 @@ mod tests { | |||
| 259 | assert!(Bio::try_new(&"é".repeat(MAX_BIO_LEN)).is_ok()); | 322 | assert!(Bio::try_new(&"é".repeat(MAX_BIO_LEN)).is_ok()); |
| 260 | assert!(Bio::try_new(&"é".repeat(MAX_BIO_LEN + 1)).is_err()); | 323 | assert!(Bio::try_new(&"é".repeat(MAX_BIO_LEN + 1)).is_err()); |
| 261 | } | 324 | } |
| 325 | + | ||
| 326 | + #[tokio::test] | ||
| 327 | + async fn gender_parses_the_closed_vocabulary() { | ||
| 328 | + assert_eq!(Gender::try_from_str("female").unwrap(), Gender::Female); | ||
| 329 | + assert_eq!(Gender::try_from_str("male").unwrap().as_str(), "male"); | ||
| 330 | + assert_eq!(Gender::try_from_str("other").unwrap(), Gender::Other); | ||
| 331 | + assert_eq!( | ||
| 332 | + Gender::try_from_str("undisclosed").unwrap(), | ||
| 333 | + Gender::Undisclosed | ||
| 334 | + ); | ||
| 335 | + // The vocabulary is closed: no synonyms, no case play, no blank. | ||
| 336 | + assert!(Gender::try_from_str("woman").is_err()); | ||
| 337 | + assert!(Gender::try_from_str("FEMALE").is_err()); | ||
| 338 | + assert!(Gender::try_from_str("").is_err()); | ||
| 339 | + } | ||
| 340 | + | ||
| 341 | + #[tokio::test] | ||
| 342 | + async fn address_trims_and_respects_the_bound() { | ||
| 343 | + assert_eq!( | ||
| 344 | + Address::try_new(" Çamlık Mah. 2. Sk. No: 7 ") | ||
| 345 | + .unwrap() | ||
| 346 | + .as_str(), | ||
| 347 | + "Çamlık Mah. 2. Sk. No: 7" | ||
| 348 | + ); | ||
| 349 | + // Blank is "not given" — the three-state PATCH clears it, never stores it. | ||
| 350 | + assert!(Address::try_new(" ").is_err()); | ||
| 351 | + assert!(Address::try_new(&"x".repeat(MAX_ADDRESS_LEN)).is_ok()); | ||
| 352 | + assert!(Address::try_new(&"x".repeat(MAX_ADDRESS_LEN + 1)).is_err()); | ||
| 353 | + } | ||
| 262 | } | 354 | } |
src/domain/user.rsmodified+30 -1
| @@ -14,7 +14,9 @@ use crate::domain::monotonic_id::next_uuid; | |||
| 14 | use crate::domain::note_file::FileContentType; | 14 | use crate::domain::note_file::FileContentType; |
| 15 | use crate::domain::person::PersonId; | 15 | use crate::domain::person::PersonId; |
| 16 | use crate::domain::preferences::{Language, PaletteColor, Theme}; | 16 | use crate::domain::preferences::{Language, PaletteColor, Theme}; |
| 17 | -use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone}; | 17 | +use crate::domain::profile::{ |
| 18 | + Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone, | ||
| 19 | +}; | ||
| 18 | use crate::domain::role::Role; | 20 | use crate::domain::role::Role; |
| 19 | use crate::error::{AppError, ValidationError}; | 21 | use crate::error::{AppError, ValidationError}; |
| 20 | use crate::validate::{validate_password, validate_required, validate_username}; | 22 | use crate::validate::{validate_password, validate_required, validate_username}; |
| @@ -264,6 +266,13 @@ pub struct User { | |||
| 264 | pub(crate) email: Option<Email>, | 266 | pub(crate) email: Option<Email>, |
| 265 | pub(crate) phone: Option<Phone>, | 267 | pub(crate) phone: Option<Phone>, |
| 266 | pub(crate) birth_date: Option<BirthDate>, | 268 | pub(crate) birth_date: Option<BirthDate>, |
| 269 | + /// Self-declared gender, a postal address, and who to call when this | ||
| 270 | + /// person is unreachable. Optional like everything above — the same | ||
| 271 | + /// "filled in later, `None` = never chose" contract. | ||
| 272 | + pub(crate) gender: Option<Gender>, | ||
| 273 | + pub(crate) address: Option<Address>, | ||
| 274 | + pub(crate) emergency_contact_name: Option<PersonName>, | ||
| 275 | + pub(crate) emergency_contact_phone: Option<Phone>, | ||
| 267 | // Frontend UI preferences. Optional like the personal info: `None` means | 276 | // Frontend UI preferences. Optional like the personal info: `None` means |
| 268 | // "never chose", which the frontend renders as the device preference. | 277 | // "never chose", which the frontend renders as the device preference. |
| 269 | pub(crate) theme: Option<Theme>, | 278 | pub(crate) theme: Option<Theme>, |
| @@ -306,6 +315,10 @@ impl User { | |||
| 306 | email: None, | 315 | email: None, |
| 307 | phone: None, | 316 | phone: None, |
| 308 | birth_date: None, | 317 | birth_date: None, |
| 318 | + gender: None, | ||
| 319 | + address: None, | ||
| 320 | + emergency_contact_name: None, | ||
| 321 | + emergency_contact_phone: None, | ||
| 309 | theme: None, | 322 | theme: None, |
| 310 | language: None, | 323 | language: None, |
| 311 | palette_color: None, | 324 | palette_color: None, |
| @@ -361,6 +374,22 @@ impl User { | |||
| 361 | self.birth_date.as_ref() | 374 | self.birth_date.as_ref() |
| 362 | } | 375 | } |
| 363 | 376 | ||
| 377 | + pub fn get_gender(&self) -> Option<Gender> { | ||
| 378 | + self.gender | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | + pub fn get_address(&self) -> Option<&Address> { | ||
| 382 | + self.address.as_ref() | ||
| 383 | + } | ||
| 384 | + | ||
| 385 | + pub fn get_emergency_contact_name(&self) -> Option<&PersonName> { | ||
| 386 | + self.emergency_contact_name.as_ref() | ||
| 387 | + } | ||
| 388 | + | ||
| 389 | + pub fn get_emergency_contact_phone(&self) -> Option<&Phone> { | ||
| 390 | + self.emergency_contact_phone.as_ref() | ||
| 391 | + } | ||
| 392 | + | ||
| 364 | pub fn get_theme(&self) -> Option<Theme> { | 393 | pub fn get_theme(&self) -> Option<Theme> { |
| 365 | self.theme | 394 | self.theme |
| 366 | } | 395 | } |
src/service/user.rsmodified+11 -1
| @@ -9,7 +9,9 @@ use crate::domain::board::Board; | |||
| 9 | use crate::domain::note_file::FileContentType; | 9 | use crate::domain::note_file::FileContentType; |
| 10 | use crate::domain::person::PersonId; | 10 | use crate::domain::person::PersonId; |
| 11 | use crate::domain::preferences::{Language, PaletteColor, Theme}; | 11 | use crate::domain::preferences::{Language, PaletteColor, Theme}; |
| 12 | -use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone}; | 12 | +use crate::domain::profile::{ |
| 13 | + Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone, | ||
| 14 | +}; | ||
| 13 | use crate::domain::role::Role; | 15 | use crate::domain::role::Role; |
| 14 | use crate::domain::user::{Password, StudentNumber, User, UserId, Username}; | 16 | use crate::domain::user::{Password, StudentNumber, User, UserId, Username}; |
| 15 | use crate::error::AppError; | 17 | use crate::error::AppError; |
| @@ -176,6 +178,10 @@ pub async fn set_profile( | |||
| 176 | birth_date: Option<Option<BirthDate>>, | 178 | birth_date: Option<Option<BirthDate>>, |
| 177 | display_name: Option<Option<DisplayName>>, | 179 | display_name: Option<Option<DisplayName>>, |
| 178 | bio: Option<Option<Bio>>, | 180 | bio: Option<Option<Bio>>, |
| 181 | + gender: Option<Option<Gender>>, | ||
| 182 | + address: Option<Option<Address>>, | ||
| 183 | + emergency_contact_name: Option<Option<PersonName>>, | ||
| 184 | + emergency_contact_phone: Option<Option<Phone>>, | ||
| 179 | // The subject specialisation, clearable like `bio`; membership in the | 185 | // The subject specialisation, clearable like `bio`; membership in the |
| 180 | // school's `Settings::get_branches()` list is the caller's check, not this | 186 | // school's `Settings::get_branches()` list is the caller's check, not this |
| 181 | // one's. | 187 | // one's. |
| @@ -195,6 +201,10 @@ pub async fn set_profile( | |||
| 195 | birth_date, | 201 | birth_date, |
| 196 | display_name, | 202 | display_name, |
| 197 | bio, | 203 | bio, |
| 204 | + gender, | ||
| 205 | + address, | ||
| 206 | + emergency_contact_name, | ||
| 207 | + emergency_contact_phone, | ||
| 198 | branch, | 208 | branch, |
| 199 | student_number, | 209 | student_number, |
| 200 | ) | 210 | ) |
src/web/dto.rsmodified+22 -0
| @@ -182,6 +182,20 @@ pub struct UserResponse { | |||
| 182 | pub phone: Option<String>, | 182 | pub phone: Option<String>, |
| 183 | #[schema(example = "1990-01-02")] | 183 | #[schema(example = "1990-01-02")] |
| 184 | pub birth_date: Option<String>, | 184 | pub birth_date: Option<String>, |
| 185 | + /// Self-declared gender: `female`, `male`, `other`, or `undisclosed`; | ||
| 186 | + /// `null` = never chosen. | ||
| 187 | + #[schema(example = "female")] | ||
| 188 | + pub gender: Option<String>, | ||
| 189 | + /// Postal address; `null` when unset, at most `max_address_len` characters. | ||
| 190 | + #[schema(example = "Çamlık Mah. 2. Sk. No: 7, Bornova / İzmir")] | ||
| 191 | + pub address: Option<String>, | ||
| 192 | + /// Who to call when this person is unreachable; `null` when unset. Same | ||
| 193 | + /// gate as the other contact fields — never on the public profile. | ||
| 194 | + #[schema(example = "Mehmet Yılmaz")] | ||
| 195 | + pub emergency_contact_name: Option<String>, | ||
| 196 | + /// The emergency contact's phone, same shape as `phone`; `null` when unset. | ||
| 197 | + #[schema(example = "+90 555 987 65 43")] | ||
| 198 | + pub emergency_contact_phone: Option<String>, | ||
| 185 | /// UI color scheme: `light` or `dark`. `null` = never chosen — the client | 199 | /// UI color scheme: `light` or `dark`. `null` = never chosen — the client |
| 186 | /// should fall back to the device preference. | 200 | /// should fall back to the device preference. |
| 187 | #[schema(example = "dark")] | 201 | #[schema(example = "dark")] |
| @@ -218,6 +232,14 @@ impl UserResponse { | |||
| 218 | email: user.get_email().map(|v| v.as_str().to_string()), | 232 | email: user.get_email().map(|v| v.as_str().to_string()), |
| 219 | phone: user.get_phone().map(|v| v.as_str().to_string()), | 233 | phone: user.get_phone().map(|v| v.as_str().to_string()), |
| 220 | birth_date: user.get_birth_date().map(|v| v.as_str().to_string()), | 234 | birth_date: user.get_birth_date().map(|v| v.as_str().to_string()), |
| 235 | + gender: user.get_gender().map(|v| v.as_str().to_string()), | ||
| 236 | + address: user.get_address().map(|v| v.as_str().to_string()), | ||
| 237 | + emergency_contact_name: user | ||
| 238 | + .get_emergency_contact_name() | ||
| 239 | + .map(|v| v.as_str().to_string()), | ||
| 240 | + emergency_contact_phone: user | ||
| 241 | + .get_emergency_contact_phone() | ||
| 242 | + .map(|v| v.as_str().to_string()), | ||
| 221 | theme: user.get_theme().map(|v| v.as_str().to_string()), | 243 | theme: user.get_theme().map(|v| v.as_str().to_string()), |
| 222 | language: user.get_language().map(|v| v.as_str().to_string()), | 244 | language: user.get_language().map(|v| v.as_str().to_string()), |
| 223 | palette_color: user.get_palette_color().map(|v| v.as_str().to_string()), | 245 | palette_color: user.get_palette_color().map(|v| v.as_str().to_string()), |
src/web/limits.rsmodified+8 -0
| @@ -21,6 +21,7 @@ use utoipa_axum::routes; | |||
| 21 | use crate::constant::*; | 21 | use crate::constant::*; |
| 22 | use crate::domain::badge::BADGES; | 22 | use crate::domain::badge::BADGES; |
| 23 | use crate::domain::preferences::{LANGUAGES, THEMES}; | 23 | use crate::domain::preferences::{LANGUAGES, THEMES}; |
| 24 | +use crate::domain::profile::GENDERS; | ||
| 24 | use crate::domain::role::ROLES; | 25 | use crate::domain::role::ROLES; |
| 25 | use crate::state::AppState; | 26 | use crate::state::AppState; |
| 26 | 27 | ||
| @@ -47,6 +48,8 @@ struct UserLimits { | |||
| 47 | max_display_name_len: usize, | 48 | max_display_name_len: usize, |
| 48 | /// Free text under a profile's name. | 49 | /// Free text under a profile's name. |
| 49 | max_bio_len: usize, | 50 | max_bio_len: usize, |
| 51 | + /// A postal address's length bound. | ||
| 52 | + max_address_len: usize, | ||
| 50 | /// A student number's length bound (free text; unique inside the school, | 53 | /// A student number's length bound (free text; unique inside the school, |
| 51 | /// and only ever held by a `student` account). | 54 | /// and only ever held by a `student` account). |
| 52 | max_student_number_len: usize, | 55 | max_student_number_len: usize, |
| @@ -68,6 +71,9 @@ struct UserLimits { | |||
| 68 | /// Accepted `language` preference values (`null` clears it). | 71 | /// Accepted `language` preference values (`null` clears it). |
| 69 | #[schema(example = json!(["tr", "en"]))] | 72 | #[schema(example = json!(["tr", "en"]))] |
| 70 | languages: Vec<&'static str>, | 73 | languages: Vec<&'static str>, |
| 74 | + /// Accepted `gender` profile values (`null` = never chosen). | ||
| 75 | + #[schema(example = json!(["female", "male", "other", "undisclosed"]))] | ||
| 76 | + genders: Vec<&'static str>, | ||
| 71 | /// Shape a `palette_color` preference must match, as a regular expression | 77 | /// Shape a `palette_color` preference must match, as a regular expression |
| 72 | /// (`null` clears it). Open on purpose — any hex accent color, not a fixed | 78 | /// (`null` clears it). Open on purpose — any hex accent color, not a fixed |
| 73 | /// palette — so this is a pattern, not a value list like `themes`. Matches | 79 | /// palette — so this is a pattern, not a value list like `themes`. Matches |
| @@ -538,6 +544,7 @@ impl LimitsResponse { | |||
| 538 | max_name_len: MAX_NAME_LEN, | 544 | max_name_len: MAX_NAME_LEN, |
| 539 | max_display_name_len: MAX_DISPLAY_NAME_LEN, | 545 | max_display_name_len: MAX_DISPLAY_NAME_LEN, |
| 540 | max_bio_len: MAX_BIO_LEN, | 546 | max_bio_len: MAX_BIO_LEN, |
| 547 | + max_address_len: MAX_ADDRESS_LEN, | ||
| 541 | max_student_number_len: MAX_STUDENT_NUMBER_LEN, | 548 | max_student_number_len: MAX_STUDENT_NUMBER_LEN, |
| 542 | max_profile_courses: MAX_PROFILE_COURSES, | 549 | max_profile_courses: MAX_PROFILE_COURSES, |
| 543 | max_profile_classes: MAX_PROFILE_CLASSES, | 550 | max_profile_classes: MAX_PROFILE_CLASSES, |
| @@ -547,6 +554,7 @@ impl LimitsResponse { | |||
| 547 | roles: ROLES.iter().map(|role| role.as_str()).collect(), | 554 | roles: ROLES.iter().map(|role| role.as_str()).collect(), |
| 548 | themes: THEMES.iter().map(|theme| theme.as_str()).collect(), | 555 | themes: THEMES.iter().map(|theme| theme.as_str()).collect(), |
| 549 | languages: LANGUAGES.iter().map(|language| language.as_str()).collect(), | 556 | languages: LANGUAGES.iter().map(|language| language.as_str()).collect(), |
| 557 | + genders: GENDERS.iter().map(|gender| gender.as_str()).collect(), | ||
| 550 | palette_color_pattern: PALETTE_COLOR_PATTERN, | 558 | palette_color_pattern: PALETTE_COLOR_PATTERN, |
| 551 | palette_color_len: PALETTE_COLOR_LEN, | 559 | palette_color_len: PALETTE_COLOR_LEN, |
| 552 | session_duration_days: SESSION_DURATION_DAYS, | 560 | session_duration_days: SESSION_DURATION_DAYS, |
src/web/users.rsmodified+27 -1
| @@ -18,7 +18,9 @@ use crate::domain::badge::{self, BadgeAward}; | |||
| 18 | use crate::domain::class_group::ClassGroupId; | 18 | use crate::domain::class_group::ClassGroupId; |
| 19 | 19 | ||
| 20 | use crate::domain::preferences::{Language, PaletteColor, Theme}; | 20 | use crate::domain::preferences::{Language, PaletteColor, Theme}; |
| 21 | -use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone, ProfileStats}; | 21 | +use crate::domain::profile::{ |
| 22 | + Address, Bio, BirthDate, DisplayName, Email, Gender, PersonName, Phone, ProfileStats, | ||
| 23 | +}; | ||
| 22 | use crate::domain::role::Role; | 24 | use crate::domain::role::Role; |
| 23 | use crate::domain::user::{Password, StudentNumber, User, UserId, Username}; | 25 | use crate::domain::user::{Password, StudentNumber, User, UserId, Username}; |
| 24 | use crate::error::{AppError, ErrorResponse, ValidationError}; | 26 | use crate::error::{AppError, ErrorResponse, ValidationError}; |
| @@ -94,6 +96,19 @@ struct UpdateProfile { | |||
| 94 | /// Free text under the profile's name. | 96 | /// Free text under the profile's name. |
| 95 | #[schema(example = "Sınıfın en hızlı pomodorocusu.", max_length = 500)] | 97 | #[schema(example = "Sınıfın en hızlı pomodorocusu.", max_length = 500)] |
| 96 | bio: Option<String>, | 98 | bio: Option<String>, |
| 99 | + /// Self-declared gender: `female`, `male`, `other`, or `undisclosed`. | ||
| 100 | + /// A closed vocabulary — anything else is a `400`. | ||
| 101 | + #[schema(example = "female")] | ||
| 102 | + gender: Option<String>, | ||
| 103 | + /// Postal address, at most `max_address_len` characters (from `GET /limits`). | ||
| 104 | + #[schema(example = "Çamlık Mah. 2. Sk. No: 7, Bornova / İzmir", max_length = 500)] | ||
| 105 | + address: Option<String>, | ||
| 106 | + /// Who to call when the person is unreachable. Same rules as `name`. | ||
| 107 | + #[schema(example = "Mehmet Yılmaz", max_length = 100)] | ||
| 108 | + emergency_contact_name: Option<String>, | ||
| 109 | + /// The emergency contact's phone, same shape as `phone`. | ||
| 110 | + #[schema(example = "+90 555 987 65 43")] | ||
| 111 | + emergency_contact_phone: Option<String>, | ||
| 97 | /// The teacher's subject specialisation: one of the school's `branches` from | 112 | /// The teacher's subject specialisation: one of the school's `branches` from |
| 98 | /// `GET /settings`, by name. Omit to keep the current value; send `""` to | 113 | /// `GET /settings`, by name. Omit to keep the current value; send `""` to |
| 99 | /// clear it (a school that lists no subjects stores none). | 114 | /// clear it (a school that lists no subjects stores none). |
| @@ -220,6 +235,13 @@ async fn apply_profile( | |||
| 220 | let birth_date = merge_field(req.birth_date.as_deref(), BirthDate::try_new)?; | 235 | let birth_date = merge_field(req.birth_date.as_deref(), BirthDate::try_new)?; |
| 221 | let display_name = merge_field(req.display_name.as_deref(), DisplayName::try_new)?; | 236 | let display_name = merge_field(req.display_name.as_deref(), DisplayName::try_new)?; |
| 222 | let bio = merge_field(req.bio.as_deref(), Bio::try_new)?; | 237 | let bio = merge_field(req.bio.as_deref(), Bio::try_new)?; |
| 238 | + let gender = merge_field(req.gender.as_deref(), Gender::try_from_str)?; | ||
| 239 | + let address = merge_field(req.address.as_deref(), Address::try_new)?; | ||
| 240 | + let emergency_contact_name = merge_field(req.emergency_contact_name.as_deref(), |v| { | ||
| 241 | + PersonName::try_new("emergency_contact_name", v) | ||
| 242 | + })?; | ||
| 243 | + let emergency_contact_phone = | ||
| 244 | + merge_field(req.emergency_contact_phone.as_deref(), Phone::try_new)?; | ||
| 223 | let student_number = merge_student_number(req.student_number.as_deref(), user.get_role())?; | 245 | let student_number = merge_student_number(req.student_number.as_deref(), user.get_role())?; |
| 224 | // Only a request that actually names a branch pays the settings read. | 246 | // Only a request that actually names a branch pays the settings read. |
| 225 | let branch = match req.branch { | 247 | let branch = match req.branch { |
| @@ -239,6 +261,10 @@ async fn apply_profile( | |||
| 239 | birth_date, | 261 | birth_date, |
| 240 | display_name, | 262 | display_name, |
| 241 | bio, | 263 | bio, |
| 264 | + gender, | ||
| 265 | + address, | ||
| 266 | + emergency_contact_name, | ||
| 267 | + emergency_contact_phone, | ||
| 242 | branch, | 268 | branch, |
| 243 | student_number, | 269 | student_number, |
| 244 | ) | 270 | ) |
tests/integration.rsmodified+105 -0
| @@ -5649,6 +5649,111 @@ async fn profile_rejects_invalid_fields() { | |||
| 5649 | } | 5649 | } |
| 5650 | } | 5650 | } |
| 5651 | 5651 | ||
| 5652 | +// --- users: gender, address, emergency contact ------------------------------ | ||
| 5653 | + | ||
| 5654 | +#[tokio::test] | ||
| 5655 | +async fn profile_extra_fields_round_trip_via_users_me() { | ||
| 5656 | + let app = mem_app().await; | ||
| 5657 | + let bob = login(&app, "bob").await; | ||
| 5658 | + | ||
| 5659 | + // A fresh account carries none of the extras. | ||
| 5660 | + let me = send(&app, "GET", "/auth/me", Some(&bob), None).await; | ||
| 5661 | + assert_eq!(me.status, StatusCode::OK); | ||
| 5662 | + for field in [ | ||
| 5663 | + "gender", | ||
| 5664 | + "address", | ||
| 5665 | + "emergency_contact_name", | ||
| 5666 | + "emergency_contact_phone", | ||
| 5667 | + ] { | ||
| 5668 | + assert!(me.body[field].is_null(), "{field} should start null"); | ||
| 5669 | + } | ||
| 5670 | + | ||
| 5671 | + // Set all four in one patch. | ||
| 5672 | + let res = send( | ||
| 5673 | + &app, | ||
| 5674 | + "PATCH", | ||
| 5675 | + "/users/me", | ||
| 5676 | + Some(&bob), | ||
| 5677 | + Some(json!({ | ||
| 5678 | + "gender": "female", | ||
| 5679 | + "address": " Çamlık Mah. 2. Sk. No: 7 ", | ||
| 5680 | + "emergency_contact_name": "Mehmet Yılmaz", | ||
| 5681 | + "emergency_contact_phone": "+90 555 987 65 43", | ||
| 5682 | + })), | ||
| 5683 | + ) | ||
| 5684 | + .await; | ||
| 5685 | + assert_eq!(res.status, StatusCode::OK, "{}", res.body); | ||
| 5686 | + assert_eq!(res.body["gender"], "female"); | ||
| 5687 | + assert_eq!(res.body["address"], "Çamlık Mah. 2. Sk. No: 7"); // trimmed | ||
| 5688 | + assert_eq!(res.body["emergency_contact_name"], "Mehmet Yılmaz"); | ||
| 5689 | + assert_eq!(res.body["emergency_contact_phone"], "+90 555 987 65 43"); | ||
| 5690 | + | ||
| 5691 | + // Partial patch: only the address changes, everything else survives. | ||
| 5692 | + let res = send( | ||
| 5693 | + &app, | ||
| 5694 | + "PATCH", | ||
| 5695 | + "/users/me", | ||
| 5696 | + Some(&bob), | ||
| 5697 | + Some(json!({ "address": "Yeni Mah." })), | ||
| 5698 | + ) | ||
| 5699 | + .await; | ||
| 5700 | + assert_eq!(res.status, StatusCode::OK); | ||
| 5701 | + assert_eq!(res.body["address"], "Yeni Mah."); | ||
| 5702 | + assert_eq!(res.body["gender"], "female"); | ||
| 5703 | + assert_eq!(res.body["emergency_contact_name"], "Mehmet Yılmaz"); | ||
| 5704 | + assert_eq!(res.body["emergency_contact_phone"], "+90 555 987 65 43"); | ||
| 5705 | + | ||
| 5706 | + // Empty string clears exactly the field it was sent for. | ||
| 5707 | + let res = send( | ||
| 5708 | + &app, | ||
| 5709 | + "PATCH", | ||
| 5710 | + "/users/me", | ||
| 5711 | + Some(&bob), | ||
| 5712 | + Some(json!({ "gender": "" })), | ||
| 5713 | + ) | ||
| 5714 | + .await; | ||
| 5715 | + assert_eq!(res.status, StatusCode::OK); | ||
| 5716 | + assert!(res.body["gender"].is_null()); | ||
| 5717 | + assert_eq!(res.body["address"], "Yeni Mah."); | ||
| 5718 | + | ||
| 5719 | + // The merged state is what /auth/me reports afterwards. | ||
| 5720 | + let me = send(&app, "GET", "/auth/me", Some(&bob), None).await; | ||
| 5721 | + assert!(me.body["gender"].is_null()); | ||
| 5722 | + assert_eq!(me.body["address"], "Yeni Mah."); | ||
| 5723 | + assert_eq!(me.body["emergency_contact_phone"], "+90 555 987 65 43"); | ||
| 5724 | +} | ||
| 5725 | + | ||
| 5726 | +#[tokio::test] | ||
| 5727 | +async fn profile_rejects_invalid_extra_fields() { | ||
| 5728 | + let app = mem_app().await; | ||
| 5729 | + let bob = login(&app, "bob").await; | ||
| 5730 | + | ||
| 5731 | + let bad = [ | ||
| 5732 | + json!({ "gender": "woman" }), // not in the vocabulary | ||
| 5733 | + json!({ "gender": "FEMALE" }), // the vocabulary is lowercase | ||
| 5734 | + json!({ "address": "x".repeat(501) }), // one over the bound | ||
| 5735 | + json!({ "address": " " }), // whitespace-only is not a value | ||
| 5736 | + json!({ "emergency_contact_phone": "123" }), | ||
| 5737 | + json!({ "emergency_contact_phone": "letters" }), | ||
| 5738 | + json!({ "emergency_contact_name": " " }), | ||
| 5739 | + ]; | ||
| 5740 | + for body in bad { | ||
| 5741 | + let res = send(&app, "PATCH", "/users/me", Some(&bob), Some(body.clone())).await; | ||
| 5742 | + assert_eq!(res.status, StatusCode::BAD_REQUEST, "should reject {body}"); | ||
| 5743 | + } | ||
| 5744 | + | ||
| 5745 | + // A rejected patch must not have half-applied. | ||
| 5746 | + let me = send(&app, "GET", "/auth/me", Some(&bob), None).await; | ||
| 5747 | + for field in [ | ||
| 5748 | + "gender", | ||
| 5749 | + "address", | ||
| 5750 | + "emergency_contact_name", | ||
| 5751 | + "emergency_contact_phone", | ||
| 5752 | + ] { | ||
| 5753 | + assert!(me.body[field].is_null(), "{field} should still be null"); | ||
| 5754 | + } | ||
| 5755 | +} | ||
| 5756 | + | ||
| 5652 | #[tokio::test] | 5757 | #[tokio::test] |
| 5653 | async fn admin_reads_and_edits_any_profile_with_guards() { | 5758 | async fn admin_reads_and_edits_any_profile_with_guards() { |
| 5654 | let (app, db) = app_and_db().await; | 5759 | let (app, db) = app_and_db().await; |
tests/limits_completeness.rsmodified+1 -0
| @@ -503,6 +503,7 @@ const MOVED_TABLES: &[(&str, &str)] = &[ | |||
| 503 | ("src/domain/role.rs", "ROLES"), | 503 | ("src/domain/role.rs", "ROLES"), |
| 504 | ("src/domain/preferences.rs", "THEMES"), | 504 | ("src/domain/preferences.rs", "THEMES"), |
| 505 | ("src/domain/preferences.rs", "LANGUAGES"), | 505 | ("src/domain/preferences.rs", "LANGUAGES"), |
| 506 | + ("src/domain/profile.rs", "GENDERS"), | ||
| 506 | ("src/domain/message.rs", "SENDER_FOLDERS"), | 507 | ("src/domain/message.rs", "SENDER_FOLDERS"), |
| 507 | ("src/domain/message.rs", "RECIPIENT_FOLDERS"), | 508 | ("src/domain/message.rs", "RECIPIENT_FOLDERS"), |
| 508 | ("src/domain/badge.rs", "BADGES"), | 509 | ("src/domain/badge.rs", "BADGES"), |
tests/partial_patch_users.rsmodified+58 -0
| @@ -210,3 +210,61 @@ async fn omitted_keeps_empty_clears_and_validation_still_bites() { | |||
| 210 | "bad palette color refused" | 210 | "bad palette color refused" |
| 211 | ); | 211 | ); |
| 212 | } | 212 | } |
| 213 | + | ||
| 214 | +/// The new profile extras ride the same three-state merge: omitted (and | ||
| 215 | +/// `null`) keeps, `""` clears, and an out-of-vocabulary value is a `400` — | ||
| 216 | +/// the field inventory must not grow into a second, looser code path. | ||
| 217 | +#[tokio::test] | ||
| 218 | +async fn extra_profile_fields_merge_field_by_field() { | ||
| 219 | + let (app, db) = app_and_db().await; | ||
| 220 | + let who = login_as(&app, &db, "ece", "student").await; | ||
| 221 | + | ||
| 222 | + let set = send( | ||
| 223 | + &app, | ||
| 224 | + "PATCH", | ||
| 225 | + "/users/me", | ||
| 226 | + Some(&who), | ||
| 227 | + Some(json!({ "gender": "other", "address": "Deniz Mah." })), | ||
| 228 | + ) | ||
| 229 | + .await; | ||
| 230 | + assert_eq!(set.status, StatusCode::OK, "{}", set.body); | ||
| 231 | + | ||
| 232 | + // An explicit null keeps, and the field not named survives untouched. | ||
| 233 | + let kept = send( | ||
| 234 | + &app, | ||
| 235 | + "PATCH", | ||
| 236 | + "/users/me", | ||
| 237 | + Some(&who), | ||
| 238 | + Some(json!({ "address": null })), | ||
| 239 | + ) | ||
| 240 | + .await; | ||
| 241 | + assert_eq!(kept.status, StatusCode::OK); | ||
| 242 | + assert_eq!(kept.body["gender"], "other", "omitted gender kept"); | ||
| 243 | + assert_eq!(kept.body["address"], "Deniz Mah.", "null keeps address"); | ||
| 244 | + | ||
| 245 | + // `""` clears one field; the other stays. | ||
| 246 | + let cleared = send( | ||
| 247 | + &app, | ||
| 248 | + "PATCH", | ||
| 249 | + "/users/me", | ||
| 250 | + Some(&who), | ||
| 251 | + Some(json!({ "address": "" })), | ||
| 252 | + ) | ||
| 253 | + .await; | ||
| 254 | + assert_eq!(cleared.status, StatusCode::OK); | ||
| 255 | + assert_eq!(cleared.body["address"], json!(null)); | ||
| 256 | + assert_eq!(cleared.body["gender"], "other", "gender lost to the clear"); | ||
| 257 | + | ||
| 258 | + // The gender vocabulary is closed: an unknown word is a 400. | ||
| 259 | + let refused = send( | ||
| 260 | + &app, | ||
| 261 | + "PATCH", | ||
| 262 | + "/users/me", | ||
| 263 | + Some(&who), | ||
| 264 | + Some(json!({ "gender": "woman" })), | ||
| 265 | + ) | ||
| 266 | + .await; | ||
| 267 | + assert_eq!(refused.status, StatusCode::BAD_REQUEST); | ||
| 268 | + let after = send(&app, "GET", "/auth/me", Some(&who), None).await.body; | ||
| 269 | + assert_eq!(after["gender"], "other", "a refused patch writes nothing"); | ||
| 270 | +} | ||
tests/regress_profile.rsmodified+13 -1
| @@ -99,6 +99,10 @@ async fn a_peer_profile_carries_no_contact_fields() { | |||
| 99 | "email": "ada@example.com", | 99 | "email": "ada@example.com", |
| 100 | "phone": "+90 555 123 45 67", | 100 | "phone": "+90 555 123 45 67", |
| 101 | "birth_date": "1990-01-02", | 101 | "birth_date": "1990-01-02", |
| 102 | + "gender": "female", | ||
| 103 | + "address": "Çamlık Mah. 2. Sk. No: 7, Bornova / İzmir", | ||
| 104 | + "emergency_contact_name": "Mehmet Yılmaz", | ||
| 105 | + "emergency_contact_phone": "+90 555 987 65 43", | ||
| 102 | })), | 106 | })), |
| 103 | ) | 107 | ) |
| 104 | .await; | 108 | .await; |
| @@ -107,7 +111,15 @@ async fn a_peer_profile_carries_no_contact_fields() { | |||
| 107 | let seen = profile(&app, &peer, &ada_id).await; | 111 | let seen = profile(&app, &peer, &ada_id).await; |
| 108 | assert_eq!(seen.status, StatusCode::OK, "{}", seen.body); | 112 | assert_eq!(seen.status, StatusCode::OK, "{}", seen.body); |
| 109 | assert_eq!(seen.body["username"], "ada"); | 113 | assert_eq!(seen.body["username"], "ada"); |
| 110 | - for private in ["email", "phone", "birth_date"] { | 114 | + for private in [ |
| 115 | + "email", | ||
| 116 | + "phone", | ||
| 117 | + "birth_date", | ||
| 118 | + "gender", | ||
| 119 | + "address", | ||
| 120 | + "emergency_contact_name", | ||
| 121 | + "emergency_contact_phone", | ||
| 122 | + ] { | ||
| 111 | assert!( | 123 | assert!( |
| 112 | seen.body.get(private).is_none(), | 124 | seen.body.get(private).is_none(), |
| 113 | "{private} must not ride on a profile: {}", | 125 | "{private} must not ride on a profile: {}", |
tests/spec_bounds.rsmodified+9 -0
| @@ -246,6 +246,15 @@ fn expectations() -> Vec<(&'static str, &'static str, &'static str, i64)> { | |||
| 246 | MAX_DISPLAY_NAME_LEN as i64, | 246 | MAX_DISPLAY_NAME_LEN as i64, |
| 247 | ), | 247 | ), |
| 248 | ("UpdateProfile", "bio", "maxLength", MAX_BIO_LEN as i64), | 248 | ("UpdateProfile", "bio", "maxLength", MAX_BIO_LEN as i64), |
| 249 | + // Free text with the same length cap the bio has. | ||
| 250 | + ("UpdateProfile", "address", "maxLength", MAX_ADDRESS_LEN as i64), | ||
| 251 | + // The emergency contact is a person's name, held to the same bound. | ||
| 252 | + ( | ||
| 253 | + "UpdateProfile", | ||
| 254 | + "emergency_contact_name", | ||
| 255 | + "maxLength", | ||
| 256 | + MAX_NAME_LEN as i64, | ||
| 257 | + ), | ||
| 249 | // A branş is one entry of the school's `branches` list, so it is | 258 | // A branş is one entry of the school's `branches` list, so it is |
| 250 | // bounded by the same per-entry length the list itself is. | 259 | // bounded by the same per-entry length the list itself is. |
| 251 | ( | 260 | ( |