# HG changeset patch # User Mads Kiilerich # Date 1453250831 -3600 # Node ID b4b57beb49283931502d5d51d90c69eb7e81f9ba # Parent 779d43be59c62422b77e2603d1e86175fa2282a8 comments: limit comment deletion to a 5 minutes grace period It is really a bad idea to delete a comment after the content and references to it has been sent in mails. Ultimately, comments should be editable and versioned - "delete" should then just hide the comment. Note: this is just done at the UI level - not verified on the server diff -r 779d43be59c6 -r b4b57beb4928 kallithea/model/db.py --- a/kallithea/model/db.py Wed Jan 20 01:47:11 2016 +0100 +++ b/kallithea/model/db.py Wed Jan 20 01:47:11 2016 +0100 @@ -2197,6 +2197,10 @@ elif self.pull_request_id is not None: return self.pull_request.url(anchor=anchor) + def deletable(self): + return self.created_on > datetime.datetime.now() - datetime.timedelta(minutes=5) + + class ChangesetStatus(Base, BaseModel): __tablename__ = 'changeset_statuses' __table_args__ = ( diff -r 779d43be59c6 -r b4b57beb4928 kallithea/templates/changeset/changeset_file_comment.html --- a/kallithea/templates/changeset/changeset_file_comment.html Wed Jan 20 01:47:11 2016 +0100 +++ b/kallithea/templates/changeset/changeset_file_comment.html Wed Jan 20 01:47:11 2016 +0100 @@ -26,8 +26,10 @@ - %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or co.author.user_id == c.authuser.user_id: -
${_('Delete')}
+ %if co.author.user_id == c.authuser.user_id or h.HasRepoPermissionAny('repository.admin')(c.repo_name): + %if co.deletable(): +
${_('Delete')}
+ %endif %endif