remotes/origin/hotfix/LIL-661
gzbender 8 years ago
parent 4bfa505a56
commit b93beb3d5d
  1. 3
      api/v1/views.py
  2. 8
      apps/course/templates/course/lesson.html
  3. 3
      apps/school/templates/school/livelesson_detail.html
  4. 13
      web/src/components/Comment.vue
  5. 15
      web/src/components/CommentForm.vue
  6. 16
      web/src/components/Comments.vue
  7. 13
      web/src/js/modules/api.js
  8. 69
      web/src/sass/_common.sass

@ -454,6 +454,7 @@ class ObjectCommentsViewSet(ExtendedModelViewSet):
queryset = Comment.objects.all() queryset = Comment.objects.all()
serializer_class = CommentCreateSerializer serializer_class = CommentCreateSerializer
permission_classes = (IsAuthorObjectOrAdmin,) permission_classes = (IsAuthorObjectOrAdmin,)
ordering_fields = ('update_at', )
def get_queryset(self): def get_queryset(self):
queryset = self.queryset queryset = self.queryset
@ -470,7 +471,7 @@ class ObjectCommentsViewSet(ExtendedModelViewSet):
queryset = queryset.filter(deactivated_at__isnull=True) queryset = queryset.filter(deactivated_at__isnull=True)
elif is_deactivated == '2': elif is_deactivated == '2':
queryset = queryset.filter(deactivated_at__isnull=False) queryset = queryset.filter(deactivated_at__isnull=False)
return queryset.order_by('update_at') return queryset
def get_serializer_class(self): def get_serializer_class(self):
if self.request.method == 'POST': if self.request.method == 'POST':

@ -118,13 +118,7 @@
<div class="section__center center center_sm"> <div class="section__center center center_sm">
<div class="title">Задавайте вопросы:</div> <div class="title">Задавайте вопросы:</div>
<div class="questions" id="comments_block"> <div class="questions" id="comments_block">
<comments obj-type="lesson" obj-id="{{ lesson.id }}" :is-chat="true" <comments obj-type="lesson" obj-id="{{ lesson.id }}"></comments>
{% if request.user.is_authenticated %}
user-id="{{ request.user.id }}" user-photo="{{ request.user.photo.url }}"
{% endif %}
default-author-picture="{% static 'img/user_default.jpg' %}"
access-token="{{ request.user.auth_token }}"></comments>
</div> </div>
</div> </div>
</div> </div>

@ -21,7 +21,8 @@
mozallowfullscreen allowfullscreen> mozallowfullscreen allowfullscreen>
</iframe> </iframe>
<span>Если видео не загрузилось, - уменьшите качество видео или <a href="#" onclick="location.reload();">обновите страницу</a></span> <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> <!--<iframe class="lesson__chat_frame" src="https://vimeo.com/live-chat/{{ livelesson.stream_index }}" frameborder="0"></iframe>-->
<comments obj-type="live-lesson" obj-id="{{ livelesson.id }}" :is-chat="true"></comments>
{% else %} {% else %}
{% if livelesson.cover %} {% if livelesson.cover %}
<img class="video__pic" src="{{ livelesson.cover.image.url }}"/> <img class="video__pic" src="{{ livelesson.cover.image.url }}"/>

@ -9,7 +9,7 @@
</div> </div>
<div v-if="! comment.author.photo" class="questions__ava ava"> <div v-if="! comment.author.photo" class="questions__ava ava">
<img class="ava__pic" :src="store.defaultUserPhoto"> <img class="ava__pic" :src="$root.store.defaultUserPhoto">
</div> </div>
<div class="questions__wrap"> <div class="questions__wrap">
@ -24,13 +24,13 @@
</div> </div>
</div> </div>
<div class="questions__foot" v-if="! controller.isChat"> <div class="questions__foot" v-if="! controller.isChat">
<button @click="controller.reply(comment)" v-if="store.user.id" class="questions__action question__reply-button">ОТВЕТИТЬ</button> <button @click="controller.reply(comment)" v-if="$root.store.user.id" class="questions__action question__reply-button">ОТВЕТИТЬ</button>
<button @click="controller.remove(comment)" v-if="store.user.id == comment.author.id" class="questions__action question__reply-button">УДАЛИТЬ</button> <button @click="controller.remove(comment)" v-if="$root.store.user.id == comment.author.id" class="questions__action question__reply-button">УДАЛИТЬ</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<comment-form v-if="store.user.id && !controller.$data.isChat && controller.$data.replyTo && controller.$data.replyTo.id == comment.id" <comment-form v-if="$root.store.user.id && !controller.$data.isChat && controller.$data.replyTo && controller.$data.replyTo.id == comment.id"
:controller="controller"></comment-form> :controller="controller"></comment-form>
<ul v-if="comment.children" v-for="(node, index) in comment.children" :key="index"> <ul v-if="comment.children" v-for="(node, index) in comment.children" :key="index">
@ -48,11 +48,6 @@
export default { export default {
name: 'comment', name: 'comment',
props: ['controller', 'comment',], props: ['controller', 'comment',],
data() {
return {
store: window.VUE_STORE,
}
},
computed: { computed: {
isHeart(){ isHeart(){
return this.comment.content === '❤'; return this.comment.content === '❤';

@ -1,7 +1,7 @@
<template> <template>
<div class="questions__form" :class="{'questions__item_reply': controller.$data.replyTo}"> <div class="questions__form" :class="{'questions__item_reply': controller.$data.replyTo}">
<div class="questions__ava ava"> <div class="questions__ava ava">
<img class="ava__pic" :src="store.user.photo || store.defaultUserPhoto"> <img class="ava__pic" :src="$root.store.user.photo || $root.store.defaultUserPhoto">
</div> </div>
<div class="questions__wrap"> <div class="questions__wrap">
<div class="questions__field"> <div class="questions__field">
@ -11,9 +11,15 @@
<div class="questions__form-foot"> <div class="questions__form-foot">
<button v-if="controller.isChat" class="questions__btn" <button v-if="controller.isChat" class="questions__btn"
@click="controller.addHeart"><svg class="icon questions__heart"><use xlink:href="/static/img/sprite.svg#icon-like"></use></svg></button> @click="controller.addHeart"><svg class="icon questions__heart"><use xlink:href="/static/img/sprite.svg#icon-like"></use></svg></button>
<button class="questions__btn" :class="{'btn btn_light': ! controller.isChat}" @click="add">ОТПРАВИТЬ</button> <button class="questions__btn" :class="{'btn btn_light': ! controller.isChat}" @click="add">
<button v-show="controller.$data.replyTo" class="questions__btn" :class="{'btn btn_light': ! controller.isChat}" <span :class="{'mobile-hide': controller.isChat }">ОТПРАВИТЬ</span>
@click="controller.cancelReply">ОТМЕНИТЬ</button> <span class="mobile-show" v-if="controller.isChat">
<svg class="icon questions__send-icon"><use xlink:href="/static/img/sprite.svg#icon-plus"></use></svg>
</span>
</button>
<button v-show="! controller.isChat && controller.$data.replyTo" class="questions__btn" @click="controller.cancelReply">
<span>ОТМЕНИТЬ</span>
</button>
</div> </div>
</div> </div>
</div> </div>
@ -29,7 +35,6 @@
data() { data() {
return { return {
content: '', content: '',
store: window.VUE_STORE,
} }
}, },
methods: { methods: {

@ -7,7 +7,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<comment-form v-if="store.user.id && ! replyTo" :controller="controller"></comment-form> <comment-form v-if="$root.store.user.id && ! replyTo" :controller="controller"></comment-form>
</div> </div>
</template> </template>
@ -25,7 +25,6 @@
replyTo: null, replyTo: null,
nodes: [], nodes: [],
controller: this, controller: this,
store: window.VUE_STORE,
flatComments: {}, flatComments: {},
} }
}, },
@ -44,9 +43,9 @@
this.loading = true; this.loading = true;
let request = api.addObjComment(this.objId, this.objType, { let request = api.addObjComment(this.objId, this.objType, {
content: content, content: content,
author: this.store.user.id, author: this.$root.store.user.id,
parent: this.replyTo && this.replyTo.id, parent: this.replyTo && this.replyTo.id,
}, this.store.accessToken); });
request.then((response) => { request.then((response) => {
vm.loading = false; vm.loading = false;
vm.onAdd(response.data); vm.onAdd(response.data);
@ -63,7 +62,7 @@
} }
let vm = this; let vm = this;
this.loading = true; this.loading = true;
let request = api.removeObjComment(comment.id, this.store.accessToken); let request = api.removeObjComment(comment.id);
request.then((response) => { request.then((response) => {
vm.loading = false; vm.loading = false;
vm.onRemove(comment); vm.onRemove(comment);
@ -73,11 +72,12 @@
if(this.flatComments[comment.id]){ if(this.flatComments[comment.id]){
return; return;
} }
const method = this.isChat ? 'push' : 'unshift';
if(comment.parent){ if(comment.parent){
this.flatComments[comment.parent].children.unshift(comment); this.flatComments[comment.parent].children[method](comment);
} }
else{ else{
this.nodes.unshift(comment); this.nodes[method](comment);
} }
this.flatComments[comment.id] = comment; this.flatComments[comment.id] = comment;
}, },
@ -114,7 +114,7 @@
mounted() { mounted() {
let vm = this; let vm = this;
this.loading = true; this.loading = true;
let request = api.getObjComments(this.objId, this.objType, this.store.accessToken); let request = api.getObjComments(this.objId, this.objType, this.isChat ? 'update_at' : '-update_at');
request request
.then((response) => { .then((response) => {
vm.loading = false; vm.loading = false;

@ -510,31 +510,32 @@ export const api = {
} }
}); });
}, },
getObjComments: (objId, objType, accessToken) => { getObjComments: (objId, objType, ordering) => {
return api.get('/api/v1/obj-comments/', { return api.get('/api/v1/obj-comments/', {
params: { params: {
obj_id: objId, obj_id: objId,
obj_type: objType, obj_type: objType,
ordering: ordering || '',
}, },
headers: { headers: {
'Authorization': `Token ${accessToken}`, 'Authorization': `Token ${window.LIL_STORE.accessToken}`,
} }
}); });
}, },
addObjComment: (objId, objType, commentJson, accessToken) => { addObjComment: (objId, objType, commentJson) => {
let data = commentJson; let data = commentJson;
data.obj_id = objId; data.obj_id = objId;
data.obj_type = objType; data.obj_type = objType;
return api.post('/api/v1/obj-comments/', data, { return api.post('/api/v1/obj-comments/', data, {
headers: { headers: {
'Authorization': `Token ${accessToken}`, 'Authorization': `Token ${window.LIL_STORE.accessToken}`,
} }
}); });
}, },
removeObjComment: (commentId, accessToken) => { removeObjComment: (commentId) => {
return api.delete(`/api/v1/obj-comments/${commentId}/`, { return api.delete(`/api/v1/obj-comments/${commentId}/`, {
headers: { headers: {
'Authorization': `Token ${accessToken}`, 'Authorization': `Token ${window.LIL_STORE.accessToken}`,
} }
}); });
} }

@ -2819,10 +2819,12 @@ a.grey-link
&__item &__item
&:not(:last-child) &:not(:last-child)
margin-bottom: 25px margin-bottom: 25px
+m
padding: 10px 0
&_reply &_reply
padding-left: 80px padding-left: 80px
+m +m
padding: 0 padding: 10px 0
&__reply-info &__reply-info
display: none display: none
margin-bottom: 10px margin-bottom: 10px
@ -2863,6 +2865,8 @@ a.grey-link
&__btn &__btn
margin: 0 15px; margin: 0 15px;
border-radius: 20px border-radius: 20px
+m
margin-left: 0
&__details &__details
margin-bottom: 5px margin-bottom: 5px
&__head, &__head,
@ -2881,6 +2885,7 @@ a.grey-link
&__author &__author
margin-right: 15px margin-right: 15px
&__date &__date
font-size: 10px
display: inline-block display: inline-block
&__foot &__foot
height: 20px height: 20px
@ -2891,36 +2896,51 @@ a.grey-link
fill: #d40700 fill: #d40700
width: 28px width: 28px
height: 28px height: 28px
&__send-icon
fill: $gray
width: 20px
height: 20px
&--heart &--heart
&__content &__content
font-size: 24px; font-size: 24px;
color: #d40700; color: #d40700;
&--chat &__items &--chat &__items
background: white; background: white;
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 5px;
max-height: 400px; max-height: 400px;
overflow: auto; overflow: auto;
+m
max-height: inherit
&--chat &__item, &--chat &__item_reply
+m
padding: 0
&--chat &__ava &--chat &__ava
height: 40px height: 40px
margin-right: 10px margin-right: 10px
flex: 0 0 40px flex: 0 0 40px
+m
display: none
&--chat &__content &--chat &__content
margin-bottom: 10px margin-bottom: 10px
&--chat &__wrap &--chat &__wrap
display: flex display: flex
flex: 0 0 calc(100% - 60px); flex: 0 0 calc(100% - 60px);
+m
flex: 1
&--chat &__field &--chat &__field
margin-bottom: 0; margin-bottom: 0;
flex: 0 0 calc(100% - 160px); flex: 0 0 calc(100% - 160px);
+m
flex: 1
&--chat &__btn &--chat &__btn
font-weight: 600; font-weight: 600;
text-shadow: 1px 1px #fff; text-shadow: 1px 1px #fff;
+m
margin: 0 0 0 15px;
&--chat &__form-foot &--chat &__form-foot
display: flex; display: flex;
.share .share
&__title &__title
@ -3702,6 +3722,11 @@ a.grey-link
+m +m
display: none display: none
.mobile-show
display: none
+m
display: block
.school .school
display: flex display: flex
position: relative position: relative

Loading…
Cancel
Save