1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-23 00:10:01 +00:00

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) DB_TABLE_PREFIX + 'torrents.id'), primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey( user_id = db.Column(db.Integer, db.ForeignKey(
'users.id', ondelete='CASCADE')) 'users.id', ondelete='CASCADE'))
created_time = db.Column(db.DateTime(timezone=False), default=datetime.utcnow)
text = db.Column(db.String(length=255), nullable=False) text = db.Column(db.String(length=255), nullable=False)
user = db.relationship('User', uselist=False, back_populates='comments') user = db.relationship('User', uselist=False, back_populates='comments')
@ -332,6 +333,11 @@ class Comment(db.Model):
def __repr__(self): def __repr__(self):
return '<Comment %r>' % self.id 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): class UserLevelType(IntEnum):
REGULAR = 0 REGULAR = 0

View file

@ -142,6 +142,7 @@
{% if g.user.is_admin %} {% if g.user.is_admin %}
<th style="width:auto;">Delete</th> <th style="width:auto;">Delete</th>
{% endif %} {% endif %}
<th style="width:auto;">Date</th>
<th style="width:auto;">User</th> <th style="width:auto;">User</th>
<th style="width:100%;">Comment</th> <th style="width:100%;">Comment</th>
</thead> </thead>
@ -162,7 +163,8 @@
<span>Anonymous</span> <span>Anonymous</span>
{% endif %} {% endif %}
</td> </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> </tr>
{% endfor %} {% endfor %}
<tbody> <tbody>