Browse Source

Some fixes

merge-requests/76/head
deing 6 years ago
parent
commit
b757a10a7f
No known key found for this signature in database GPG Key ID: DA34C790D267C164
  1. 4
      tildes/static/js/behaviors/comment-reply-button.js
  2. 2
      tildes/tildes/templates/topic.jinja2
  3. 6
      tildes/tildes/views/topic.py

4
tildes/static/js/behaviors/comment-reply-button.js

@ -81,13 +81,13 @@ $.onmount("[data-js-comment-reply-button]", function() {
var originalCommentTimestamp = new Date( var originalCommentTimestamp = new Date(
$parentComment $parentComment
.find(".comment-header time")
.find(".comment-posted-time")
.first() .first()
.attr("datetime") .attr("datetime")
); );
if (Date.now() - originalCommentTimestamp > 1000 * 3600 * 24 * 62) { if (Date.now() - originalCommentTimestamp > 1000 * 3600 * 24 * 62) {
var warningDiv = document.createElement("div"); var warningDiv = document.createElement("div");
warningDiv.classList.add("toast");
warningDiv.classList.add("toast", "toast-minor", "toast-warning");
warningDiv.innerHTML = warningDiv.innerHTML =
"The comment you're replying to is over two months old. Are you sure you want to continue?"; "The comment you're replying to is over two months old. Are you sure you want to continue?";
clone.querySelector("form").prepend(warningDiv); clone.querySelector("form").prepend(warningDiv);

2
tildes/tildes/templates/topic.jinja2

@ -214,7 +214,7 @@
data-js-confirm-leave-page-unsaved data-js-confirm-leave-page-unsaved
> >
{% if old_topic_warning %} {% if old_topic_warning %}
<div class="toast">The topic you're replying to is over two months old. Are you sure you want to continue?</div>
<div class="toast toast-minor toast-warning">The topic you're replying to is over two months old. Are you sure you want to continue?</div>
{% endif %} {% endif %}
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}"> <input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}">

6
tildes/tildes/views/topic.py

@ -6,7 +6,7 @@
from collections import namedtuple from collections import namedtuple
from typing import Any, Optional, Union from typing import Any, Optional, Union
from datetime import datetime, timedelta, timezone
from datetime import timedelta
from marshmallow import missing, ValidationError from marshmallow import missing, ValidationError
from marshmallow.fields import Boolean, String from marshmallow.fields import Boolean, String
from pyramid.httpexceptions import HTTPFound from pyramid.httpexceptions import HTTPFound
@ -28,7 +28,7 @@ from tildes.enums import (
TopicSortOption, TopicSortOption,
) )
from tildes.lib.database import ArrayOfLtree from tildes.lib.database import ArrayOfLtree
from tildes.lib.datetime import SimpleHoursPeriod
from tildes.lib.datetime import SimpleHoursPeriod, utc_now
from tildes.models.comment import Comment, CommentNotification, CommentTree from tildes.models.comment import Comment, CommentNotification, CommentTree
from tildes.models.group import Group, GroupWikiPage from tildes.models.group import Group, GroupWikiPage
from tildes.models.log import LogComment, LogTopic from tildes.models.log import LogComment, LogTopic
@ -377,7 +377,7 @@ def get_topic(request: Request, comment_order: CommentTreeSortOption) -> dict:
old_topic_warning = False old_topic_warning = False
if datetime.now(timezone.utc) - topic.created_time > timedelta(days=62):
if utc_now() - topic.created_time > timedelta(days=62):
old_topic_warning = True old_topic_warning = True
return { return {

Loading…
Cancel
Save