From 92f312cf5ad7edd7f5f259fa62d462c087110149 Mon Sep 17 00:00:00 2001 From: Sawy Date: Wed, 20 Sep 2023 16:52:59 +0300 Subject: [PATCH] CV2-3738: remove privacy code --- app/graph/types/team_type.rb | 2 +- app/models/project.rb | 13 ------------- app/models/team.rb | 4 ++-- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/graph/types/team_type.rb b/app/graph/types/team_type.rb index 19dd4c40d8..8403dd5335 100644 --- a/app/graph/types/team_type.rb +++ b/app/graph/types/team_type.rb @@ -215,7 +215,7 @@ def join_requests field :projects, ProjectType.connection_type, null: true def projects - object.recent_projects.allowed(object) + object.recent_projects end field :sources_count, GraphQL::Types::Int, null: true do diff --git a/app/models/project.rb b/app/models/project.rb index 293376537e..5e622ed495 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -5,14 +5,6 @@ class Project < ApplicationRecord include AssignmentConcern include AnnotationBase::Association - module PrivacySettings - ALL = 0 - EDITORS = 1 - ADMINS = 2 - end - - scope :allowed, ->(team) { where('privacy <= ?', Project.privacy_for_role(team)) } - attr_accessor :project_media_ids_were, :previous_project_group_id, :previous_default_project_id, :items_destination_project_id belongs_to :user, optional: true @@ -259,11 +251,6 @@ def self.bulk_update_medias_count(pids) pids_count.each { |pid, count| Rails.cache.write("check_cached_field:Project:#{pid}:medias_count", count) } end - def self.privacy_for_role(team = Team.current, user = User.current) - role = user && team ? user.role(team) : '' - { 'editor' => PrivacySettings::EDITORS, 'admin' => PrivacySettings::ADMINS }[role] || PrivacySettings::ALL - end - def before_destroy_later self.move_project_medias end diff --git a/app/models/team.rb b/app/models/team.rb index 5e1aa51f74..9f756ff64b 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -54,7 +54,7 @@ def members_count end def projects_count - self.projects.allowed(self).permissioned.count + self.projects.permissioned.count end def as_json(_options = {}) @@ -63,7 +63,7 @@ def as_json(_options = {}) id: self.team_graphql_id, avatar: self.avatar, name: self.name, - projects: self.recent_projects.allowed(team), + projects: self.recent_projects, slug: self.slug } end