From 09310284aee7724514e51a478e7682c42228ae75 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 15 Feb 2018 07:39:16 +0300 Subject: [PATCH 1/6] Add full cover data to lesson serializer --- api/v1/serializers/course.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/v1/serializers/course.py b/api/v1/serializers/course.py index feb6fb78..3e6f81fc 100644 --- a/api/v1/serializers/course.py +++ b/api/v1/serializers/course.py @@ -287,6 +287,9 @@ class LessonCreateSerializer(serializers.ModelSerializer): self.dispatch_content(lesson, content) return lesson + def to_representation(self, instance): + return LessonSerializer(instance, context=self.context).to_representation(instance) + class LessonSerializer(LessonCreateSerializer): # course = CourseSerializer() From d2a4513e01cd0f82b92f8071154088a28b42cd40 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 15 Feb 2018 07:50:02 +0300 Subject: [PATCH 2/6] Add pending & draft courses to user profile page --- apps/user/templates/user/profile.html | 21 +++++++++++++++++++++ apps/user/views.py | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/apps/user/templates/user/profile.html b/apps/user/templates/user/profile.html index f9d85cdb..d655a3ad 100644 --- a/apps/user/templates/user/profile.html +++ b/apps/user/templates/user/profile.html @@ -69,6 +69,13 @@ + +
@@ -85,6 +92,20 @@
+
+
+
+ {% include "course/course_items.html" with course_items=pending %} +
+
+
+
+
+
+ {% include "course/course_items.html" with course_items=drafts %} +
+
+
diff --git a/apps/user/views.py b/apps/user/views.py index 3b3f1daa..5b8675fd 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -27,6 +27,12 @@ class UserView(DetailView): context['published'] = Course.objects.filter( author=self.object, status=Course.PUBLISHED ) + context['pending'] = Course.objects.filter( + author=self.object, status=Course.PENDING + ) + context['drafts'] = Course.objects.filter( + author=self.object, status=Course.DRAFT + ) context['paid'] = Course.objects.none() return context From 4ebf579d0047317f289b6dcf0addf43f89a5923b Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 15 Feb 2018 08:48:41 +0300 Subject: [PATCH 3/6] Fix profile settings template --- apps/user/templates/user/profile-settings.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/user/templates/user/profile-settings.html b/apps/user/templates/user/profile-settings.html index 4af4e6ba..6c069960 100644 --- a/apps/user/templates/user/profile-settings.html +++ b/apps/user/templates/user/profile-settings.html @@ -152,37 +152,37 @@
INSTAGRAM
- +
FACEBOOK
- +
TWITTER
- +
PINTEREST
- +
YOUTUBE
- +
VKONTAKTE
- +
From 8ef20f5715043933c90a63791ad97f89b0a8eadd Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 15 Feb 2018 09:18:59 +0300 Subject: [PATCH 4/6] Fix DeactivatedQueryset --- project/mixins.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/project/mixins.py b/project/mixins.py index 6c6681f3..6496c259 100644 --- a/project/mixins.py +++ b/project/mixins.py @@ -10,6 +10,10 @@ class BaseModel(models.Model): class DeactivatedQueryset(models.Manager): + def get_queryset(self): + queryset = super().get_queryset() + return queryset.filter(deactivated_at__isnull=True) + def allow_delete(self): super().delete() From ade463616bc6434e6c59229c06107a616e68c13a Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 15 Feb 2018 09:20:32 +0300 Subject: [PATCH 5/6] LIL-234. Add simple templates for notification & payments settings --- .../templates/user/notification-settings.html | 71 +++++++++++++++++++ apps/user/templates/user/payment-history.html | 69 ++++++++++++++++++ .../user/templates/user/profile-settings.html | 6 +- apps/user/templates/user/profile.html | 2 +- apps/user/views.py | 16 ++++- project/urls.py | 6 +- 6 files changed, 163 insertions(+), 7 deletions(-) create mode 100644 apps/user/templates/user/notification-settings.html create mode 100644 apps/user/templates/user/payment-history.html diff --git a/apps/user/templates/user/notification-settings.html b/apps/user/templates/user/notification-settings.html new file mode 100644 index 00000000..fee35ff5 --- /dev/null +++ b/apps/user/templates/user/notification-settings.html @@ -0,0 +1,71 @@ +{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} + +
+
+
+
Подтверждение почты
+
На электронный адрес + sasha@lil.city отправлено письмо с кодом подтверждения. Введите код, чтобы подтвердить почту.
+
+
+
+ +
+
+ +
+
+ Если у вас нет кода или письмо где-то затерялось, вы можете получить новый код подтверждения. Отправить новый код? +
+
+
+
+
+
+
+
+
Уведомления и рассылка
+ + + + + + + +
+
+ +
+
+
+
+{% endblock content %} \ No newline at end of file diff --git a/apps/user/templates/user/payment-history.html b/apps/user/templates/user/payment-history.html new file mode 100644 index 00000000..fcf26606 --- /dev/null +++ b/apps/user/templates/user/payment-history.html @@ -0,0 +1,69 @@ +{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} + +
+
+
Вывести деньги со счета
+
+
+
На вашем счету 20. 123 рублей
+
+
СУММА
+
+ +
+
Размер выводимой суммы не должно быть менее 2000 рублей.
+
+
+
НОМЕР КРЕДИТНОЙ КАРТЫ + * +
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+
История платежей
+
+
+
+
Ноябрь. Школа Lil City
+
2000.00
+
Получено
+
+
+
Общий курс по иллюстрации
+
2000.00
+
Получено
+
+
+
Ноябрь. Школа Lil City
+
2000.00
+
Получено
+
+
+
+ +
+
+
+
+{% endblock content %} diff --git a/apps/user/templates/user/profile-settings.html b/apps/user/templates/user/profile-settings.html index 6c069960..ce6e1842 100644 --- a/apps/user/templates/user/profile-settings.html +++ b/apps/user/templates/user/profile-settings.html @@ -2,9 +2,9 @@ diff --git a/apps/user/templates/user/profile.html b/apps/user/templates/user/profile.html index d655a3ad..0e094c31 100644 --- a/apps/user/templates/user/profile.html +++ b/apps/user/templates/user/profile.html @@ -2,7 +2,7 @@
- Редактировать + Редактировать {% if user.photo %}
diff --git a/apps/user/views.py b/apps/user/views.py index 5b8675fd..4de9a29a 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -3,7 +3,7 @@ from PIL import Image from os.path import splitext from django.contrib.auth import login from django.shortcuts import render, reverse -from django.views.generic import DetailView, UpdateView +from django.views.generic import DetailView, UpdateView, TemplateView from django.contrib import messages from django.contrib.auth import get_user_model from django.contrib.auth.decorators import login_required, permission_required @@ -37,6 +37,20 @@ class UserView(DetailView): return context +class NotificationEditView(TemplateView): + template_name = 'user/notification-settings.html' + + def get(self, request, pk=None): + return super().get(request) + + +class PaymentHistoryView(TemplateView): + template_name = 'user/payment-history.html' + + def get(self, request, pk=None): + return super().get(request) + + class UserEditView(UpdateView): model = User template_name = 'user/profile-settings.html' diff --git a/project/urls.py b/project/urls.py index 94812354..90fa3814 100644 --- a/project/urls.py +++ b/project/urls.py @@ -24,7 +24,7 @@ from apps.course.views import ( lessoncomment, CourseEditView, ) from apps.course.models import Course -from apps.user.views import UserView, UserEditView +from apps.user.views import UserView, UserEditView, NotificationEditView, PaymentHistoryView urlpatterns = [ path('admin/', admin.site.urls), @@ -40,7 +40,9 @@ urlpatterns = [ path('lesson//comment', lessoncomment, name='lessoncomment'), path('search/', SearchView.as_view(), name='search'), path('user//', UserView.as_view(), name='user'), - path('user//edit/', UserEditView.as_view(), name='user-edit'), + path('user//edit', UserEditView.as_view(), name='user-edit-profile'), + path('user//notifications', NotificationEditView.as_view(), name='user-edit-notifications'), + path('user//payments', PaymentHistoryView.as_view(), name='user-edit-payments'), path('privacy', TemplateView.as_view(template_name="templates/lilcity/privacy_policy.html"), name='privacy'), path('terms', TemplateView.as_view(template_name="templates/lilcity/terms.html"), name='terms'), path('refund-policy', TemplateView.as_view(template_name="templates/lilcity/refund_policy.html"), name='refund_policy'), From d847be5664cdb51623ac1c40d93e8146f4c4c686 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Thu, 15 Feb 2018 09:58:33 +0300 Subject: [PATCH 6/6] Fix recursion error --- api/v1/serializers/course.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/api/v1/serializers/course.py b/api/v1/serializers/course.py index 3e6f81fc..33e6c962 100644 --- a/api/v1/serializers/course.py +++ b/api/v1/serializers/course.py @@ -291,11 +291,32 @@ class LessonCreateSerializer(serializers.ModelSerializer): return LessonSerializer(instance, context=self.context).to_representation(instance) -class LessonSerializer(LessonCreateSerializer): +class LessonSerializer(serializers.ModelSerializer): # course = CourseSerializer() cover = ImageObjectSerializer() content = ContentSerializer(many=True) + class Meta: + model = Lesson + fields = ( + 'id', + 'title', + 'short_description', + 'course', + 'cover', + 'content', + 'created_at', + 'update_at', + 'deactivated_at', + ) + + read_only_fields = ( + 'id', + 'created_at', + 'update_at', + 'deactivated_at', + ) + class CourseSerializer(CourseCreateSerializer): author = UserSerializer()