def _buildIssueFromDictionary(dict, user): check_noProject = dict.has_key('noProject') issue_trackerURL = dict['trackerURL'] issue_projectId = dict['project_id'] issue_projectName = dictOrEmpty(dict, 'project_name') check_createProject = dict.has_key('createProject') newProject_name = dictOrEmpty(dict, 'newProjectName') newProject_homeURL = dictOrEmpty(dict, 'newProjectHomeURL') newProject_trackerURL = dictOrEmpty(dict, 'newProjectTrackerURL') issue_key = dictOrEmpty(dict, 'key') issue_title = dictOrEmpty(dict, 'title') issue_description = dictOrEmpty(dict, 'description') _throwIfIssueExists(issue_trackerURL, user) issue = None if (check_noProject): if (not issue_title or not issue_description): raise BaseException('title and description are required') issue = Issue.newIssueOrphan(issue_title, issue_description, user) else: project = None if (check_createProject): if (not newProject_name or not newProject_homeURL or not newProject_trackerURL): raise BaseException( 'all parameters for new project are required') projectHomeURLValidationError = validateURL(newProject_homeURL) if (projectHomeURLValidationError): raise BaseException('invalid project URL (' + newProject_homeURL + ') - ' + projectHomeURLValidationError) projectTrackerURLValidationError = validateURL( newProject_trackerURL) if (projectTrackerURLValidationError): raise BaseException('invalid project tracker URL (' + newProject_trackerURL + ') - ' + projectTrackerURLValidationError) project = Project.newProject(newProject_name, user, newProject_homeURL, newProject_trackerURL) else: project = Project.objects.get(pk=int(issue_projectId)) if (newProject_homeURL != project.homeURL): project.homeURL = newProject_homeURL if (not issue_key or not issue_title): raise BaseException('key and title are required') issueURLValidationError = validateIssueURL(issue_trackerURL) if (issueURLValidationError): raise BaseException('invalid issue URL (' + issue_trackerURL + ') - ' + issueURLValidationError) issue = Issue.newIssue(project, issue_key, issue_title, user, issue_trackerURL) return issue
def _buildOfferFromDictionary(dict, user): check_noProject = dict.has_key('noProject') issue_trackerURL = dict['trackerURL'] issue_projectId = dict['project_id'] issue_projectName = dictOrEmpty(dict, 'project_name') check_createProject = dict.has_key('createProject') newProject_name = dictOrEmpty(dict, 'newProjectName') newProject_homeURL = dictOrEmpty(dict, 'newProjectHomeURL') newProject_trackerURL = dictOrEmpty(dict, 'newProjectTrackerURL') issue_key = dictOrEmpty(dict, 'key'); issue_title = dictOrEmpty(dict, 'title'); issue_description = dictOrEmpty(dict, 'description'); _throwIfIssueExists(issue_trackerURL, user) issue = None if(check_noProject): if(not issue_title or not issue_description): raise BaseException('title and description are required') issue = Issue.newIssueOrphan(issue_title, issue_description, user) else: project = None if(check_createProject): if(not newProject_name or not newProject_homeURL or not newProject_trackerURL): raise BaseException('all parameters for new project are required') projectHomeURLValidationError = validateURL(newProject_homeURL) if(projectHomeURLValidationError): raise BaseException('invalid project URL ('+newProject_homeURL+') - '+projectHomeURLValidationError) projectTrackerURLValidationError = validateURL(newProject_trackerURL) if(projectTrackerURLValidationError): raise BaseException('invalid project tracker URL ('+newProject_trackerURL+') - '+projectTrackerURLValidationError) project = Project.newProject(newProject_name, user, newProject_homeURL, newProject_trackerURL) else: project = Project.objects.get(pk=int(issue_projectId)) if(newProject_homeURL != project.homeURL): project.homeURL = newProject_homeURL if(not issue_key or not issue_title): raise BaseException('key and title are required') issueURLValidationError = validateIssueURL(issue_trackerURL) if(issueURLValidationError): raise BaseException('invalid issue URL ('+issue_trackerURL+') - '+issueURLValidationError) issue = Issue.newIssue(project, issue_key, issue_title, user, issue_trackerURL) return _buildOfferFromDictionary_and_issue(dict, user, issue);
def process_issue_url(trackerURL, user): result = {} result["urlValidationError"] = validateIssueURL(trackerURL) if(not result["urlValidationError"]): issues = Issue.objects.filter(trackerURL__iexact=trackerURL) issue_already_exists = issues.count() >= 1 if(issues.count() > 1): logger.warning("Database inconsistency: more than one issue found with url = %s"%trackerURL) if(issue_already_exists): result["issue"] = {"id":issues[0].id} return result else: issueInfo = fetchIssueInfo(trackerURL) _append_project_id_and_update_db_if_needed(issueInfo, trackerURL, user) result["issueInfo"] = issueInfo.__dict__ return result
def process_issue_url(trackerURL, user): result = {} result["urlValidationError"] = validateIssueURL(trackerURL) if (not result["urlValidationError"]): issues = Issue.objects.filter(trackerURL__iexact=trackerURL) issue_already_exists = issues.count() >= 1 if (issues.count() > 1): logger.warning( "Database inconsistency: more than one issue found with url = %s" % trackerURL) if (issue_already_exists): result["issue"] = {"id": issues[0].id} return result else: issueInfo = fetchIssueInfo(trackerURL) _append_project_id_and_update_db_if_needed(issueInfo, trackerURL, user) result["issueInfo"] = issueInfo.__dict__ return result