import sys
import os
from redminelib import Redmine
import json
from collections import OrderedDict
from datetime import datetime
import array
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from Common import Redmine_Tokken
날짜 = 31
def project_count():
count = 0
for project in Redmine_Tokken.redmine_token().project.all():
count = count + 1
return count
def project_list_original():
pj_name = []; pj_id = []; pj_list = []
for project in Redmine_Tokken.redmine_token().project.all():
pj_name.append(project.name)
pj_id.append(project.id)
pj_list.append(project.identifier)
return pj_name, pj_id, pj_list
def project_list_sort():
pj_name_project = []
pj_name_id = []
pj_identifier_project = []
프로젝트 = project_list_original()
프로젝트이름카운트 = 0
프로젝트카운트 = 0
for project in 프로젝트[0]:
if 프로젝트[0][프로젝트이름카운트][0:6] == "[프로젝트]":
pj_name_project.append(프로젝트[0][프로젝트이름카운트])
pj_name_id.append(프로젝트[1][프로젝트이름카운트])
pj_identifier_project.append(프로젝트[2][프로젝트이름카운트])
프로젝트카운트 = 프로젝트카운트 + 1
프로젝트이름카운트 = 프로젝트이름카운트 + 1
return pj_name_project, pj_identifier_project, 프로젝트카운트, pj_name_id
def project_dict():
project_name_info = project_list_sort()[0]
project_identifier_info = project_list_sort()[1]
file_data = OrderedDict()
return {'Project':{'name': [i for i in project_name_info], 'identifier': [i for i in project_identifier_info]}}
def pj_identifier_project_issues():
issues = []
숫자카운트 = 0
프로젝트식별자 = project_list_sort()[1]
for project in 프로젝트식별자:
issues.append(Redmine_Tokken.redmine_token().issue.filter(project_id='{}'.format(프로젝트식별자[숫자카운트]), status_id ='*'))
숫자카운트 = 숫자카운트 + 1
return issues
def projects_Memeber(프로젝트식별자):
projects_Memeber = Redmine_Tokken.redmine_token().project_membership.filter(project_id='{}'.format(프로젝트식별자))
for i in projects_Memeber:
return [dict(i) for i in projects_Memeber]
"""
'assigned_to'= 담당자
'attachments' = 첨부파일 (리스트)
'author' = 저자
'changesets' = 범주
'children' = 하위일감 (리스트)
'closed_on' = 완료일 # 일감 상태가 Closed 될때만 가능
'created_on' = 등록일
# 결함일 경우
'custom_fields[0]' = 유형 - value (딕셔너리) # 결함유형
'custom_fields[1]' = 결함 심각도 - value (딕셔너리)
'custom_fields[2]' = 보고자 - value # 자주 쓰지는 않는 필드
'custom_fields[3]' = 보고처 - value # 자주 쓰지는 않는 필드
# 결함이 아닐 경우
'custom_fields[2]' = 보고자 - value # 자주 쓰지는 않는 필드
'custom_fields[3]' = 보고처 - value # 자주 쓰지는 않는 필드
'description' = 일감 내용
'done_ratio' = 진척도
'due_date' = 완료기한
'id' = 이슈번호
'journals' = 이력
'parent' = 상위일감 (삭제되어도 상위일감 값 자체는 존재함)
'priority' = 우선순위
'project' = 프로젝트
'relations' = 연결된 일감
'start_date' = 시작일
'status' = 상태
'subject' = 일감 제목
'time_entries' = 작업시간
'tracker' = 일감 유형
'updated_on' = 변경일
'watchers' = 일감 관리자
"""
today = datetime.date(datetime.today())
def input_projects_issues(프로젝트식별자, tracker_id):
New = []; Resolved = []
issues = Redmine_Tokken.redmine_token().issue.filter(project_id='{}'.format(프로젝트식별자), tracker_id = tracker_id)
for project in issues:
created_on = today - datetime.date(project.created_on)
updated_on = today - datetime.date(project.updated_on)
if created_on.days < 날짜:
if str(project.status) == 'New':
New.append(project)
if updated_on.days < 날짜:
if project.created_on != project.updated_on:
if str(project.status) == 'Resolved':
Resolved.append(project)
return New, Resolved
def status_projects_issues(프로젝트식별자):
New = []; Confirmed = []; Assigned = []; InProgress = []; Resolved = []; Closed = []; NeedsFeedback = []; Rejected = []
status = Redmine_Tokken.redmine_token().issue.filter(project_id='{}'.format(프로젝트식별자))
for project in status:
updated_on = today - datetime.date(project.updated_on)
if updated_on.days < 날짜:
if str(project.status) == 'New':
New.append(project)
if str(project.status) == 'Confirmed':
Confirmed.append(project)
if str(project.status) == 'Assigned':
Assigned.append(project)
if str(project.status) == 'In Progress':
InProgress.append(project)
if str(project.status) == 'Resolved':
Resolved.append(project)
if str(project.status) == 'Closed':
Closed.append(project)
if str(project.status) == 'Needs Feedback':
NeedsFeedback.append(project)
if str(project.status) == 'Rejected':
Rejected.append(project)
return New, Confirmed, Assigned, InProgress, Resolved, Closed, NeedsFeedback, Rejected
def projects_issues_trackerinfo(프로젝트식별자):
Common = []; Feature = []; Defect = []; Request = []
status = Redmine_Tokken.redmine_token().issue.filter(project_id='{}'.format(프로젝트식별자))
for project in status:
updated_on = today - datetime.date(project.updated_on)
if updated_on.days < 날짜:
if str(project.tracker) == 'Common':
Common.append(project)
if str(project.tracker) == 'Feature':
Feature.append(project)
if str(project.tracker) == 'Defect':
Defect.append(project)
if str(project.tracker) == 'Request':
Request.append(project)
return Common, Feature, Defect, Request
def tracker_projects_issues(프로젝트식별자, tracker_id):
일감 = []
status = Redmine_Tokken.redmine_token().issue.filter(project_id='{}'.format(프로젝트식별자), tracker_id =tracker_id)
for project in status:
updated_on = today - datetime.date(project.updated_on)
if updated_on.days < 날짜:
일감.append(project)
return 일감
def change_status_id(인자값):
인자값종류 = [1,2,3,5,7,8,10,11]
인자값속성 = ['New', 'In Progress', 'Resolved', 'Closed', 'Needs Feedback', 'Rejected', 'Assigned', 'Confirmed']
return 인자값속성[인자값종류.index(int(인자값))]
def change_tracker_id(인자값):
인자값종류 = [1,2,3,6,7,8,9]
인자값속성 = ['Defect', 'Feature', 'Common', 'Request', 'Patch', 'Issue', 'Review']
return 인자값속성[인자값종류.index(int(인자값))]
def return_assigned_to_id(프로젝트식별자):
idcheck = projects_Memeber(프로젝트식별자)
idlist = []; idname = []
try:
for k in idcheck:
idlist.append(k['user']['id'])
idname.append(k['user']['name'])
except KeyError:
pass
idcount = []
count = 0
for i in idlist:
shot = []
try:
for j in Redmine_Tokken.redmine_token().issue.filter(project_id='{}'.format(프로젝트식별자), assigned_to_id = idlist[count]):
shot.append(j)
except IndexError:
pass
count = count + 1
idcount.append(len(shot))
return idname, idcount