Skip to content

Commit 545671f

Browse files
committed
Fix display of today's line
Adjust color applied to macro ressource task
1 parent 533adcb commit 545671f

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

planning/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
----------
55
"""
66

7-
__version__ = "2.2.0"
7+
__version__ = "2.2.1"

planning/gantt.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,22 +2245,22 @@ def _svg_calendar(
22452245

22462246
if is_it_today:
22472247

2248-
x = tu_middle_x
2248+
x_today = tu_middle_x
22492249
if scale == DRAW_WITH_WEEKLY_SCALE:
2250-
x = round(
2250+
x_today = round(
22512251
tu_start_x
22522252
+ (today.weekday() * ((tu_end_x - tu_start_x) / 7.0)),
22532253
2,
22542254
)
22552255
elif scale == DRAW_WITH_MONTHLY_SCALE:
22562256
_, mtdays = calendar.monthrange(today.year, today.month)
2257-
x = round(
2257+
x_today = round(
22582258
tu_start_x + (today.day * ((tu_end_x - tu_start_x) / mtdays)), 2
22592259
)
22602260

22612261
vlines.add(
22622262
svgwrite.shapes.Rect(
2263-
insert=(x, 1 * cm),
2263+
insert=(x_today, 1 * cm),
22642264
size=(0.2 * cm, (maxy + 1) * cm),
22652265
fill=COLORS.TODAY.value,
22662266
stroke="lightgray",
@@ -2795,16 +2795,19 @@ def make_svg_for_resources(
27952795
nb_tasks = 0 # includes all resource's tasks in chart period, although he's on leave
27962796
# nb_tasks_with_presence = 0
27972797
project_task: Task = None
2798-
project_color = r.color or COLORS.RESSOURCES.value
2798+
# project_color = r.color or COLORS.RESSOURCES.value
27992799

28002800
for t in ressources_tasks[r]:
28012801
# if t.get_resources() is not None and r in t.get_resources():
28022802
if t.start_date() <= end_date and start_date <= t.end_date():
28032803

28042804
nb_tasks += 1
28052805
project_task_name = t.project or t.name
2806+
task_project = self.get_project(project_task_name)
2807+
project_color = task_project.color if task_project is not None else COLORS.RESSOURCES.value
28062808
# Create a project task with the ressource color
28072809
if one_line_for_tasks and project_task is None:
2810+
28082811
project_task = Task(project_task_name, color=project_color, is_project=True)
28092812
project_task.start = t.start_date()
28102813
project_task.stop = t.end_date()
@@ -2857,9 +2860,12 @@ def make_svg_for_resources(
28572860
project_task = Task(project_task_name, color=project_color, is_project=True)
28582861
project_task.start = t.start_date()
28592862
project_task.stop = t.end_date()
2863+
28602864
# Otherwise add the task's project name to the macro project task name
28612865
# and update the end date of the project if the task ends later
2866+
# Use a global default color for the task
28622867
else:
2868+
project_task.color = COLORS.RESSOURCES.value
28632869
project_task.name = project_task.name + " / " + project_task_name
28642870
project_task.fullname = project_task.name
28652871
if t.end_date() > project_task.stop:
@@ -3381,6 +3387,13 @@ def get_tasks(self):
33813387
flist.append(r)
33823388
return flist
33833389

3390+
def get_project(self, project_name):
3391+
""" Return the project with the name in parameter"""
3392+
for task in self.tasks:
3393+
if isinstance(task, Project) and task.name == project_name:
3394+
return task
3395+
return None
3396+
33843397
def csv(self, csv=None):
33853398
"""
33863399
Create CSV output from projects

0 commit comments

Comments
 (0)