6254: add "groups" to user setup process; these comma separated groups entered in...
[arvados.git] / apps / workbench / app / controllers / users_controller.rb
index 0ca5a85f018af48187865efe030195bbdeeebdbf..d657f926039e1b2dbd8130456242e909e617e16d 100644 (file)
@@ -52,15 +52,15 @@ class UsersController < ApplicationController
                1.month.ago.beginning_of_month,
                Time.now.beginning_of_month]]
     @spans.each do |span, threshold_start, threshold_end|
-      @activity[:logins][span] = Log.
+      @activity[:logins][span] = Log.select(%w(uuid modified_by_user_uuid)).
         filter([[:event_type, '=', 'login'],
                 [:object_kind, '=', 'arvados#user'],
                 [:created_at, '>=', threshold_start],
                 [:created_at, '<', threshold_end]])
-      @activity[:jobs][span] = Job.
+      @activity[:jobs][span] = Job.select(%w(uuid modified_by_user_uuid)).
         filter([[:created_at, '>=', threshold_start],
                 [:created_at, '<', threshold_end]])
-      @activity[:pipeline_instances][span] = PipelineInstance.
+      @activity[:pipeline_instances][span] = PipelineInstance.select(%w(uuid modified_by_user_uuid)).
         filter([[:created_at, '>=', threshold_start],
                 [:created_at, '<', threshold_end]])
       @activity.each do |type, act|
@@ -212,6 +212,22 @@ class UsersController < ApplicationController
         end
 
         if User.setup setup_params
+          if params[:groups]
+            new_groups = params[:groups].split(',').map(&:strip).compact.select{|i| !i.to_s.empty?}
+            can_login_perms = Link.where(tail_uuid: params[:user_email],
+                                         head_kind: 'arvados#user',
+                                         link_class: 'permission',
+                                         name: 'can_login')
+            if can_login_perms.any?
+              perm = can_login_perms.first
+              props = perm.properties
+              if new_groups != props[:groups]
+                props[:groups] = new_groups
+                perm.save!
+              end
+            end
+          end
+
           format.js
         else
           self.render_error status: 422
@@ -329,14 +345,15 @@ class UsersController < ApplicationController
     end
 
     # oid login perm
-    oid_login_perms = Link.where(tail_uuid: user.email,
+    can_login_perms = Link.where(tail_uuid: user.email,
                                    head_kind: 'arvados#user',
                                    link_class: 'permission',
                                    name: 'can_login')
 
-    if oid_login_perms.any?
-      prefix_properties = oid_login_perms.first.properties
-      current_selections[:identity_url_prefix] = prefix_properties[:identity_url_prefix]
+    if can_login_perms.any?
+      perm_properties = can_login_perms.first.properties
+      current_selections[:identity_url_prefix] = perm_properties[:identity_url_prefix]
+      current_selections[:groups] = perm_properties[:groups].andand.join(', ')
     end
 
     # repo perm