Make models documentation
This commit is contained in:
parent
4555627bd3
commit
c216b44b2a
@ -1,6 +1,11 @@
|
|||||||
*****
|
|
||||||
TODOs
|
Models
|
||||||
*****
|
------
|
||||||
|
|
||||||
|
.. automodule:: main.models
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Extra Functions
|
Extra Functions
|
||||||
---------------
|
---------------
|
||||||
|
@ -15,6 +15,7 @@ Welcome to ZenDesk Access Controller's documentation!
|
|||||||
todo.rst
|
todo.rst
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from zenpy.lib.exception import APIException
|
|||||||
from main.models import UserProfile
|
from main.models import UserProfile
|
||||||
|
|
||||||
|
|
||||||
# Дополнительные функции
|
|
||||||
def set_and_get_name(user_profile: UserProfile):
|
def set_and_get_name(user_profile: UserProfile):
|
||||||
"""
|
"""
|
||||||
Функция устанавливает поле :class:`username` текущим именем в Zendesk
|
Функция устанавливает поле :class:`username` текущим именем в Zendesk
|
||||||
@ -22,10 +22,13 @@ def set_and_get_name(user_profile: UserProfile):
|
|||||||
return user_profile.user.username
|
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
|
Функция устанавливает поле :class:`user.email` текущей почтой в Zendesk
|
||||||
|
|
||||||
|
.. TODO::
|
||||||
|
Переделать с получением данных через API
|
||||||
|
|
||||||
:param UP: Объект профиля пользователя
|
:param UP: Объект профиля пользователя
|
||||||
:type UP: :class:`main.models.UserProfile`
|
:type UP: :class:`main.models.UserProfile`
|
||||||
:return: Почта пользователя
|
:return: Почта пользователя
|
||||||
@ -34,10 +37,13 @@ def set_and_get_email(user_profile: UserProfile): # TODO: Переделать
|
|||||||
return user_profile.user.email
|
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
|
Функция устанавливает поле :class:`role` текущей ролью в Zendesk
|
||||||
|
|
||||||
|
.. TODO::
|
||||||
|
Переделать с получением данных через API
|
||||||
|
|
||||||
:param UP: Объект профиля пользователя
|
:param UP: Объект профиля пользователя
|
||||||
:type UP: :class:`main.models.UserProfile`
|
:type UP: :class:`main.models.UserProfile`
|
||||||
:return: Роль пользователя
|
:return: Роль пользователя
|
||||||
@ -46,10 +52,13 @@ def set_and_get_role(user_profile: UserProfile): # TODO: Переделать
|
|||||||
return user_profile.role
|
return user_profile.role
|
||||||
|
|
||||||
|
|
||||||
def load_and_get_image(user_profile: UserProfile): # TODO: Переделать с получением изображения через API
|
def load_and_get_image(user_profile: UserProfile):
|
||||||
"""
|
"""
|
||||||
Функция загружает и устанавливает изображение в поле :class:`image`
|
Функция загружает и устанавливает изображение в поле :class:`image`
|
||||||
|
|
||||||
|
.. TODO::
|
||||||
|
Переделать с получением изображения через API
|
||||||
|
|
||||||
:param UP: Объект профиля пользователя
|
:param UP: Объект профиля пользователя
|
||||||
:type UP: :class:`main.models.UserProfile`
|
:type UP: :class:`main.models.UserProfile`
|
||||||
:return: Название изображения
|
:return: Название изображения
|
||||||
@ -88,7 +97,7 @@ def check_user_auth(email: str, password: str) -> bool:
|
|||||||
:param password: Пароль пользователя
|
:param password: Пароль пользователя
|
||||||
:type password: :class:`str`
|
:type password: :class:`str`
|
||||||
:return: True, если входные данные верны, иначе False
|
:return: True, если входные данные верны, иначе False
|
||||||
:raise :class:`APIException`: исключение, вызываемое если пользователь не аутентифицирован
|
:raise: :class:`APIException`: исключение, вызываемое если пользователь не аутентифицирован
|
||||||
:rtype: :class:`bool`
|
:rtype: :class:`bool`
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -5,6 +5,18 @@ from django.db import models
|
|||||||
|
|
||||||
|
|
||||||
class UserProfile(models.Model):
|
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)
|
user = models.OneToOneField(to=User, on_delete=models.CASCADE)
|
||||||
role = models.IntegerField()
|
role = models.IntegerField()
|
||||||
image = models.ImageField(upload_to='user_avatars')
|
image = models.ImageField(upload_to='user_avatars')
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Django==3.1.6
|
Django==3.1.6
|
||||||
Pillow==8.1.0
|
Pillow==8.1.0
|
||||||
zenpy~=2.0.24
|
zenpy~=2.0.24
|
||||||
django-registration==3.1.1
|
django_registration==3.1.1
|
||||||
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user