From 89a60f00460da79299f2a275e60bb0d1a3f573a1 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 22 Aug 2018 21:52:13 +0500 Subject: [PATCH] =?UTF-8?q?LIL-623=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BD=D1=8B=D0=B9=20?= =?UTF-8?q?=D1=83=D1=80=D0=BE=D0=BA=20=D1=83=20=D0=BF=D1=80=D0=B5=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/user/forms.py | 2 ++ apps/user/migrations/0023_user_trial_lesson.py | 18 ++++++++++++++++++ apps/user/models.py | 1 + apps/user/templates/user/profile-settings.html | 13 ++++++++++++- apps/user/views.py | 5 +++++ project/templates/blocks/teachers.html | 17 +++++++++++------ web/src/sass/_common.sass | 7 +++++++ 7 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 apps/user/migrations/0023_user_trial_lesson.py diff --git a/apps/user/forms.py b/apps/user/forms.py index 2445d522..d20ee0ea 100644 --- a/apps/user/forms.py +++ b/apps/user/forms.py @@ -18,6 +18,7 @@ class UserEditForm(forms.ModelForm): # gender = forms.ChoiceField(choices=User.GENDER_CHOICES, required=False) gender = forms.CharField(required=False) # about = forms.CharField() + trial_lesson = forms.URLField(required=False) old_password = forms.CharField(required=False) new_password1 = forms.CharField(required=False) new_password2 = forms.CharField(required=False) @@ -41,6 +42,7 @@ class UserEditForm(forms.ModelForm): 'birthday', 'gender', 'about', + 'trial_lesson', 'old_password', 'new_password1', 'new_password2', diff --git a/apps/user/migrations/0023_user_trial_lesson.py b/apps/user/migrations/0023_user_trial_lesson.py new file mode 100644 index 00000000..33a0aab5 --- /dev/null +++ b/apps/user/migrations/0023_user_trial_lesson.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.6 on 2018-08-22 12:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('user', '0022_user_instagram_hashtag'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='trial_lesson', + field=models.URLField(blank=True, default='', null=True), + ), + ] diff --git a/apps/user/models.py b/apps/user/models.py index 7391b0c8..0df7cd01 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -75,6 +75,7 @@ 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) objects = UserManager() diff --git a/apps/user/templates/user/profile-settings.html b/apps/user/templates/user/profile-settings.html index 5502c21d..90470b96 100644 --- a/apps/user/templates/user/profile-settings.html +++ b/apps/user/templates/user/profile-settings.html @@ -150,7 +150,18 @@ {% for error in form.about.errors %}
{{ error }}
{% endfor %} - + + {% if is_teacher %} +
+
Пробный урок
+
+ +
+ {% for error in form.trial_lesson.errors %} +
{{ error }}
+ {% endfor %} +
+ {% endif %}
Пароль
diff --git a/apps/user/views.py b/apps/user/views.py index 309fb0e0..a14daef6 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -210,6 +210,11 @@ class ProfileEditView(UpdateView): self.object = self.get_object() return super().dispatch(request, *args, **kwargs) + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['is_teacher'] = self.object.role == User.TEACHER_ROLE + return context + def post(self, request, *args, **kwargs): # it's magic *-*-*-*-* if 'photo' in request.FILES: diff --git a/project/templates/blocks/teachers.html b/project/templates/blocks/teachers.html index 2b251b33..4cea46f3 100644 --- a/project/templates/blocks/teachers.html +++ b/project/templates/blocks/teachers.html @@ -17,10 +17,15 @@
- {{ teacher.get_full_name }}{% if teacher.instagram_hashtag %}, - - {{ teacher.instagram_hashtag }} - +
+ {{ teacher.get_full_name }}{% if teacher.instagram_hashtag %}, + + {{ teacher.instagram_hashtag }} + + {% endif %} +
+ {% if teacher.trial_lesson %} + ПРОБНЫЙ УРОК {% endif %}