diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2019-08-27 16:13:13 +1000 |
---|---|---|
committer | Daniel Axtens <dja@axtens.net> | 2019-08-30 17:39:06 +1000 |
commit | f94bb4eb3693d581c0658eba6ab4aa7723eca955 (patch) | |
tree | 22dae6af1ae2ca8da03898ddf9dc98a853efac30 /patchwork/templatetags | |
parent | dde885c6c2f5e03388630320bc03a4cbe1040c64 (diff) | |
download | patchwork-f94bb4eb3693d581c0658eba6ab4aa7723eca955.tar patchwork-f94bb4eb3693d581c0658eba6ab4aa7723eca955.tar.gz |
models: Add commit_url_format to Project
Add a new field to Project, commit_url_format, which specifies a
format string that can be used to generate a link to a particular
commit for a project.
This is used in the display of a patch, to render the patch's commit
as a clickable link back to the commit on the SCM website.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Diffstat (limited to 'patchwork/templatetags')
-rw-r--r-- | patchwork/templatetags/patch.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py index 757f873..d2537ba 100644 --- a/patchwork/templatetags/patch.py +++ b/patchwork/templatetags/patch.py @@ -66,3 +66,15 @@ def patch_checks(patch): @stringfilter def msgid(value): return escape(value.strip('<>')) + + +@register.filter(name='patch_commit_display') +def patch_commit_display(patch): + commit = patch.commit_ref + fmt = patch.project.commit_url_format + + if not fmt: + return escape(commit) + + return mark_safe('<a href="%s">%s</a>' % (escape(fmt.format(commit)), + escape(commit))) |