Merge branch 'master' of https://gitlab.com/lilcity/backend into feature/LIL-582

remotes/origin/hotfix/LIL-661
gzbender 8 years ago
commit e2671221cb
  1. 14
      api/v1/views.py
  2. 2
      apps/course/templates/course/_items.html
  3. 19
      apps/course/templates/course/lesson.html
  4. 2
      apps/payment/models.py
  5. 9
      apps/payment/views.py
  6. 15
      apps/school/templates/school/livelesson_detail.html
  7. 4
      web/package.json
  8. 41
      web/src/components/blocks/Image.vue
  9. 22
      web/src/sass/_common.sass

@ -426,10 +426,10 @@ class AuthorRequestViewSet(ExtendedModelViewSet):
class PaymentViewSet(ExtendedModelViewSet):
queryset = Payment.objects.filter(status__isnull=False).order_by('-created_at')
queryset = Payment.objects.all()
serializer_class = PaymentSerializer
permission_classes = (IsAdmin,)
filter_fields = ('status',)
filter_fields = ('status', 'user',)
ordering_fields = (
'id', 'user__email',
'user__first_name', 'user__last_name',
@ -437,6 +437,16 @@ class PaymentViewSet(ExtendedModelViewSet):
)
search_fields = ('user__email', 'user__first_name', 'user__last_name',)
def get_queryset(self):
queryset = self.queryset
course = self.request.query_params.get('course')
weekdays = self.request.query_params.getlist('weekdays[]')
if course:
queryset = CoursePayment.objects.filter(course=course)
if weekdays:
queryset = SchoolPayment.objects.filter(weekdays__overlap=weekdays)
return queryset.filter(status__isnull=False).order_by('-created_at')
class ContestViewSet(ExtendedModelViewSet):
queryset = Contest.objects.all()

@ -48,7 +48,7 @@
</a>
<div class="courses__details">
<a class="courses__theme theme {{ theme_color }}"
href="{% url 'courses' %}?category={{ course.category.title }}">{{ course.category | upper }}</a>
href="{% url 'courses' %}?category={{ course.category.id }}">{{ course.category | upper }}</a>
{% if not course.is_free %}
<div class="courses__price">{{ course.price|floatformat:"-2" }}₽</div>
{% endif %}

@ -37,6 +37,25 @@
<div>
<div class="lesson__subtitle subtitle">{{ lesson.title }}</div>
<div class="lesson__content">{{ lesson.short_description }}</div>
<a href="{% url 'user' lesson.author.id %}">
<div class="lesson__user user">
{% if lesson.author.photo %}
<div class="user__ava ava">
<img class="ava__pic" src="{{ lesson.author.photo.url }}">
</div>
{% else %}
<div class="user__ava ava">
<img class="ava__pic" src="{% static 'img/user_default.jpg' %}">
</div>
{% endif %}
<div class="user__info">
<div class="user__name">{{ lesson.author.get_full_name }}</div>
<div class="user__meta">
<div class="user__date">{{ lesson.created_at_humanize }}</div>
</div>
</div>
</div>
</a>
</div>
</div>
</div>

@ -190,7 +190,7 @@ class SchoolPayment(Payment):
month_price_sum = aggregate.get('month_price__sum', 0) * weekday_count // all_weekday_count
else:
month_price_sum = aggregate.get('month_price__sum', 0)
if month_price_sum >= config.SERVICE_DISCOUNT_MIN_AMOUNT:
if self.id is None and month_price_sum >= config.SERVICE_DISCOUNT_MIN_AMOUNT:
discount = config.SERVICE_DISCOUNT
else:
discount = 0

@ -197,12 +197,18 @@ class PaymentwallCallbackView(View):
payment.status = pingback.get_type()
payment.data = payment_raw_data
if pingback.is_deliverable():
effective_amount = pingback.get_parameter('effective_price_amount')
if effective_amount:
payment.amount = effective_amount
transaction_to_mixpanel.delay(
payment.user.id,
payment.amount,
now().strftime('%Y-%m-%dT%H:%M:%S'),
product_type_name,
)
if product_type_name == 'school':
school_payment = SchoolPayment.objects.filter(
user=payment.user,
@ -252,6 +258,7 @@ class PaymentwallCallbackView(View):
'update_at': payment.update_at,
}
payment.save()
product_payment_to_mixpanel.delay(
payment.user.id,
f'{product_type_name.title()} payment',
@ -269,6 +276,7 @@ class PaymentwallCallbackView(View):
product_type_name,
payment.roistat_visit,
)
author_balance = getattr(payment, 'author_balance', None)
if author_balance and author_balance.type == AuthorBalance.IN:
if pingback.is_deliverable():
@ -277,7 +285,6 @@ class PaymentwallCallbackView(View):
payment.author_balance.status = AuthorBalance.PENDING
else:
payment.author_balance.status = AuthorBalance.DECLINED
payment.author_balance.save()
return HttpResponse('OK')
else:

@ -8,20 +8,19 @@
<div class="lesson">
<div class="lesson__subtitle subtitle">{{ livelesson.title }}</div>
<div class="lesson__content">{{ livelesson.short_description }}</div>
<div class="lesson__video video">
{% if livelesson.stream_index %}
<a class="lesson__video video" href="#">
<iframe class="lesson__video_frame" src="https://player.vimeo.com/video/{{ livelesson.stream_index }}?autoplay=1" frameborder="0" webkitallowfullscreen
mozallowfullscreen allowfullscreen>
</iframe>
</a>
Если видео не загрузилось, уменьшите качество видео или <a href="#" onclick="location.reload();">обновите страницу</a>
<iframe class="lesson__video_frame" src="https://player.vimeo.com/video/{{ livelesson.stream_index }}?autoplay=1" frameborder="0" webkitallowfullscreen
mozallowfullscreen allowfullscreen>
</iframe>
<span>Если видео не загрузилось, - уменьшите качество видео или <a href="#" onclick="location.reload();">обновите страницу</a></span>
<iframe class="lesson__chat_frame" src="https://vimeo.com/live-chat/{{ livelesson.stream_index }}" frameborder="0"></iframe>
{% else %}
{% if livelesson.cover %}
<img class="video__pic" src="{{ livelesson.cover.image.url }}"/>
{% else %}
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>

@ -34,9 +34,13 @@
"webpack": "^3.10.0"
},
"dependencies": {
"autosize": "^4.0.2",
"autosize-input": "^1.0.2",
"axios": "^0.17.1",
"babel-polyfill": "^6.26.0",
"baguettebox.js": "^1.10.0",
"downscale": "^1.0.4",
"glob": "^7.1.2",
"history": "^4.7.2",
"ilyabirman-likely": "^2.3.0",
"inputmask": "^3.3.11",

@ -1,5 +1,5 @@
<template>
<div class="kit__photo" :class="{ 'has-image': !! imageUrl }">
<div class="kit__photo" :class="{ 'loading': loading, 'has-image': !! imageUrl }">
<svg class="icon icon-add-plus" v-if="!imageUrl">
<use xlink:href="/static/img/sprite.svg#icon-add-plus"></use>
</svg>
@ -10,6 +10,7 @@
<script>
import {api} from "../../js/modules/api";
import downscale from 'downscale';
export default {
name: "lil-image",
@ -22,19 +23,37 @@
methods: {
onImageAdded(event) {
this.loading = true;
const maxSize = 1600;
let file = event.target.files[0];
let reader = new FileReader();
const reader = new FileReader();
reader.onload = () => {
api.uploadImage(reader.result, this.accessToken)
.then((response) => {
this.loading = false;
this.$emit('update:imageId', response.data.id);
this.$emit('update:imageUrl', response.data.image);
})
.catch((error) => {
this.loading = false;
console.log('error', error);
let img = document.createElement('img');
img.onload = () => {
let w = 0;
let h = 0;
if(img.width > img.height) {
w = maxSize;
h = 0;
}
else {
w = 0;
h = maxSize;
}
downscale(img.src, w, h).then((dataURL) => {
img = null;
api.uploadImage(dataURL, this.accessToken)
.then((response) => {
this.loading = false;
this.$emit('update:imageId', response.data.id);
this.$emit('update:imageUrl', response.data.image);
})
.catch((error) => {
this.loading = false;
console.log('error', error);
});
});
}
img.src = reader.result;
};
if (file) {
reader.readAsDataURL(file);

@ -2725,6 +2725,8 @@ a.grey-link
object-fit: cover
width: 100%
height: 100%
&__user
margin-bottom: 30px
.lessons
@ -3480,6 +3482,24 @@ a.grey-link
.icon
font-size: 20px
fill: #B5B5B5
&.loading &-image
visibility: hidden
&.loading
.icon
visibility: hidden
&:after
content: ''
position: absolute
top: 50%
left: 50%
width: 24px
height: 24px
margin: -12px 0 0 -12px
border: 3px solid #B5B5B5
border-left: 3px solid transparent
border-radius: 50%
animation: loading .6s infinite linear
&__file
position: absolute
top: 0
@ -3886,7 +3906,7 @@ a.grey-link
position: relative
padding-left: 17px
&:before
content: ''
content: '-'
position: absolute
top: 0
left: 0

Loading…
Cancel
Save