diff --git a/docs/source/code.rst b/docs/source/code.rst index 1c8af9f..3c660f7 100644 --- a/docs/source/code.rst +++ b/docs/source/code.rst @@ -1,6 +1,11 @@ -***** -TODOs -***** + +Models +------ + +.. automodule:: main.models + :members: + + Extra Functions --------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 778a091..2fcbe88 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -15,6 +15,7 @@ Welcome to ZenDesk Access Controller's documentation! todo.rst + Indices and tables ================== diff --git a/main/extra_func.py b/main/extra_func.py index 305e897..3f679c8 100644 --- a/main/extra_func.py +++ b/main/extra_func.py @@ -6,7 +6,7 @@ from zenpy.lib.exception import APIException from main.models import UserProfile -# Дополнительные функции + def set_and_get_name(user_profile: UserProfile): """ Функция устанавливает поле :class:`username` текущим именем в Zendesk @@ -22,10 +22,13 @@ def set_and_get_name(user_profile: UserProfile): return user_profile.user.username -def set_and_get_email(user_profile: UserProfile): # TODO: Переделать с получением данных через API +def set_and_get_email(user_profile: UserProfile): """ Функция устанавливает поле :class:`user.email` текущей почтой в Zendesk + .. TODO:: + Переделать с получением данных через API + :param UP: Объект профиля пользователя :type UP: :class:`main.models.UserProfile` :return: Почта пользователя @@ -34,10 +37,13 @@ def set_and_get_email(user_profile: UserProfile): # TODO: Переделать return user_profile.user.email -def set_and_get_role(user_profile: UserProfile): # TODO: Переделать с получением данных через API +def set_and_get_role(user_profile: UserProfile): """ Функция устанавливает поле :class:`role` текущей ролью в Zendesk + .. TODO:: + Переделать с получением данных через API + :param UP: Объект профиля пользователя :type UP: :class:`main.models.UserProfile` :return: Роль пользователя @@ -46,10 +52,13 @@ def set_and_get_role(user_profile: UserProfile): # TODO: Переделать return user_profile.role -def load_and_get_image(user_profile: UserProfile): # TODO: Переделать с получением изображения через API +def load_and_get_image(user_profile: UserProfile): """ Функция загружает и устанавливает изображение в поле :class:`image` + .. TODO:: + Переделать с получением изображения через API + :param UP: Объект профиля пользователя :type UP: :class:`main.models.UserProfile` :return: Название изображения @@ -88,7 +97,7 @@ def check_user_auth(email: str, password: str) -> bool: :param password: Пароль пользователя :type password: :class:`str` :return: True, если входные данные верны, иначе False - :raise :class:`APIException`: исключение, вызываемое если пользователь не аутентифицирован + :raise: :class:`APIException`: исключение, вызываемое если пользователь не аутентифицирован :rtype: :class:`bool` """ try: diff --git a/main/models.py b/main/models.py index 96d04db..53b404d 100644 --- a/main/models.py +++ b/main/models.py @@ -5,6 +5,18 @@ from django.db import models class UserProfile(models.Model): + """ + Модель профиля пользователя + + :param user: OneToOneField к модели :class:`django.contrib.auth.models.User` + :param role: Код роли пользователя + :type role: :class:`integer` + :param image: Аватарка + :type image: :class:`img` + :param name: Имя пользователя на нашем сайте + :type name: :class:`str` + """ + user = models.OneToOneField(to=User, on_delete=models.CASCADE) role = models.IntegerField() image = models.ImageField(upload_to='user_avatars') diff --git a/requirements.txt b/requirements.txt index e40b267..b2e4c64 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ Django==3.1.6 Pillow==8.1.0 zenpy~=2.0.24 -django-registration==3.1.1 +django_registration==3.1.1 # Documentation