Hide public communty.ecs6v2.1.0
authorHeiko Bernlöhr <[email protected]>
Wed, 15 Feb 2023 09:30:36 +0000 (15 10:30 +0100)
committerHeiko Bernlöhr <[email protected]>
Wed, 15 Feb 2023 09:30:36 +0000 (15 10:30 +0100)
If allow_anonymous is not set in ecs_config.yml then the public
community will be hidden.

app/controllers/admin/communities_controller.rb
app/controllers/admin/participants_controller.rb
app/views/admin/participants/_form.html.erb

index 8012eec..86692d4 100644 (file)
@@ -28,7 +28,11 @@ class Admin::CommunitiesController < ApplicationController
   end
 
   def list
-    @communities=Community.all.distinct
+    if ECS_CONFIG["participants"]["allow_anonymous"]
+      @communities=Community.all.distinct
+    else
+      @communities=Community.all.where.not(name: "public").distinct
+    end
   end
 
   def show
index 4825073..beabd28 100644 (file)
@@ -72,6 +72,11 @@ class Admin::ParticipantsController < ApplicationController
   def new
     @participant = Participant.new
     @organizations = Organization.all.order(:id)
+    if ECS_CONFIG["participants"]["allow_anonymous"]
+      @communities=Community.all.distinct
+    else
+      @communities=Community.all.where.not(name: "public").distinct
+    end
     @participant.identities.build
   end
 
@@ -90,6 +95,11 @@ class Admin::ParticipantsController < ApplicationController
   def edit
     @participant = Participant.find(params[:id])
     @organizations = Organization.all.order(:id)
+    if ECS_CONFIG["participants"]["allow_anonymous"]
+      @communities=Community.all.distinct
+    else
+      @communities=Community.all.where.not(name: "public").distinct
+    end
   end
 
   def reset
index dd85b60..2aaf202 100644 (file)
@@ -110,7 +110,7 @@ License along with ECS. If not, see <http://www.gnu.org/licenses/>.
       <th>join</th>
     </tr>
   
-    <% Community.all.each do |community| %>
+    <% @communities.each do |community| %>
            <tr valign="top" class="<%= cycle('list-line-odd', 'list-line-even') %>">
   <!--      <tr align="left" valign="top"> -->
           <TD>