10.1.11. Class cerebro.aclasses.Task¶
-
class
cerebro.aclasses.
Task
(task_id)[source]¶ Task class.
Methods
activity()
add_hashtags()
allocated()
budget()
creation_time()
creator_id()
data()
finish()
flags()
hashtags()
id()
moderator_id()
modification_time()
name()
parent_id()
parent_url()
payments()
planned_time()
possible_statuses()
priority()
progress()
project_id()
remove_allocated()
remove_hashtags()
set_activity()
set_allocated()
set_budget()
set_finish()
set_flag()
set_name()
set_planned_time()
set_priority()
set_progress()
set_start()
set_status()
spent()
start()
status()
tags()
task = cerebro.core.current_task()
task = cerebro.core.task(task_id)
tasks = cerebro.core.selected_tasks(task_id)
-
ALLOCATED_
= ''¶ Allocated user tuple fields
-
ALLOCATED_FLAGS
= 2¶ User flags.
User flags
are described in the classcerebro.aclasses.Users
.
-
ALLOCATED_ID
= 0¶ User ID.
-
ALLOCATED_NAME
= 1¶ User full name.
-
DATA_
= ''¶ Task tuple fields
-
DATA_ACTIVITY_ID
= 6¶ Activity ID.
-
DATA_ACTIVITY_NAME
= 5¶ Activity name.
-
DATA_ALLOCATED
= 20¶ Users allocated to the task. Type - string. The separator is ‘;’.
-
DATA_BUDGET
= 29¶ Amount budgeted for the task and its subtasks, subtotal.
-
DATA_CREATED
= 9¶ Time of the task creation. Type - datetime.
-
DATA_CREATOR_ID
= 18¶ The ID of the user who created the task.
-
DATA_DURATION
= 22¶ The calculated task duration, calendar days. Type - float.
-
DATA_FLAGS
= 16¶
-
DATA_HUMAN_FINISH
= 26¶ The gap between 01.01.2000 and the manually set up task finishing date, days. Type - float.
-
DATA_HUMAN_START
= 25¶ The gap between 01.01.2000 and the manually set up task starting date, days. Type - float.
-
DATA_ID
= 1¶ Task ID.
-
DATA_MODERATOR_ID
= 17¶ The ID of the user who modified the task.
-
DATA_MODIFIED
= 19¶ The time of data modification. Type - datetime.
-
DATA_MTM
= 0¶ Time of data modification. Type - datetime.
-
DATA_NAME
= 3¶ Task name.
-
DATA_OFFSET
= 21¶ The gap between 01.01.2000 and the calculated task starting date, days. Type - float.
-
DATA_PARENT_ID
= 2¶ Parent task ID.
-
DATA_PARENT_URL
= 4¶ Full path to the parent task. Example: /Test project/Scene 1/.
-
DATA_PLANNED
= 12¶ Task planned time, hours. Type - float.
-
DATA_PRIVILEGE
= 24¶ The current user’s access rights to the task. Type - int.
-
DATA_PROGRESS
= 11¶ Progress. Type - float от 0.0 до 100.0.
-
DATA_PROJECT_ID
= 23¶ The ID of the project, the task belongs to.
-
DATA_RESOURCE_APPROVED
= 34¶ Material resource time to sign off, subtotal for the task and its subtasks - confirmed, hours. Type - float.
-
DATA_RESOURCE_DECLARED
= 33¶ Material resource time to sign off, subtotal for the task and its subtasks - declared, hours. Type - float.
-
DATA_RESOURCE_SELF_APPROVED
= 32¶ Material resource time to sign off - confirmed, minutes. Type - float.
-
DATA_RESOURCE_SELF_DECLARED
= 31¶ Material resource time to sign off - declared, minutes. Type - float.
-
DATA_SELF_BUDGET
= 27¶ Amount budgeted for the task.
-
DATA_SELF_SPENT
= 28¶ Amount of budget signed off the task.
-
DATA_SELF_USERS_APPROVED
= 8¶ Users’ work time confirmed to sign off, minutes. Type - float.
-
DATA_SELF_USERS_DECLARED
= 7¶ Users’ work time declared to sign off, minutes. Type - float.
-
DATA_SPENT
= 30¶ Amount signed off the task and its subtasks, subtotal.
-
DATA_STATUS_ID
= 35¶ Status ID.
-
DATA_THUMBS
= 15¶ Hash sums of the file thumbnails. Type - string. The separator is ‘;’.
-
DATA_USERS_APPROVED
= 14¶ Users’ work time confirmed to sign off on this task and its subtasks, hours. Type - float.
-
DATA_USERS_DECLARED
= 13¶ Users’ work time declared to sign off on this task and its subtasks, hours. Type - float.
-
FLAG_
= ''¶ Task flags
-
FLAG_ASSIGNED
= 38¶ The current user is allocated to this task.
-
FLAG_CLOSED
= 2¶ The task is closed.
-
FLAG_CLOSED_EFFECTIVE
= 30¶ The task is closed because an upper-level task is closed.
-
FLAG_DELETED
= 0¶ The task has been deleted.
-
FLAG_FORUM_LOCKED
= 5¶ The task forum has been set read-only.
-
FLAG_HAS_CHILD
= 32¶ The task has subtasks.
-
FLAG_HAS_MESSAGES
= 33¶ The task has messages in the Forum thread.
-
FLAG_HAS_PLANNED
= 56¶ The task has its own planned time.
-
FLAG_HAS_PROGRESS
= 59¶ The task has its own progress.
-
FLAG_HAS_REFERENCE
= 62¶ The task has reference.
-
FLAG_HAS_SUB_PERMS
= 35¶ The task has customized access rights
-
FLAG_INTEREST
= 39¶ The current user follows the task.
-
FLAG_IS_REFERENCE
= 61¶ The task is reference.
-
FLAG_LAST_EV_APPROVED
= 45¶ The last message in the task Forum is approved.
-
FLAG_LAST_EV_CLIENT_VIS
= 44¶ The last message in the task Forum is visible for clients.
-
FLAG_NEED_ANSWER
= 34¶ The task is pending reply (according to the access rights of the current user).
-
FLAG_PERM_INHERIT_BLOCK
= 1¶ Inherited access rights to the task have been reset.
-
FLAG_SUSPENED
= 4¶ The task suspended (paused).
-
FLAG_SUSPENED_EFFECTIVE
= 31¶ The task is suspended because an upper-level task is suspended.
-
FLAG_TASK_AS_EVENT
= 3¶ The task is an event.
-
PAYMENT_
= ''¶ Payment tuple fields
-
PAYMENT_COMMENT
= 7¶ Text comment on the payment.
-
PAYMENT_FLAGS
= 4¶
-
PAYMENT_ID
= 2¶ Payment ID.
-
PAYMENT_MONEY
= 5¶ Payment amount, abstract currency units.
-
PAYMENT_MTM
= 0¶ Time of data modification. Type - datetime.
-
PAYMENT_RECORD_TIME
= 6¶ Payment sign off time. Type - datetime.
-
PAYMENT_TASK_ID
= 3¶ Task ID.
-
PAYMENT_USER_ID
= 1¶ The ID of the user who signed the payment off.
-
PAYMENT__FLAG_
= ''¶ Payment flags
-
PAYMENT__FLAG_CANCEL
= 1¶ Payment canceled.
-
PRIORITY_
= ''¶ Priority values
-
PRIORITY_ABOVE_NORMAL
= 1¶ Above normal.
-
PRIORITY_BELOW_NORMAL
= -1¶ Below normal.
-
PRIORITY_CRITICAL
= 3¶ Critical.
-
PRIORITY_HIGH
= 2¶ High.
-
PRIORITY_LOW
= -2¶ Low.
-
PRIORITY_NORMAL
= 0¶ Normal.
-
activity
()[source]¶ Returns: task activity type. ‘(0, ‘’)’ means that the task activity type is not set. Return type: tuple(activity_id, activity_name) - a 2-field tuple: Activity ID, activity name. See also
Parameters: hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). Adds hashtags to the task.
See also
-
allocated
()[source]¶ Returns: a list of tuples on users
allocated to the task.Return type: list(tuple,) Example: defining if a material resource was allocated to the task:
for user in task.allocated(): if cerebro.aclasses.Users.is_resource(user[task.ALLOCATED_FLAGS]) == True: print('The resource was allocated to the task:', user[task.ALLOCATED_NAME])
See also
-
data
()[source]¶ Returns: tuple on the task
.Return type: tuple Actually, the most part of the methods of this class are interfaces to this tuple. Therefore, you can use its data directly from the tuple.
task.creator_id() == task.data()[task.DATA_CREATOR_ID] task.priority() == task.data()[task.DATA_PRIORITY] # и так далее
-
flags
()[source]¶ Returns: task flags
.Return type: int if cerebro.core.has_flag(task.flags(), task.FLAG_FORUM_LOCKED): # checking if the Forum is locked read-only return
See also
Returns: a list of hashtags to the task. Return type: list(string,) Example: printing hashtags:
for ht in task.hashtags(): print('Hashtag:', ht)
See also
-
parent_url
()[source]¶ Returns: full path to the parent task. Пример: ‘/Test project/Scene 1/’. Return type: string
-
payments
()[source]¶ Returns: a list of tuples on payments
on the task.Return type: list(tuple,) Example: checking if a payment was canceled:
for pay in task.payments(): if pay[task.PAYMENT_MONEY] > 1000 and cerebro.core.has_flag(pay[task.PAYMENT_FLAGS], task.PAYMENT__FLAG_CANCEL)==True: cerebro.core.print_warning('Payment of more than 1000 was canceled', task.name())
-
possible_statuses
()[source]¶ Returns: a list of tuples on statuses
, which can be set for the task.Return type: list(tuple,) In the Cerebro system for each status, permissions for switching each status are set. In addition, each status has a flag of inheritance. On the task-containers you can set only the statuses that have this flag enabled. Therefore, the list of possible statuses depends on user rights, the current status, as well as the presence / lack of sub-tasks in the task.
Example of determining the possibility to set ‘completed’ status for the task:
possible_statuses = task.possible_statuses() for status in possible_statuses: if status[cerebro.aclasses.Statuses.DATA_NAME] == 'completed': task.set_status(status[cerebro.aclasses.Statuses.DATA_ID]) break
See also
-
priority
()[source]¶ Returns: priority
of the task.Return type: int if task.priority() == task.PRIORITY_CRITICAL: cerebro.core.print_warning('A critical priority task', task.name())
See also
-
remove_allocated
(user_id)[source]¶ Parameters: user_id (int) – user ID. Dismisses a user from the task.
Example: getting material resources off the task:
allocated = task.allocated() for user in allocated: if cerebro.aclasses.Users.is_resource(user[task.ALLOCATED_FLAGS]) == True: task.remove_allocated(user[task.ALLOCATED_ID])
See also
Parameters: hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). Remove hashtags from the task.
See also
-
set_activity
(activity_id)[source]¶ Parameters: activity_id (int) – Activity type ID. Sets an activity type for a task. ‘0’ sets the task activity type to ‘No activity’.
Example: setting ‘animation’ activity type:
activities = cerebro.core.activities() for activity in activities.data(): if activity[activities.DATA_NAME] == 'animation': task.set_activity(activity[activities.DATA_ID]) break
See also
-
set_allocated
(user_id)[source]¶ Parameters: user_id (int) – user ID. Allocates a user to the task.
Example: allocating all workforce (users except material resources) to the task:
users = cerebro.core.users() for user in users.data(): if cerebro.aclasses.Users.is_resource(user[users.DATA_FLAGS]) != True: task.set_allocated(user[users.DATA_ID])
See also
-
set_budget
(budget)[source]¶ Parameters: budget (float) – in currency units. Sets the task budget amount.
‘None’ resets the user-defined budget amount. After that the task budget sets equal to the total amounts of its subtasks.
See also
-
set_finish
(time)[source]¶ Parameters: time (float) – time period from 01.01.2000, days. Sets task finish time, days from 01.01.2000, UTC.
task.set_finish(4506.75) # task finish time is May 03, 2012 18:00 UTC
‘None’ value resets the user-defined task finish time. After that the task finish time derives from the task planned time and the actual working time schedule.
Example: setting task finish time 3 days later from the actual moment:
import datetime datetime_now = datetime.datetime.utcnow() datetime_2000 = datetime.datetime(2000, 1, 1) timedelta = datetime_now - datetime_2000 days = timedelta.total_seconds()/(24*60*60) + 3 task.set_finish(days)
See also
-
set_flag
(flag, is_set)[source]¶ Parameters: Sets
task flag
. If ‘is_set’ is True, the flag sets on, otherwise - sets off.# Setting a 'Closed' status to a task task.set_flag(task.FLAG_CLOSED, True)
See also
-
set_name
(name)[source]¶ Parameters: name (string) – task name. Sets a new name for a task.
Warning
Task name MAY NOT contain the following symbols: / # : ? & ‘ ” , + |
See also
-
set_planned_time
(hours)[source]¶ Parameters: hours (float) – task planned work hours. Sets the planned time for a task, hours.
‘None’ value resets the user-defined planned time. After that the planned time starts to derive from the task start/finish dates and a working schedule.
See also
-
set_priority
(prior)[source]¶ Parameters: prior (int) – task priority. Sets
task priority
.task.set_priority(task.PRIORITY_HIGHT)
See also
-
set_progress
(progress)[source]¶ Parameters: progress (float) – task progress value, from 0.0 to 100.0. Sets task progress value. If set to 100, the task is considered fulfilled(Done).
‘None’ value resets the user-defined task progress value. After that the task progress starts to derive from the subtasks’ progress values.
See also
-
set_start
(time)[source]¶ Parameters: time (float) – time period from 01.01.2000, days. Sets the task start time, days from 01.01.2000, UTC.
task.set_start(4506.375) # start time is May 03, 2012 9:00 UTC
‘None’ value resets the user-defined task start time. After that the start time is derived from the task’s predecessors’ start time and the actual working time schedule.
Example: setting task start time equal to the current time:
import datetime datetime_now = datetime.datetime.utcnow() datetime_2000 = datetime.datetime(2000, 1, 1) timedelta = datetime_now - datetime_2000 days = timedelta.total_seconds()/(24*60*60) task.set_start(days)
See also
-
set_status
(status_id)[source]¶ Parameters: status_id (int) – status ID. Sets a task status. ‘0’ sets the task status to ‘No status’.
Example: setting ‘closed’ status:
statuses = cerebro.core.statuses() for status in statuses.data(): if status[statuses.DATA_NAME] == 'closed': task.set_status(status[statuses.DATA_ID]) break
See also
-
status
()[source]¶ Returns: Task status. ‘(0,’‘)’ means that task status is not set. Return type: tuple(status_id, status_name) - a 2-field tuple: status ID, status name. See also
Returns: task tag list. Return type: list( cerebro.aclasses.Tag
,)