hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB69d4295Ahmet Kaan Gümüş2 months ago536 commits
| 1 | //! Instance visibility: the two questions every instance-scoped surface asks |
| 2 | //! before it reads or writes anything — whether this caller may act on one |
| 3 | //! instance, and which instances are theirs at all. Both lived in |
| 4 | //! [`crate::web::instances`] while the HTTP layer was their only caller; the |
| 5 | //! RAG scope deriver ([`super::rag_scope`]) asks the same two questions, and a |
| 6 | //! service may not reach up into the web layer — nor grow a second copy of a |
| 7 | //! rule that two surfaces must never disagree about. |
| 8 | //! |
| 9 | //! The D10 rule itself is [`super::class_course::ensure_instance_teacher`], |
| 10 | //! which [`can_manage_instance`] asks as a boolean so a route can word its own |
| 11 | //! `403`; the row reads are [`crate::db`]'s. |
| 12 | |
| 13 | use HashSet; |
| 14 | |
| 15 | use crateDatabase; |
| 16 | use crate; |
| 17 | use crateClassGroupId; |
| 18 | use crateRole; |
| 19 | use crateUser; |
| 20 | use crateAppError; |
| 21 | |
| 22 | /// Whether `user` may act inside this instance — D10, asked as a boolean so a |
| 23 | /// handler can word its own `403` (the one gate every instance-scoped route |
| 24 | /// shares; [`super::class_course::ensure_instance_teacher`] is the same rule |
| 25 | /// with the refusal in it). |
| 26 | pub async |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | /// The instances a caller may see, each with whether they run it: the |
| 39 | /// instances their class sections carry (a student's roster, and a homeroom |
| 40 | /// teacher's), the instances they were assigned to teach (a teacher), and — |
| 41 | /// for a homeroom teacher — their own section's. The per-instance answer is |
| 42 | /// the same D10 rule every instance-scoped gate applies, computed once for the |
| 43 | /// list. |
| 44 | /// |
| 45 | /// [`crate::web::instances`] serves this set to every caller as |
| 46 | /// `GET /instances/me`; the catalog-wide list other instance routes hand a |
| 47 | /// manager+ is [`crate::web::courses`]'. [`super::rag_scope`] scopes a RAG |
| 48 | /// question by it, which is why it lives here now. |
| 49 | /// |
| 50 | /// Staff are *not* members of the section they run, so the two ways a teacher |
| 51 | /// reaches a class section are read separately and unioned: `class_member` (a |
| 52 | /// student's live stint) and the homeroom column (`class_group.teacher`, read |
| 53 | /// through [`super::class_group::list_for_teacher`]). Leaving the second out |
| 54 | /// dropped every row for a homeroom teacher who was neither enrolled nor |
| 55 | /// assigned — even though [`super::class_course::ensure_instance_teacher`] |
| 56 | /// lets them act on all of them. |
| 57 | pub async |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 |