Class: ModelFilePolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/model_file_policy.rb

Defined Under Namespace

Classes: Scope

Constant Summary

Constants inherited from ApplicationPolicy

ApplicationPolicy::STANDARD_EDIT_PERMISSIONS, ApplicationPolicy::STANDARD_VIEW_PERMISSIONS

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#record, #user

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#destroy_all?, #edit?, #index?, #initialize, #new?

Constructor Details

This class inherits a constructor from ApplicationPolicy

Instance Method Details

#bulk_edit? ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/policies/model_file_policy.rb', line 36

def bulk_edit?
  bulk_update?
end

#bulk_update? ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/policies/model_file_policy.rb', line 40

def bulk_update?
  can_update_model?
end

#convert? ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/policies/model_file_policy.rb', line 24

def convert?
  can_update_model? && @record.convertable? && !@record.problems.exists?(category: :non_manifold)
end

#create? ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/policies/model_file_policy.rb', line 20

def create?
  can_update_model?
end

#destroy? ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/policies/model_file_policy.rb', line 32

def destroy?
  can_update_model?
end

#print? ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
# File 'app/policies/model_file_policy.rb', line 11

def print?
  all_of(
    @user&.is_printer?,
    none_of(
      SiteSettings.demo_mode_enabled?
    )
  )
end

#raw? ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/policies/model_file_policy.rb', line 7

def raw?
  show?
end

#show? ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
5
# File 'app/policies/model_file_policy.rb', line 2

def show?
  return false unless ModelPolicy.new(@user, @record.model).show?
  @user&.is_moderator? || @record.previewable? || check_permissions(@record.model, ["view", "edit", "own"], @user)
end

#update? ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/policies/model_file_policy.rb', line 28

def update?
  can_update_model?
end