Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions front_end/messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1784,5 +1784,6 @@
"switchToBotAccount": "Přepnout na účet bota",
"impersonationBannerText": "Momentálně si prohlížíte Metaculus jako váš bot.",
"stopImpersonating": "Přepnout zpět na můj účet",
"editedOnDate": "Upraveno dne {date}",
"othersCount": "Ostatní ({count})"
}
1 change: 1 addition & 0 deletions front_end/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@
"CPIsHidden": "Community Prediction is hidden",
"createdByUserOnDate": "Created by {user} on {date}",
"edited": "edited",
"editedOnDate": "Edited on {date}",
"tournamentHidePostsToMainFeed": "Hide tournament posts in main feed",
"me": "me",
"forecastDisclaimer": "Based on {predictionCount} predictions by {forecasterCount} forecasters",
Expand Down
1 change: 1 addition & 0 deletions front_end/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1784,5 +1784,6 @@
"switchToBotAccount": "Cambiar a cuenta de bot",
"impersonationBannerText": "Actualmente estás viendo Metaculus como tu bot.",
"stopImpersonating": "Volver a mi cuenta",
"editedOnDate": "Editado el {date}",
"othersCount": "Otros ({count})"
}
1 change: 1 addition & 0 deletions front_end/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1782,5 +1782,6 @@
"switchToBotAccount": "Mudar para Conta de Bot",
"impersonationBannerText": "Você está visualizando o Metaculus atualmente como seu bot.",
"stopImpersonating": "Voltar para minha conta",
"editedOnDate": "Editado em {date}",
"othersCount": "Outros ({count})"
}
1 change: 1 addition & 0 deletions front_end/messages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1781,5 +1781,6 @@
"switchToBotAccount": "切換到機器人帳戶",
"impersonationBannerText": "您目前正在以您的機器人帳戶查看 Metaculus。",
"stopImpersonating": "切換回我的帳戶",
"editedOnDate": "編輯於 {date}",
"withdrawAfterPercentSetting2": "問題總生命周期後撤回"
}
1 change: 1 addition & 0 deletions front_end/messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1786,5 +1786,6 @@
"switchToBotAccount": "切换到机器人账户",
"impersonationBannerText": "您当前正在以机器人身份查看 Metaculus。",
"stopImpersonating": "切换回我的账户",
"editedOnDate": "编辑于 {date}",
"othersCount": "其他({count})"
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,27 @@ const IndividualNotebookPage: FC<{
<CircleDivider className="mx-1" />

<span className="whitespace-nowrap">
{formatDate(locale, new Date(postData.published_at))}
</span>
<CircleDivider className="mx-1" />
<span className="whitespace-nowrap">
Edited on{" "}
{formatDate(locale, new Date(postData.notebook.edited_at))}
{formatDate(
locale,
new Date(postData.published_at ?? postData.notebook.created_at)
)}
</span>
{postData.notebook.edited_at &&
(!postData.published_at ||
new Date(postData.published_at) <=
new Date(postData.notebook.edited_at)) && (
<>
<CircleDivider className="mx-1" />
<span className="whitespace-nowrap">
{t("editedOnDate", {
date: formatDate(
locale,
new Date(postData.notebook.edited_at)
),
})}
</span>
</>
)}
<CircleDivider className="mx-1" />
<span className="whitespace-nowrap">
{t("estimatedReadingTime", {
Expand Down
5 changes: 4 additions & 1 deletion posts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ def get_queryset(self) -> PostQuerySet:
return super().get_queryset().defer("embedding_vector")


class Notebook(TimeStampedModel, TranslatedModel): # type: ignore
class Notebook(TranslatedModel):
created_at = models.DateTimeField(default=timezone.now, editable=False)
edited_at = models.DateTimeField(editable=False, null=True)

markdown = models.TextField()
image_url = models.ImageField(null=True, blank=True, upload_to="user_uploaded")
markdown_summary = models.TextField(blank=True, default="")
Expand Down
12 changes: 7 additions & 5 deletions questions/services/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ def update_conditional(


def update_notebook(notebook: Notebook, **kwargs):
post = getattr(notebook, "post", None)

# We want to update edited at for approved notebooks only
if post and post.status == post.CurationStatus.APPROVED:
kwargs["edited_at"] = timezone.now()

notebook, _ = model_update(
instance=notebook,
fields=[
"markdown",
"type",
"image_url",
],
fields=["markdown", "type", "image_url", "edited_at"],
data=kwargs,
)

Expand Down