diff --git a/apps/auth/views.py b/apps/auth/views.py index 4cea8327..6c3cd79b 100644 --- a/apps/auth/views.py +++ b/apps/auth/views.py @@ -11,6 +11,7 @@ from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt from django.views.generic import FormView, View from django.views.generic.edit import BaseFormView +from django.shortcuts import redirect from apps.notification.utils import send_email from .forms import LearnerRegistrationForm @@ -56,9 +57,9 @@ class LearnerRegistrationView(FormView): class LogoutView(View): - def post(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): logout(request) - return JsonResponse({"success": True}) + return redirect('/') class LoginView(FormView): diff --git a/apps/course/models.py b/apps/course/models.py index 12db9652..2cbc6d27 100644 --- a/apps/course/models.py +++ b/apps/course/models.py @@ -18,10 +18,13 @@ class Like(models.Model): class Course(models.Model): + PENDING = 0 + PUBLISHED = 1 + ARCHIVED = 2 STATUS_CHOICES = ( - (0, 'Pending'), - (1, 'Published'), - (2, 'Archived'), + (PENDING, 'Pending'), + (PUBLISHED, 'Published'), + (ARCHIVED, 'Archived'), ) author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) title = models.CharField('Название курса', max_length=100, db_index=True) diff --git a/apps/user/templates/user/profile.html b/apps/user/templates/user/profile.html new file mode 100644 index 00000000..2142dca5 --- /dev/null +++ b/apps/user/templates/user/profile.html @@ -0,0 +1,92 @@ +{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} +
+
+
+ Редактировать + {% if user.photo %} +
+ +
+ {% else %} +
+ +
+ {% endif %} +
+
{{ user.get_full_name }}
+ +
+
+ {{ user.about }} +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+ {% include "course/course_items.html" with course_items=paid %} +
+
+
+
+
+
+ {% include "course/course_items.html" with course_items=published %} +
+
+
+
+
+
+
+{% endblock content %} \ No newline at end of file diff --git a/apps/user/views.py b/apps/user/views.py index 91ea44a2..18d7c9ce 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -1,3 +1,18 @@ from django.shortcuts import render +from django.views.generic import DetailView +from django.contrib.auth import get_user_model -# Create your views here. +from apps.course.models import Course + +User = get_user_model() + + +class UserView(DetailView): + model = User + template_name = 'user/profile.html' + + def get_context_data(self, object): + context = super().get_context_data() + context['published'] = Course.objects.filter(author=self.object, status=Course.PUBLISHED) + context['paid'] = Course.objects.none() + return context diff --git a/project/templates/lilcity/index.html b/project/templates/lilcity/index.html index 82789c1b..ad4b9122 100644 --- a/project/templates/lilcity/index.html +++ b/project/templates/lilcity/index.html @@ -70,8 +70,8 @@ -