chore: reorganize para current/, rails 8.1, testes e readme
- move app para current/ (estrutura capistrano) - rails 7.2 → 8.1, ruby 3.2, sqlite3 2.x - adiciona primary_key Idinformativo no model - schema.rb completo com todas as tabelas - testes minitest: models (Tag, Informativo, Tema) e controllers - readme atualizado em pt-br com stack e instruções de desenvolvimento - gitignore exclui dump.sql, *.duckdb e sqlite3
This commit is contained in:
10
current/app/models/admin_user.rb
Normal file
10
current/app/models/admin_user.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class AdminUser < ApplicationRecord
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :database_authenticatable,
|
||||
:recoverable, :rememberable, :validatable
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :database_authenticatable,
|
||||
:recoverable, :rememberable, :validatable
|
||||
end
|
||||
3
current/app/models/application_record.rb
Normal file
3
current/app/models/application_record.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
0
current/app/models/concerns/.keep
Normal file
0
current/app/models/concerns/.keep
Normal file
27
current/app/models/informativo.rb
Normal file
27
current/app/models/informativo.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
class Informativo < ApplicationRecord
|
||||
self.table_name = "informativo"
|
||||
self.primary_key = "Idinformativo"
|
||||
has_and_belongs_to_many :tags
|
||||
|
||||
before_save :meta
|
||||
|
||||
def temas
|
||||
Tema.where("cod_tema = #{self.tema1} or cod_tema = #{self.tema2} or cod_tema = #{self.tema3}").map(&:tema)
|
||||
end
|
||||
|
||||
def as_markdown
|
||||
html = HTMLPage.new :contents => self.Descricao
|
||||
html.markdown
|
||||
end
|
||||
|
||||
def to_html
|
||||
Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render(self.markdown)
|
||||
end
|
||||
|
||||
private
|
||||
def meta
|
||||
#expire_page action: "show", id: params[:list][:id]
|
||||
self.Datainc = DateTime.now unless self.Datainc
|
||||
end
|
||||
|
||||
end
|
||||
16
current/app/models/tag.rb
Normal file
16
current/app/models/tag.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Tag < ApplicationRecord
|
||||
has_and_belongs_to_many :informativos
|
||||
before_save :parameterize
|
||||
validates :nome, uniqueness: true
|
||||
|
||||
def self.top
|
||||
Tag.limit(80).order("count DESC")
|
||||
end
|
||||
|
||||
private
|
||||
def parameterize
|
||||
self.nome.strip!
|
||||
self.param = self.nome.parameterize
|
||||
puts "Tag: #{self.nome}"
|
||||
end
|
||||
end
|
||||
11
current/app/models/tema.rb
Normal file
11
current/app/models/tema.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Tema < ApplicationRecord
|
||||
self.table_name = "temas"
|
||||
|
||||
def self.infos
|
||||
Tema.where(cod_tema_sub: 0).where.not(padrao: "").map { |t| [t.padrao, t.count] }.sort_by { |_, c| -c }
|
||||
end
|
||||
|
||||
def informativos
|
||||
Informativo.where("tema1 = ? OR tema2 = ? OR tema3 = ?", cod_tema, cod_tema, cod_tema)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user