This commit is contained in:
j3d1 2023-12-06 04:51:47 +01:00
parent 999dc95b0b
commit 76dd805262
8 changed files with 72 additions and 28 deletions

View file

@ -8,8 +8,8 @@ class IssueSerializer(serializers.ModelSerializer):
class Meta:
model = IssueThread
fields = ('id', 'timeline')
read_only_fields = ('id', 'timeline')
fields = ('id', 'timeline', 'name', 'state', 'assigned_to', 'last_activity')
read_only_fields = ('id', 'timeline', 'last_activity')
@staticmethod
def get_timeline(obj):

View file

@ -1,24 +0,0 @@
# Generated by Django 4.2.7 on 2023-12-06 03:34
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tickets', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='issue_thread',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='tickets.issuethread'),
),
migrations.AlterField(
model_name='statechange',
name='issue_thread',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state_changes', to='tickets.issuethread'),
),
]

View file

@ -0,0 +1,45 @@
# Generated by Django 4.2.7 on 2023-12-06 03:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tickets', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='issuethread',
name='assigned_to',
field=models.CharField(max_length=255, null=True),
),
migrations.AddField(
model_name='issuethread',
name='last_activity',
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name='issuethread',
name='name',
field=models.CharField(default='unnamed issue', max_length=255),
preserve_default=False,
),
migrations.AddField(
model_name='issuethread',
name='state',
field=models.CharField(default='new', max_length=255),
),
migrations.AlterField(
model_name='comment',
name='issue_thread',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='tickets.issuethread'),
),
migrations.AlterField(
model_name='statechange',
name='issue_thread',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state_changes', to='tickets.issuethread'),
),
]

View file

@ -6,6 +6,10 @@ from inventory.models import Event
class IssueThread(SoftDeleteModel):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
state = models.CharField(max_length=255, default='new')
assigned_to = models.CharField(max_length=255, null=True)
last_activity = models.DateTimeField(auto_now=True)
class Comment(models.Model):

View file

@ -50,6 +50,10 @@ class IssueApiTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.json()), 1)
self.assertEqual(response.json()[0]['id'], issue.id)
self.assertEqual(response.json()[0]['name'], issue.name)
self.assertEqual(response.json()[0]['state'], issue.state)
self.assertEqual(response.json()[0]['assigned_to'], issue.assigned_to)
self.assertEqual(response.json()[0]['last_activity'], issue.last_activity.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
self.assertEqual(len(response.json()[0]['timeline']), 4)
self.assertEqual(response.json()[0]['timeline'][0]['type'], 'mail')
self.assertEqual(response.json()[0]['timeline'][1]['type'], 'state')

View file

@ -112,7 +112,7 @@ export default {
};
</script>
<style lang="scss">
<style lang="scss" scoped>
@import "../scss/navbar.scss";
.nav-tabs {
@ -131,6 +131,7 @@ export default {
padding-bottom: 1rem !important;
border: var(--gray) solid 1px !important;
border-bottom: none !important;
color: var(--blue) !important;
&.active {
background: black !important;

View file

@ -123,6 +123,13 @@ const store = new Vuex.Store({
appendItem(state, item) {
state.loadedItems.push(item);
},
replaceTickets(state, tickets) {
state.tickets = tickets;
},
updateTicket(state, updatedTicket) {
const ticket = state.tickets.filter(({id}) => id === updatedTicket.id)[0];
Object.assign(ticket, updatedTicket);
},
createToast(state, {title, message, color}) {
var toast = {title, message, color, key: state.keyIncrement}
state.toasts.push(toast);
@ -179,7 +186,11 @@ const store = new Vuex.Store({
commit('updateLastUsed', {box: item.box, cid: item.cid});
const {data} = await axios.post(`/1/${getters.getEventSlug}/item`, item);
commit('appendItem', data);
}
},
async loadTickets({commit}) {
const {data} = await axios.get('/2/tickets/');
commit('replaceTickets', data);
},
}
});

View file

@ -37,6 +37,9 @@ export default {
gotoDetail(ticket) {
this.$router.push({name: 'ticket', params: {id: ticket.id}});
}
},
created() {
this.$store.dispatch('loadTickets');
}
};
</script>