stash
This commit is contained in:
parent
4799a7cd5d
commit
69ce11c331
4 changed files with 50 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from tickets.models import IssueThread, Comment, StateChange, Assignment, ItemRelation
|
||||
from tickets.models import IssueThread, Comment, StateChange, Assignment, ItemRelation, ShippingCode
|
||||
|
||||
|
||||
class IssueThreadAdmin(admin.ModelAdmin):
|
||||
|
@ -23,8 +23,13 @@ class ItemRelationAdmin(admin.ModelAdmin):
|
|||
pass
|
||||
|
||||
|
||||
class ShippingCodesAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
admin.site.register(IssueThread, IssueThreadAdmin)
|
||||
admin.site.register(Comment, CommentAdmin)
|
||||
admin.site.register(StateChange, StateChangeAdmin)
|
||||
admin.site.register(Assignment, AssignmentAdmin)
|
||||
admin.site.register(ItemRelation, ItemRelationAdmin)
|
||||
admin.site.register(ShippingCode, ShippingCodesAdmin)
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.test import TestCase, Client
|
|||
|
||||
from authentication.models import ExtendedUser
|
||||
from mail.models import Email, EmailAttachment
|
||||
from tickets.models import IssueThread, StateChange, Comment
|
||||
from tickets.models import IssueThread, StateChange, Comment, ShippingCode
|
||||
from django.contrib.auth.models import Permission
|
||||
from knox.models import AuthToken
|
||||
|
||||
|
@ -24,8 +24,17 @@ class ShippingCodeApiTest(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json(), [])
|
||||
|
||||
def test_issues_list(self):
|
||||
ShippingCode.objects.create(code='1234', type='2kg-eu')
|
||||
response = self.client.get('/api/2/shipping_codes/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json()[0]['code'], '1234')
|
||||
self.assertEqual(response.json()[0]['used_at'], None)
|
||||
self.assertEqual(response.json()[0]['issue_thread'], None)
|
||||
self.assertEqual(response.json()[0]['type'], '2kg-eu')
|
||||
|
||||
def test_issues_create(self):
|
||||
response = self.client.post('/api/2/shipping_codes/', {'code': '1234'})
|
||||
response = self.client.post('/api/2/shipping_codes/', {'code': '1234', 'type': '2kg-eu'})
|
||||
self.assertEqual(response.status_code, 201)
|
||||
self.assertEqual(response.json()['code'], '1234')
|
||||
self.assertEqual(response.json()['used_at'], None)
|
||||
|
|
|
@ -434,12 +434,11 @@ const store = createStore({
|
|||
commit('setMessageTemplates', data);
|
||||
}
|
||||
},
|
||||
async updateMessageTemplate({commit, state}, template) {
|
||||
async updateMessageTemplate({dispatch, state}, template) {
|
||||
const {data, success} = await http.patch(`/2/message_templates/${template.id}/`,
|
||||
{'message': template.message}, state.user.token);
|
||||
const {data: newTemplates, success: newSuccess} = await http.get('/2/message_templates/', state.user.token);
|
||||
if (data && success) {
|
||||
commit('setMessageTemplates', data);
|
||||
dispatch('fetchMessageTemplates');
|
||||
}
|
||||
},
|
||||
async fetchMessageTemplateVariables({commit, state}) {
|
||||
|
@ -448,11 +447,13 @@ const store = createStore({
|
|||
commit('setMessageTemplateVariables', data);
|
||||
}
|
||||
},
|
||||
async createMessageTemplate({commit, state}, template_name) {
|
||||
const {data, success} = await http.post('/2/message_templates/', {name: template_name, message: '-'}, state.user.token);
|
||||
const {data: newTemplates, success: newSuccess} = await http.get('/2/message_templates/', state.user.token);
|
||||
async createMessageTemplate({dispatch, state}, template_name) {
|
||||
const {data, success} = await http.post('/2/message_templates/', {
|
||||
name: template_name,
|
||||
message: '-'
|
||||
}, state.user.token);
|
||||
if (data && success) {
|
||||
commit('setMessageTemplates', data);
|
||||
dispatch('fetchMessageTemplates');
|
||||
}
|
||||
},
|
||||
async fetchShippingCodes({commit, state}) {
|
||||
|
@ -461,10 +462,10 @@ const store = createStore({
|
|||
commit('setShippingCodes', data);
|
||||
}
|
||||
},
|
||||
async createShippingCode({commit, state}, code) {
|
||||
async createShippingCode({dispatch, state}, code) {
|
||||
const {data, success} = await http.post('/2/shipping_codes/', code, state.user.token);
|
||||
if (data && success) {
|
||||
commit('setShippingCodes', data);
|
||||
dispatch('fetchShippingCodes');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<h3>Shipping Codes</h3>
|
||||
<ul>
|
||||
<li v-for="code in shippingCodes" :key="code.code">
|
||||
{{ code.type }} - {{ code.code }}
|
||||
<span v-if="code.issue_thread == null">{{ code.type }} - {{ code.code }}</span>
|
||||
<span v-else><s>{{ code.type }} - {{ code.code }}</s> <a
|
||||
:href="'/'+ getEventSlug + '/ticket/' + code.issue_thread">Issue</a></span>
|
||||
</li>
|
||||
</ul>
|
||||
<!--Table
|
||||
|
@ -25,15 +27,16 @@
|
|||
</template>
|
||||
</Table-->
|
||||
<div class="mt-3">
|
||||
<textarea class="form-control mb-3" rows="5" placeholder="Shipping Code List" v-model="bulk_codes" v-if="bulk"></textarea>
|
||||
<textarea class="form-control mb-3" rows="5" placeholder="Shipping Code List" v-model="bulk_codes"
|
||||
v-if="bulk"></textarea>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Shipping Code" v-model="code" v-if="!bulk">
|
||||
<select class="form-control" v-model="type">
|
||||
<option value="2kg-eu">2kg DE</option>
|
||||
<option value="2kg-uk">2kg EU</option>
|
||||
<option value="2kg-us">5kg DE</option>
|
||||
<option value="2kg-us">5kg EU</option>
|
||||
<option value="2kg-us">10kg DE</option>
|
||||
<option value="2kg-de">2kg DE</option>
|
||||
<option value="2kg-eu">2kg EU</option>
|
||||
<option value="5kg-de">5kg DE</option>
|
||||
<option value="5kg-eu">5kg EU</option>
|
||||
<option value="10kg-de">10kg DE</option>
|
||||
</select>
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">
|
||||
|
@ -51,7 +54,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {mapActions, mapState} from 'vuex';
|
||||
import {mapActions, mapGetters, mapState} from 'vuex';
|
||||
import Table from '@/components/Table';
|
||||
|
||||
export default {
|
||||
|
@ -65,18 +68,24 @@ export default {
|
|||
bulk: false,
|
||||
};
|
||||
},
|
||||
computed: mapState(['shippingCodes']),
|
||||
computed: {
|
||||
...mapState(['shippingCodes']),
|
||||
...mapGetters(['getEventSlug']),
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['fetchShippingCodes', 'createShippingCode']),
|
||||
createSingleOrBulkShippingCode() {
|
||||
if (this.bulk) {
|
||||
this.bulk_codes.split('\n').forEach(code => {
|
||||
this.createShippingCode({code: code.trim(), type: this.type});
|
||||
const jobs = this.bulk_codes.split('\n').map(code => {
|
||||
return this.createShippingCode({code: code.trim(), type: this.type});
|
||||
});
|
||||
Promise.all(jobs).then(() => {
|
||||
this.bulk_codes = '';
|
||||
});
|
||||
} else {
|
||||
this.createShippingCode({code: this.code, type: this.type});
|
||||
this.createShippingCode({code: this.code, type: this.type}).then(() => {
|
||||
this.code = '';
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue