stash
This commit is contained in:
parent
67cfd61d63
commit
d6aff053fe
3 changed files with 32 additions and 23 deletions
|
@ -5,7 +5,7 @@ from rest_framework.decorators import api_view, permission_classes
|
||||||
from rest_framework.permissions import IsAuthenticated
|
from rest_framework.permissions import IsAuthenticated
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from notifications.models import MessageTemplate
|
from notifications.models import MessageTemplate, UserNotificationChannel
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from notifications.templates import TEMPLATE_VARS
|
from notifications.templates import TEMPLATE_VARS
|
||||||
|
@ -17,11 +17,22 @@ class MessageTemplateSerializer(serializers.ModelSerializer):
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class UserNotificationChannelSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = UserNotificationChannel
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class MessageTemplateViewSet(viewsets.ModelViewSet):
|
class MessageTemplateViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = MessageTemplateSerializer
|
serializer_class = MessageTemplateSerializer
|
||||||
queryset = MessageTemplate.objects.all()
|
queryset = MessageTemplate.objects.all()
|
||||||
|
|
||||||
|
|
||||||
|
class UserNotificationChannelViewSet(viewsets.ModelViewSet):
|
||||||
|
serializer_class = UserNotificationChannelSerializer
|
||||||
|
queryset = UserNotificationChannel.objects.all()
|
||||||
|
|
||||||
|
|
||||||
@api_view(['GET'])
|
@api_view(['GET'])
|
||||||
@permission_classes([IsAuthenticated])
|
@permission_classes([IsAuthenticated])
|
||||||
@permission_required('tickets.add_issuethread_manual', raise_exception=True) # TDOO: change this permission
|
@permission_required('tickets.add_issuethread_manual', raise_exception=True) # TDOO: change this permission
|
||||||
|
@ -31,7 +42,7 @@ def get_template_vars(self):
|
||||||
|
|
||||||
router = routers.SimpleRouter()
|
router = routers.SimpleRouter()
|
||||||
router.register(r'message_templates', MessageTemplateViewSet)
|
router.register(r'message_templates', MessageTemplateViewSet)
|
||||||
|
router.register(r'user_notification_channels', UserNotificationChannelViewSet)
|
||||||
urlpatterns = ([
|
urlpatterns = ([
|
||||||
re_path('message_template_variables', get_template_vars),
|
re_path('message_template_variables', get_template_vars),
|
||||||
] + router.urls)
|
] + router.urls)
|
||||||
|
|
|
@ -20,6 +20,7 @@ const store = createStore({
|
||||||
messageTemplates: [],
|
messageTemplates: [],
|
||||||
messageTemplateVariables: [],
|
messageTemplateVariables: [],
|
||||||
shippingVouchers: [],
|
shippingVouchers: [],
|
||||||
|
userNotificationChannels: [],
|
||||||
|
|
||||||
loadedItems: {},
|
loadedItems: {},
|
||||||
loadedTickets: {},
|
loadedTickets: {},
|
||||||
|
@ -540,8 +541,15 @@ const store = createStore({
|
||||||
state.fetchedData.tickets = 0;
|
state.fetchedData.tickets = 0;
|
||||||
await Promise.all([dispatch('loadTickets'), dispatch('fetchShippingVouchers')]);
|
await Promise.all([dispatch('loadTickets'), dispatch('fetchShippingVouchers')]);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
async fetchUserNotificationChannels({commit, state}) {
|
||||||
|
if (!state.user.token) return;
|
||||||
|
const {data, success} = await http.get('/2/user_notification_channels/', state.user.token);
|
||||||
|
if (data && success) {
|
||||||
|
state.userNotificationChannels = data;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
persistentStatePlugin({ // TODO change remember to some kind of enable field
|
persistentStatePlugin({ // TODO change remember to some kind of enable field
|
||||||
prefix: "lf_",
|
prefix: "lf_",
|
||||||
|
|
|
@ -1,22 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<Table
|
<ul>
|
||||||
:columns="['slug', 'name']"
|
<li v-for="channel in userNotificationChannels" :key="channel.id">
|
||||||
:items="events"
|
{{ channel.name }}
|
||||||
:keyName="'slug'"
|
</li>
|
||||||
>
|
</ul>
|
||||||
<template #actions="{ item }">
|
|
||||||
<div class="btn-group">
|
|
||||||
<button class="btn btn-secondary" @click.stop="changeEvent(item)">
|
|
||||||
<font-awesome-icon icon="archive"/>
|
|
||||||
use
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-danger" @click.stop="">
|
|
||||||
<font-awesome-icon icon="trash"/>
|
|
||||||
delete
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</Table>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -26,8 +13,11 @@ import Table from '@/components/Table';
|
||||||
export default {
|
export default {
|
||||||
name: 'Notifications',
|
name: 'Notifications',
|
||||||
components: {Table},
|
components: {Table},
|
||||||
computed: mapState(['events']),
|
computed: mapState(['userNotificationChannels']),
|
||||||
methods: mapActions(['changeEvent']),
|
methods: mapActions(['fetchUserNotificationChannels']),
|
||||||
|
mounted() {
|
||||||
|
this.fetchUserNotificationChannels();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue