From 03711ef538db9e00689bfdb5fe17580643855d27 Mon Sep 17 00:00:00 2001
From: Sun Qi <qui.sun@external.telekom.de>
Date: Sat, 19 Jul 2014 21:45:40 +0000
Subject: [PATCH] Changed the ietfauth file to allow to change the replaces
 relationship without setting the doc stream. Fixes ticket #1305. Commit ready
 for merge.  - Legacy-Id: 8146

---
 ietf/ietfauth/utils.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ietf/ietfauth/utils.py b/ietf/ietfauth/utils.py
index 96bca58b9..1ab5f2181 100644
--- a/ietf/ietfauth/utils.py
+++ b/ietf/ietfauth/utils.py
@@ -100,9 +100,23 @@ def is_authorized_in_doc_stream(user, doc):
     document."""
     if has_role(user, ["Secretariat"]):
         return True
-
+    '''
     if not doc.stream or not user.is_authenticated():
         return False
+    '''
+
+    if not user.is_authenticated():
+        return False
+
+    if not doc.stream:
+        group_req = None
+        if has_role(user, ["Area Director"]):
+            return True
+        if not doc.group.type == "individ":
+            group_req = Q(group=doc.group)
+        if not group_req:
+            return False
+        return bool(Role.objects.filter(Q(name__in=("chair", "secr", "delegate", "auth"), person__user=user) & group_req))
 
     # must be authorized in the stream or group