LIL-670 Добавить кнопку удаления рядом с комментарием

remotes/origin/hotfix/LIL-691
gzbender 7 years ago
parent 534fb4467e
commit 09e3bd4315
  1. 4
      api/v1/views.py
  2. 7
      project/templates/blocks/lil_store_js.html
  3. 13
      web/src/components/Comment.vue
  4. 7
      web/src/sass/_common.sass

@ -1,7 +1,7 @@
from django.contrib.auth import get_user_model
from rest_framework import status, views, viewsets, generics
from rest_framework.decorators import detail_route, list_route, action
from rest_framework.decorators import detail_route, list_route, action, permission_classes
from rest_framework.response import Response
from . import ExtendedModelViewSet
@ -451,7 +451,6 @@ class CommentViewSet(ExtendedModelViewSet):
class ObjectCommentsViewSet(ExtendedModelViewSet):
queryset = Comment.objects.all()
serializer_class = CommentCreateSerializer
permission_classes = (IsAuthorObjectOrAdmin,)
ordering_fields = ('update_at', )
def get_queryset(self):
@ -495,6 +494,7 @@ class ObjectCommentsViewSet(ExtendedModelViewSet):
except Exception as e:
print(e)
@permission_classes((IsAuthorObjectOrAdmin,))
def perform_destroy(self, instance):
obj_type = None
obj_id = None

@ -2,6 +2,12 @@
{% load setting from settings %}
<script>
window.LIL_STORE = {
roles: {
USER_ROLE: 0,
AUTHOR_ROLE: 1,
TEACHER_ROLE: 2,
ADMIN_ROLE: 3,
},
pusherKey: '{% setting "PUSHER_KEY" %}',
staticUrl: '{% static "" %}',
accessToken: '{{ request.user.auth_token }}',
@ -9,6 +15,7 @@
defaultUserPhoto: "{% static 'img/user_default.jpg' %}",
user: {
id: '{{ request.user.id|default:'' }}',
role: +'{{ request.user.role }}',
photo: '{% if request.user.photo %}{{ request.user.photo.url }}{% else %}{% static 'img/user_default.jpg' %}{% endif %}',
}
};

@ -23,9 +23,16 @@
<span v-if="! isHeart">{{ comment.content }}</span>
</div>
</div>
<div class="questions__foot" v-if="! controller.isChat">
<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="$root.store.user.id == comment.author.id" class="questions__action question__reply-button">УДАЛИТЬ</button>
<div class="questions__foot">
<button @click="controller.reply(comment)" v-if="$root.store.user.id && ! controller.isChat" class="questions__action question__reply-button">ОТВЕТИТЬ</button>
<button @click="controller.remove(comment)"
v-if="$root.store.user.id == comment.author.id || $root.store.user.role == $root.store.roles.ADMIN_ROLE"
class="questions__action question__reply-button">
<span v-if="! controller.isChat">УДАЛИТЬ</span>
<span v-if="controller.isChat">
<svg class="icon questions__delete-icon"><use xlink:href="/static/img/sprite.svg#icon-delete"></use></svg>
</span>
</button>
</div>
</div>
</div>

@ -2872,6 +2872,7 @@ a.grey-link
margin-left: 0
&__details
margin-bottom: 5px
flex: 1
&__head,
&__action
+fb
@ -2903,6 +2904,12 @@ a.grey-link
fill: $gray
width: 20px
height: 20px
&__delete-icon
fill: #C8C8C8
width: 17px
height: 17px
:hover
fill: #000000
&--heart
&__content
font-size: 24px

Loading…
Cancel
Save