Add images and documents settings to admin panel

This commit is contained in:
Julian Herrero
2019-05-16 16:14:40 +02:00
parent 35cd26c117
commit 220bfb065a
13 changed files with 146 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ class Setting < ApplicationRecord
end
def type
if %w[feature process proposals map html homepage].include? prefix
if %w[feature process proposals map html homepage uploads].include? prefix
prefix
else
"configuration"
@@ -19,6 +19,14 @@ class Setting < ApplicationRecord
value.present?
end
def content_type?
key.split(".").last == "content_types"
end
def content_type_group
key.split(".").second
end
class << self
def [](key)
where(key: key).pluck(:value).first.presence
@@ -44,6 +52,25 @@ class Setting < ApplicationRecord
setting.destroy if setting.present?
end
def mime_types
{
"images" => {
"jpg" => "image/jpeg",
"png" => "image/png",
"gif" => "image/gif"
},
"documents" => {
"pdf" => "application/pdf",
"doc" => "application/msword",
"docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"xls" => "application/x-ole-storage",
"xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"csv" => "text/plain",
"zip" => "application/zip"
}
}
end
def defaults
{
"feature.featured_proposals": nil,