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 %}