Rename 'published' to 'public' (for recipe)
This commit is contained in:
parent
eaef6dc77e
commit
4f739593b8
20 changed files with 92 additions and 91 deletions
|
|
@ -21,16 +21,14 @@ pub async fn recipes_list_fragments(
|
|||
Extension(context): Extension<Context>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
let recipes = Recipes {
|
||||
published: connection
|
||||
.get_all_published_recipe_titles(
|
||||
public: connection
|
||||
.get_all_public_recipe_titles(
|
||||
context.tr.current_lang_code(),
|
||||
context.user.as_ref().map(|u| u.id),
|
||||
)
|
||||
.await?,
|
||||
unpublished: if let Some(user) = context.user.as_ref() {
|
||||
connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
.await?
|
||||
private: if let Some(user) = context.user.as_ref() {
|
||||
connection.get_all_private_recipe_titles(user.id).await?
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -51,16 +51,14 @@ pub async fn home_page(
|
|||
Extension(context): Extension<Context>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
let recipes = Recipes {
|
||||
published: connection
|
||||
.get_all_published_recipe_titles(
|
||||
public: connection
|
||||
.get_all_public_recipe_titles(
|
||||
context.tr.current_lang_code(),
|
||||
context.user.as_ref().map(|u| u.id),
|
||||
)
|
||||
.await?,
|
||||
unpublished: if let Some(user) = context.user.as_ref() {
|
||||
connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
.await?
|
||||
private: if let Some(user) = context.user.as_ref() {
|
||||
connection.get_all_private_recipe_titles(user.id).await?
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -44,14 +44,11 @@ pub async fn edit(
|
|||
if let Some(recipe) = connection.get_recipe(recipe_id, false).await? {
|
||||
if model::can_user_edit_recipe(user, &recipe) {
|
||||
let recipes = Recipes {
|
||||
published: connection
|
||||
.get_all_published_recipe_titles(
|
||||
context.tr.current_lang_code(),
|
||||
Some(user.id),
|
||||
)
|
||||
public: connection
|
||||
.get_all_public_recipe_titles(context.tr.current_lang_code(), Some(user.id))
|
||||
.await?,
|
||||
unpublished: connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
private: connection
|
||||
.get_all_private_recipe_titles(user.id)
|
||||
.await?,
|
||||
current_id: Some(recipe_id),
|
||||
};
|
||||
|
|
@ -98,7 +95,7 @@ pub async fn view(
|
|||
) -> Result<Response> {
|
||||
match connection.get_recipe(recipe_id, true).await? {
|
||||
Some(recipe) => {
|
||||
if !recipe.is_published
|
||||
if !recipe.is_public
|
||||
&& (context.user.is_none() || recipe.user_id != context.user.as_ref().unwrap().id)
|
||||
{
|
||||
return Ok(Html(
|
||||
|
|
@ -115,15 +112,15 @@ pub async fn view(
|
|||
}
|
||||
|
||||
let recipes = Recipes {
|
||||
published: connection
|
||||
.get_all_published_recipe_titles(
|
||||
public: connection
|
||||
.get_all_public_recipe_titles(
|
||||
context.tr.current_lang_code(),
|
||||
context.user.as_ref().map(|u| u.id),
|
||||
)
|
||||
.await?,
|
||||
unpublished: if let Some(user) = context.user.as_ref() {
|
||||
private: if let Some(user) = context.user.as_ref() {
|
||||
connection
|
||||
.get_all_unpublished_recipe_titles(user.id)
|
||||
.get_all_private_recipe_titles(user.id)
|
||||
.await?
|
||||
} else {
|
||||
vec![]
|
||||
|
|
|
|||
|
|
@ -152,14 +152,14 @@ pub async fn set_language(
|
|||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn set_is_published(
|
||||
pub async fn set_is_public(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(context): Extension<Context>,
|
||||
ExtractRon(ron): ExtractRon<ron_api::SetIsPublished>,
|
||||
ExtractRon(ron): ExtractRon<ron_api::SetIsPublic>,
|
||||
) -> Result<StatusCode> {
|
||||
check_user_rights_recipe(&connection, &context.user, ron.recipe_id).await?;
|
||||
connection
|
||||
.set_recipe_is_published(ron.recipe_id, ron.is_published)
|
||||
.set_recipe_is_public(ron.recipe_id, ron.is_public)
|
||||
.await?;
|
||||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue