2022-04-29 14:13:54 +02:00
|
|
|
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from .settings import WekanSettings
|
2022-04-29 14:56:51 +02:00
|
|
|
from app.consumer.baseConsumer import BaseGroup, BaseUser, Consumer
|
2022-04-29 14:13:54 +02:00
|
|
|
from .api import WekanApi
|
|
|
|
from .models import User
|
|
|
|
|
|
|
|
|
2022-04-29 14:56:51 +02:00
|
|
|
class WekanConsumer(Consumer):
|
2022-04-29 14:13:54 +02:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self._settings = WekanSettings()
|
|
|
|
self._api = WekanApi(self._settings)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def api(self):
|
|
|
|
return self._api
|
|
|
|
|
|
|
|
@api.setter
|
|
|
|
def api(self, api):
|
|
|
|
self._api = api
|
|
|
|
|
|
|
|
def create_user(self, user: BaseUser):
|
2022-04-29 15:50:33 +02:00
|
|
|
if self._api.get_user(user.username) == None:
|
|
|
|
return self._api.create_user(username=user.username, email=user.email, password="")
|
|
|
|
raise Exception("[Wekan] User already exists")
|
2022-04-29 14:13:54 +02:00
|
|
|
|
|
|
|
def create_group(self, group: BaseGroup):
|
|
|
|
print("Create Wekan Group: ", group)
|
|
|
|
pass
|
|
|
|
|