mobile_api
This commit is contained in:
parent
08fbb99c3e
commit
a20b916aa8
@ -2,7 +2,9 @@
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime, date
|
||||
# pyrefly: ignore [missing-import]
|
||||
from odoo import http
|
||||
# pyrefly: ignore [missing-import]
|
||||
from odoo.http import request
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@ -167,18 +169,28 @@ class MobileStudent(http.Controller):
|
||||
], fields=['id', 'name', 'state', 'start_date'], order='start_date asc', limit=5)
|
||||
|
||||
# Announcements
|
||||
announcements = request.env['education.announcement'].search_read(
|
||||
ann_records = request.env['education.announcement'].sudo().search(
|
||||
[('active', '=', True)],
|
||||
fields=['id', 'name', 'date', 'summary'],
|
||||
order='date desc, id desc',
|
||||
order='id desc',
|
||||
limit=5
|
||||
)
|
||||
announcements = []
|
||||
for a in ann_records:
|
||||
ann_title = getattr(a, 'title', None) or getattr(a, 'name', 'Announcement')
|
||||
ann_date = getattr(a, 'date_published', None) or getattr(a, 'date', None) or ''
|
||||
ann_content = getattr(a, 'content', None) or getattr(a, 'summary', None) or ''
|
||||
announcements.append({
|
||||
'id': a.id,
|
||||
'name': ann_title,
|
||||
'date': str(ann_date),
|
||||
'summary': str(ann_content)[:100]
|
||||
})
|
||||
|
||||
# Recent Results
|
||||
results = request.env['education.exam.result'].search([
|
||||
results = request.env['education.exam.result'].sudo().search([
|
||||
('student_id', '=', student.id),
|
||||
('published', '=', True)
|
||||
], order='published_date desc, id desc', limit=5)
|
||||
], order='id desc', limit=5)
|
||||
|
||||
results_data = []
|
||||
for r in results:
|
||||
@ -278,10 +290,10 @@ class MobileStudent(http.Controller):
|
||||
@require_student
|
||||
def get_results(self, student, **kwargs):
|
||||
try:
|
||||
results = request.env['education.exam.result'].search([
|
||||
results = request.env['education.exam.result'].sudo().search([
|
||||
('student_id', '=', student.id),
|
||||
('published', '=', True)
|
||||
], order='published_date desc, id desc')
|
||||
], order='id desc')
|
||||
|
||||
results_data = []
|
||||
for r in results:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user