Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Back-end_Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Agendador
Back-end_Server
Commits
4d70ae81
Commit
4d70ae81
authored
Aug 21, 2018
by
Matheus Horstmann
🐴
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'translation_fix' into 'develop'
Adjust translation for models and controllers to pt-BR See merge request
!84
parents
f04ded56
2d17fb17
Pipeline
#17341
passed with stages
in 1 minute and 25 seconds
Changes
31
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
849 additions
and
251 deletions
+849
-251
app/controllers/api/v1/citizen_uploads_controller.rb
app/controllers/api/v1/citizen_uploads_controller.rb
+12
-6
app/controllers/api/v1/citizens_controller.rb
app/controllers/api/v1/citizens_controller.rb
+30
-15
app/controllers/api/v1/city_halls_controller.rb
app/controllers/api/v1/city_halls_controller.rb
+30
-15
app/controllers/api/v1/dependants_controller.rb
app/controllers/api/v1/dependants_controller.rb
+30
-17
app/controllers/api/v1/forms_controller.rb
app/controllers/api/v1/forms_controller.rb
+24
-12
app/controllers/api/v1/notifications_controller.rb
app/controllers/api/v1/notifications_controller.rb
+17
-14
app/controllers/api/v1/occupations_controller.rb
app/controllers/api/v1/occupations_controller.rb
+16
-9
app/controllers/api/v1/professionals_controller.rb
app/controllers/api/v1/professionals_controller.rb
+49
-25
app/controllers/api/v1/resource_bookings_controller.rb
app/controllers/api/v1/resource_bookings_controller.rb
+18
-9
app/controllers/api/v1/resource_shifts_controller.rb
app/controllers/api/v1/resource_shifts_controller.rb
+14
-7
app/controllers/api/v1/resource_types_controller.rb
app/controllers/api/v1/resource_types_controller.rb
+8
-4
app/controllers/api/v1/resources_controller.rb
app/controllers/api/v1/resources_controller.rb
+14
-7
app/controllers/api/v1/schedules_controller.rb
app/controllers/api/v1/schedules_controller.rb
+46
-28
app/controllers/api/v1/sectors_controller.rb
app/controllers/api/v1/sectors_controller.rb
+21
-11
app/controllers/api/v1/service_places_controller.rb
app/controllers/api/v1/service_places_controller.rb
+18
-11
app/controllers/api/v1/service_types_controller.rb
app/controllers/api/v1/service_types_controller.rb
+13
-7
app/controllers/api/v1/shifts_controller.rb
app/controllers/api/v1/shifts_controller.rb
+19
-11
app/controllers/api/v1/solicitations_controller.rb
app/controllers/api/v1/solicitations_controller.rb
+7
-4
app/models/address.rb
app/models/address.rb
+10
-5
app/models/citizen.rb
app/models/citizen.rb
+4
-2
app/models/city_hall.rb
app/models/city_hall.rb
+2
-1
app/models/service_place.rb
app/models/service_place.rb
+9
-4
app/models/shift.rb
app/models/shift.rb
+5
-3
app/models/solicitation.rb
app/models/solicitation.rb
+8
-6
app/serializers/citizen_upload_serializer.rb
app/serializers/citizen_upload_serializer.rb
+10
-5
app/validators/cep_validator.rb
app/validators/cep_validator.rb
+3
-2
app/validators/cpf_validator.rb
app/validators/cpf_validator.rb
+3
-2
app/validators/email_validator.rb
app/validators/email_validator.rb
+4
-3
app/workers/citizen_upload_worker.rb
app/workers/citizen_upload_worker.rb
+4
-2
config/locales/pt-BR.yml
config/locales/pt-BR.yml
+399
-2
test/controllers/cep_controller_test.rb
test/controllers/cep_controller_test.rb
+2
-2
No files found.
app/controllers/api/v1/citizen_uploads_controller.rb
View file @
4d70ae81
...
...
@@ -39,7 +39,8 @@ module Api::V1
# Check if uploads are not null for current citizen
if
@uploads
.
nil?
render
json:
{
errors:
[
"You don't have the permission to view citizen uploads."
]
# errors: ["You don't have the permission to view citizen uploads."]
errors:
[
"Você não tem permissão para visualizar os uploads de cidadão!"
]
},
status:
403
return
end
...
...
@@ -79,7 +80,8 @@ module Api::V1
authorize
@upload_id
,
:show?
rescue
render
json:
{
errors:
[
"You're not allowed to view this citizen upload log."
]
# errors: ["You're not allowed to view this citizen upload log."]
errors:
[
"Você não tem permissão para visualizar este log de upload de cidadão!"
]
},
status:
403
return
end
...
...
@@ -90,7 +92,8 @@ module Api::V1
# If log not found, displays not found message
if
path
.
nil?
render
json:
{
errors:
[
"Log not found for current task."
]
# errors: ["Log not found for current task."]
errors:
[
"Log não encontrado para tarefa atual!"
]
},
status:
404
# Otherwise, send file
...
...
@@ -134,7 +137,8 @@ module Api::V1
authorize
upload_object
,
:create?
rescue
render
json:
{
errors:
[
"You're not allowed to perform citizen uploads."
]
# errors: ["You're not allowed to perform citizen uploads."]
errors:
[
"Você não tem permissão para fazer upload de cidadão!"
]
},
status:
403
return
end
...
...
@@ -146,11 +150,13 @@ module Api::V1
CitizenUploadWorker
.
perform_async
(
upload_object
.
id
,
content
,
permission
,
city_id
)
render
json:
{
errors:
[
"Citizens scheduled to be imported!"
]
# errors: ["Citizens scheduled to be imported!"]
errors:
[
"Cidadãos agendados para serem importados!"
]
},
status:
201
else
render
json:
{
errors:
[
"Undefined citizens to import."
]
# errors: ["Undefined citizens to import."]
errors:
[
"Cidadãos para importar indefinidos!"
]
},
status:
404
end
end
...
...
app/controllers/api/v1/citizens_controller.rb
View file @
4d70ae81
...
...
@@ -29,7 +29,8 @@ module Api::V1
if
@citizens
.
nil?
render
json:
{
errors:
[
"You don't have the permission to view citizens."
]
# errors: ["You don't have the permission to view citizens."]
errors:
[
"Você não tem permissão para listar cidadãos!"
]
},
status:
403
else
response
=
Hash
.
new
...
...
@@ -45,7 +46,8 @@ module Api::V1
def
picture
if
@citizen
.
nil?
render
json:
{
errors:
[
"User
#{
params
[
:id
]
}
does not exist."
]
# errors: ["User #{params[:id]} does not exist."]
errors:
[
"Usuário
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -53,7 +55,8 @@ module Api::V1
authorize
@citizen
,
:show_picture?
rescue
render
json:
{
errors:
[
"You're not allowed to view this citizen."
]
# errors: ["You're not allowed to view this citizen."]
errors:
[
"Você não tem permissão para visualizar este cidadão!"
]
},
status:
403
return
end
...
...
@@ -62,7 +65,8 @@ module Api::V1
if
path
.
nil?
render
json:
{
errors:
[
"User
#{
params
[
:id
]
}
does not have a picture."
]
# errors: ["User #{params[:id]} does not have a picture."]
errors:
[
"Usuário
#{
params
[
:id
]
}
não possui uma foto!"
]
},
status:
404
else
if
not
params
[
:size
].
nil?
...
...
@@ -96,7 +100,8 @@ module Api::V1
authorize
@citizen
,
:schedule?
rescue
render
json:
{
errors:
[
"You're not allowed to schedule for this citizen."
]
# errors: ["You're not allowed to schedule for this citizen."]
errors:
[
"Você não tem permissão para agendar para este cidadão!"
]
},
status:
403
return
end
...
...
@@ -111,7 +116,8 @@ module Api::V1
def
show
if
@citizen
.
nil?
render
json:
{
errors:
[
"User
#{
params
[
:id
]
}
does not exist."
]
# errors: ["User #{params[:id]} does not exist."]
errors:
[
"Usuário
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -119,7 +125,8 @@ module Api::V1
authorize
@citizen
,
:show?
rescue
render
json:
{
errors:
[
"You're not allowed to view this citizen."
]
# errors: ["You're not allowed to view this citizen."]
errors:
[
"Você não tem permissão para visualizar este cidadão!"
]
},
status:
403
return
end
...
...
@@ -181,7 +188,8 @@ module Api::V1
def
update
if
@citizen
.
nil?
render
json:
{
errors:
[
"User
#{
params
[
:id
]
}
does not exist."
]
# errors: ["User #{params[:id]} does not exist."]
errors:
[
"Usuário
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
if
@citizen
.
update
(
citizen_params
)
...
...
@@ -196,7 +204,8 @@ module Api::V1
def
destroy
if
@citizen
.
nil?
render
json:
{
errors:
[
"User
#{
params
[
:id
]
}
does not exist."
]
# errors: ["User #{params[:id]} does not exist."]
errors:
[
"Usuário
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -204,7 +213,8 @@ module Api::V1
authorize
@citizen
,
:deactivate?
rescue
render
json:
{
errors:
[
"You're not allowed to deactivate this citizen."
]
# errors: ["You're not allowed to deactivate this citizen."]
errors:
[
"Você não tem permissão para desativar este cidadão!"
]
},
status:
403
return
end
...
...
@@ -225,7 +235,8 @@ module Api::V1
def
change_password
if
@citizen
.
nil?
render
json:
{
errors:
[
"User
#{
params
[
:id
]
}
does not exist."
]
# errors: ["User #{params[:id]} does not exist."]
errors:
[
"Usuário
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -233,14 +244,16 @@ module Api::V1
authorize
@citizen
,
:change_password?
rescue
render
json:
{
errors:
[
"You're not allowed to change password for this citizen."
]
# errors: ["You're not allowed to change password for this citizen."]
errors:
[
"Você não tem permissão para mudar a senha deste cidadão!"
]
},
status:
403
return
end
if
@citizen
.
email
.
present?
render
json:
{
errors:
[
"This citizen has an e-mail registered, use it for resetting the password!"
]
# errors: ["This citizen has an e-mail registered, use it for resetting the password!"]
errors:
[
"Este cidadão possui e-mail registrado, use-o para resetar sua senha!"
]
},
status:
401
return
end
...
...
@@ -253,14 +266,16 @@ module Api::V1
birth_date
!=
params
[
:birth_date
]
)
render
json:
{
errors:
[
"CPF and birth date do not match!"
]
# errors: ["CPF and birth date do not match!"]
errors:
[
"CPF ou data de nascimento inválidos!"
]
},
status:
403
return
end
if
params
[
:password
]
!=
params
[
:password_confirmation
]
render
json:
{
errors:
[
"Passwords do not match!"
]
# errors: ["Passwords do not match!"]
errors:
[
"As senhas informadas devem ser iguais!"
]
},
status:
403
return
end
...
...
app/controllers/api/v1/city_halls_controller.rb
View file @
4d70ae81
...
...
@@ -29,7 +29,8 @@ module Api::V1
if
@city_halls
.
nil?
render
json:
{
errors:
[
"You don't have the permission to view city halls."
]
# errors: ["You don't have the permission to view city halls."]
errors:
[
"Você não tem permissão para listar prefeituras!"
]
},
status:
403
return
else
...
...
@@ -47,14 +48,16 @@ module Api::V1
def
show
if
@city_hall
.
nil?
render
json:
{
errors:
[
"City hall
#{
params
[
:id
]
}
does not exist."
]
# errors: ["City hall #{params[:id]} does not exist."]
errors:
[
"Prefeitura
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
begin
authorize
@city_hall
,
:show?
rescue
render
json:
{
errors:
[
"You don't have the permission to view this city hall."
]
# errors: ["You don't have the permission to view this city hall."]
errors:
[
"Você não tem permissão para visualizar esta prefeitura!"
]
},
status:
403
return
end
...
...
@@ -72,7 +75,8 @@ module Api::V1
authorize
@city_hall
,
:create?
rescue
render
json:
{
errors:
[
"You don't have the permission to create city halls."
]
# errors: ["You don't have the permission to create city halls."]
errors:
[
"Você não tem permissão para criar prefeituras!"
]
},
status:
403
return
end
...
...
@@ -89,14 +93,16 @@ module Api::V1
def
update
if
@city_hall
.
nil?
render
json:
{
errors:
[
"City hall
#{
params
[
:id
]
}
does not exist."
]
# errors: ["City hall #{params[:id]} does not exist."]
errors:
[
"Prefeitura
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
begin
authorize
@city_hall
,
:update?
rescue
render
json:
{
errors:
[
"You don't have the permission to create city halls."
]
# errors: ["You don't have the permission to update city halls."]
errors:
[
"Você não tem permissão para atualizar prefeituras!"
]
},
status:
403
return
end
...
...
@@ -113,14 +119,16 @@ module Api::V1
def
destroy
if
@city_hall
.
nil?
render
json:
{
errors:
[
"City hall
#{
params
[
:id
]
}
does not exist."
]
# errors: ["City hall #{params[:id]} does not exist."]
errors:
[
"Prefeitura
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
begin
authorize
@city_hall
,
:destroy?
rescue
render
json:
{
errors:
[
"You're not allowed to destroy this city hall."
]
# errors: ["You're not allowed to destroy this city hall."]
errors:
[
"Você não tem permissão para remover esta prefeitura!"
]
},
status:
403
return
end
...
...
@@ -139,7 +147,8 @@ module Api::V1
def
picture
if
@city_hall
.
nil?
render
json:
{
errors:
[
"City hall
#{
params
[
:id
]
}
does not exist."
]
# errors: ["City hall #{params[:id]} does not exist."]
errors:
[
"Prefeitura
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -147,7 +156,8 @@ module Api::V1
authorize
@city_hall
,
:picture?
rescue
render
json:
{
errors:
[
"You're not allowed to view this city hall."
]
# errors: ["You're not allowed to view this city hall."]
errors:
[
"Você não tem permissão para visualizar esta prefeitura!"
]
},
status:
403
return
end
...
...
@@ -156,7 +166,8 @@ module Api::V1
if
path
.
nil?
render
json:
{
errors:
[
"City hall
#{
params
[
:id
]
}
does not have a picture."
]
# errors: ["City hall #{params[:id]} does not have a picture."]
errors:
[
"Prefeitura
#{
params
[
:id
]
}
não possui uma foto!"
]
},
status:
404
else
if
not
params
[
:size
].
nil?
...
...
@@ -180,7 +191,8 @@ module Api::V1
def
upload_picture
if
@city_hall
.
nil?
render
json:
{
errors:
[
"City hall
#{
params
[
:id
]
}
does not exist."
]
# errors: ["City hall #{params[:id]} does not exist."]
errors:
[
"Prefeitura
#{
params
[
:id
]
}
não existe!"
]
},
status:
404
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -188,7 +200,8 @@ module Api::V1
authorize
@city_hall
,
:update?
rescue
render
json:
{
errors:
[
"You're not allowed to update this city hall."
]
# errors: ["You're not allowed to update this city hall."]
errors:
[
"Você não tem permissão para atualizar esta prefeitura!"
]
},
status:
403
return
end
...
...
@@ -203,11 +216,13 @@ module Api::V1
@city_hall
.
save
render
json:
{
errors:
[
"City hall avatar uploaded!"
]
# errors: ["City hall avatar uploaded!"]
errors:
[
"Avatar da prefeitura atualizado!"
]
},
status:
201
else
render
json:
{
errors:
[
"Avatar parameter undefined."
]
# errors: ["Avatar parameter undefined."]
errors:
[
"Avatar indefinido!"
]
},
status:
400
end
end
...
...
app/controllers/api/v1/dependants_controller.rb
View file @
4d70ae81
...
...
@@ -14,7 +14,7 @@
# along with Agendador. If not, see <https://www.gnu.org/licenses/>.
module
Api::V1
class
DependantsController
<
ApplicationController
class
DependantsController
<
ApplicationController
include
Authenticable
include
HasPolicies
...
...
@@ -27,7 +27,8 @@ module Api::V1
def
index
if
@citizen
.
nil?
render
json:
{
errors:
[
"Citizen
#{
params
[
:citizen_id
]
}
does not exist."
]
# errors: ["Citizen #{params[:citizen_id]} does not exist."]
errors:
[
"Cidadão
#{
params
[
:citizen_id
]
}
não existe!"
]
},
status: :not_found
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -35,7 +36,8 @@ module Api::V1
authorize
@citizen
,
:show_dependants?
rescue
render
json:
{
errors:
[
"You're not allowed to view this dependant."
]
# errors: ["You're not allowed to view this dependant."]
errors:
[
"Você não tem permissão para visualizar este dependente!"
]
},
status:
403
return
end
...
...
@@ -65,16 +67,19 @@ module Api::V1
def
show
if
@citizen
.
nil?
render
json:
{
errors:
[
"Citizen
#{
params
[
:citizen_id
]
}
does not exist."
]
# errors: ["Citizen #{params[:citizen_id]} does not exist."]
errors:
[
"Cidadão
#{
params
[
:citizen_id
]
}
não existe!"
]
},
status: :not_found
else
if
@dependant
.
nil?
render
json:
{
errors:
[
"Dependant
#{
params
[
:id
]
}
does not exist."
]
# errors: ["Dependant #{params[:id]} does not exist."]
errors:
[
"Dependente
#{
params
[
:id
]
}
não existe!"
]
},
status: :not_found
elsif
@dependant
.
citizen
.
responsible_id
!=
@citizen
.
id
render
json:
{
errors:
[
"Dependant
#{
params
[
:id
]
}
does not belong to citizen
#{
params
[
:citizen_id
]
}
."
]
# errors: ["Dependant #{params[:id]} does not belong to citizen #{params[:citizen_id]}."]
errors:
[
"Dependente
#{
params
[
:id
]
}
não pertence ao cidadão
#{
params
[
:citizen_id
]
}
."
]
},
status: :forbidden
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -82,7 +87,8 @@ module Api::V1
authorize
@citizen
,
:show_dependants?
rescue
render
json:
{
errors:
[
"You're not allowed to view this dependant."
]
# errors: ["You're not allowed to view this dependant."]
errors:
[
"Você não tem permissão para visualizar este dependente!"
]
},
status:
403
return
end
...
...
@@ -97,7 +103,8 @@ module Api::V1
def
create
if
@citizen
.
nil?
render
json:
{
errors:
[
"Citizen
#{
params
[
:citizen_id
]
}
does not exist."
]
# errors: ["Citizen #{params[:citizen_id]} does not exist."]
errors:
[
"Cidadão
#{
params
[
:citizen_id
]
}
não existe!"
]
},
status: :not_found
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -105,7 +112,8 @@ module Api::V1
authorize
@citizen
,
:create_dependants?
rescue
render
json:
{
errors:
[
"You're not allowed to create dependants."
]
# errors: ["You're not allowed to create dependants."]
errors:
[
"Você não tem permissão para criar dependentes!"
]
},
status:
403
return
end
...
...
@@ -116,7 +124,7 @@ module Api::V1
if
new_params
[
:cep
].
blank?
new_params
[
:cep
]
=
@citizen
.
cep
end
# Create new citizen associated with new dependant
citizen
=
Citizen
.
new
(
new_params
)
citizen
.
active
=
true
...
...
@@ -134,7 +142,7 @@ module Api::V1
if
not
citizen
.
save
render
json:
citizen
.
errors
,
status: :unprocessable_entity
else
else
@dependant
=
Dependant
.
new
(
citizen_id:
citizen
.
id
)
if
@dependant
.
save
...
...
@@ -151,16 +159,19 @@ module Api::V1
def
update
if
@citizen
.
nil?
render
json:
{
errors:
[
"Citizen
#{
params
[
:citizen_id
]
}
does not exist."
]
# errors: ["Citizen #{params[:citizen_id]} does not exist."]
errors:
[
"Cidadão
#{
params
[
:citizen_id
]
}
não existe!"
]
},
status: :not_found
else
if
@dependant
.
nil?
render
json:
{
errors:
[
"Dependant
#{
params
[
:id
]
}
does not exist."
]
# errors: ["Dependant #{params[:id]} does not exist."]
errors:
[
"Dependente
#{
params
[
:id
]
}
não existe!"
]
},
status: :not_found
elsif
@dependant
.
citizen
.
responsible_id
!=
@citizen
.
id
render
json:
{
errors:
[
"Dependant
#{
params
[
:id
]
}
does not belong to citizen
#{
params
[
:id
]
}
."
]
# errors: ["Dependant #{params[:id]} does not belong to citizen #{params[:id]}."]
errors:
[
"Dependente
#{
params
[
:id
]
}
não pertence ao cidadão
#{
params
[
:id
]
}
."
]
},
status: :forbidden
else
# Allow request only if the citizen is reachable from current user
...
...
@@ -168,7 +179,8 @@ module Api::V1
authorize
@citizen
,
:create_dependants?
rescue
render
json:
{
errors:
[
"You're not allowed to create dependants."
]
# errors: ["You're not allowed to create dependants."]
errors:
[
"Você não tem permissão para criar dependentes!"
]
},
status:
403
return
end
...
...
@@ -197,7 +209,7 @@ module Api::V1
new_params
[
:city_id
]
=
Address
.
get_city_id
(
new_params
[
:cep
])
end
if
@dependant
.
citizen
.
update
(
new_params
)
and
if
@dependant
.
citizen
.
update
(
new_params
)
and
render
json:
@dependant
.
complete_info_response
else
render
json:
@dependant
.
citizen
.
errors
,
status: :unprocessable_entity
...
...
@@ -211,7 +223,8 @@ module Api::V1
def
destroy
if
@dependant
.
nil?
render
json:
{
errors:
[
"Dependant
#{
params
[
:id
]
}
does not exist."
]
# errors: ["Dependant #{params[:id]} does not exist."]
errors:
[
"Dependente
#{
params
[
:id
]
}
não existe!"
]
},
status: :not_found
else
@dependant
.
citizen
.
active
=
false
...
...
app/controllers/api/v1/forms_controller.rb
View file @
4d70ae81
...
...
@@ -80,7 +80,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -101,7 +102,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -122,7 +124,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -155,7 +158,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -176,7 +180,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -231,7 +236,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -346,7 +352,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -556,7 +563,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -577,7 +585,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -672,7 +681,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -693,7 +703,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
@@ -714,7 +725,8 @@ module Api::V1
else
render
json:
{
errors:
[
"You're not allowed to view this form."
]
# errors: ["You're not allowed to view this form."]
errors:
[
"Você não tem permissão para visualizar este formulário!"
]
},
status:
403
return
end
...
...
app/controllers/api/v1/notifications_controller.rb
View file @
4d70ae81
...
...
@@ -18,55 +18,57 @@ module Api::V1
include
Authenticable
before_action
:set_notification
,
only:
[
:show
,
:update
,
:destroy
]
# GET /notifications
# GET /notifications
def
index
@notifications
=
Notification
.
where
(
account_id:
current_user
.
first
.
account_id
)
.
where
(
read:
false
)
render
json:
@notifications
end
# POST /notifications
# POST /notifications
def
create
notification
=
notification_params
if
notification
[
"account_id"
].
nil?
notification
[
"account_id"
]
=
current_user
.
first
.
account_id
end
end
@notification
=
Notification
.
new
(
notification
)
authorize
@notification
,
:create?
if
@notification
.
save
render
json:
@notification
,
status: :created
render
json:
@notification
,
status: :created
else
render
json:
@notification
.
errors
,
status: :unprocessable_entity
end
end
# GET /notifications/:id
# GET /notifications/:id
def
show