def task_delete_txn(task): """Performs all necessary operations in a single transaction when a task is deleted. """ to_delete = [] to_delete += GCIComment.all(keys_only=True).ancestor(task) to_delete += GCIWorkSubmission.all(keys_only=True).ancestor(task) to_delete += [task.key()] db.delete(to_delete)
def task_delete_txn(task): """Performs all necessary operations in a single transaction when a task is deleted. """ to_delete = [] to_delete += GCIComment.all(keys_only=True).ancestor(task) to_delete += GCIWorkSubmission.all(keys_only=True).ancestor(task) to_delete += [task.key()] db.delete(to_delete)
def process_task(task): """Conversion to make GCI Tasks ID based and getting rid of unnecessary properties. """ if task.key().name(): # Get the values for all the properties in the GCITask model from the # old entity to create the new entity. new_task_properties = {} for prop in TASK_PROPERTIES: new_task_properties[prop] = getattr(task, prop) new_task_properties['org'] = task.scope new_task = GCITask(**new_task_properties) new_task_key = new_task.put() if new_task_key: # Update all the comments with the new task as the parent comments = GCIComment.all().ancestor(task).fetch(1000) for c in comments: new_comm_properties = {} for c_prop in COMMENT_PROPERTIES: new_comm_properties[c_prop] = getattr(c, c_prop) new_comment = GCIComment(parent=new_task_key, **new_comm_properties) # set these fields to behave like last_modified_on/by new_comment.modified_on = new_comment.created_on new_comment.modified_by = new_comment.created_by yield operation.db.Put(new_comment) yield operation.counters.Increment("comment_updated") # Update all the work submission entities with the new task as the parent work_submissions = GCIWorkSubmission.all().ancestor(task).fetch(1000) for ws in work_submissions: new_ws_properties = {} for ws_prop in WORK_SUBMISSION_PROPERTIES: new_ws_properties[ws_prop] = getattr(ws, ws_prop) new_ws = GCIWorkSubmission(parent=new_task_key, **new_ws_properties) yield operation.db.Put(new_ws) yield operation.counters.Increment("work_submission_updated") yield operation.counters.Increment("task_updated")
def workSubmissions(self): """Returns the GCIWorksubmissions that have the given task as parent.""" q = GCIWorkSubmission.all() q.ancestor(self) return q.fetch(1000)
def workSubmissions(self): """Returns the GCIWorksubmissions that have the given task as parent. """ q = GCIWorkSubmission.all() q.ancestor(self) return q.fetch(1000)