Skip to content

Commit

Permalink
Merge pull request #119 from INRIM/t_12703
Browse files Browse the repository at this point in the history
[ADD] added anag_servizi get rest api
  • Loading branch information
Marcoapu authored Oct 24, 2024
2 parents b090a07 + 142d69a commit 42c5952
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
3 changes: 2 additions & 1 deletion inrim_controllo_accessi_api/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
from . import lettore
from . import documento
from . import tag
from . import settore_ente
from . import settore_ente
from . import anag_servizi
12 changes: 12 additions & 0 deletions inrim_controllo_accessi_api/controllers/anag_servizi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import http

from .api_controller_inrim import InrimApiController, BadRequest

class InrimApiAnagServizi(InrimApiController):

@http.route('/api/anag_servizi', auth="none", type='http', methods=['GET'],
csrf=False)
def api_get_ca_anag_servizi(self, **params):
self.check_token('ca.anag_servizi', 'read')
return self.handle_response(
*self.model.rest_get(params), is_list=True)
3 changes: 1 addition & 2 deletions inrim_controllo_accessi_api/controllers/settore_ente.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class InrimApiSettoreEnte(InrimApiController):
@http.route('/api/settore_ente', auth="none", type='http', methods=['GET'],
csrf=False)
def api_get_ca_settore_ente(self, **params):
model = 'ca.settore_ente'
self.check_token(model, 'read')
self.check_token('ca.settore_ente', 'read')
return self.handle_response(
*self.model.rest_get(params), is_list=True)
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,42 @@ class CaAnagServizi(models.Model):
'This CodRef already exists.')
]

def rest_boby_hint(self):
return {
"name": "",
"ca_persona_id": "",
}

def rest_get_record(self):
vals = {
'id': self.id,
'name': self.name,
'ca_settore_ente_id': self.f_m2o(self.ca_settore_ente_id),
'ca_settore_persona_id': self.f_m2o(self.ca_settore_persona_id),
'settore_ente_name': self.settore_ente_name,
'ca_persona_id': self.f_m2o(self.ca_persona_id),
'type_ids': self.f_m2m(self.type_ids),
'virtual': self.virtual,
'ca_ente_azienda_id': self.f_m2o(self.ca_ente_azienda_id),
'generic': self.generic,
'spazio_id': self.f_m2o(self.spazio_id),
'tipo_spazio_id': self.f_m2o(self.tipo_spazio_id),
'abbreviation': self.abbreviation,
'description': self.description,
'cod_ref': self.cod_ref,
'date_start': self.f_date(self.date_start),
'date_end': self.f_date(self.date_end),
'tipo_ente_azienda_ids': self.f_m2m(self.tipo_ente_azienda_ids)
}
return vals

def rest_eval_body(self, body):
body, msg = super().rest_eval_body(
body, [
'name', 'ca_persona_id'
])
return body, msg

@api.constrains('date_start', 'date_end')
def _check_date(self):
for record in self:
Expand Down

0 comments on commit 42c5952

Please sign in to comment.