Repository: oppia/oppia

Issue:
In the collection editor, there should be a card in the Settings tab to show whether the collection is private/public.
In the exploration editor settings tab, there is a card to show who has access to the exploration and whether the exploration is private/public. We should have something similar for the collection editor.



Discussion:
@kevinlee12 Any updates on this ?

In progress!

On Mon, Sep 26, 2016 at 11:11 PM, Avijit Gupta notifications@github.com
wrote:

> @kevinlee12 https://github.com/kevinlee12 Any updates on this ?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> https://github.com/oppia/oppia/issues/2026#issuecomment-249775144, or mute
> the thread
> https://github.com/notifications/unsubscribe-auth/AFfdMCVsN1UG4AYzMwd47eHoKCMCgKefks5quLOLgaJpZM4Iwg0Q
> .

@kevinlee12 Thanks!

Things to do (will be marking them as I complete this locally):
- [x] public/private frontend private/public display
- [x] backend owners/editors/viewers controllers
  - [x] assign user to group (owners, editors, or viewers)
  - [ ] release ownership to community (will not implement yet)
- [x] JS Rights API owners/managers/playtesters UI
- [x] frontend display owners/managers/playtesters UI
- [x] auto update changes on screen
Hi @kevinlee12 how is this going?
Hi Allan, issue in progress!

On Sat, Nov 26, 2016 at 10:15 PM, Allan Zhou <notifications@github.com>
wrote:

> Hi @kevinlee12 <https://github.com/kevinlee12> how is this going?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/oppia/oppia/issues/2026#issuecomment-263104589>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AFfdMM_Kbu0cbj4LRN3_6mWqok2K7B0Dks5rCR_ogaJpZM4Iwg0Q>
> .
>

Hi @kevinlee12 -- this issue has been around for at least two months; do you have some idea of when you'll complete it by? Thanks!
Will be done after finals (~2 weeks, there are a few API issues that are
taking awhile to fiddle around, otherwise it's ready to ship)

On Sat, Nov 26, 2016 at 10:23 PM, Sean Lip <notifications@github.com> wrote:

> Hi @kevinlee12 <https://github.com/kevinlee12> -- this issue has been
> around for at least two months; do you have some idea of when you'll
> complete it by? Thanks!
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/oppia/oppia/issues/2026#issuecomment-263104815>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AFfdMJuYqyyDGnDkX71pVjw_vy5lA4NQks5rCSH1gaJpZM4Iwg0Q>
> .
>

Ah, ok, thanks -- would it be possible to get a PR in for this by 15 Dec at the latest, then?
It'll be tight, but I'll get it in ASAP

> On Nov 26, 2016, at 10:28 PM, Sean Lip <notifications@github.com> wrote:
> 
> Ah, ok, thanks -- would it be possible to get a PR in for this by 15 Dec at the latest, then?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.
> 

A quick update: I chatted with @kevinlee12, and he plans to send an update tomorrow with firm timelines, since this project has been taking a while.
Follow-on update: @kevinlee12 has confirmed that this PR should be in by 15 Dec.
Whoops, I had a date miscalculation when I last replied to @seanlip, I will finish by Dec. 19-21
New checklist (overrides the previous checklist):
- [x] show single owner
- [x] show private/public status

Resolving patch:
diff --git a/core/controllers/collection_editor.py b/core/controllers/collection_editor.py
--- a/core/controllers/collection_editor.py
+++ b/core/controllers/collection_editor.py
@@ -110,6 +110,8 @@ def get(self, collection_id):
             'collection_id': collection.id,
             'is_private': rights_manager.is_collection_private(collection_id),
             'nav_mode': feconf.NAV_MODE_CREATE,
+            'owner_names': rights_manager.get_collection_owner_names(
+                collection_id),
             'title': collection.title,
             'SHOW_COLLECTION_NAVIGATION_TAB_HISTORY': (
                 feconf.SHOW_COLLECTION_NAVIGATION_TAB_HISTORY),
diff --git a/core/domain/email_manager.py b/core/domain/email_manager.py
--- a/core/domain/email_manager.py
+++ b/core/domain/email_manager.py
@@ -528,13 +528,13 @@ def send_role_notification_email(
         raise Exception(
             'Invalid role: %s' % recipient_role)
 
-    role_descriptipn = EDITOR_ROLE_EMAIL_HTML_ROLES[recipient_role]
-    rights_html = EDITOR_ROLE_EMAIL_RIGHTS_FOR_ROLE[role_descriptipn]
+    role_description = EDITOR_ROLE_EMAIL_HTML_ROLES[recipient_role]
+    rights_html = EDITOR_ROLE_EMAIL_RIGHTS_FOR_ROLE[role_description]
 
     email_subject = email_subject_template % exploration_title
     email_body = email_body_template % (
         recipient_user_settings.username, inviter_user_settings.username,
-        role_descriptipn, exploration_id, exploration_title, rights_html,
+        role_description, exploration_id, exploration_title, rights_html,
         exploration_id, EMAIL_FOOTER.value)
 
     _send_email(
diff --git a/core/domain/rights_manager.py b/core/domain/rights_manager.py
--- a/core/domain/rights_manager.py
+++ b/core/domain/rights_manager.py
@@ -294,6 +294,13 @@ def get_collection_rights(collection_id, strict=True):
         model, feconf.ACTIVITY_TYPE_COLLECTION)
 
 
+def get_collection_owner_names(collection_id):
+    """Retrieves the owners for this collection from the datastore."""
+    collection_rights = get_collection_rights(collection_id)
+    return user_services.get_human_readable_user_ids(
+        collection_rights.owner_ids)
+
+
 def is_collection_private(collection_id):
     collection_rights = get_collection_rights(collection_id)
     return collection_rights.status == ACTIVITY_STATUS_PRIVATE


Test patch:
diff --git a/core/domain/rights_manager_test.py b/core/domain/rights_manager_test.py
--- a/core/domain/rights_manager_test.py
+++ b/core/domain/rights_manager_test.py
@@ -498,6 +498,10 @@ def test_ownership_of_collection(self):
             self.user_id_a, self.COLLECTION_ID, self.user_id_b,
             rights_manager.ROLE_EDITOR)
 
+        self.assertListEqual(['A'],
+                             rights_manager.get_collection_owner_names(
+                                 self.COLLECTION_ID))
+
         self.assertTrue(
             rights_manager.Actor(self.user_id_a).is_owner(
                 feconf.ACTIVITY_TYPE_COLLECTION, self.COLLECTION_ID))
@@ -512,6 +516,10 @@ def test_ownership_of_collection(self):
     def test_newly_created_collection(self):
         self.save_new_default_collection(self.COLLECTION_ID, self.user_id_a)
 
+        self.assertListEqual(['A'],
+                             rights_manager.get_collection_owner_names(
+                                 self.COLLECTION_ID))
+
         self.assertTrue(
             rights_manager.Actor(self.user_id_a).can_play(
                 feconf.ACTIVITY_TYPE_COLLECTION, self.COLLECTION_ID))
@@ -594,6 +602,11 @@ def test_inviting_collaborator_to_collection(self):
             self.user_id_a, self.COLLECTION_ID, self.user_id_b,
             rights_manager.ROLE_EDITOR)
 
+        # Ensure User A is the only user in the owner names list.
+        self.assertListEqual(['A'],
+                             rights_manager.get_collection_owner_names(
+                                 self.COLLECTION_ID))
+
         # Ensure User B is now an editor of the collection.
         self.assertTrue(
             rights_manager.Actor(self.user_id_b).can_play(