diff --git a/api/v1/serializers/config.py b/api/v1/serializers/config.py
index 526d2066..9298a024 100644
--- a/api/v1/serializers/config.py
+++ b/api/v1/serializers/config.py
@@ -27,6 +27,9 @@ class ConfigSerializer(serializers.ModelSerializer):
REFERRAL_BONUS = serializers.IntegerField()
MAIN_PAGE_VIDEO_URL = serializers.CharField(required=False)
MAIN_PAGE_VIDEO_PREVIEW_IMG = serializers.SerializerMethodField()
+ NUMBER_OF_STUDENTS = serializers.IntegerField()
+ NUMBER_OF_COUNTRIES = serializers.IntegerField()
+ NUMBER_OF_CITIES = serializers.IntegerField()
class Meta:
model = Config
@@ -50,6 +53,9 @@ class ConfigSerializer(serializers.ModelSerializer):
'REFERRAL_BONUS',
'MAIN_PAGE_VIDEO_URL',
'MAIN_PAGE_VIDEO_PREVIEW_IMG',
+ 'NUMBER_OF_STUDENTS',
+ 'NUMBER_OF_COUNTRIES',
+ 'NUMBER_OF_CITIES',
)
def get_SCHOOL_LOGO_IMAGE(self, config):
diff --git a/apps/config/migrations/0014_auto_20190605_1338.py b/apps/config/migrations/0014_auto_20190605_1338.py
new file mode 100644
index 00000000..a89f0dc8
--- /dev/null
+++ b/apps/config/migrations/0014_auto_20190605_1338.py
@@ -0,0 +1,28 @@
+# Generated by Django 2.0.7 on 2019-06-05 13:38
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('config', '0013_config_main_page_video_preview_img'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='config',
+ name='NUMBER_OF_CITIES',
+ field=models.IntegerField(default=107),
+ ),
+ migrations.AddField(
+ model_name='config',
+ name='NUMBER_OF_COUNTRIES',
+ field=models.IntegerField(default=81),
+ ),
+ migrations.AddField(
+ model_name='config',
+ name='NUMBER_OF_STUDENTS',
+ field=models.IntegerField(default=17000),
+ ),
+ ]
diff --git a/apps/config/models.py b/apps/config/models.py
index 18756e20..daf9bc0e 100644
--- a/apps/config/models.py
+++ b/apps/config/models.py
@@ -23,6 +23,9 @@ class Config(models.Model):
REFERRAL_BONUS = models.IntegerField(default=10)
MAIN_PAGE_VIDEO_URL = models.URLField(max_length=126, default='https://www.youtube.com/embed/1w3amQGtQyc')
MAIN_PAGE_VIDEO_PREVIEW_IMG = models.ImageField(null=True, blank=True)
+ NUMBER_OF_STUDENTS = models.IntegerField(default=17000)
+ NUMBER_OF_COUNTRIES = models.IntegerField(default=81)
+ NUMBER_OF_CITIES = models.IntegerField(default=107)
def save(self, *args, **kwargs):
self.pk = 1
@@ -57,5 +60,8 @@ class Config(models.Model):
'REFERRAL_BONUS': '',
'MAIN_PAGE_VIDEO_URL': '',
'MAIN_PAGE_VIDEO_PREVIEW_IMG': '',
+ 'NUMBER_OF_STUDENTS': '',
+ 'NUMBER_OF_COUNTRIES': '',
+ 'NUMBER_OF_CITIES': '',
}
return obj
diff --git a/apps/course/templatetags/plural.py b/apps/course/templatetags/plural.py
index 8637d05c..e6327347 100644
--- a/apps/course/templatetags/plural.py
+++ b/apps/course/templatetags/plural.py
@@ -4,14 +4,23 @@ from django.template.defaultfilters import stringfilter
register = template.Library()
-@register.filter(is_safe=False)
-@stringfilter
-def rupluralize(value, arg):
+def _ruplural(value, arg):
args = arg.split(',')
try:
_value = str(0 if not value or int(value) <= 0 else value)[-1:]
- value = value + ' ' + args[0 if _value == '1' else (1 if _value in '234' else 2)]
- return value
+ return args[0 if _value == '1' else (1 if _value in '234' else 2)]
except:
raise template.TemplateSyntaxError
return ''
+
+
+@register.filter(is_safe=False)
+@stringfilter
+def rupluralize(value, arg):
+ return value + ' ' + _ruplural(value, arg)
+
+
+@register.filter(is_safe=False)
+@stringfilter
+def ruplural(value, arg):
+ return _ruplural(value, arg)
diff --git a/project/templates/blocks/about.html b/project/templates/blocks/about.html
index d86d6cf7..71a8b0b6 100644
--- a/project/templates/blocks/about.html
+++ b/project/templates/blocks/about.html
@@ -1,4 +1,5 @@
{% load static %}
+{% load ruplural from plural %}
@@ -20,26 +21,26 @@
-
> 12000
-
учеников
+
> {{ config.NUMBER_OF_STUDENTS }}
+
{{ config.NUMBER_OF_STUDENTS|ruplural:'ученик,ученика,учеников' }}
прошли обучение в Lil School
{{ works_count }}
-
работ
+
{{ works_count|ruplural:'работа,работы,работ' }}
создано учениками Lil School.
Большую часть из них легко найти в
инстаграм
-
32
-
страны
+
{{ config.NUMBER_OF_COUNTRIES }}
+
{{ config.NUMBER_OF_COUNTRIES|ruplural:'страна,страны,стран' }}
где живут талантливые ученики Lil School
-
107
-
городов
+
{{ config.NUMBER_OF_CITIES }}
+
{{ config.NUMBER_OF_CITIES|ruplural:'город,города,городов' }}
со всего мира со счастливыми учениками Lil School
diff --git a/web/src/js/modules/api.js b/web/src/js/modules/api.js
index 6ce13717..cbf27e8f 100644
--- a/web/src/js/modules/api.js
+++ b/web/src/js/modules/api.js
@@ -89,13 +89,6 @@ export const api = {
}
});
},
- likeCourse: (courseId) => {
- return api.post(`/api/v1/courses/${courseId}/like`, {
- headers: {
- 'Authorization': `Token ${window.LIL_STORE.accessToken}`,
- }
- });
- },
loadLive: (courseId, accessToken) => {
return api.get(`/api/v1/live-lesson/${courseId}/`, {
headers: {
diff --git a/web/src/js/modules/content.js b/web/src/js/modules/content.js
index e12df7ed..6be64da8 100644
--- a/web/src/js/modules/content.js
+++ b/web/src/js/modules/content.js
@@ -1,23 +1,13 @@
import $ from 'jquery';
import {loadScript} from '../utils';
-import {api} from '../modules/api';
function getVideoPopup($videoEl){
const $container = $videoEl.parent();
- const courseId = $videoEl.data('courseId');
let $popup = $container.children('.video-ended-popup');
if(! $popup[0]){
- $popup = $('');
- /*if(courseId){
- $popup.addClass('video-ended-popup_black');
-
- $popup.find('.video-ended-popup__like-btn').click(() => {
- api.likeCourse(courseId).then(() => {
- $popup.addClass('video-ended-popup_black');
- });
- });
- }*/
-
+ $popup = $('');
$container.append($popup);
}
return $popup;
@@ -34,16 +24,36 @@ $(document).ready(function () {
const player = new Vimeo.Player(this);
player.on('pause', function(data) {
if(data.percent == 1){
- getVideoPopup($iframe).show().animate({opacity: 1}, 200);
+ const $popup = getVideoPopup($iframe);
+ $popup.show().animate({opacity: 1}, 200);
if (document.fullscreenElement){
document.exitFullscreen();
}
+ const courseId = $iframe.data('courseId');
+ if(courseId && window.LIL_STORE.user.id && !window.LIL_STORE.data.courseLiked){
+ $popup.addClass('video-ended-popup_loading');
+ $.get('/api/v1/likes/course-liked/', {
+ course_id: courseId,
+ user_id: window.LIL_STORE.user.id
+ }).then(response => {
+ if(! response.is_liked){
+ $popup.addClass('video-ended-popup_like');
+ $popup.find('.video-ended-popup__like-btn').click(() => {
+ $.post(`/course/${courseId}/like`).then(response => {
+ $popup.removeClass('video-ended-popup_like');
+ window.LIL_STORE.data.courseLiked = response.success;
+ });
+ });
+ }
+ $popup.removeClass('video-ended-popup_loading');
+ });
+ }
}
});
player.on('play', function() {
const $p = getVideoPopup($iframe);
if($p.is(':visible')){
- $p.animate({opacity: 0}, 800).then(() => {$p.hide();});
+ $p.animate({opacity: 0}, 800).then(() => {$p.hide().attr('class', 'video-ended-popup');});
}
});
});
diff --git a/web/src/js/modules/courses.js b/web/src/js/modules/courses.js
index 8b94d36d..f6cb4152 100644
--- a/web/src/js/modules/courses.js
+++ b/web/src/js/modules/courses.js
@@ -91,9 +91,11 @@ $(document).ready(function () {
if (data.is_liked) {
likedCourseElement.addClass('active');
likedCourseElement.attr('data-liked', '1');
+ window.LIL_STORE.data.courseLiked = true;
} else {
likedCourseElement.removeClass('active');
likedCourseElement.attr('data-liked', '0');
+ window.LIL_STORE.data.courseLiked = false;
}
}
})
diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass
index e7b0a5b6..d1be59bd 100755
--- a/web/src/sass/_common.sass
+++ b/web/src/sass/_common.sass
@@ -4801,12 +4801,21 @@ a
background-color: #151a1e
margin-left: 0
+ & .loading-loader
+ display: none
+
&_like
background-image: url(../img/video-ended-popup-like.jpg)
&_black
background: url(../img/video-ended-popup-logo.png) no-repeat center #141a1d
+ &_loading
+ background: #141a1d
+
+ &_loading .loading-loader
+ display: block
+
&__like-btn
background: url(../img/heart.png) no-repeat center
position: absolute