Skip to content

Commit

Permalink
CV2-3738: remove privacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Sep 20, 2023
1 parent cff56f2 commit 92f312c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/graph/types/team_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand All @@ -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
Expand Down

0 comments on commit 92f312c

Please sign in to comment.