summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
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