Added date column t o comments

This commit is contained in:
Sn0wCrack 2017-05-16 13:00:36 +10:00 committed by nyaadev
parent fe6abf33c1
commit c3a637c8eb
2 changed files with 9 additions and 1 deletions

View File

@ -325,6 +325,7 @@ class Comment(db.Model):
DB_TABLE_PREFIX + 'torrents.id'), primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey(
'users.id', ondelete='CASCADE'))
created_time = db.Column(db.DateTime(timezone=False), default=datetime.utcnow)
text = db.Column(db.String(length=255), nullable=False)
user = db.relationship('User', uselist=False, back_populates='comments')
@ -332,6 +333,11 @@ class Comment(db.Model):
def __repr__(self):
return '<Comment %r>' % self.id
@property
def created_utc_timestamp(self):
''' Returns a UTC POSIX timestamp, as seconds '''
return (self.created_time - UTC_EPOCH).total_seconds()
class UserLevelType(IntEnum):
REGULAR = 0

View File

@ -142,6 +142,7 @@
{% if g.user.is_admin %}
<th style="width:auto;">Delete</th>
{% endif %}
<th style="width:auto;">Date</th>
<th style="width:auto;">User</th>
<th style="width:100%;">Comment</th>
</thead>
@ -162,7 +163,8 @@
<span>Anonymous</span>
{% endif %}
</td>
<td class="col-md-10">{{ comment.text }}</td>
<td class="col-md-1" data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M UTC') }}</td>
<td class="col-md-9">{{ comment.text }}</td>
</tr>
{% endfor %}
<tbody>