Module 'aclasses' contains descriptions of data types (classes), used in Cerebro Python API.
classcerebro.aclasses.AbstractAttachment(event_id, message_id, attach_id)
Basic class of attachment. Provides basic functions to access attachment properties
DATA_= ''
DATA_COMMENT= 7 | Text comment. Type - string. |
DATA_EVENT_ID= 1 | Message ID. Type - int. |
DATA_FILE_HASH= 10 | Attachment file hash sum. Type - string. |
DATA_FILE_PATH= 8 | File path to attachment. Type - string. |
DATA_FILE_SIZE= 5 | Attachment filesize, bytes. Type - int. |
DATA_GROUP_ID= 2 | Attachment ID. Type - int. |
DATA_HAS_REVIEW= 4 | A mediafile has a review. 0 - no, 1 - yes. |
DATA_IS_LINK= 3 | Attachment type: 0 - file, 1 - link. |
DATA_MTM= 0 | Data modification time. Type - datetime. |
DATA_NAME= 6 | Attachment name. Type - string. |
DATA_REVIEW_HASH= 11 | Review file hash sum. Type - string. |
DATA_REVIEW_PATH= 9 | Path to review file. Type - string. |
DATA_THUMB1_HASH= 12 | First thumbnail hash sum. Type - string. |
DATA_THUMB2_HASH= 13 | Second thumbnail hash sum. Type - string. |
DATA_THUMB3_HASH= 14 | Third thumbnail hash sum. Type - string. |
comment()
Returns: | text comment to the attachment. |
Return type: | string |
file_path()
Returns: | the path to the file. May be absent if there is no file in the file storage. In thise case, an empty string is returned. |
Return type: | string |
file_size()
Returns: | the attachment’s filesize in bytes. In case the attachment is a link, returns 0. |
Return type: | int |
has_review()
Returns: | True, If the attachment has audiovisual review. |
Return type: | bool |
hashtags(hashtags)
Returns: | Returns list of hashtags |
Return type: | list(string, ) |
is_link()
Returns: | True, if the attachment is a link to a file. |
Return type: | bool |
name()
Returns: | attachment filename. If the attachment is a link to a file, returns full path to the file. |
Return type: | string |
review_path()
Returns: | the path to the review file (overlayed audiovisual comments over the source media file). May be absent if there is no file in the file storage. In thise case, an empty string is returned. |
Return type: | string |
classcerebro.aclasses.AbstractMessage(event_id, message_id)
Basic class of message. Provides basic functions to access message properties
DATA_= ''
DATA_APPROVED_TIME= 8 | Approved time to be signed off, minutes. |
DATA_CREATED= 5 | Time of message creation. Type - datetime. |
DATA_CREATOR_ID= 13 | ID of the user who created the message. |
DATA_CREATOR_NAME= 4 | Message author name. |
DATA_FLAGS= 9 | Message flags. |
DATA_ID= 1 | Message ID. |
DATA_MODERATOR_ID= 14 | ID of the user who modified the message. |
DATA_MODERATOR_NAME= 10 | Name of the user who modified the message. |
DATA_MTM= 0 | Time of data modification. Type - datetime. |
DATA_PID= 2 | Parent message ID. |
DATA_TEXT= 7 | Message text in html format. |
DATA_TID= 11 | ID of the task the message refers to. |
DATA_TYPE= 3 | Message type. |
DATA_WORK_TIME= 6 | Working time, minutes. |
DATA_XMTM= 12 | Real time of data modification. Type - datetime. |
FLAG_= ''
FLAG_APPROVED= 1 | The message is confirmed / approved (applicable to Report). |
FLAG_CLIENT_VISIBLE= 0 | The message is visible for clients. |
TYPE_= ''
TYPE_CLIENT_REVIEW= 4 | Client review. |
TYPE_DEFINITION= 0 | Definition. |
TYPE_NOTE= 3 | Note. |
TYPE_REPORT= 2 | Report. |
TYPE_RESOURCE_REPORT= 5 | Resourse report. |
TYPE_REVIEW= 1 | Review. |
TYPE_STATUS_CHANGES= 6 | Message of change of the status of the task. |
approved_time
Returns: | working time approved to sign off, minutes. If the message type is Report or Resource Report, this is a working time approved to sign off. For all the rest message types returns 0. |
Return type: | int |
hashtags(hashtags)
Returns: | Returns a list of hashtags. |
Return type: | list(string, ) |
is_approved()
Returns: | True, if message type is Report or Resource Report and it is marked as Approved. Such a Report/Resource Report has approved time equal to declared. |
Return type: | bool |
if message.is_approved() == True:
print('work_time == approved_time', message.work_time() == message.approved_time())
is_client_visible()
Returns: | True, if the message is marked as Visible to Clients/ |
Return type: | bool |
parent_message_id()
Returns: | parent message ID (Parent message is the message being replied by the current message). As a rule, message ID of Definitions is 0, it means Definitions have no parent messages. |
Return type: | int |
if message.type() != message.TYPE_DEFINITION:
parent_id = message.parent_message_id()
print('Parent message', cerebro.core.message(parent_id).text_as_plain())
posted_time()
Returns: | time of message creation. |
Return type: | datetime |
task_id()
Returns: | Returns ID of the task the message refers to. |
Return type: | int |
text_as_html()
Returns: | message text in html format. |
Return type: | string |
text_as_plain()
Returns: | message text in plain text format. |
Return type: | string |
type()
Returns: | message type. |
Return type: | int |
if message.type() == message.TYPE_REPORT:
print('Signed off working time', message.work_time())
work_time()
Returns: | working time signed off in the message, minutes. If the message type is Report or Resource Report, this is a working time declared to sign off. If the message type is Review, this is a working time approved to sign off for the preceding Report or Resource Report. For all the rest message types returns 0. |
Return type: | int |
classcerebro.aclasses.Activities
Activity types class
activities = cerebro.core.activities()
DATA_COLOR= 2 | Activity type color. RGB format is presented as an integer. |
DATA_ID= 0 | Activity ID. |
DATA_NAME= 1 | Activity type name. |
data()
Returns: | a list of tuples on activity types. |
Return type: | list(tuple,) |
classcerebro.aclasses.AbstractTag(tag_id)
Basic class of task tag.
Note
In Cerebro tags are used as additional task attributes. Having been applied to a project, a tag applies automatically to the task. In the process of working with tasks, gradually, tags are being filled with values.
TYPE_= ''
TYPE_ENUM= 1 | Enumeration. |
TYPE_INTEGER= 0 | Integer. |
TYPE_MULTI_ENUM= 4 | Multi enumeration. |
TYPE_REAL= 2 | Real number. |
TYPE_STRING= 3 | String. |
elements()
Returns: | a list of possible enumeration elements. If tag type is neither Enumeration nor Multi enumeration, None is returned. |
Return type: | [(element_id, element_name),] - a list of 2-field tuples: enumeration element ID, enumeration name |
id()
Returns: | Tag ID. |
Return type: | int |
name()
Returns: | tag name. |
Return type: | string |
type()
Returns: | tag type. |
Return type: | int |
classcerebro.aclasses.Attachment(message_id, attach_id)
Bases:cerebro.aclasses.AbstractAttachment
Attachment class.
attach = cerebro.core.current_attachment()
attachs = message.attachments()
add_hashtags(hashtags)
Parameters: | hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). |
See also
data()
Returns: | tuple of the attachment. |
Return type: | tuple |
attach.file_hash() == attach.data()[attach.DATA_FILE_HASH]
attach.is_link() == (attach.data()[attach.DATA_IS_LINK] != 0)
# и так далее
file_hash()
Returns: | file hash sum. |
Return type: | string |
if attach.is_link() != True: # Checking if the attachment is a file, not a link
# Downloading the file
file_name = cerebro.cargador.file_name_form_hash(attach.file_hash()) # attempting to resolve the file name from the file hash sum
if file_name == '' or file_name == None: # if the file is missing in our file storage, attempting to download it
cerebro.cargador.download_file(attach.file_hash())
If attachment is a link, it has no hash, as far as the linked files, are not added to Cargador file storage
id()
Returns: | attachment ID. |
Return type: | int |
message_id()
Returns: | the ID of the message the attachment belongs to. |
Return type: | int |
remove_hashtags(hashtags)
Parameters: | hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). |
See also
review_hash()
Returns: | file hash sum of a review file (overlayed audiovisual comments). |
Return type: | string |
set_comment(comment)
Parameters: | comment (string) – a comment to the attachment. |
new_attachs = event.new_attachments()
for attach in new_attachs:
if attach.is_link() == True: # if the new attachment is a link
attach.set_comment(i.comment() + '. It's a link') # adding a comment
thumbnail_hashs()
Returns: | list of the hash sums of the file’s thumbnails. |
Return type: | list(string,) |
classcerebro.aclasses.NewAttachment(event_id, message_id, attach_id)
Bases: cerebro.aclasses.AbstractAttachment
New attachment class.
The objects of the class are used in the cerebro.events.BeforeEventMessage event in the new_attachments() method.
def before_event(event):
evtype = event.event_type()
if evtype == event.EVENT_CREATION_OF_MESSAGE or evtype == event.EVENT_CHANGING_OF_MESSAGE:
new_attachs = event.new_attachments()
for attach in new_attachs:
print(attach.name())
add_hashtags(hashtags)
Parameters: | hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). |
See also
remove_hashtags(hashtags)
Parameters: | hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). |
See also
set_comment(comment)
Parameters: | comment (string) – a comment to the attachment. |
new_attachs = event.new_attachments()
for attach in new_attachs:
if attach.is_link() == True: # if the new attachment is a link
attach.set_comment(i.comment() + '. It's a link') # adding a comment
set_name(name)
Parameters: | name (string) – attachment name. |
new_attachs = event.new_attachments()
for attach in new_attachs:
if attach.is_link() != True: # if the new attachment is a file
attach.set_name('Attachment - ' + i.name()) # changing the name
classcerebro.aclasses.Message(message_id)
Bases: cerebro.aclasses.AbstractMessage
Message class.
message = cerebro.core.current_message()
message = cerebro.core.message(message_id)
add_hashtags(hashtags)
Parameters: | hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). |
See also
attachments()
Returns: | a list of attachments to the message. |
Return type: | list cerebro.aclasses.Attachment |
creator_id()
Returns: | message author’s ID. |
Return type: | int |
data()
Returns: | data tuple on the message. |
Return type: | tuple |
message.creator_id() == message.data()[message.DATA_CREATOR_ID]
message.is_client_visible() == cerebro.core.has_flag(message.data()[message.DATA_FLAGS], message.FLAG_CLIENT_VISIBLE)
# etc.
id()
Returns: | message ID. |
Return type: | int |
moderator_id()
Returns: : | message moderator’s ID. |
Return type: | int |
modification_time()
Returns: | time when the message was changed. |
Return type: | datetime |
remove_hashtags(hashtags)
Parameters: | hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). |
See also
classcerebro.aclasses.Perm
Access rights class.
Some actions with Cerebro objects, whether it is creating, modifying task/message properties or creating projects/users, require appropriate permissions.
The action types that require permissions are described below.
Use the functions of the cerebro.core module to check the permissions:
PERM_GLOBAL_= ''
PERM_GLOBAL_FILE_STORAGES= 60 | File storage management. Allows to allocate available file storages for project data. |
PERM_GLOBAL_MATERIAL_RESOURCES= 56 | Material resource management. Allows to create/delete material resources. |
PERM_GLOBAL_SALARIES_AND_WORKING_SCHEDULES= 59 | Schedule and salary management. Allows to set users’ man hour rates and working time schedules. |
PERM_GLOBAL_TAGS_AND_ACTIVITIES= 61 | Tags and activities management. Allows to create/delete tags and activity types. |
PERM_GLOBAL_USERS= 62 | User account management. Allows to create users, groups, roles and adjust the ‘Who sees whom’ settings. |
PERM_MESSAGE_= ''
PERM_MESSAGE_EDITABLE= 3 | Allows to edit message text and attachments. Also, allows to delete the message. |
PERM_MESSAGE_PROPERTIES= 16 | Allows to edit such message properties as ‘Visible for clients’ and ‘Report approved’. |
PERM_TASK_= ''
PERM_TASK_ANY_MESSAGE= 10 | Any message edit. Allows to edit all messages. |
PERM_TASK_BUDGET= 30 | Task budget edit. Allows to edit task budget. |
PERM_TASK_CREATE_CLIENT_REVIEW= 26 | Client reviews creation. Allows to create messages of the ‘Client review’ type. |
PERM_TASK_CREATE_DEFINITION= 18 | Defifnitions creation. Allows to create messages of the ‘Definition’ type. |
PERM_TASK_CREATE_NOTE= 24 | Notes creation. Allows to create messages of the ‘Note’ type. |
PERM_TASK_CREATE_REPORT= 20 | Reports creation. Allows to create messages of the ‘Report’ and ‘Resource Report’ types. |
PERM_TASK_CREATE_REVIEW= 22 | Reviews creation. Allows to create messages of the ‘Review’ type. |
PERM_TASK_LAST_MESSAGE= 34 | Last message edit. Allows to edit unreplied messages by other users. |
PERM_TASK_MANAGMENT= 6 | Task management. Allows to create/delete tasks. |
PERM_TASK_MESSAGES_PROPERTIES= 16 | Message properties edit. Allows to edit such message properties as ‘Visible for clients’ and ‘Report approved’. |
PERM_TASK_PROGRESS= 32 | Task progress edit. Allows to alter task progress, except setting it to 100%. |
PERM_TASK_PROPERTIES= 8 | Task properties change. Allows to edit almost all task properties except tags and budget. |
PERM_TASK_TAG= 14 | Task tags edit. Allows to edit task tags. |
classcerebro.aclasses.Statuses
Statuses class.
statuses = cerebro.core.statuses()
DATA_= ''
DATA_COLOR= 6 | Status color. RGB format is presented as an integer. |
DATA_DESCRIPTION= 4 | Status description. |
DATA_FLAGS= 2 | Status flags. |
DATA_ICON= 5 | Status icon. XPM format. |
DATA_ID= 0 | Status ID. |
DATA_NAME= 1 | Status name. |
DATA_ORDER= 3 | Status order number. |
FLAG_= ''
FLAG_INHERITABLE= 1 | Status is inherited. |
TYPE_= ''
TYPE_IS_IN_PROGRESS= 1 | Task is performed. |
TYPE_IS_STOPPED= 2 | Task is stopped. |
TYPE_IS_SUSPENDED= 0 | Task is suspended. |
data()
Returns: | a list of tuples on all statuses. |
Return type: | list(tuple,) |
See also:
inheritable(status_flags)
Parameters: | status_flags (int) – status flag values. |
Returns: | True, if the flag is installed as inherited. |
Return type: | bool |
The inherited status under task container installation is inherited by all sub-tasks within the task.
Example of sample status, you can set to tasks-containers
inherit_statuses = list()
statuses = cerebro.core.statuses()
for status in statuses.data():
if cerebro.aclasses.Statuses.inheritable(status[statuses.DATA_FLAGS]) == True:
inherit_statuses.append(status)
type(status_flags)
Parameters: | status_flags (int) – status flag values. |
Returns: | status type. |
Return type: | int |
classcerebro.aclasses.Tag(task_id, tag_id)
Bases: cerebro.aclasses.AbstractTag
Task tag class.
Note
In Cerebro tags are used as additional task attributes. Having been applied to a project, a tag applies automatically to the task. In the process of working with tasks, gradually, tags are being filled with values.
tags = task.tags()
for tag in tаgs:
print('Task tag', tag.name(), tag.value())
set_value(val)
Sets tag value. ‘None’ sets tag value to ‘not set’.
Depending on tag type, different value types may be set:
if tag.type() == tag.TYPE_INTEGER: # integer
tag.set_value(int)
elif tag.type() == tag.TYPE_ENUM: # enumeration
tag.set_value(element_id) # enumeration element ID
elif tag.type() == tag.TYPE_REAL: # real number
tag.set_value(float)
elif tag.type() == tag.TYPE_STRING: # string
tag.set_value(string)
elif tag.type() == tag.TYPE_MULTI_ENUM: # multi enumeration
tag.set_value([element_id,]) # a list of enumeration elements IDs
Resetting tag value:
if tag.value() != None:
tag.set_value(None)
In case of ‘enumeration’ and ‘multi enumeration’, the IDs to set values are taken from the list of elements elements().
elems = tag.elements()
if len(elems) > 0: # for the 'enumeration' type.
tag.set_value(elems[0][0])
if len(elems) > 1: # for the 'multi enumeration' type.
# setting two elements
elems_to_set = [ elems[0][0], elems[1][0] ]
tag.set_value(elems_to_set)
See also
task_id()
Returns: | task ID. |
Return type: | int |
value()
Returns: | tag value. If the value is not set, returns None. |
if tag.type() == tag.TYPE_INTEGER: # integer
return int
elif tag.type() == tag.TYPE_ENUM: # enumeration
return (element_id, element_name) # 2-field tuple: enumeration element ID, enumeration name
elif tag.type() == tag.TYPE_REAL: # real number
return float
elif tag.type() == tag.TYPE_STRING: # string
return string
elif tag.type() == tag.TYPE_MULTI_ENUM: # multi enumeration
return [(element_id, element_name),] # list of 2-field tuples: enumeration element ID, enumeration name
See also
classcerebro.aclasses.Task(task_id)
Task class.
task = cerebro.core.current_task()
task = cerebro.core.task(task_id)
tasks = cerebro.core.selected_tasks(task_id)
ALLOCATED_= ''
ALLOCATED_FLAGS= 2 | User flags. User flags are described in the class cerebro.aclasses.Users |
ALLOCATED_ID= 0 | User ID. |
ALLOCATED_NAME= 1 | User full name. |
DATA_= ''
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 | Task flags. |
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_PRIORITY= 10 | Priority. |
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_= ''
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_COMMENT= 7 | Text comment on the payment. |
PAYMENT_FLAGS= 4 | Payment flags. |
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__FLAG_CANCEL= 1 | Payment canceled. |
PRIORITY_= ''
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()
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
add_hashtags(hashtags)
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()
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
budget()
Returns: | task budget, currency units. |
Return type: | float |
See also
creation_time()
Returns: | time of task creation. |
Return type: | datetime |
creator_id()
Returns: | task creator’s ID. |
Return type: | int |
data()
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]
# etc
finish()
Returns: | task finish time. |
Return type: | datetime |
See also
flags()
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
hashtags()
Returns: | a list of hashtags to the task. |
Return type: | list(string,) |
for ht in task.hashtags():
print('Hashtag:', ht)
See also
id()
Returns: | task ID. |
Return type: | int |
moderator_id()
Returns: | task modifier’s ID. |
Return type: | int |
modification_time()
Returns: | time of task modification. |
Return type: | datetime |
name()
Returns: | task name. |
Return type: | string |
See also
parent_id()
Returns: | parent task ID. |
Return type: | int |
parent_url()
Returns: | full path to the parent task. Пример: ‘/Test project/Scene 1/’. |
Return type: | string |
payments()
Returns: | a list of tuples on payments on the task. |
Return type: | list(tuple,) |
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())
planned_time()
Returns: | task planned time, hours. |
Return type: | float |
See also
possible_statuses()
Returns: | a list of tuples on statuses, which can be set for the task. |
Return type: | list(tuple,) |
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()
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
progress()
Returns: | task progress value, from 0.0 to 100.0. |
Return type: | float |
See also
project_id()
Returns: | ID of the project, the task belongs to. |
Return type: | int |
remove_allocated(user_id)
Parameters: | user_id (int) – user ID. |
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
remove_hashtags(hashtags)
Parameters: | hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). |
See also
set_activity(activity_id)
Parameters: | activity_id (int) – Activity type ID. |
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)
Parameters: | user_id (int) – user ID. |
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)
Parameters: | budget (float) – in currency units. |
‘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)
Parameters: | time (float) – time period from 01.01.2000, days. |
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)
Parameters: | |
# Setting a 'Closed' status to a task
task.set_flag(task.FLAG_CLOSED, True)
See also
set_name(name)
Parameters: | name (string) – task name. |
Warning
Task name MAY NOT contain the following symbols: / # : ? & ‘ ” , + |
See also
`set_planned_time(hours)`
Parameters: | hours (float) – task planned work 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)
Parameters: | prior (int) – task priority. |
task.set_priority(task.PRIORITY_HIGHT)
See also
set_progress(progress)
Parameters: | progress (float) – task progress value, from 0.0 to 100.0. |
‘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)
Parameters: | time (float) – time period from 01.01.2000, days. |
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)
Parameters: | status_id (int) – status ID. |
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
spent()
Returns: | total amount of payments signed off the task budget. |
Return type: | float |
start()
Returns: | task start time. |
Return type: | datetime |
See also
status()
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
tags()
Returns: | task tag list. |
Return type: | list(cerebro.aclasses.Tag,) |
classcerebro.aclasses.Users
Users class.
The user list consists of users (Cerebro user accounts) and material resources - items/units which do not have actual user accounts but are involved in production process, for example, an editing post or video camera are material resources.
users = cerebro.core.users()
DATA_= ''
DATA_EMAIL= 6 | User’s E-mail address. |
DATA_FIRST_NAME= 4 | User first name. |
DATA_FLAGS= 2 | User flags. |
DATA_FULL_NAME= 1 | User full name. |
DATA_ICQ= 8 | User’s ICQ/Skype ID. |
DATA_ID= 0 | User ID. |
DATA_LAST_NAME= 5 | User last name. |
DATA_LOGIN= 3 | User login. |
DATA_PHONE= 7 | User’s phone number. |
FLAG_= ''
FLAG_IS_RESOURCE= 1 | Is a material resource. |
data()
Returns: | a list of tuples on users. |
Return type: | list(tuple,) |
is_resource(user_flags)
Parameters: | user_flags (int) – user flag values. |
Returns: | True, if flag is set to ‘material resource’. |
Return type: | bool |
resources = list()
users = cerebro.core.users()
for user in users.data():
if cerebro.aclasses.Users.is_resource(user[users.DATA_FLAGS]) == True:
resources.append(user)