Exemple #1
0
    def update_issue_operation_result(issue_id, operation_type, solution,
                                      comments, user_id):
        result = False
        try:
            issue = ProjectIssue.objects.get(int(issue_id))
            if str(operation_type) == "1":  # 解决问题
                field = "Solution"
                old_value = str(issue.__dict__[field])
                issue.__dict__[field] = int(solution)
                issue.Status = 4
                issue.ResolvedTime = DateTimeHelper.getcnow()
                issue.UpdateTime = DateTimeHelper.getcnow()
                issue.Solver = user_id
                issue.Processor = issue.Creator
                issue.save()
                IssueService.send_notification_email(issue, "修复了问题",
                                                     EMAIL_TEMPLATES['Issue'])
                IssueService.create_issue_activity(issue, field, "", "",
                                                   "解决了问题", user_id, 2, 1)

            if str(operation_type) == "2":  # 关闭问题
                field = "Status"
                old_value = str(issue.__dict__[field])
                value = 3
                issue.Status = 3
                issue.Processor = issue.Creator
                issue.ClosedTime = DateTimeHelper.getcnow()
                issue.UpdateTime = DateTimeHelper.getcnow()
                issue.save()
                IssueService.create_issue_activity(issue, field, "", "",
                                                   "关闭了问题", user_id, 2, 1)

            if str(operation_type) == "3":  # 重新打开问题
                field = "Status"
                old_value = str(issue.__dict__[field])
                value = 5
                if issue.Solver:
                    issue.Processor = issue.Solver
                else:
                    issue.Processor = user_id
                issue.Solution = 1
                issue.ReopenCounts = issue.ReopenCounts + 1
                issue.UpdateTime = DateTimeHelper.getcnow()
                issue.Status = 5
                issue.save()
                IssueService.send_notification_email(issue, "重新打开了问题",
                                                     EMAIL_TEMPLATES['Issue'])
                IssueService.create_issue_activity(issue, field, "", "",
                                                   "重新打开了问题", user_id, 2, 1)

            if comments != "":
                IssueService.create_issue_activity(issue, 0, '', '',
                                                   "备注" + comments, user_id, 1,
                                                   1)

            result = True
        except Exception as ex:
            SimpleLogger.error(ex)
        return result
Exemple #2
0
    def create_intesting_message(fortesting, summary_info,
                                 email_template_path):
        email_templates = open(email_template_path, 'rb').read().decode()
        project = Project.objects.get(fortesting.ProjectID)
        submitior = UserService.get_user(fortesting.Commitor)
        version = ForTestingService.get_fortesting_version(fortesting)
        vm_fortesting = VM_ProjectForTesting(fortesting)
        tester_name = "--"
        if len(vm_fortesting.fortesting_testers()) > 0:
            tester_name = vm_fortesting.fortesting_testers()[0].member_name()
        title = "项目:【" + project.PBTitle + version + "】" + summary_info
        email_templates = email_templates.replace("${SUBMITIONINFO}", title)
        email_templates = email_templates.replace(
            "${SUBMITTIME}", str(DateTimeHelper.getcnow()))
        email_templates = email_templates.replace("${TPID}",
                                                  str(fortesting.id))
        email_templates = email_templates.replace("${PROJECTNAME}",
                                                  project.PBTitle)
        email_templates = email_templates.replace(
            "${STARTTIME}", str(vm_fortesting.testing_start_date()))
        email_templates = email_templates.replace(
            "${ENDTIME}", str(vm_fortesting.testing_deadline()))
        email_templates = email_templates.replace(
            "${SUBMITIOR}", str(submitior.last_name + submitior.first_name))
        email_templates = email_templates.replace("${TESTER}", tester_name)
        email_templates = email_templates.replace("${VERSION}", version)

        return email_templates
 def fortesting_commit(login_user, fortesting, status):
     message = "已经将项目提测信息,通知到项目成员。!"
     build_summary = "已经提测了!"
     result = [False, '']
     try:
         print(fortesting.EmailNotificationStatus)
         notification_status = (eval(
             fortesting.EmailNotificationStatus)[int(status) - 1] == 0)
         print(notification_status)
         if notification_status:
             result[0] = True
             result[1] = message
             fortesting.CommitTime = DateTimeHelper.getcnow()
             fortesting.Commitor = login_user.id
             email_notification_status = ForTestingService.get_email_notification_status(
                 fortesting.EmailNotificationStatus, status)
             fortesting.EmailNotificationStatus = email_notification_status
             fortesting.save()
             email_template = EMAIL_TEMPLATES['ForTesting']
             ForTestingService.send_notification_email(
                 fortesting.id, build_summary, email_template)
             ForTestingService.log_commit_activity(login_user, fortesting)
     except Exception as ex:
         message = str(ex)
         SimpleLogger.exception(ex)
     return result
 def create_commit_message(fortesting, summary_info, email_template_path):
     email_templates = open(email_template_path, 'rb').read().decode()
     project = Project.objects.get(fortesting.ProjectID)
     projectname = project.PBTitle
     module = ProjectModule.objects.get(fortesting.ProjectModuleID)
     module_name = "--"
     code_addr = ProjectCodeUrl.objects.get(fortesting.ProjectCode)
     if module:
         module_name = module.Name
     platform = SystemConfigService.get_platform_name(project.PBPlatform)
     submitior = UserService.get_user(fortesting.Commitor)
     title = "项目:【" + platform + projectname + ForTestingService.get_fortesting_version(
         fortesting) + "】" + summary_info
     email_templates = email_templates.replace("${SUBMITIONINFO}", title)
     email_templates = email_templates.replace("${SUBMITTIME}", str(DateTimeHelper.getcnow()))
     email_templates = email_templates.replace("${SUBMITID}", str(fortesting.id))
     email_templates = email_templates.replace("${PROJECTNAME}", projectname)
     email_templates = email_templates.replace("${PROJECTMODULENAME}", module_name)
     email_templates = email_templates.replace("${SUBMITIOR}", str(submitior.last_name + submitior.first_name))
     email_templates = email_templates.replace("${PLATFORM}", str(platform))
     email_templates = email_templates.replace("${VERSION}", ForTestingService.get_fortesting_version(fortesting))
     if code_addr:
         email_templates = email_templates.replace("${CODEURI}", code_addr.CodeRepertory)
         email_templates = email_templates.replace("${BRANCH}", code_addr.Branch)
     else:
         email_templates = email_templates.replace("${CODEURI}", "")
         email_templates = email_templates.replace("${BRANCH}", "")
     email_templates = email_templates.replace("${FUNCTIONCHANGE}", str(fortesting.TestingFeature))
     email_templates = email_templates.replace("${SUGGESTION}", str(fortesting.TestingAdvice))
     return email_templates
Exemple #5
0
 def return_device(request):
     device_id=request.POST.get("device_id",0)
     device=Device.objects.get(device_id)
     device.DeviceStatus=1
     device.DeviceReturnTime=DateTimeHelper.getcnow()
     DeviceService.add_device_history(device)
     DeviceService.log_return_activity(request.user,device)
     device.DeviceBorrower=0
     device.save()
Exemple #6
0
 def createemailmessage(testsubmition, summaryinfo, buildstatus, buildno,
                        emailtemplatepath):
     emailtemplates = open(emailtemplatepath, 'rb').read()
     projectname = DAL_TestProject.get_testproject(
         testsubmition.TPSProductName).TPName
     platform = TestSubmitionService.getdicvaluebyid(
         testsubmition.TPSPlatform)
     submitior = UserService.getuser(testsubmition.TPSSubmiter)
     emailtemplates = emailtemplates.replace(
         "${SUBMITIONINFO}", "项目:【" + platform + projectname +
         TestSubmitionService.get_project_version(testsubmition) + "】" +
         summaryinfo)
     emailtemplates = emailtemplates.replace("${SUBMITTIME}",
                                             str(DateTimeHelper.getcnow()))
     emailtemplates = emailtemplates.replace("${SUBMITID}",
                                             str(testsubmition.id))
     emailtemplates = emailtemplates.replace("${PROJECTNAME}", projectname)
     emailtemplates = emailtemplates.replace(
         "${SUBMITIOR}", str(submitior.last_name + submitior.first_name))
     emailtemplates = emailtemplates.replace("${PLATFORM}", str(platform))
     emailtemplates = emailtemplates.replace(
         "${VERSION}",
         TestSubmitionService.get_project_version(testsubmition))
     emailtemplates = emailtemplates.replace(
         "${SVNVERSION}", str(testsubmition.TPSCodeVersion))
     emailtemplates = emailtemplates.replace("${SVNADDRESS}",
                                             str(testsubmition.TPSCodeUrl))
     emailtemplates = emailtemplates.replace(
         "${FUNCTIONCHANGE}", str(testsubmition.TPSFunctionChange))
     emailtemplates = emailtemplates.replace("${BUGFIX}",
                                             str(testsubmition.TPSBugFix))
     emailtemplates = emailtemplates.replace(
         "${SUGGESTION}", str(testsubmition.TPSAdvice4Testing))
     emailtemplates = emailtemplates.replace(
         "${PACKAGEFORTESTING}", str(testsubmition.TPSPackageAddress))
     emailtemplates = emailtemplates.replace(
         "${BUILDURL}",
         str(
             TestSubmitionService.getbuildurl(
                 testsubmition.TPSJenkinsJobName, buildno)))
     emailtemplates = emailtemplates.replace(
         "${BUILDLOGURL}",
         str(
             TestSubmitionService.getbuildlog(
                 testsubmition.TPSJenkinsJobName, buildno)))
     emailtemplates = emailtemplates.replace(
         "${BUILDSTATUS}",
         str(TestSubmitionService.getbuildstatus(buildstatus)))
     emailtemplates = emailtemplates.replace(
         "${CODECHANGELOG}",
         TestSubmitionService.get_changelog(testsubmition.TPSCodeChangeLog))
     return emailtemplates
Exemple #7
0
 def borrow_device(request):
     message=""
     device_id=request.POST.get("device_id",0)
     device=Device.objects.get(device_id)
     if DeviceService.is_ready(device):
         device.DeviceStatus=3
         device.DeviceBorrorwTime=DateTimeHelper.getcnow()
         device.DeviceBorrower=request.user.id
         device.save()
         DeviceService.log_borrow_activity(request.user,device)
     else:
         message="此设备已经被借走,请联系管理员或者设备使用人。"
     return message
Exemple #8
0
 def init_device(request,device):
     new_device=device
     new_device.DeviceName=request.POST.get("DeviceName")
     new_device.DeviceNumber=request.POST.get("DeviceNumber")
     new_device.DeviceOS=request.POST.get("DeviceOS")
     new_device.DeviceOSVersion=request.POST.get("DeviceOSVersion")
     new_device.DeviceScreenSize=request.POST.get("DeviceScreenSize")
     new_device.DeviceType=request.POST.get("DeviceType")
     new_device.DeviceBorrower=request.POST.get("DeviceBorrower")
     if new_device.DeviceBorrower!=0:
         new_device.DeviceStatus=2
         device.DeviceBorrorwTime=DateTimeHelper.getcnow()
         DeviceService.log_lend_activity(request.user,device)  
     return new_device
Exemple #9
0
 def update_issue(issue_id, field, value, new_text, user_id):
     result = False
     try:
         issue = ProjectIssue.objects.get(int(issue_id))
         old_value = str(issue.__dict__[field])
         if old_value != str(value):
             if field == "OSVersion":
                 temp = value.split(",")
                 issue.__dict__[field] = int(temp[0])
                 issue.__dict__['DeviceOS'] = int(temp[1])
             else:
                 issue.__dict__[field] = value
             issue.UpdateTime = DateTimeHelper.getcnow()
             issue.save()
             if field == 'Processor':
                 IssueService.send_notification_email(issue,"更新了问题",EMAIL_TEMPLATES['Issue'])
             result = True
             IssueService.create_issue_activity(issue, field, value, old_value, new_text, user_id, 2, 1)
     except Exception as ex:
         SimpleLogger.exception(ex)
     return result
 def fortesting_finished(login_user, fortesting, status):
     message = "测试完成通知,已经发送给所有项目成员!"
     build_summary = "已经完成测试!"
     result = []
     try:
         notification_status = eval(fortesting.EmailNotificationStatus)[int(status) - 1] == 0
         if notification_status:
             email_notification_status = ForTestingService.get_email_notification_status(
                 fortesting.EmailNotificationStatus, status)
             fortesting.EmailNotificationStatus = email_notification_status
             fortesting.TestingFinishedDate = DateTimeHelper.getcnow()
             fortesting.save()
             # email_template=EMAIL_TEMPLATES['TestingFinished']
             # ForTestingService.send_notification_email(fortesting.id,build_summary,email_template)
             ForTestingService.log_finish_testing_activity(login_user, fortesting)
             result.append(notification_status)
             result.append(message)
     except Exception as ex:
         message = str(ex)
         SimpleLogger.exception(ex)
     return result
Exemple #11
0
 def updatesubmitiontime(submitid):
     submitionid = submitid
     testSubmition = DAL_TestSubmition.gettestsubmition(submitionid)
     testSubmition.TPSSubmitTime = DateTimeHelper.getcnow()
     testSubmition.TPSStatus = TestJobStatusEnum.JobStatus_Submited
     DAL_TestSubmition.addtestsubmition(testSubmition)