summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-04-16 01:16:52 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-04-16 01:16:52 -0400
commit7aabbe788bb4e26ee9c7cfc0e18692b487e11099 (patch)
treee1032beb86e35caafb164e694d2aa7e2e9664de2 /main
parent046e6c8b6152a8142ed838e5c406cc04c18f2533 (diff)
parent155bf43a28e404f327a7bcff214c22e212627673 (diff)
Merge branch 'archweb-generic'
Diffstat (limited to 'main')
-rw-r--r--main/fixtures/groups.json29
-rw-r--r--main/templatetags/pgp.py19
-rw-r--r--main/utils.py15
3 files changed, 50 insertions, 13 deletions
diff --git a/main/fixtures/groups.json b/main/fixtures/groups.json
index 67cab6cf..e1ef0556 100644
--- a/main/fixtures/groups.json
+++ b/main/fixtures/groups.json
@@ -206,6 +206,11 @@
"user"
],
[
+ "change_staffgroup",
+ "devel",
+ "staffgroup"
+ ],
+ [
"add_userprofile",
"devel",
"userprofile"
@@ -471,5 +476,29 @@
},
"model": "auth.group",
"pk": 8
+},
+{
+ "fields": {
+ "name": "Retired Hackers",
+ "permissions": []
+ },
+ "model": "auth.group",
+ "pk": 9
+},
+{
+ "fields": {
+ "name": "Retired Trusted Users",
+ "permissions": []
+ },
+ "model": "auth.group",
+ "pk": 10
+},
+{
+ "fields": {
+ "name": "Support Staff",
+ "permissions": []
+ },
+ "model": "auth.group",
+ "pk": 11
}
]
diff --git a/main/templatetags/pgp.py b/main/templatetags/pgp.py
index 2417f688..455e8f9c 100644
--- a/main/templatetags/pgp.py
+++ b/main/templatetags/pgp.py
@@ -44,21 +44,14 @@ def pgp_key_link(key_id, link_text=None):
return '<a href="%s" title="PGP key search for %s">%s</a>' % values
-@cache_function(1741)
-def name_for_key(normalized):
- try:
- matching_key = DeveloperKey.objects.select_related(
- 'owner').get(key=normalized, owner_id__isnull=False)
- return matching_key.owner.get_full_name()
- except DeveloperKey.DoesNotExist:
- return None
-
-
@register.simple_tag
-def user_pgp_key_link(key_id):
+def user_pgp_key_link(dev_keys, key_id):
normalized = key_id[-16:]
- name = name_for_key(normalized)
- return pgp_key_link(key_id, name)
+ found = dev_keys.get(normalized, None)
+ if found:
+ return pgp_key_link(key_id, found.owner.get_full_name())
+ else:
+ return pgp_key_link(key_id, None)
@register.filter(needs_autoescape=True)
diff --git a/main/utils.py b/main/utils.py
index cf156566..f94f314d 100644
--- a/main/utils.py
+++ b/main/utils.py
@@ -4,6 +4,8 @@ except ImportError:
import pickle
import hashlib
+import markdown
+from markdown.extensions import Extension
from django.core.cache import cache
from django.db import connections, router
@@ -109,6 +111,19 @@ def database_vendor(model, mode='read'):
return connections[database].vendor
+class EscapeHtml(Extension):
+ def extendMarkdown(self, md, md_globals):
+ del md.preprocessors['html_block']
+ del md.inlinePatterns['html']
+
+
+def parse_markdown(text, allow_html=False):
+ if allow_html:
+ return markdown.markdown(text, enable_attributes=False)
+ ext = [EscapeHtml()]
+ return markdown.markdown(text, extensions=ext, enable_attributes=False)
+
+
def groupby_preserve_order(iterable, keyfunc):
'''Take an iterable and regroup using keyfunc to determine whether items
belong to the same group. The order of the iterable is preserved and