Merge remote-tracking branch 'origin/master' into feature/lil-580

# Conflicts:
#	apps/school/templates/school/livelesson_detail.html
remotes/origin/hotfix/LIL-661
nikita 8 years ago
commit 78d7ee0de6
  1. 15
      api/v1/views.py
  2. 2
      apps/course/templates/course/_items.html
  3. 2
      apps/payment/models.py
  4. 9
      apps/payment/views.py
  5. 13
      apps/school/templates/school/livelesson_detail.html
  6. 4
      web/package.json
  7. 43
      web/src/components/blocks/Image.vue
  8. 18
      web/src/sass/_common.sass

@ -419,13 +419,24 @@ 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',
'amount', 'created_at',
)
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')

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

@ -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>
<a class="lesson__video video" href="#">
<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 }}"/>
{% 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">
<div class="kit__photo" :class="{'loading': loading}">
<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);
@ -51,4 +70,4 @@
display: block;
object-fit: contain;
}
</style>
</style>

@ -3482,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

Loading…
Cancel
Save