- Restructured back-end part of project - moved on web api;
- removed banner section;
- removed get latest video and text lessons section;
- changed some parts of api (see all sections which key is changed/removed):
- patronymic -> middle_name;
- photo -> image;
- text -> description (not in all parts);
- added translation for error;
- added remove thank and need (see corresponding sections below);
http://5.101.119.32:8488/api/v2/m/
- git clone http://5.101.125.14/Iskander/frigg.git
- virtualenv .env
- source .env/bin/activate
- (.env) pip install -r requirements.txt
- (.env) python manage.py migrate
- (.env) python manage.py runserver
Admin user creadentials:
- email - admin@example.com
- username - admin
- password - admin
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
Сколько приоритетов нужд?
- Есть только 2 приоритета - Обычная (0) и Срочная (1)
Как получить список всего сразу без пагинации?
- добавить приставку /all/ к юрлу
- API for registration
- API for login user
- API for logout user
- API for password change
- API for send password reset link
- API for password recover
- API for get profile page
- API for change profile page data
- API for text lessons
- API for detailed text lessons
- API for add text lesson to favorites
- API for remove text lesson from favorites
- API for video lessons
- API for detailed video lessons
- API for video preview
- API for add video lesson to favorites
- API for remove video lesson from favorites
- API for add need
- API for get all needs
- API for detailed needs
- API for delete need
- API for response on need
- API for get all user needs
- API for add thank
- API for get all thanks
- API for detailed thanks
- API for delete thank
- API for thank view
- API for get all user thanks
If user not authenticated
- Code: 403 Forbidden
- Content:
{
"error": "Учетные данные не были предоставлены."
}
If detailed resource not found
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
POST: registration/
Registration of user by email, username and password.
Parameter | Description |
---|---|
username | required(max=30) |
required(max=254 - RFC 3696) | |
password | required(min=6) |
Parameter | Description |
---|---|
key | Token key on success response |
- Code: 200 OK
- Content:
{
"key": "08a75440e13e76c941f3936fbd4423e08bb04b55"
}
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."
}
POST: login/
Authentification of user by email and password.
Parameter | Description |
---|---|
required | |
password | required |
Parameter | Description |
---|---|
key | Token key on success response |
- Code: 200 OK
- Content:
{
"key": "08a75440e13e76c941f3936fbd4423e08bb04b55"
}
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": "Это поле не может быть пустым."
}
POST: logout/
Disconnect user from the server.
- Code: 200 OK
- Content:
{
"success": "Вы успешно вышли из системы."
}
POST: password/change/
Parameter | Description |
---|---|
old_password | required |
new_password1 | required(min=8, max=128) |
new_password2 | required(min=8, max=128) |
- Code: 200 OK
- Content:
{
"success": "Новый пароль успешно сохранен."
}
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 символов."
}
POST: password/reset/
Reset current password of user and send password recover link on the email.
Parameter | Description |
---|---|
required(max=254, RFC 3696) |
- Code: 200 OK
- Content:
{
"success": "На вашу почту была отправлена инструкция о востановлении пароля."
}
If email is empty
- Code: 400 Bad Request
- Content:
{
"email": "Это поле не может быть пустым."
}
If email is invalid
- Code: 400 Bad Request
- Content:
{
"email": "Введите корректный адрес электронной почты."
}
GET: user/
Get current logged user profile data
Parameter | Description |
---|---|
id | logged user id |
user email | |
image | user photo link for render |
first_name | user first name |
last_name | user last name |
middle_name | user middle name |
city | user city |
phone_number | 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 |
- Code: 200 OK
- Content:
{
"id": 2,
"email": "admin@example.com",
"image": "http://5.101.125.15:8484/media/images/users/example_i4mu6yE.jpg",
"first_name": "Carina",
"last_name": "Marvin",
"middle_name": "Patronymic 0",
"city": "Lake Neola",
"phone_number": "01234567890",
"start_url": "http://www.howell-brown.com/",
"latest_text_lessons": [
{
"id": 50,
"text_author": "Автор текстовог оурока",
"title": "Title 49",
"seen_count": 0,
"created_at": "2016-06-29T10:01:40.117670Z",
"description": "Blanditiis nisi totam quasi deleniti quo qui. Adipisci similique excepturi molestias blanditiis. Officia amet molestias magnam.",
"image": "http://5.101.125.15:8484/media/images/text-lessons/example_A0dAEqf.jpg"
}
...
],
"latest_video_lessons": [
{
"id": 50,
"video_author": "Niger",
"title": "Title 49",
"seen_count": 0,
"created_at": "2016-06-29T10:01:40.138831Z",
"description": "Odio dolorum nulla totam fuga magni. Itaque porro esse modi quasi mollitia quo nihil. Labore consectetur similique animi nam quis labore officia.",
"video_url": "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
}
PUT | PATCH: user/
Update current user profile data
Parameter | Description |
---|---|
image | optional(max=100 - for name) |
first_name | optional(max=30) |
last_name | optional(max=30) |
middle_name | optional(max=30) |
optional(max=254 - RFC 3696 standart) | |
city | optional(max=30) |
phone_number | optional(max=30) |
start_url | optional(max=200) |
- Code: 200 OK
- Content:
{
"id": 1,
"email": "dev1dor@ukr.net",
"image": "http://localhost:8000/media/user_default.png",
"first_name": "",
"last_name": "",
"middle_name": "",
"city": "",
"phone_number": null,
"latest_text_lessons": [
{
"id": 1,
"title": "Текстовый урок",
"description": "цуацуацуа",
"text_author": "Автор текстовог оурока",
"created_at": "2016-09-03T13:10:06Z",
"image": "http://localhost:8000/media/text/images_4VI9QYG.jpg"
}
...
],
"latest_video_lessons": [
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg"
}
...
],
"completed_lessons": 0,
"favorite_lessons": 0
}
If image invalid
- Code: 400 Bad Request
- Content:
{
"image": "Загруженный файл не является корректным файлом. "
}
GET: consultants/
Get consultant list with their rmail, phone, skype and photo.
- Code: 200 OK
- Content:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 3,
"first_name": "Name",
"last_name": "Fak",
"image": "http://localhost:8000/media/user_default.png",
"email": "",
"phone_number": "+380938321243",
"skype": "Skyper"
}
...
]
}
GET: user/favorites/video-lessons/
- Code: 200 OK
- Content:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_favorited": true,
"is_viewed": false
}
...
]
}
GET: user/favorites/text-lessons/
- Code: 200 OK
- Content:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"title": "Текстовый урок",
"description": "цуацуацуа",
"text_author": "Автор текстовог оурока",
"created_at": "2016-09-03T13:10:06Z",
"image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
"is_favorited": true,
"is_viewed": false
}
...
]
}
GET: user/views/video-lessons/
- Code: 200 OK
- Content:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_favorited": false
}
]
}
GET: user/views/text-lessons/
- Code: 200 OK
- Content:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"title": "Текстовый урок",
"description": "цуацуацуа",
"text_author": "Автор текстовог оурока",
"created_at": "2016-09-03T13:10:06Z",
"image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
"is_favorited": true,
"is_viewed": false
}
]
}
GET: text-lessons/
- Code: 200 OK
- Content:
{
"count": 50,
"next": "http://localhost:8000/text-lessons/?page=2",
"previous": null,
"results": [
{
"id": 1,
"title": "Текстовый урок",
"description": "цуацуацуа",
"text_author": "Автор текстовог оурока",
"created_at": "2016-09-03T13:10:06Z",
"image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
"is_viewed": false,
"is_favorited": true
}
]
}
GET: text-lessons/:id/
- Code: 200 OK
- Content:
{
"id": 1,
"title": "Текстовый урок",
"description": "цуацуацуа",
"text_author": "Автор текстовог оурока",
"created_at": "2016-09-03T13:10:06Z",
"image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
"is_viewed": false,
"is_favorited": false
}
POST: text-lessons/:id/favorites/
- Code: 200 OK (if already added, otherwise 201 Created)
- Content:
{
"id": 1,
"title": "Текстовый урок",
"description": "цуацуацуа",
"text_author": "Автор текстовог оурока",
"created_at": "2016-09-03T13:10:06Z",
"image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
"is_viewed": false,
"is_favorited": false
}
If not such text lesson
- Code: 400 Bad Request
- Content:
{
"error": "Feed matching query does not exist."
}
DELETE: text-lessons/:id/favorites/
- Code: 204 No Content
GET: video-lessons/
- Code: 200 OK
- Content:
{
"count": 50,
"next": "http://localhost:8000/video-lessons/?page=2",
"previous": null,
"results": [
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_favorited": true
}
]
}
GET: video-lessons/:id/
- Code: 200 OK
- Content:
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_favorited": false,
"similar_lessons": [
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_favorited": true
},
...
]
}
If not lesson
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
POST: video-lessons/:id/views/
- Code: 201 Created
- Content:
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_favorited": false,
"similar_lessons": [
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_favorited": true
},
...
]
}
If user already seen
- Code: 400 Bad Request
- Content:
{
"error": "Вы уже проголосовали за этот видеоурок."
}
POST: video-lessons/:id/favorites/
- Code: 200 OK (if already added, otherwise 201 Created)
- Content:
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_favorited": true
}
If not such video lesson
- Code: 400 Bad Request
- Content:
{
"error": "Feed matching query does not exist."
}
DELETE: video-lessons/:id/favorites/
- Code: 204 No Content
GET: online-lesson/
- 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",
"similar_lessons": [
{
"id": 1,
"video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
"video_author": "Niger",
"title": "Видео",
"description": "Видео декср",
"created_at": "2016-09-03T13:08:35Z",
"preview_image": "http://localhost:8000/media/text/images.jpg",
"is_viewed": false,
"is_responded": false
},
...
]
}
If not online lesson
- Code: 404 Not Found
- Content:
{
"error": "Онлайн трансляция не найдена."
}
POST: supports/
Parameter | Description |
---|---|
text | required(200) |
- Code: 201 Created
- Content:
{
"id": 102,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": null
},
"created_at": "2016-06-22T10:02:18.058116Z",
"text": "2323f23"
}
POST: wishes/
Parameter | Description |
---|---|
text | required(200) |
- Code: 201 Created
- Content:
{
"id": 102,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": null
},
"created_at": "2016-06-22T10:02:18.058116Z",
"text": "2323f23"
}
POST: needs/
Parameter | Description |
---|---|
title | required(50) |
text | required(200) |
priority | required(8, choices=[0, 1]) |
image | optional |
where priority: |
- 0 is "Обычная";
- 1 is "Срочная";
- Code: 201 Created
- Content:
{
"id": 6,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:11:39.413390Z",
"title": "Title image",
"description": "Description some",
"priority": 0,
"image": "http://localhost:8000/media/need_default.png",
"response_count": 0,
"is_responded": false
}
GET: needs/
- Code: 200 OK
- Content:
{
"count": 102,
"next": "http://localhost:8000/needs/?page=2",
"previous": null,
"results": [
{
"id": 6,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:11:39.413390Z",
"title": "Title image",
"description": "Description some",
"priority": 0,
"image": "http://localhost:8000/media/need_default.png",
"response_count": 0,
"is_responded": false
}
]
}
GET: needs/:id/
- Code: 200 OK
- Content:
{
"id": 6,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:11:39.413390Z",
"title": "Title image",
"description": "Description some",
"priority": 0,
"image": "http://localhost:8000/media/need_default.png",
"response_count": 0,
"is_responded": false
}
If not need
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
DELETE: needs/:id/
- Code: 204 No Content
If not need
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
If need not belongs to user
- Code: 400 Bad Request
- Content:
{
"error": "You can not remove feed that don't belongs to you."
}
POST: needs/:id/responses/
- Code: 201 Created
- Content:
{
"id": 6,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:11:39.413390Z",
"title": "Title image",
"description": "Description some",
"priority": 0,
"image": "http://localhost:8000/media/need_default.png",
"response_count": 0,
"is_responded": true
}
If user already responsed on need
- Code: 400 Bad Request
- Content:
{
"error": "Вы уже откликнулись на эту нужду"
}
GET: user/needs/
- Code: 200 OK
- Content:
{
"count": 12,
"next": "http://localhost:8000/user/needs/?page=2",
"previous": null,
"results": [
{
"id": 6,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:11:39.413390Z",
"title": "Title image",
"description": "Description some",
"priority": 0,
"image": "http://localhost:8000/media/need_default.png",
"response_count": 0,
"is_responded": false
}
]
}
POST: thanks/
Parameter | Description |
---|---|
title | required(50) |
text | required(200) |
address | required(100) |
photo | optional |
- Code: 201 Created
- Content:
{
"id": 10,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:16:36.778923Z",
"title": "Title image23f2",
"description": "Description some23f23",
"address": null,
"image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
"views_count": 0,
"is_viewed": false
}
GET: thanks/
- Code: 200 OK
- Content:
{
"count": 201,
"next": "http://localhost:8000/thanks/?page=2",
"previous": null,
"results": [
{
"id": 10,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:16:36.778923Z",
"title": "Title image23f2",
"description": "Description some23f23",
"address": null,
"image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
"views_count": 0,
"is_viewed": false
}
...
]
}
GET: thanks/:id/
- Code: 200 OK
- Content:
{
"id": 10,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:16:36.778923Z",
"title": "Title image23f2",
"description": "Description some23f23",
"address": null,
"image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
"views_count": 0,
"is_viewed": false
}
If not thank
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
DELETE: thanks/:id/
- Code: 204 No Content
If not thank
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
If thank not belongs to user
- Code: 400 Bad Request
- Content:
{
"error": "You can not remove feed that don't belongs to you."
}
POST: thanks/:id/views/
- Code: 201 Created
- Content:
{
"id": 10,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:16:36.778923Z",
"title": "Title image23f2",
"description": "Description some23f23",
"address": null,
"image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
"views_count": 0,
"is_viewed": true
}
If user already viewed this thank
- Code: 400 Bad Request
- Content:
{
"error": "Вы уже просмотрели эту благодарность."
}
GET: user/thanks/
- Code: 200 OK
- Content:
{
"count": 201,
"next": "http://localhost:8000/thanks/?page=2",
"previous": null,
"results": [
{
"id": 10,
"user": {
"id": 1,
"first_name": "",
"last_name": "",
"middle_name": ""
},
"created_at": "2016-09-03T12:16:36.778923Z",
"title": "Title image23f2",
"description": "Description some23f23",
"address": null,
"image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
"views_count": 0,
"is_viewed": false
}
...
]
}