Invalidate markup cache on ticket edit

Fixes #168
This commit is contained in:
Drew DeVault 2019-04-25 15:36:42 -04:00
parent d5ac173fa4
commit d350f56408
2 changed files with 8 additions and 0 deletions

View File

@ -5,6 +5,7 @@ from srht.database import db
from srht.flask import loginrequired
from srht.validation import Validation
from todosrht.access import get_tracker, get_ticket
from todosrht.filters import invalidate_markup_cache
from todosrht.search import find_usernames
from todosrht.tickets import add_comment, mark_seen, assign, unassign
from todosrht.types import Event, EventType
@ -199,6 +200,8 @@ def ticket_edit_POST(owner, name, ticket_id):
ticket.description = desc
db.session.commit()
invalidate_markup_cache(ticket)
return redirect(ticket_url(ticket))
@ticket.route("/<owner>/<name>/<int:ticket_id>/add_label", methods=["POST"])

View File

@ -67,6 +67,11 @@ def render_comment(comment):
def render_ticket_description(ticket):
return render_markup(ticket.tracker, ticket.description)
def invalidate_markup_cache(obj):
class_name = obj.__class__.__name__
key = f"todo.sr.ht:cache_rendered_markup:{class_name}:{obj.id}"
redis.delete(key)
def label_badge(label, cls="", remove_from_ticket=None):
"""Return HTML markup rendering a label badge.