Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create assertion route #465

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/controllers/assertions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# frozen_string_literal: true

class AssertionsController < ApplicationController
authorize_resource

active_scaffold :assertion do |config|
config.create.label = :create_assertion_label
config.list.sorting = { name: "ASC" }
config.list.columns = [:name]
config.columns = [:name]
config.actions.exclude :deleted_records

end



end
13 changes: 12 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class Ability
Major, Institution,
]

DOCUMENT_MODELS = [
Assertion
]

PLACE_MODELS = [
City, State, Country,
City, State, Country
]

CONFIGURATION_MODELS = [
Expand Down Expand Up @@ -81,6 +85,7 @@ def initialize(user)
initialize_phases(user, roles)
initialize_courses(user, roles)
initialize_education(user, roles)
initialize_documents(user, roles)
initialize_places(user, roles)
initialize_admissions(user, roles)
initialize_configurations(user, roles)
Expand Down Expand Up @@ -218,6 +223,12 @@ def initialize_education(user, roles)
end
end

def initialize_documents(user, roles)
if roles[Role::ROLE_SECRETARIA]
can :manage, Ability::DOCUMENT_MODELS
end
end

def initialize_places(user, roles)
if roles[:manager]
can :manage, Ability::PLACE_MODELS
Expand Down
11 changes: 11 additions & 0 deletions app/models/assertion.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class Assertion < ApplicationRecord
has_paper_trail

validates :name, presence: true

def to_label
"#{self.name}"
end
end
17 changes: 17 additions & 0 deletions config/locales/assertion.pt-BR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

pt-BR:
active_scaffold:
create_assertion_label: "Adicionar Declaração"

activerecord:
attributes:
assertion:
name: "Nome da Declaração"
params: "Parâmetros configuráveis da declaração"

models:
assertion:
one: "Documento"
other: "Documentos"
5 changes: 4 additions & 1 deletion config/locales/navigation.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pt-BR:
student: Alunos
dismissal: Desligamentos
enrollment: Matrículas
enrollment: Matrículas
enrollment_hold: Trancamentos
level: Níveis
dismissal_reason: Razões de Desligamento
Expand Down Expand Up @@ -54,6 +53,10 @@ pt-BR:
major: Cursos
institution: Instituições

documents:
label: Documentos
assertion: Declarações

locations:
label: Localidades
city: Cidades
Expand Down
5 changes: 5 additions & 0 deletions config/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ def can_read?(*args)
submenu.modelitem Institution
end

documents_models = [Assertion]
mainhelper.listitem :documents, documents_models do |submenu|
submenu.modelitem Assertion
end

locations_models = [City, State, Country]
mainhelper.listitem :locations, locations_models do |submenu|
submenu.modelitem City
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
record_select_routes
end

resources :assertions do
concerns :active_scaffold
end

resources :levels do
concerns :active_scaffold
end
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20242204223140_create_assertions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateAssertions < ActiveRecord::Migration[7.0]
def change
create_table :assertions do |t|
t.string :name

t.timestamps
end
end
end
8 changes: 7 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading