From f1bf09cd0dd695af52bd595f91c84245e4b49ee4 Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 27 Sep 2018 15:58:39 +0500 Subject: [PATCH] =?UTF-8?q?LIL-626=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=C2=A0=D0=BB=D0=B8=D0=BD=D0=BA=20=D0=BD=D0=B0=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=84=D0=B8=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0045_merge_20180926_0200.py | 14 +++++ apps/course/templates/course/_items.html | 4 +- apps/course/templates/course/course.html | 4 +- .../templates/course/course_only_lessons.html | 2 +- apps/course/templates/course/lesson.html | 2 +- apps/user/forms.py | 1 + apps/user/migrations/0024_user_slug.py | 18 +++++++ apps/user/models.py | 10 ++++ .../user/templates/user/profile-settings.html | 36 +++++++------ apps/user/views.py | 1 + project/settings.py | 1 + project/templates/blocks/lil_store_js.html | 5 +- project/templates/blocks/teachers.html | 2 +- project/urls.py | 1 + web/src/js/app.js | 12 ++++- web/src/js/modules/profile.js | 54 ++++++++++++++----- web/src/sass/_common.sass | 4 ++ 17 files changed, 132 insertions(+), 39 deletions(-) create mode 100644 apps/course/migrations/0045_merge_20180926_0200.py create mode 100644 apps/user/migrations/0024_user_slug.py diff --git a/apps/course/migrations/0045_merge_20180926_0200.py b/apps/course/migrations/0045_merge_20180926_0200.py new file mode 100644 index 00000000..9d49802a --- /dev/null +++ b/apps/course/migrations/0045_merge_20180926_0200.py @@ -0,0 +1,14 @@ +# Generated by Django 2.0.6 on 2018-09-26 02:00 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('course', '0044_course_age'), + ('course', '0044_livelessoncomment'), + ] + + operations = [ + ] diff --git a/apps/course/templates/course/_items.html b/apps/course/templates/course/_items.html index f27bd326..0bb7c7d2 100644 --- a/apps/course/templates/course/_items.html +++ b/apps/course/templates/course/_items.html @@ -57,7 +57,7 @@
{{ course.short_description | safe | linebreaks | truncatechars_html:300 }}
- + {% if course.author.photo %}
@@ -69,7 +69,7 @@ {% endif %}
- +
{{ course.author.get_full_name }}
diff --git a/apps/course/templates/course/course.html b/apps/course/templates/course/course.html index 2502b9a0..5b651689 100644 --- a/apps/course/templates/course/course.html +++ b/apps/course/templates/course/course.html @@ -74,7 +74,7 @@
{{ course.title }}
{{ course.short_description | safe | linebreaks }}
- +
{% if course.author.photo %}
@@ -274,7 +274,7 @@
{{ course.title }}
{{ course.short_description | safe | linebreaks }}
-
+
{% if course.author.photo %}
diff --git a/apps/course/templates/course/course_only_lessons.html b/apps/course/templates/course/course_only_lessons.html index 0e6e601d..b603874b 100644 --- a/apps/course/templates/course/course_only_lessons.html +++ b/apps/course/templates/course/course_only_lessons.html @@ -72,7 +72,7 @@
{{ course.title }}
{{ course.short_description | safe | linebreaks }}
-
+
{% if course.author.photo %}
diff --git a/apps/course/templates/course/lesson.html b/apps/course/templates/course/lesson.html index 547bb402..f6fb6a9c 100644 --- a/apps/course/templates/course/lesson.html +++ b/apps/course/templates/course/lesson.html @@ -34,7 +34,7 @@
{{ lesson.title }}
{{ lesson.short_description | safe | linebreaks }}
-
+
{% if lesson.author.photo %}
diff --git a/apps/user/forms.py b/apps/user/forms.py index d20ee0ea..e6092adf 100644 --- a/apps/user/forms.py +++ b/apps/user/forms.py @@ -36,6 +36,7 @@ class UserEditForm(forms.ModelForm): 'first_name', 'last_name', 'email', + 'slug', 'phone', 'city', 'country', diff --git a/apps/user/migrations/0024_user_slug.py b/apps/user/migrations/0024_user_slug.py new file mode 100644 index 00000000..3ebe7d0a --- /dev/null +++ b/apps/user/migrations/0024_user_slug.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.6 on 2018-09-26 13:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('user', '0023_user_trial_lesson'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='slug', + field=models.SlugField(allow_unicode=True, blank=True, max_length=100, null=True, unique=True), + ), + ] diff --git a/apps/user/models.py b/apps/user/models.py index 47008960..f9723e31 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -1,4 +1,5 @@ from json import dumps + from rest_framework.authtoken.models import Token from phonenumber_field.modelfields import PhoneNumberField @@ -9,6 +10,7 @@ from django.contrib.auth.models import AbstractUser, UserManager as BaseUserMana from django.contrib.postgres import fields as pgfields from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ +from django.urls import reverse from api.v1 import serializers from apps.notification.utils import send_email @@ -76,6 +78,10 @@ class User(AbstractUser): photo = models.ImageField('Фото', null=True, blank=True, upload_to='users') show_in_mainpage = models.BooleanField('Показывать на главной странице', default=False) trial_lesson = models.URLField(default='', null=True, blank=True) + slug = models.SlugField( + allow_unicode=True, null=True, blank=True, + max_length=100, unique=True, db_index=True, + ) objects = UserManager() @@ -85,6 +91,10 @@ class User(AbstractUser): class Meta(AbstractUser.Meta): ordering = ('-date_joined',) + @property + def url(self): + return reverse('user', args=[self.slug or self.id]) + def serialized(self): user_data = serializers.user.UserSerializer(instance=self).data user_data = dumps(user_data, ensure_ascii=False) diff --git a/apps/user/templates/user/profile-settings.html b/apps/user/templates/user/profile-settings.html index 90470b96..cf1dc2e1 100644 --- a/apps/user/templates/user/profile-settings.html +++ b/apps/user/templates/user/profile-settings.html @@ -1,4 +1,8 @@ -{% extends "templates/lilcity/index.html" %} {% load static %} {% load thumbnail %} {% block content %} +{% extends "templates/lilcity/index.html" %} +{% load static %} +{% load settings %} +{% load thumbnail %} +{% block content %}