Merge pull request #2902 from expsa/younes_dev_odex25_project

IMP Project Status Report to project module for tracking project prog…
This commit is contained in:
kchyounes19 2025-04-27 12:59:26 +01:00 committed by GitHub
commit fb21eefb4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 13 deletions

View File

@ -186,6 +186,7 @@
width: 100%;
padding-right: 15px;
margin-top: 20px;
page-break-inside: avoid;
}
</style>
<div class="page">

View File

@ -55,17 +55,17 @@ class ReportProjectStatus(models.AbstractModel):
_logger.warning("All task counts are zero, using dummy data")
task_data = {'new': 1, 'in_progress': 1, 'done': 1}
font_path = os.path.join(os.path.dirname(__file__), 'img', 'amiri-regular.ttf')
if not os.path.exists(font_path):
font_path = get_module_resource('project_base', 'static/fonts', 'amiri-regular.ttf')
if not font_path:
_logger.warning("Arabic font not found. Using default font.")
font_path = None
if font_path:
prop = matplotlib.font_manager.FontProperties(fname=font_path)
else:
prop = None
# font_path = os.path.join(os.path.dirname(__file__), 'img', 'amiri-regular.ttf')
# if not os.path.exists(font_path):
# font_path = get_module_resource('project_base', 'static/fonts', 'amiri-regular.ttf')
# if not font_path:
# _logger.warning("Arabic font not found. Using default font.")
# font_path = None
#
# if font_path:
# prop = matplotlib.font_manager.FontProperties(fname=font_path)
# else:
# prop = None
fig = plt.figure(figsize=(5, 4))
@ -80,11 +80,13 @@ class ReportProjectStatus(models.AbstractModel):
colors = ['#f0312e', '#add8e6', '#90ee90']
plt.pie(sizes, labels=labels, autopct='%1.1f%%', colors=colors, startangle=90,
textprops={'fontproperties': prop, 'fontsize': 16} if prop else {'fontsize': 16})
textprops= {'fontsize': 16})
# {'fontproperties': prop, 'fontsize': 16} if prop else
plt.axis('equal')
plt.rcParams['font.size'] = 18
title_text = format_arabic('احصائيات المهام')
plt.title(title_text, fontproperties=prop if prop else None)
plt.title(title_text)
# fontproperties = prop if prop else None
buffer = io.BytesIO()
plt.savefig(buffer, format='png', bbox_inches='tight', dpi=300)