pub struct PageSnapshot {
pub id: Uuid,
pub course_id: Uuid,
pub chapter_id: Option<Uuid>,
pub url_path: String,
pub title: String,
pub hidden: bool,
pub order_number: i32,
pub content: Arc<Vec<GutenbergBlock>>,
pub exercises: Vec<CmsPageExercise>,
pub exercise_slides: Vec<CmsPageExerciseSlide>,
pub exercise_tasks: Vec<CmsPageExerciseTask>,
pub joins_page_language_group_id: Option<Uuid>,
}Expand description
A course page: its metadata, its stored blocks and its exercises, in the shape the CMS page
save takes. Exercise blocks in content are stored stripped to their id, as the CMS stores
them; the exercises themselves are in exercises, exercise_slides and exercise_tasks.
Fields§
§id: Uuid§course_id: Uuid§chapter_id: Option<Uuid>None for top-level pages.
url_path: String§title: String§order_number: i32Position among the pages of the same chapter (or the top-level pages). 0 is reserved for a chapter’s front page.
content: Arc<Vec<GutenbergBlock>>Shared with the page records made from the snapshot.
exercises: Vec<CmsPageExercise>§exercise_slides: Vec<CmsPageExerciseSlide>§exercise_tasks: Vec<CmsPageExerciseTask>§joins_page_language_group_id: Option<Uuid>For a page publishing creates: the page language group of its versions in the course’s
other languages that it joins. None for every other page, whatever group it is in.
Implementations§
Source§impl PageSnapshot
impl PageSnapshot
Sourcepub fn from_record_and_bundles(
course_id: Uuid,
record: &PageRecord,
bundles: &HashMap<Uuid, ExerciseBundle>,
) -> Result<Self, Vec<Uuid>>
pub fn from_record_and_bundles( course_id: Uuid, record: &PageRecord, bundles: &HashMap<Uuid, ExerciseBundle>, ) -> Result<Self, Vec<Uuid>>
The page record describes, with exactly the exercises its exercise blocks name, taken
from bundles. Errors with the exercise ids bundles doesn’t have.
Source§impl PageSnapshot
impl PageSnapshot
Sourcepub fn to_cms_page_update(&self) -> CmsPageUpdate
pub fn to_cms_page_update(&self) -> CmsPageUpdate
The CMS page save payload that writes this snapshot.
Sourcepub fn normalize_for_storage(&mut self)
pub fn normalize_for_storage(&mut self)
Trims and normalises the title and path the way the page save does, so that the snapshot equals the page publishing it produces.
Sourcepub fn exercise_bundles(&self) -> Vec<ExerciseBundle>
pub fn exercise_bundles(&self) -> Vec<ExerciseBundle>
The page’s exercises in exercise order, each with its slides and tasks.
Sourcepub fn set_exercise_bundles<'a>(
&mut self,
bundles: impl IntoIterator<Item = &'a ExerciseBundle>,
)
pub fn set_exercise_bundles<'a>( &mut self, bundles: impl IntoIterator<Item = &'a ExerciseBundle>, )
Replaces the page’s exercises, with their slides and tasks, with bundles.
Trait Implementations§
Source§impl Clone for PageSnapshot
impl Clone for PageSnapshot
Source§fn clone(&self) -> PageSnapshot
fn clone(&self) -> PageSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposeSchema for PageSnapshot
impl ComposeSchema for PageSnapshot
Source§impl ContentEntity for PageSnapshot
impl ContentEntity for PageSnapshot
const ENTITY_TYPE: ContentEntityType = ContentEntityType::Page
fn course_id(&self) -> Uuid
Source§fn label(&self) -> &str
fn label(&self) -> &str
EntityRef::label.Source§fn parent(&self) -> Option<EntityKey>
fn parent(&self) -> Option<EntityKey>
None for entities of the course itself.Source§fn narrow(snapshot: &EntitySnapshot) -> Option<&Self>
fn narrow(snapshot: &EntitySnapshot) -> Option<&Self>
Source§async fn load_live(
conn: &mut PgConnection,
ids: &[Uuid],
) -> ModelResult<HashMap<Uuid, Self>>
async fn load_live( conn: &mut PgConnection, ids: &[Uuid], ) -> ModelResult<HashMap<Uuid, Self>>
load_live_many has them, by id.Source§async fn lock_rows(conn: &mut PgConnection, ids: &[Uuid]) -> ModelResult<()>
async fn lock_rows(conn: &mut PgConnection, ids: &[Uuid]) -> ModelResult<()>
ids must be sorted, so that concurrent lockers take the rows in
the same order.Source§impl Debug for PageSnapshot
impl Debug for PageSnapshot
Source§impl<'de> Deserialize<'de> for PageSnapshot
impl<'de> Deserialize<'de> for PageSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<&PageSnapshot> for PageRecord
impl From<&PageSnapshot> for PageRecord
Source§fn from(page: &PageSnapshot) -> Self
fn from(page: &PageSnapshot) -> Self
Source§impl From<PageSnapshot> for EntitySnapshot
impl From<PageSnapshot> for EntitySnapshot
Source§fn from(snapshot: PageSnapshot) -> Self
fn from(snapshot: PageSnapshot) -> Self
Source§impl From<PageSnapshot> for PreviewPage
impl From<PageSnapshot> for PreviewPage
Source§fn from(page: PageSnapshot) -> Self
fn from(page: PageSnapshot) -> Self
Source§impl InCourseState for PageSnapshot
impl InCourseState for PageSnapshot
fn is_in(state: &CourseState, id: Uuid) -> bool
Source§fn put_in(&self, state: &mut CourseState)
fn put_in(&self, state: &mut CourseState)
state, or replaces it there.Source§fn remove_from(state: &mut CourseState, id: Uuid)
fn remove_from(state: &mut CourseState, id: Uuid)
state; course settings stay, since a course always has them.Source§impl PartialEq for PageSnapshot
impl PartialEq for PageSnapshot
Source§impl Serialize for PageSnapshot
impl Serialize for PageSnapshot
Source§impl ToSchema for PageSnapshot
impl ToSchema for PageSnapshot
impl StructuralPartialEq for PageSnapshot
Auto Trait Implementations§
impl Freeze for PageSnapshot
impl RefUnwindSafe for PageSnapshot
impl Send for PageSnapshot
impl Sync for PageSnapshot
impl Unpin for PageSnapshot
impl UnsafeUnpin for PageSnapshot
impl UnwindSafe for PageSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].