Skip to content

Instantly share code, notes, and snippets.

@m-bo-one
Last active September 28, 2016 12:13
Show Gist options
  • Save m-bo-one/fa028d2d05f68fcc5a4c005d4fca1f4b to your computer and use it in GitHub Desktop.
Save m-bo-one/fa028d2d05f68fcc5a4c005d4fca1f4b to your computer and use it in GitHub Desktop.

Changelog

v1.0

  • added russian error presentation (add Accept-Language: ru;q=1 in header of request);
  • removed [] from error value;
  • changed error keys: non_field_errors -> error, detail -> error;

v1.1

  • changed error translation in documentation;
  • added admin panel link to docs;
  • added online-lesson descr in docs;
  • added version for api link (from api/ to api/v1.0/);

v1.2

v1.3

  • added /video-lessons/latest/ and /text-lessons/latest/ to docs;
  • removed data generation from url;

v1.4

  • added user data (first_name, last_name, patronimyc) in json render of video lessons, text lessons, thanks, needs, wishes and supports;
  • updated russian translation in admin profile;
  • updated tests;
  • increased pagination count from 10 to 20;
  • removed subversion for api link (api/v1.0 -> api/v1);

v1.5

  • updated translation for error messages;
  • added banner routes;
  • added short description of all routes;
  • added new tests: for registration and banners;

v1.6

  • added search for Needs, Thanks, Video and Text lessons (query: ?search=(title:str));
  • added filter by last period dates (such as last year, month etc.) (query: ?time_filter=(id:int))
  • added "Filters and search" column in "General information" (please read it!);

v1.7

  • restructured tables for likes;
  • changed needs response route (was /needs/1/responses/, become /needs/1/views/);
  • added is_viewed field for needs and thanks (if current user viewed this thank or resposed on need);

v1.8

  • added is_viewed field for video and text lessons;
  • added similar lessons for video lessons;

v1.9

  • fixed bug with date filter;

v1.10

  • added search filter for user needs and thanks;
  • changed priorities for needs: 0 - is "Обычная" now (default priority on server), 1 - "Срочная";

v1.11

  • changes of keys in /video-lessons/ and /video-lessons/id:int/:
    • video -> video_url (Note: see videos section for detailed answer)

v1.12

  • removed additional_lessons (replaced with favorite_lessons);
  • added favorite functionality:
    • added add/delete favorite text/video lesson (see text/video lesson section);
    • added user favorite lists of text and video lessons (see favorites section);
  • for newbies with pagination: to take all video, text lessons, needs, thanks add '/all/' to corresponding route;

v1.13

  • added functionality for text and video lessons views (see views section);

Project API link

http://5.101.125.15:8484/api/v1/

Installation

  1. git clone http://5.101.125.14/DeV1doR/CloudApp.git
  2. virtualenv .env
  3. source .env/bin/activate
  4. (.env) pip install -r requirements.txt
  5. (.env) python manage.py migrate
  6. (.env) python manage.py runserver

General information

Admin user creadentials:

Headers:

  • Authorization: Token 1af538baa9045a84c0e889f672baf83ff24 - exclude auth routes such as login, logout, registration;
  • Content-Type: application/json - except GET request;
  • Accept-Language: ru;q=1 - for russian error messages (changes locale);
  • Content-Type: multipart/form-data - for file upload (thanks, needs, user profile routes);

Filters and search:

  • for searching lessons, thanks and wishes user ?search=(title:str), where title - title of some video, text lessons or thanks or wishes.
  • for filtering lessons by some period use such query ?time_filter=(id:int), where id - time filter id from the list below:
    • 1 - за последнюю неделю;
    • 2 - за последний месяц;
    • 3 - за последний квартал (3 месяца);
    • 4 - за последние пол года;
    • 5 - за последний год;
  • examples:
    • /api/v1/video-lessons/?filter_time=2 (we filter for last month);
    • /api/v1/video-lessons/?search=Title%2020 (Title 20 with urlencode);

Admin panel

FAQ

TODO: add faq;

Quick search

Auth

Consultants (Консультатнты)

Banners (Баннеры)

Favorites (Фавориты)

Views (Просмотры)

Text lessons (Текстовые уроки)

Video lessons (Видео уроки)

Online lesson (Онлайн урок)

Supports (Спросить вопрос у поддержки)

Wishes (Пожелания)

Needs (Нужды)

Thanks (Благодарности)

Global errors

If user not authenticated

  • Code: 403 Forbidden
  • Content:
{
    "error": "Учетные данные не были предоставлены."
}

If detailed resource not found

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

Auth

API for registration

POST: registration/

Description

Registration of user by email, username and password.

Send Params

Parameter Description
username required(max=30)
email required(max=254 - RFC 3696)
password required(min=6)

Response Params

Parameter Description
key Token key on success response

Success Response

  • Code: 200 OK
  • Content:
{
    "key": "08a75440e13e76c941f3936fbd4423e08bb04b55"
}

Error Response

If username already taken

  • Code: 400 Bad Request
  • Content:
{
    "username": "Такое имя пользователя уже используется на сайте. Пожалуйста выберите другое."
}

If email already taken

  • Code: 400 Bad Request
  • Content:
{
    "email": "Юзер уже зарегистрирован по этому адресу."
}

If email or password not specified

  • Code: 400 Bad Request
  • Content:
{
    "password": "Это поле не может быть пустым."
}
or
{
    "email": "Это поле не может быть пустым."
}

If password less than 6

  • Code: 400 Bad Request
  • Content:
{
    "password": "Минимальное количество символов в пароле: 6."
}

API for login user

POST: login/

Description

Authentification of user by email and password.

Data Params

Parameter Description
email required
password required

Response Params

Parameter Description
key Token key on success response

Success Response

  • Code: 200 OK
  • Content:
{
    "key": "08a75440e13e76c941f3936fbd4423e08bb04b55"
}

Error Response

If invalid credentials

  • Code: 400 Bad Request
  • Content:
{
    "error": "Невозможно войти с предоставленными учетными данными."
}

If not email

  • Code: 400 Bad Request
  • Content:
{
    "error": "Должен включать в себя либо email пользователя либо пароль."
}

If not password

  • Code: 400 Bad Request
  • Content:
{
    "password": "Это поле не может быть пустым."
}

API for logout user

POST: logout/

Description

Disconnect user from the server.

Success Response

  • Code: 200 OK
  • Content:
{
    "success": "Вы успешно вышли из системы."
}

API for password change

POST: password/change/

Data Params

Parameter Description
old_password required
new_password1 required(min=8, max=128)
new_password2 required(min=8, max=128)

Success Response

  • Code: 200 OK
  • Content:
{
    "success": "Новый пароль успешно сохранен."
}

Error Response

If old_password or new_password1 or new_password2 missed

  • Code: 400 Bad Request
  • Content:
{ 
    "old_password": "Это поле не может быть пустым."
}
or
{ 
    "new_password1": "Это поле не может быть пустым."
}
or
{
    "new_password2": "Это поле не может быть пустым."
}

If old password is not valid

  • Code: 400 Bad Request
  • Content:
{
    "old_password": "Неправильный пароль"
}

If new passwords did not match

  • Code: 400 Bad Request
  • Content:
{
    "new_password2": "Пароли не совпадают."
}

If new password is too short (<8)

  • Code: 400 Bad Request
  • Content:
{
    "new_password2": "Введённый пароль слишком короткий. Он должен содержать как минимум 8 символов."
}

API for send password reset link

POST: password/reset/

Description

Reset current password of user and send password recover link on the email.

Data Params

Parameter Description
email required(max=254, RFC 3696)

Success Response

  • Code: 200 OK
  • Content:
{
    "success": "На вашу почту была отправлена инструкция о востановлении пароля."
}

Error Response

If email is empty

  • Code: 400 Bad Request
  • Content:
{
    "email": "Это поле не может быть пустым."
}

If email is invalid

  • Code: 400 Bad Request
  • Content:
{
    "email": "Введите корректный адрес электронной почты."
}

API for password recover

POST: password/reset/confirm/

Description

Send new user password to the server. Note: uid and token tooks from mobile application url, generated at previous route. (Exapmle: application_link?uid=(some_uid)&token=(some_token))

Data Params

Parameter Description
uid required
token required
new_password1 required(8)
new_password2 required(8)

Success Response

  • Code: 200 OK
  • Content:
{
    "success": "Пароль был успешно изменен."
}

Error Response

If one of the field is blank

  • Code: 400 Bad Request
  • Content:
{
    "token": "Это поле не может быть пустым."
}
    or
{
    "new_password2": "Это поле не может быть пустым."
}
    or
{
    "new_password1": "Это поле не может быть пустым."
}
    or
{
    "uid": "Это поле не может быть пустым."
}

If uid or token is invalid

  • Code: 400 Bad Request
  • Content:
{
    "token": "Неправильний token"
}
    or
{
    "uid": "Неправильный uid"
}

If password is too short

  • Code: 400 Bad Request
  • Content:
{
    "new_password2": "Введённый пароль слишком короткий. Он должен содержать как минимум 8 символов."
}

API for get profile page

GET: user/

Description

Get current logged user profile data

Response Params

Parameter Description
id logged user id
email user email
photo user photo link for render
first_name user first name
last_name user last name
patronymic user first name
city user city
phone user phone number
start_url user page start url
latest_text_lessons latest 10 text lessons
latest_video_lessons latest 10 video lessons
completed_lessons total count of viewed lessons
favorite_lessons total count of favorite lessons

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 2,
    "email": "admin@example.com",
    "photo": "http://5.101.125.15:8484/media/images/users/example_i4mu6yE.jpg",
    "first_name": "Carina",
    "last_name": "Marvin",
    "patronymic": "Patronymic 0",
    "city": "Lake Neola",
    "phone": "01234567890",
    "start_url": "http://www.howell-brown.com/",
    "latest_text_lessons": [
        {
            "id": 50,
            "user": {
                "id": 10,
                "first_name": "Bolden",
                "last_name": "Jerde",
                "patronymic": "Patronymic 8"
            },
            "title": "Title 49",
            "seen_count": 0,
            "created_at": "2016-06-29T10:01:40.117670Z",
            "text": "Blanditiis nisi totam quasi deleniti quo qui. Adipisci similique excepturi molestias blanditiis. Officia amet molestias magnam.",
            "photo": "http://5.101.125.15:8484/media/images/text-lessons/example_A0dAEqf.jpg"
        }
        
        ...

    ],
    "latest_video_lessons": [
        {
            "id": 50,
            "user": {
                "id": 11,
                "first_name": "Melva",
                "last_name": "Johns",
                "patronymic": "Patronymic 9"
            },
            "title": "Title 49",
            "seen_count": 0,
            "created_at": "2016-06-29T10:01:40.138831Z",
            "text": "Odio dolorum nulla totam fuga magni. Itaque porro esse modi quasi mollitia quo nihil. Labore consectetur similique animi nam quis labore officia.",
            "video": "http://5.101.125.15:8484/media/videos/video-lessons/test_video_F3WhkEx.mp4",
            "preview_image": "http://5.101.125.15:8484/media/images/video-lessons/example_F9gApEd.jpg"
        },
        
        ...

    ],
    "completed_lessons": 3,
    "favorite_lessons": 3
}

API for change profile page data

PUT | PATCH: user/

Description

Update current user profile data

Data Params

Parameter Description
photo optional(max=100 - for name)
first_name optional(max=30)
last_name optional(max=30)
patronymic optional(max=30)
email optional(max=254 - RFC 3696 standart)
city optional(max=30)
phone optional(max=30)
start_url optional(max=200)

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 2,
    "email": "admin@example.com",
    "photo": "http://5.101.125.15:8484/media/images/users/example_i4mu6yE.jpg",
    "first_name": "Carina",
    "last_name": "Marvin",
    "patronymic": "Patronymic 0",
    "city": "Lake Neola",
    "phone": "01234567890",
    "start_url": "http://www.howell-brown.com/",
    "latest_text_lessons": [
        {
            "id": 50,
            "user": {
                "id": 10,
                "first_name": "Bolden",
                "last_name": "Jerde",
                "patronymic": "Patronymic 8"
            },
            "title": "Title 49",
            "seen_count": 0,
            "created_at": "2016-06-29T10:01:40.117670Z",
            "text": "Blanditiis nisi totam quasi deleniti quo qui. Adipisci similique excepturi molestias blanditiis. Officia amet molestias magnam.",
            "photo": "http://5.101.125.15:8484/media/images/text-lessons/example_A0dAEqf.jpg"
        }
        
        ...

    ],
    "latest_video_lessons": [
        {
            "id": 50,
            "user": {
                "id": 11,
                "first_name": "Melva",
                "last_name": "Johns",
                "patronymic": "Patronymic 9"
            },
            "title": "Title 49",
            "seen_count": 0,
            "created_at": "2016-06-29T10:01:40.138831Z",
            "text": "Odio dolorum nulla totam fuga magni. Itaque porro esse modi quasi mollitia quo nihil. Labore consectetur similique animi nam quis labore officia.",
            "video": "http://5.101.125.15:8484/media/videos/video-lessons/test_video_F3WhkEx.mp4",
            "preview_image": "http://5.101.125.15:8484/media/images/video-lessons/example_F9gApEd.jpg"
        },
        
        ...

    ],
    "completed_lessons": 3,
    "additional_lessons": 100
}

Error Response

If image invalid

  • Code: 400 Bad Request
  • Content:
{
    "photo": "Загруженный файл не является корректным файлом. "
}

Consultants

API for consultant list

GET: consultants/

Description

Get consultant list with their rmail, phone, skype and photo.

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 10,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 41,
            "photo": "http://localhost:8000/media/images/consultants/example_X1uHfaS.jpg",
            "email": "burnell29@haag.info",
            "phone": "01234567890",
            "skype": "Skype 40"
        },
        
        ...
        
    ]
}

Banners

API for user banners

GET: user/banners/

Description

Get user banners with title, text, url for redirect and banner photo.

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 41,
            "title": "Title 40",
            "text": "Odit alias ab tempore earum. Sit officia pariatur fuga culpa eligendi facere. Eum fugit quos beatae.",
            "photo": "http://localhost:8000/media/images/banners/example_paGRmjR.jpg",
            "url": "http://www.vandervort.info/"
        },
        
        ...

    ]
}

API for random user banner generation from pool

GET: user/banners/current/

Description

Get one random banner from user banners pool.

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 41,
    "title": "Title 40",
    "text": "Odit alias ab tempore earum. Sit officia pariatur fuga culpa eligendi facere. Eum fugit quos beatae.",
    "photo": "http://localhost:8000/media/images/banners/example_paGRmjR.jpg",
    "url": "http://www.vandervort.info/"
}

Error Response

If not banner in pool or user already viewed all banners in pool

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

API for user banner preview

PATCH: user/banners/(id:int)/

Description

Send route for banner preview by current user.

Success Response

  • Code: 204 No Content

Error Response

If user already viewed this banner or banner does not exist

  • Code: 400 Bad Request
  • Content:
{
    "error": "Этот баннер недоступен или просмотрен уже этим пользователем."
}

Favorites

API for get user favorites video lessons

GET: user/favorites/video-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "user": {
                "id": 0,
                "first_name": "Christel",
                "last_name": "Blick",
                "patronymic": "Patronymic 2"
            },
            "title": "Lesson1",
            "seen_count": 0,
            "created_at": "2016-07-21T07:34:01.002103Z",
            "text": "Владимир Мунтян урок № 1 номер 12.05.2015 мая 12 май г.",
            "video_url": "http://cdn.ua/download/clw.com.ua/lesson_1.mp4",
            "preview_image": "http://localhost:8000/media/images/video-lessons/apostle.jpg",
            "is_viewed": false,
            "is_favorited": false
        }
    ]
}

API for get user favorites text lessons

GET: user/favorites/text-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 15,
            "user": {
                "id": 0,
                "first_name": "Christel",
                "last_name": "Blick",
                "patronymic": "Patronymic 2"
            },
            "title": "Урок №12",
            "seen_count": 0,
            "created_at": "2016-08-23T07:34:15.381512Z",
            "text": "Дорогие, облако свидетелей! Послушайте...",
            "photo": "http://localhost:8000/media/images/text-lessons/oblako_t17rTCD_8BaQOEh.jpg",
            "is_favorited": true,
            "is_viewed": false
        }
    ]
}

Views

API for get user viewed video lessons

GET: user/views/video-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "user": {
                "id": 0,
                "first_name": "Christel",
                "last_name": "Blick",
                "patronymic": "Patronymic 2"
            },
            "title": "Lesson1",
            "seen_count": 0,
            "created_at": "2016-07-21T07:34:01.002103Z",
            "text": "Владимир Мунтян урок № 1 номер 12.05.2015 мая 12 май г.",
            "video_url": "http://cdn.ua/download/clw.com.ua/lesson_1.mp4",
            "preview_image": "http://localhost:8000/media/images/video-lessons/apostle.jpg",
            "is_viewed": false,
            "is_favorited": false
        }
    ]
}

API for get user favorites text lessons

GET: user/views/text-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 15,
            "user": {
                "id": 0,
                "first_name": "Christel",
                "last_name": "Blick",
                "patronymic": "Patronymic 2"
            },
            "title": "Урок №12",
            "seen_count": 0,
            "created_at": "2016-08-23T07:34:15.381512Z",
            "text": "Дорогие, облако свидетелей! Послушайте...",
            "photo": "http://localhost:8000/media/images/text-lessons/oblako_t17rTCD_8BaQOEh.jpg",
            "is_favorited": true,
            "is_viewed": false
        }
    ]
}

Text lessons

API for text lessons

GET: text-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 50,
    "next": "http://localhost:8000/text-lessons/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "patronymic": null
            },
            "title": "Title 0",
            "created_at": "2016-06-21T08:30:46.622329Z",
            "text": "Text 0",
            "is_viewed": false,
            "is_favorited": true,
            "photo": "http://localhost:8000/media/images/lessons/example_QVZvpXn.jpg"
        }
    ]
}

API for detailed text lessons

GET: text-lessons/(id:int)/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "title": "Title 1",
    "created_at": "2016-06-22T10:32:29.984914Z",
    "text": "Text 1",
    "is_viewed": false,
    "is_favorited": false,
    "photo": "http://localhost:8000/media/images/text-lessons/example_2lM6XKz.jpg"
}

API for add text lesson to favorites

POST: text-lessons/<id:int>/favorites/

Success Response

  • Code: 200 OK (if already added, otherwise 201 Created)
  • Content:
{
    "id": 15,
    "user": {
        "id": 0,
        "first_name": "Christel",
        "last_name": "Blick",
        "patronymic": "Patronymic 2"
    },
    "title": "Урок №12",
    "seen_count": 0,
    "created_at": "2016-08-23T07:34:15.381512Z",
    "text": "Дорогие, облако свидетелей! Послушайте...",
    "photo": "/media/images/text-lessons/oblako_t17rTCD_8BaQOEh.jpg",
    "is_favorited": true,
    "is_viewed": false
}

Error Response

If not such text lesson

  • Code: 400 Bad Request
  • Content:
{
    "text_lesson": "Недопустимый первичный ключ \"134234\" - объект не существует."
}

API for remove text lesson from favorites

DELETE: text-lessons/<id:int>/favorites/

Success Response

  • Code: 204 No Content

Video lessons

API for video lessons

GET: video-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 50,
    "next": "http://localhost:8000/video-lessons/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "patronymic": null
            },
            "title": "Title 0",
            "seen_count": 0,
            "created_at": "2016-06-21T08:30:46.624591Z",
            "text": "Text 0",
            "video_url": "http://localhost:8000/media/videos/lessons/Python_Mocking.mp4",
            "preview_image": null,
            "is_viewed": false,
            "is_favorited": true
        }
    ]
}

API for detailed video lessons

GET: video-lessons/(id:int)/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "title": "Title 1",
    "seen_count": 1,
    "created_at": "2016-06-22T10:32:29.986889Z",
    "text": "Text 1",
    "video": "http://localhost:8000/media/videos/video-lessons/example_WqZMaT4.jpg",
    "preview_image": null,
    "is_viewed": false,
    "similar_lessons": [
        {
            "id": 6,
            "user": {
                "id": 2,
                "first_name": "Alferd",
                "last_name": "Doyle",
                "patronymic": "Patronymic 1"
            },
            "title": "Title 5",
            "seen_count": 0,
            "created_at": "2015-10-10T07:37:14.241013Z",
            "text": "Repellat deserunt voluptas sint laboriosam facere in. Exercitationem veniam ea esse accusamus. Quibusdam ullam facere dicta odit tenetur.",
            "video_url": "http://localhost:8000/media/videos/video-lessons/test_video_GVJHQJj.mp4",
            "preview_image": "http://localhost:8000/media/images/video-lessons/example_A81TSUv.jpg",
            "is_viewed": false,
            "is_favorited": true
        },
        
        ...
        
    ]
}

Error Response

If not lesson

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

API for video preview

POST: video-lessons/(id:int)/views/

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 6,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "title": "Title 6",
    "seen_count": 1,
    "created_at": "2016-06-21T12:08:25.508730Z",
    "text": "Text 6",
    "video_url": "/media/videos/video-lessons/example_nYGJCmj.jpg",
    "preview_image": null,
    "is_viewed": false,
    "similar_lessons": [
        {
            "id": 6,
            "user": {
                "id": 2,
                "first_name": "Alferd",
                "last_name": "Doyle",
                "patronymic": "Patronymic 1"
            },
            "title": "Title 5",
            "seen_count": 0,
            "created_at": "2015-10-10T07:37:14.241013Z",
            "text": "Repellat deserunt voluptas sint laboriosam facere in. Exercitationem veniam ea esse accusamus. Quibusdam ullam facere dicta odit tenetur.",
            "video_url": "http://localhost:8000/media/videos/video-lessons/test_video_GVJHQJj.mp4",
            "preview_image": "http://localhost:8000/media/images/video-lessons/example_A81TSUv.jpg",
            "is_viewed": false,
            "is_favorited": true
        },
        
        ...
        
    ]
}

Error Response

If user already seen

  • Code: 400 Bad Request
  • Content:
{
    "error": "Вы уже проголосовали за этот видеоурок."
}

API for add video lesson from favorites

POST: video-lessons/<id:int>/favorites/

Success Response

  • Code: 200 OK (if already added, otherwise 201 Created)
  • Content:
{
    "id": 1,
    "user": {
        "id": 0,
        "first_name": "Christel",
        "last_name": "Blick",
        "patronymic": "Patronymic 2"
    },
    "title": "Lesson1",
    "seen_count": 0,
    "created_at": "2016-07-21T07:34:01.002103Z",
    "text": "Владимир Мунтян урок № 1 номер 12.05.2015 мая 12 май г.",
    "video_url": "http://cdn.ua/download/clw.com.ua/lesson_1.mp4",
    "preview_image": "/media/images/video-lessons/apostle.jpg",
    "is_viewed": false,
    "is_favorited": true
}

Error Response

If not such video lesson

  • Code: 400 Bad Request
  • Content:
{
    "video_lesson": "Недопустимый первичный ключ \"134234\" - объект не существует."
}

API for remove video lesson to favorites

DELETE: video-lessons/<id:int>/favorites/

Success Response

  • Code: 204 No Content

Online lesson

API for online lesson

GET: online-lesson/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "created_at": "2016-06-23T14:55:58.206588Z",
    "show_date": "2016-08-12T14:55:58.205825Z",
    "link": "http://kessler.org/",
    "preview_image": "/media/images/online-lessons/example_9WaO8ln.jpg",
    "user": {
        "id": 0,
        "first_name": "Aric",
        "last_name": "Ziemann",
        "patronymic": "Patronymic 2"
    },
    "similar_lessons": [
        {
            "id": 14,
            "user": {
                "id": 2,
                "first_name": "Иван",
                "last_name": "Леон",
                "patronymic": ""
            },
            "title": "lesson12",
            "seen_count": 1,
            "created_at": "2015-05-25T13:52:08.932660Z",
            "text": "Владимир Городилов 09.09.2015 урок номер 12 № сентября сентябрь ",
            "video": "http://cdn.ua/code/clw.com.ua/?width=100%&height=94%&view=1&file=lesson_12.mp4",
            "preview_image": "/media/images/video-lessons/gorodilov_Lk7aju2.jpg",
            "is_viewed": false
        },
        ...
    ]
}

Error Response

If not online lesson

  • Code: 404 Not Found
  • Content:
{
    "error": "Онлайн трансляция не найдена."
}

Supports

API for question to support

POST: supports/

Data Params

Parameter Description
text required(200)

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 102,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T10:02:18.058116Z",
    "text": "2323f23"
}

Wishes

API for add wish

POST: wishes/

Data Params

Parameter Description
text required(200)

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 102,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T10:02:18.058116Z",
    "text": "2323f23"
}

Needs

API for add need

POST: needs/

Data Params

Parameter Description
title required(50)
text required(200)
priority required(8, choices=[0, 1])
photo optional
where priority:
  • 0 is "Обычная";
  • 1 is "Срочная";

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 102,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T11:39:23.676429Z",
    "title": "Test paypal system with python",
    "text": "Wona mac",
    "priority": 1,
    "photo": "http://localhost:8000/media/need_default.jpg",
    "response_count": 0,
    "is_viewed": false
}

API for get all needs

GET: needs/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 102,
    "next": "http://localhost:8000/needs/?page=2",
    "previous": null,
    "results": [
        {
            "id": 0,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "patronymic": null
            },
            "created_at": "2016-06-22T10:32:29.981078Z",
            "title": "Title 0",
            "text": "Text 0",
            "priority": 0,
            "photo": "http://localhost:8000/media/images/needs/example.jpg",
            "response_count": 0,
            "is_viewed": false
        }
    ]
}

API for detailed needs

GET: needs/(id:int)/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T10:32:29.991547Z",
    "title": "Title 1",
    "text": "Text 1",
    "priority": 1,
    "photo": "http://localhost:8000/media/images/needs/example_teFY2tW.jpg",
    "response_count": 0,
    "is_viewed": false
}

Error Response

If not need

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

API for response on need

POST: needs/(id:int)/views/

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 1,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T10:32:29.991547Z",
    "title": "Title 1",
    "text": "Text 1",
    "priority": 1,
    "photo": "/media/images/needs/example_teFY2tW.jpg",
    "response_count": 1,
    "is_viewed": false
}

Error Response

If user already responsed on need

  • Code: 400 Bad Request
  • Content:
{
    "error": "Вы уже откликнулись на эту нужду"
}

API for get all user needs

GET: user/needs/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 12,
    "next": "http://localhost:8000/user/needs/?page=2",
    "previous": null,
    "results": [
        {
            "id": 0,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "patronymic": null
            },
            "created_at": "2016-06-22T10:32:29.981078Z",
            "title": "Title 0",
            "text": "Text 0",
            "priority": 2,
            "photo": "http://localhost:8000/media/images/needs/example.jpg",
            "response_count": 0,
            "is_viewed": false
        }
    ]
}

Thanks

API for add thanks

POST: thanks/

Data Params

Parameter Description
title required(50)
text required(200)
address required(100)
photo optional

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 200,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T14:41:14.443747Z",
    "title": "wedwedwe",
    "text": "Debkae",
    "address": "wedwedwe",
    "photo": "http://localhost:8000/media/thank_default.png",
    "views_count": 0,
    "is_viewed": false
}

API for get all thanks

GET: thanks/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 201,
    "next": "http://localhost:8000/thanks/?page=2",
    "previous": null,
    "results": [
        {
            "id": 0,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "patronymic": null
            },
            "created_at": "2016-06-22T14:07:35.912570Z",
            "title": "Title 0",
            "text": "Id tempore quas dolore suscipit iusto. Inventore dignissimos quasi ut rerum. Voluptas aperiam sint delectus aperiam nisi consequatur magnam.",
            "address": "801 Huel Springs\nSouth Joselynhaven, AK 12212-1666",
            "photo": "http://localhost:8000/media/images/thanks/example_FeKLc4Y.jpg",
            "views_count": 0,
            "is_viewed": false
        }
    ]
}

API for detailed thanks

GET: thanks/(id:int)/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T14:07:35.934848Z",
    "title": "Title 2",
    "text": "Quo autem possimus optio reprehenderit iste neque. Tenetur quidem minima quaerat architecto laborum quidem. Deserunt qui dolorum aspernatur illum libero. Soluta ad tenetur sit sit.",
    "address": "Unit 1693 Box 1555\nDPO AP 35217-2289",
    "photo": "http://localhost:8000/media/images/thanks/example_8fjnwoE.jpg",
    "views_count": 1,
    "is_viewed": false
}

Error Response

If not thank

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

API for thank view

POST: thanks/(id:int)/views/

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 3,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "patronymic": null
    },
    "created_at": "2016-06-22T14:07:35.979268Z",
    "title": "Title 6",
    "text": "Laboriosam totam veniam illum magnam perferendis eius. Saepe illo architecto quaerat dolore. Asperiores minus sed at occaecati odio.",
    "address": "Unit 4113 Box 9635\nDPO AA 47962-8778",
    "photo": "/media/images/thanks/example_whvK1dz.jpg",
    "views_count": 1,
    "is_viewed": true
}

Error Response

If user already viewed this thank

  • Code: 400 Bad Request
  • Content:
{
    "error": "Вы уже просмотрели эту благодарность."
}

API for get all user thanks

GET: user/thanks/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 21,
    "next": "http://localhost:8000/user/thanks/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "patronymic": null
            },
            "created_at": "2016-06-22T14:07:35.934848Z",
            "title": "Title 2",
            "text": "Quo autem possimus optio reprehenderit iste neque. Tenetur quidem minima quaerat architecto laborum quidem. Deserunt qui dolorum aspernatur illum libero. Soluta ad tenetur sit sit.",
            "address": "Unit 1693 Box 1555\nDPO AP 35217-2289",
            "photo": "http://localhost:8000/media/images/thanks/example_8fjnwoE.jpg",
            "views_count": 1
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment