Update
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.

This commit is contained in:
Peter Šurda 2024-06-04 18:49:24 +08:00
parent 727829958d
commit 4eaec0e7f3
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95

81
main.py
View File

@ -1,32 +1,87 @@
#/usr/bin/env python #/usr/bin/env python
import os import os
from sys import exit
import gitea
from dotenv import load_dotenv from dotenv import load_dotenv
from taiga import TaigaAPI from taiga import TaigaAPI
load_dotenv() load_dotenv()
print("Creating object") print("Creating TaigaAPI object")
api = TaigaAPI(host=os.getenv('HOST')) taiga_api = TaigaAPI(host=os.getenv('TAIGA_HOST'))
print("Authenticating") print("Authenticating")
api.auth( taiga_api.auth(
username=os.getenv('USERNAME'), username=os.getenv('TAIGA_USERNAME'),
password=os.getenv('PASSWORD') password=os.getenv('TAIGA_PASSWORD')
) )
#new_project = api.projects.get_by_slug('test') print("Retrieving user peter")
users = taiga_api.users.list_users()
saved_user = None
for u in users:
if u.username == "PeterSurda":
saved_user = u
break
if not saved_user:
print("Can't find user PeterSurda")
exit(1)
print("Retrieving test-project")
old_project = taiga_api.projects.get_by_slug('test-project')
print("Retrieving project roles")
roles = old_project.list_roles()
saved_role = None
for r in roles:
if r.slug == 'product-owner':
saved_role = r
break
if not saved_role:
print("Can't find product-owner role for project")
exit(1)
#membership = old_project.add_membership('peter+taiga@bitmessage.at', '')
print("Retrieving project membership")
memberships = old_project.list_memberships()
found = False
for m in memberships:
if m.user == saved_user.id:
if m.role != saved_role.role.id:
print("Modifying membership")
m.role = saved_role.role.id
m.update()
else:
found = True
break
if not found:
print("Adding membership")
old_project.add_membership(email=None,
role=saved_role.id,
username=saved_user.username)
#print(new_project) #print(new_project)
print("Creating test project") #print("Creating test project")
#new_project = taiga_api.projects.create('TEST PROJECT', 'TESTING API')
#print("Creating test story")
#userstory = new_project.add_user_story(
# 'New Story', description='Blablablabla'
#)
#print("Done")
new_project = api.projects.create('TEST PROJECT', 'TESTING API') #gitea_api = gitea.Gitea(os.getenv('GITEA_HOST'),
# os.getenv('GITEA_TOKEN'))
print("Creating test story") #print("Gitea Version: " + gitea_api.get_version())
#print("API-Token belongs to user: " + gitea_api.get_user().username)
userstory = new_project.add_user_story( #org = gitea.Organization.request(gitea_api, "Sysdeploy")
'New Story', description='Blablablabla'
)
print("Done") #v = vars(org)
#print(v)