当前位置: 首页>>代码示例>>Python>>正文


Python Task.summary方法代码示例

本文整理汇总了Python中tasks.models.Task.summary方法的典型用法代码示例。如果您正苦于以下问题:Python Task.summary方法的具体用法?Python Task.summary怎么用?Python Task.summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tasks.models.Task的用法示例。


在下文中一共展示了Task.summary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import summary [as 别名]
 def create(self, request):
     task = Task()
     
     task.summary = request.POST.get('summary')
     task.detail = request.POST.get('detail')
     task.creator = request.user
     
     task.save()
     
     return task
开发者ID:goldsoft1206,项目名称:code.pinaxproject.com,代码行数:12,代码来源:handlers.py

示例2: pinax_handle_uploaded_file

# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import summary [as 别名]
def pinax_handle_uploaded_file(file, user_id):
    user_object = User.objects.get(pk=user_id)
    csv_reader = csv.DictReader(file, fieldnames=['date','start','end','duration','project','task'])
    line_data = []
    for line in csv_reader:
        line_data.append(line)

    total_time = 0
    val = {}
    pickles = {'projects': [], 'tasks': [], 'slices': []}
    for line in line_data[1:]:
        begin = datetime.strptime('T'.join((line['date'], line['start'])), '%Y-%m-%dT%H:%M')
        end = datetime.strptime('T'.join((line['date'], line['end'])), '%Y-%m-%dT%H:%M')
        total_time += int(line['duration'])
        if not val.has_key(line['project']):
            project_set = Project.objects.filter(name=line['project'], member_users=user_id)
            if  project_set:
                if len(project_set) > 1:
                    project, project_created_msg, project_created_bool = create_pinax_project(user_object, line)
                else:
                    project = project_set[0]
                    project_created_msg = _('Found project, and will add tasks and timeslices to the existing project.')
                    project_created_bool = False
            else:
                project_set = Project.objects.filter(name=line['project'])
                if project_set:
                    if len(project_set) >1:
                        project, project_created_msg, project_created_bool = create_pinax_project(user_object, line)
                    else:
                        project = project_set[0]
                        project_created_msg = _('Found project will add tasks and timeslices to the existing project.')
                        project_created_bool = False
                else:
                    project, project_created_msg, project_created_bool = create_pinax_project(user_object, line)
            val[line['project']] = {'created': project_created_bool, 'message': project_created_msg, 'project_object': project, 'tasks': {}}
            pickles['projects'].append(project)

        if not val[line['project']]['tasks'].has_key(line['task']):
            if val[line['project']]['created']:
                task = Task()
                task.summary = line['task']
                task.creator = user_object
                task.group = val[line['project']]['project_object']
                task.created = line['date']
                task_created_bool = True
            else:
                task_set = Task.objects.filter(summary=line['task'], creator=user_object, object_id=project.id)
                if not task_set or len(task_set) > 1:
                    task = Task()
                    task.summary = line['task']
                    task.creator = user_object
                    task.group = val[line['project']]['project_object']
                    task.created = line['date']
                    task_created_bool = True
                else:
                    task = task_set[0]
                    task_created_bool = False
            val[line['project']]['tasks'][line['task']]={'created': task_created_bool, 'task_object': task, 'slices': []}
            pickles['tasks'].append(task)

        if val[line['project']]['tasks'][line['task']]['created']:
            tslice = TimeSlice()
            tslice.begin = begin
            tslice.duration = int(line['duration'])
            tslice.task = val[line['project']]['tasks'][line['task']]['task_object']
            tslice.user = user_object
            slice_created_bool = True
        else:
            slice_set = TimeSlice.objects.filter(begin=begin, duration=int(line['duration']), task=task, user=user_object)
            if slice_set:
                tslice = slice_set[0]
                slice_created_bool = False
            else:
                tslice = TimeSlice()
                tslice.begin = begin
                tslice.duration = int(line['duration'])
                tslice.task = val[line['project']]['tasks'][line['task']]['task_object']
                tslice.user = user_object
                slice_created_bool = True
        val[line['project']]['tasks'][line['task']]['slices'].append(tslice)
        pickles['slices'].append(tslice)

    total_time = str(int(total_time/3600.0))+'h'

    # Okay, now we have processed the data, lets write it to a couple of files.
    import_data = DataImport.objects.create(user=user_object)
    file_name = hashlib.sha1(user_object.username + str(time.time())).hexdigest()
    import_data.complete_data.save(file_name, ContentFile(pickle.dumps(pickles)))
    import_data.partial_data.save(file_name, ContentFile(pickle.dumps(line_data[1:11])))
    import_data.save()

    return import_data.id
开发者ID:areski,项目名称:djime,代码行数:94,代码来源:importer.py


注:本文中的tasks.models.Task.summary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。