Merge branch 'hotfix/LIL-619' into 'master'

LIL-619 Выводить превью, а не оригиналы для обложек уроков

See merge request lilcity/backend!115
remotes/origin/hotfix/LIL-661
cfwme 8 years ago
commit 8a918d77db
  1. 3
      apps/course/models.py
  2. 2
      apps/course/templates/course/course_only_lessons.html
  3. 2
      apps/course/templates/course/lesson.html
  4. 8
      web/src/components/blocks/Image.vue

@ -4,7 +4,6 @@ from uuid import uuid4
from django.db import models from django.db import models
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils import timezone from django.utils import timezone
from django.utils.text import slugify
from django.utils.timezone import now from django.utils.timezone import now
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.urls import reverse_lazy from django.urls import reverse_lazy
@ -13,8 +12,6 @@ from polymorphic_tree.models import PolymorphicMPTTModel, PolymorphicTreeForeign
from project.mixins import BaseModel, DeactivatedMixin from project.mixins import BaseModel, DeactivatedMixin
from .manager import CategoryQuerySet
from apps.content.models import ImageObject, Gallery, Video, ContestWork from apps.content.models import ImageObject, Gallery, Video, ContestWork
User = get_user_model() User = get_user_model()

@ -184,7 +184,7 @@
<div class="lessons__preview"> <div class="lessons__preview">
<div class="lessons__pic-wrapper"> <div class="lessons__pic-wrapper">
<img class="lessons__pic" <img class="lessons__pic"
src="{% if lesson.cover %}{{ lesson.cover.image.url }}{% else %}{% static 'img/no_cover.png' %}{% endif %}"> src="{% if lesson.cover %}{{ lesson.cover.image_thumbnail.url }}{% else %}{% static 'img/no_cover.png' %}{% endif %}">
</div> </div>
</div> </div>
<div> <div>

@ -31,7 +31,7 @@
<div class="lesson__preview"> <div class="lesson__preview">
<div class="lesson__pic-wrapper"> <div class="lesson__pic-wrapper">
<img class="lesson__pic" <img class="lesson__pic"
src="{% if lesson.cover %}{{ lesson.cover.image.url }}{% else %}{% static 'img/no_cover.png' %}{% endif %}"> src="{% if lesson.cover %}{{ lesson.cover.image_thumbnail.url }}{% else %}{% static 'img/no_cover.png' %}{% endif %}">
</div> </div>
</div> </div>
<div> <div>

@ -14,7 +14,7 @@
export default { export default {
name: "lil-image", name: "lil-image",
props: ["imageId", "imageUrl", "accessToken"], props: ["imageId", "imageUrl", "accessToken", "longSide"],
data() { data() {
return { return {
loading: false, loading: false,
@ -23,7 +23,7 @@
methods: { methods: {
onImageAdded(event) { onImageAdded(event) {
this.loading = true; this.loading = true;
const maxSize = 1600; const longSide = +this.longSide || 1600;
let file = event.target.files[0]; let file = event.target.files[0];
const reader = new FileReader(); const reader = new FileReader();
reader.onload = () => { reader.onload = () => {
@ -32,12 +32,12 @@
let w = 0; let w = 0;
let h = 0; let h = 0;
if(img.width > img.height) { if(img.width > img.height) {
w = maxSize; w = longSide;
h = 0; h = 0;
} }
else { else {
w = 0; w = 0;
h = maxSize; h = longSide;
} }
downscale(img.src, w, h).then((dataURL) => { downscale(img.src, w, h).then((dataURL) => {
img = null; img = null;

Loading…
Cancel
Save