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..4a0ccf0e 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', @@ -57,7 +58,7 @@ class UserEditForm(forms.ModelForm): class WithdrawalForm(forms.Form): - amount = forms.DecimalField(required=True, min_value=2000) + amount = forms.DecimalField(required=True, min_value=10000) card = CreditCardField(required=True) 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 fced16c5..84d9a329 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -11,6 +11,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 @@ -77,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() @@ -86,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/blocks/profile-menu.html b/apps/user/templates/blocks/profile-menu.html index 9db83d44..5bb21b94 100644 --- a/apps/user/templates/blocks/profile-menu.html +++ b/apps/user/templates/blocks/profile-menu.html @@ -7,8 +7,8 @@ href="{% url 'user-edit-notifications' %}">Уведомления Платежи - Бонусы + +
diff --git a/apps/user/templates/user/payment-history.html b/apps/user/templates/user/payment-history.html index ab152901..b30eee13 100644 --- a/apps/user/templates/user/payment-history.html +++ b/apps/user/templates/user/payment-history.html @@ -33,9 +33,9 @@
СУММА
- +
-
Размер выводимой суммы не должно быть менее 2000 рублей.
+
Размер выводимой суммы не должен быть менее 10 000 рублей.
{% if form.amount.errors %}
{{ form.amount.errors }}
{% endif %} diff --git a/apps/user/templates/user/profile-settings.html b/apps/user/templates/user/profile-settings.html index 08e56da8..436cb374 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 %} {% include "../blocks/profile-menu.html" with active="profile" %} {% if not user.is_email_proved %}
@@ -36,7 +40,7 @@ {% empty %} {% endthumbnail %} - +
@@ -47,7 +51,7 @@
ИМЯ
- +
{% for error in form.first_name.errors %}
{{ error }}
@@ -56,7 +60,7 @@
ФАМИЛИЯ
- +
{% for error in form.last_name.errors %}
{{ error }}
@@ -81,6 +85,17 @@
{{ error }}
{% endfor %}
+
+
Ссылка
+
+
{% setting 'MAIN_HOST' %}/user/
+ +
+ {% for error in form.slug.errors %} +
{{ error }}
+ {% endfor %} +
ГОРОД
@@ -249,19 +264,6 @@
- {% endblock content %} diff --git a/apps/user/views.py b/apps/user/views.py index 249a1b41..6f54861d 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -97,6 +97,7 @@ class ProfileView(TemplateView): class UserView(DetailView): model = User template_name = 'user/author_profile.html' + query_pk_and_slug = True def get_context_data(self, object): context = super().get_context_data() diff --git a/project/templates/blocks/lil_store_js.html b/project/templates/blocks/lil_store_js.html index 8f3197a3..0d19b124 100644 --- a/project/templates/blocks/lil_store_js.html +++ b/project/templates/blocks/lil_store_js.html @@ -20,8 +20,9 @@ }, components: {}, urls: { - courses: "{% url 'courses' %}" - }, + courses: "{% url 'courses' %}", + userProfileEdit: "{% url 'user-edit-profile' %}", + } flags: { referrer: '{{ referrer.id|default:'' }}', referrerName: '{% if referrer %}{{ referrer.get_full_name }}{% endif %}', diff --git a/project/templates/blocks/teachers.html b/project/templates/blocks/teachers.html index 492ca66d..32b022bd 100644 --- a/project/templates/blocks/teachers.html +++ b/project/templates/blocks/teachers.html @@ -18,7 +18,7 @@
- {{ teacher.get_full_name }}{% if teacher.instagram_hashtag %}, + {{ teacher.get_full_name }}{% if teacher.instagram_hashtag %}, {{ teacher.instagram_hashtag }} diff --git a/project/templates/blocks/user_menu.html b/project/templates/blocks/user_menu.html index a1fdbca8..b3343158 100644 --- a/project/templates/blocks/user_menu.html +++ b/project/templates/blocks/user_menu.html @@ -16,9 +16,9 @@ {{ request.user.balance }} руб. {% endif %} - - {{ request.user.bonus|rupluralize:"бонус,бонуса,бонусов" }} - + + + {% if request.user.auth_token %} {% if request.user.role >= request.user.AUTHOR_ROLE %} diff --git a/project/urls.py b/project/urls.py index b5721fb6..cf0a3c0c 100644 --- a/project/urls.py +++ b/project/urls.py @@ -70,6 +70,7 @@ urlpatterns = [ path('user/profile/', ProfileView.as_view(), name='user-profile'), path('user/profile/edit', ProfileEditView.as_view(), name='user-edit-profile'), path('user//', UserView.as_view(), name='user'), + path('user//', UserView.as_view(), name='user'), path('user/notifications', NotificationEditView.as_view(), name='user-edit-notifications'), path('user/payments', PaymentHistoryView.as_view(), name='user-edit-payments'), path('user/bonuses', BonusHistoryView.as_view(), name='user-bonuses'), diff --git a/web/src/js/app.js b/web/src/js/app.js index f72d6767..5cee336e 100644 --- a/web/src/js/app.js +++ b/web/src/js/app.js @@ -17,7 +17,7 @@ import "./modules/courses"; import "./modules/comments"; import "./modules/comments"; import "./modules/password-show"; -import "./modules/profile"; +import {main as profileMain} from "./modules/profile"; import "./modules/notification"; import "./modules/mixpanel"; @@ -55,5 +55,15 @@ const app = new Vue({ store: window.LIL_STORE, } }, + mounted(){ + if(this.urlIs('userProfileEdit')){ + profileMain(this); + } + }, + methods: { + urlIs(urlPatternName){ + return window.location.pathname.search(this.store.urls[urlPatternName]) > -1; + }, + }, components: components }); diff --git a/web/src/js/modules/profile.js b/web/src/js/modules/profile.js index 585c35cb..3942f125 100644 --- a/web/src/js/modules/profile.js +++ b/web/src/js/modules/profile.js @@ -1,18 +1,48 @@ import $ from 'jquery'; +import slugify from 'slugify'; -$(document).ready(function () { - // Обработчик выбора пола - let genderInput = $('#gender') +export const main = () => { + // Обработчик выбора пола + let genderInput = $('#gender') - $('div.js-select-option[data-gender-option]').on('click', function (e) { - e.preventDefault(); - const currentGender = $(this).attr('data-gender'); - $('[data-gender]').removeClass('active'); - $(`[data-gender=${currentGender}]`).addClass('active'); - genderInput.val(currentGender) - }); + $('div.js-select-option[data-gender-option]').on('click', function (e) { + e.preventDefault(); + const currentGender = $(this).attr('data-gender'); + $('[data-gender]').removeClass('active'); + $(`[data-gender=${currentGender}]`).addClass('active'); + genderInput.val(currentGender) + }); - $('#referrer-url').select().click(function(){ - $(this).select(); - }); -}) + $('#user-photo-upload').change(file => { + const input = file.target; + + const reader = new FileReader(); + reader.onload = () => { + const dataURL = reader.result; + const output = document.getElementById('photo'); + output.src = dataURL; + }; + reader.readAsDataURL(input.files[0]); + }); + + const $slug = $('#user-slug'); + const changeSlug = () => { + const fName = $('#user-first-name').val(); + const lName = $('#user-last-name').val(); + $slug.val(slugify(`${fName} ${lName}`)); + } + + if(! $slug.data('current-slug')){ + $('#user-first-name').change(changeSlug); + $('#user-last-name').change(changeSlug); + $slug.change(() => { + $('#user-first-name').unbind('change', changeSlug); + $('#user-last-name').unbind('change', changeSlug); + }); + changeSlug(); + } + + $('#referrer-url').select().click(function(){ + $(this).select(); + }); +} diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index 56747a04..afe6fd2c 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -2167,6 +2167,10 @@ a.grey-link width: 100px &__append text-transform: uppercase + &__text + height: 36px + font-size: 18px + padding-top: 6px &__input, &__textarea width: 100%