- 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;
- 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/);
- https://nodeadscloudapp.herokuapp.com now deprecated; Use http://5.101.125.15:8484 instead;
- added /video-lessons/latest/ and /text-lessons/latest/ to docs;
- removed data generation from url;
- 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);
- updated translation for error messages;
- added banner routes;
- added short description of all routes;
- added new tests: for registration and banners;
- 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!);
- 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);
- added is_viewed field for video and text lessons;
- added similar lessons for video lessons;
- fixed bug with date filter;
- added search filter for user needs and thanks;
- changed priorities for needs: 0 - is "Обычная" now (default priority on server), 1 - "Срочная";
- changes of keys in /video-lessons/ and /video-lessons/id:int/:
- video -> video_url (Note: see videos section for detailed answer)
- 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;
- added functionality for text and video lessons views (see views section);
http://5.101.125.15:8484/api/v1/
- git clone http://5.101.125.14/DeV1doR/CloudApp.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
TODO: add faq;
- 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 response on need
- API for get all user needs
- API for add thank
- API for get all thanks
- API for detailed thanks
- 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": "Введите корректный адрес электронной почты."
}
POST: password/reset/confirm/
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))
Parameter | Description |
---|---|
uid | required |
token | required |
new_password1 | required(8) |
new_password2 | required(8) |
- Code: 200 OK
- Content:
{
"success": "Пароль был успешно изменен."
}
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 символов."
}
GET: user/
Get current logged user profile data
Parameter | Description |
---|---|
id | logged user id |
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 |
- 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
}
PUT | PATCH: user/
Update current user profile data
Parameter | Description |
---|---|
photo | optional(max=100 - for name) |
first_name | optional(max=30) |
last_name | optional(max=30) |
patronymic | optional(max=30) |
optional(max=254 - RFC 3696 standart) | |
city | optional(max=30) |
phone | optional(max=30) |
start_url | optional(max=200) |
- 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
}
If image invalid
- Code: 400 Bad Request
- Content:
{
"photo": "Загруженный файл не является корректным файлом. "
}
GET: consultants/
Get consultant list with their rmail, phone, skype and photo.
- 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"
},
...
]
}
GET: user/banners/
Get user banners with title, text, url for redirect and banner photo.
- 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/"
},
...
]
}
GET: user/banners/current/
Get one random banner from user banners pool.
- 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/"
}
If not banner in pool or user already viewed all banners in pool
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
PATCH: user/banners/(id:int)/
Send route for banner preview by current user.
- Code: 204 No Content
If user already viewed this banner or banner does not exist
- Code: 400 Bad Request
- Content:
{
"error": "Этот баннер недоступен или просмотрен уже этим пользователем."
}
GET: user/favorites/video-lessons/
- 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
}
]
}
GET: user/favorites/text-lessons/
- 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
}
]
}
GET: user/views/video-lessons/
- 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
}
]
}
GET: user/views/text-lessons/
- 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
}
]
}
GET: text-lessons/
- 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"
}
]
}
GET: text-lessons/(id:int)/
- 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"
}
POST: text-lessons/<id:int>/favorites/
- 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
}
If not such text lesson
- Code: 400 Bad Request
- Content:
{
"text_lesson": "Недопустимый первичный ключ \"134234\" - объект не существует."
}
DELETE: text-lessons/<id:int>/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,
"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
}
]
}
GET: video-lessons/(id:int)/
- 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
},
...
]
}
If not lesson
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
POST: video-lessons/(id:int)/views/
- 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
},
...
]
}
If user already seen
- Code: 400 Bad Request
- Content:
{
"error": "Вы уже проголосовали за этот видеоурок."
}
POST: video-lessons/<id:int>/favorites/
- 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
}
If not such video lesson
- Code: 400 Bad Request
- Content:
{
"video_lesson": "Недопустимый первичный ключ \"134234\" - объект не существует."
}
DELETE: video-lessons/<id:int>/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",
"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
},
...
]
}
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": "",
"patronymic": 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": "",
"patronymic": 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]) |
photo | optional |
where priority: |
- 0 is "Обычная";
- 1 is "Срочная";
- 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
}
GET: needs/
- 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
}
]
}
GET: needs/(id:int)/
- 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
}
If not need
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
POST: needs/(id:int)/views/
- 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
}
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": 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
}
]
}
POST: thanks/
Parameter | Description |
---|---|
title | required(50) |
text | required(200) |
address | required(100) |
photo | optional |
- 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
}
GET: thanks/
- 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
}
]
}
GET: thanks/(id:int)/
- 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
}
If not thank
- Code: 404 Not Found
- Content:
{
"error": "Не найдено."
}
POST: thanks/(id:int)/views/
- 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
}
If user already viewed this thank
- Code: 400 Bad Request
- Content:
{
"error": "Вы уже просмотрели эту благодарность."
}
GET: user/thanks/
- 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
}
]
}