Class: Problem
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Problem
- Includes:
- PublicIDable
- Defined in:
- app/models/problem.rb
Constant Summary collapse
- CATEGORIES =
[ :missing, # i18n-tasks-use t("problems.categories.missing") t("problems.model.missing.title") t("problems.model.missing.description_html") t("problems.model_file.missing.title") t("problems.model_file.missing.description_html") :empty, # i18n-tasks-use t("problems.categories.empty") t("problems.model.empty.title") t("problems.model.empty.description_html") t("problems.model_file.empty.title") t("problems.model_file.empty.description_html") :destination_exists, # No longer used, but kept for compatibility :nesting, # i18n-tasks-use t("problems.categories.nesting") t("problems.model.nesting.title") t("problems.model.nesting.description_html") :inefficient, # i18n-tasks-use t("problems.categories.inefficient") t("problems.model_file.inefficient.title") t("problems.model_file.inefficient.description_html") :duplicate, # i18n-tasks-use t("problems.categories.duplicate") t("problems.model_file.duplicate.title") t("problems.model_file.duplicate.description_html") :no_image, # i18n-tasks-use t("problems.categories.no_image") t("problems.model.no_image.title") t("problems.model.no_image.description_html") :no_3d_model, # i18n-tasks-use t("problems.categories.no_3d_model") t("problems.model.no_3d_model.title") t("problems.model.no_3d_model.description_html") :non_manifold, # i18n-tasks-use t("problems.categories.non_manifold") t("problems.model_file.non_manifold.title") t("problems.model_file.non_manifold.description_html") :inside_out, # i18n-tasks-use t("problems.categories.inside_out") t("problems.model_file.inside_out.title") t("problems.model_file.inside_out.description_html") :no_license, # i18n-tasks-use t("problems.categories.no_license") t("problems.model.no_license.title") t("problems.model.no_license.description_html") :no_links, # i18n-tasks-use t("problems.categories.no_links") t("problems.model.no_links.title") t("problems.model.no_links.description_html") :no_creator, # i18n-tasks-use t("problems.categories.no_creator") t("problems.model.no_creator.title") t("problems.model.no_creator.description_html") :no_tags, # i18n-tasks-use t("problems.categories.no_tags") t("problems.model.no_tags.title") t("problems.model.no_tags.description_html") :http_error, # i18n-tasks-use t("problems.categories.http_error") t("problems.link.http_error.title") t("problems.link.http_error.description") :file_naming # i18n-tasks-use t("problems.categories.file_naming") t("problems.model.file_naming.title") t("problems.model.file_naming.description_html") ]
- SEVERITIES =
[ :silent, :info, :warning, :danger ]
- DEFAULT_SEVERITIES =
ActiveSupport::HashWithIndifferentAccess.new( missing: :danger, empty: :info, nesting: :warning, inefficient: :info, duplicate: :warning, no_image: :silent, no_3d_model: :silent, non_manifold: :warning, inside_out: :warning, no_license: :silent, no_links: :silent, no_creator: :silent, no_tags: :silent, http_error: :info, file_naming: :warning )
- ICONS =
ActiveSupport::HashWithIndifferentAccess.new( missing: "question-mark-circle", nesting: "files-alt", duplicate: "files", inefficient: "file-earmark-zip", no_image: "file-earmark-image", no_creator: "person-x", no_tags: "label", http_error: "question-mark-circle", file_naming: "folder-cross" )
- RESOLUTIONS =
{ missing: :destroy, empty: :destroy, nesting: :merge, inefficient: :convert, duplicate: :destroy, no_image: :upload, no_3d_model: :upload, non_manifold: :show, inside_out: :show, no_license: :edit, no_links: :edit, no_creator: :edit, no_tags: :edit, http_error: :edit, file_naming: :organize }
Constants inherited from ApplicationRecord
ApplicationRecord::SAFE_NAME_LENGTH
Class Method Summary collapse
Instance Method Summary collapse
Methods included from PublicIDable
Methods inherited from ApplicationRecord
Class Method Details
.create_or_clear(problematic, category, should_exist, options = {}) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'app/models/problem.rb', line 77 def self.create_or_clear(problematic, category, should_exist, = {}) if should_exist problematic.problems.including_ignored.where(category: category).first_or_create!.update() else problematic.problems.including_ignored.where(category: category).destroy_all end should_exist end |
Instance Method Details
#icon ⇒ Object
94 95 96 |
# File 'app/models/problem.rb', line 94 def icon ICONS[category] || "fire" end |
#parent ⇒ Object
86 87 88 89 90 91 92 |
# File 'app/models/problem.rb', line 86 def parent if problematic_type == "ModelFile" problematic.model elsif problematic_type == "Link" problematic.linkable end end |
#resolution_strategy ⇒ Object
116 117 118 |
# File 'app/models/problem.rb', line 116 def resolution_strategy RESOLUTIONS[category.to_sym] or raise NotImplementedError.new(category) end |