hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB08aa13eAhmet Kaan Gümüş2 months ago378 commits
| 1 | //! Module entitlements as data, on the school side of the line. |
| 2 | //! |
| 3 | //! Two reads, no writes — selling a module is the vendor's act and lives on |
| 4 | //! `/schools/{slug}/modules` in [`crate::web::builder`]. What stands here is |
| 5 | //! what a client needs to draw the product: the deployment's catalog (which |
| 6 | //! modules exist, what each one needs, how they are packaged) and the caller's |
| 7 | //! own switched-on set, so a frontend hides a nest the school never bought |
| 8 | //! instead of discovering it as a `403`. |
| 9 | //! |
| 10 | //! Both routes are ungated on purpose: an entitlement lookup that a disabled |
| 11 | //! module could switch off would be unusable exactly when it is needed. The |
| 12 | //! catalog is unauthenticated for the same reason `GET /limits` is — it is a |
| 13 | //! deploy-time constant, identical for every school. |
| 14 | |
| 15 | use Json; |
| 16 | use Serialize; |
| 17 | use ToSchema; |
| 18 | use OpenApiRouter; |
| 19 | use routes; |
| 20 | |
| 21 | use crateErrorResponse; |
| 22 | use crate; |
| 23 | use crateAppState; |
| 24 | use crateCurrentUser; |
| 25 | use crateResolvedTenant; |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | /// One school's entitlements, both halves of the partition. `disabled` is |
| 34 | /// carried rather than left to the client to subtract: the two lists together |
| 35 | /// are the whole catalog, so a client can render the switchboard from one |
| 36 | /// response. |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | /// What the caller's own school has, without the vendor's half of the picture. |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | /// One sellable module: its name, the bundle it is sold in, and what it cannot |
| 71 | /// work without. |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | /// One commercial bundle and the modules it sells. |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | /// The whole catalog, identical for every school in the deployment. |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | /// Every module this deployment can sell, what each one requires, and the |
| 110 | /// packages they are bundled in. Unauthenticated and deploy-constant, like |
| 111 | /// `GET /limits`: fetch once, cache for the session. |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | async |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | /// What the caller's school has switched on. Any logged-in user may read it — |
| 139 | /// it is what the client needs to draw its own navigation, not a privileged |
| 140 | /// fact. |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | async |
| 152 | |
| 153 | |
| 154 | |
| 155 |