From 0872e9ffe3fb1b25d784a2d97c4d91cd8a1b62f2 Mon Sep 17 00:00:00 2001
From: David Friedman <friedman.david@gmail.com>
Date: Mon, 3 Jul 2017 11:47:17 -0400
Subject: [PATCH] Settings option to hide institutional ID and editor forms in
 user profile.

---
 course/auth.py            | 4 ++++
 local_settings.example.py | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/course/auth.py b/course/auth.py
index a7cfc4aa..939261b6 100644
--- a/course/auth.py
+++ b/course/auth.py
@@ -859,6 +859,10 @@ class UserForm(StyledModelForm):
             else:
                 self.fields["institutional_id"].widget.\
                         attrs['disabled'] = True
+            if not settings.RELATE_SHOW_INST_ID_FORM:
+                self.helper.layout[1].css_class = 'well hidden'
+            if not settings.RELATE_SHOW_EDITOR_FORM:
+                self.helper.layout[2].css_class = 'well hidden'
 
         if self.instance.name_verified:
             self.fields["first_name"].widget.attrs['disabled'] = True
diff --git a/local_settings.example.py b/local_settings.example.py
index 43a1756c..c9c956e0 100644
--- a/local_settings.example.py
+++ b/local_settings.example.py
@@ -85,7 +85,7 @@ ADMINS = (
     )
 
 # If your email service do not allow nonauthorized sender, uncomment the following
-# statement and change the configurations above accordingly, noticing that all 
+# statement and change the configurations above accordingly, noticing that all
 # emails will be sent using the EMAIL_ settings above.
 #RELATE_EMAIL_SMTP_ALLOW_NONAUTHORIZED_SENDER = False
 
@@ -184,6 +184,10 @@ RELATE_SIGN_IN_BY_SAML2_ENABLED = False
 # or you don't want to verfiy insitutional ID they submit.
 RELATE_EDITABLE_INST_ID_BEFORE_VERIFICATION = True
 
+# If set to False, these fields will be hidden in the user profile form.
+RELATE_SHOW_INST_ID_FORM = True
+RELATE_SHOW_EDITOR_FORM = True
+
 # }}}
 
 
-- 
GitLab