Publisher JSON is now all lowercase

This commit is contained in:
konrad 2017-11-29 16:23:19 +01:00 committed by kolaente
parent 6f22a1a671
commit 37a39cbae6
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 16 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<template>
<div v-if="user.authenticated">
<h1>{{ publisher.Name }}</h1>
<h1>{{ publisher.name }}</h1>
<div class="ui info message" v-if="loading">
<icon name="refresh" spin></icon>&nbsp;&nbsp;
@ -51,7 +51,7 @@
this.publisherList = [
{
header: this.translate('general').name,
content: this.publisher.Name
content: this.publisher.name
}
]

View File

@ -154,8 +154,8 @@ export default {
// Loop throught the data we got from our API and prepare an array to display all authors
for (const b in bs) {
this.publishers[i] = {
ID: {content: bs[b].ID, hide: true}, // Don't show the ID
Name: {content: bs[b].Name, link: '/publishers/' + bs[b].ID} // Add a link to the element
id: {content: bs[b].id, hide: true}, // Don't show the id
name: {content: bs[b].name, link: '/publishers/' + bs[b].id} // Add a link to the element
}
// increment dat shit
@ -179,7 +179,7 @@ export default {
this.$on('delete-submit', function () {
// Prevent again deleting already deleted publishers
if (obj) {
HTTP.delete('publishers/' + obj.ID.content)
HTTP.delete('publishers/' + obj.id.content)
.then(response => {
if (response.status === 200 && response.data.Message === 'success') {
// Fire a notification
@ -200,7 +200,7 @@ export default {
})
},
editPublisher (publisher) {
router.push({ name: 'publisher-edit', params: { id: publisher.ID.content } })
router.push({ name: 'publisher-edit', params: { id: publisher.id.content } })
}
}
}

View File

@ -8,7 +8,7 @@
<form class="ui form" v-bind:class="{ loading: loading }" v-if="!success" @submit.prevent="insertOrUpdatePublisher">
<div class="field">
<label v-lang.general.name></label>
<input name="Name" :placeholder="langGeneral.name" type="text" v-model="publisher.Name" required v-focus>
<input name="name" :placeholder="langGeneral.name" type="text" v-model="publisher.name" required v-focus>
</div>
<button class="ui blue button" type="submit" v-lang.general.submit></button>
</form>
@ -28,7 +28,7 @@
publisherID: this.$route.params.id,
edit: false,
publisher: {
Name: ''
name: ''
}
}
},
@ -82,7 +82,7 @@
// Finally Send it
// If we want to newly insert it, make a different request
if (this.edit) {
HTTP.post('publishers/' + this.publisher.ID, {publisher: this.publisher})
HTTP.post('publishers/' + this.publisher.id, {publisher: this.publisher})
.then(response => {
this.loading = false

View File

@ -2,10 +2,10 @@ package models
// Publisher holds publisher informations
type Publisher struct {
ID int64 `xorm:"int(11) autoincr not null unique pk"`
Name string `xorm:"varchar(250) not null"`
Created int64 `xorm:"created"`
Updated int64 `xorm:"updated"`
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
Name string `xorm:"varchar(250) not null" json:"name"`
Created int64 `xorm:"created" json:"created"`
Updated int64 `xorm:"updated" json:"updated"`
}
// TableName returns the table name for publishers struct

View File

@ -17,7 +17,9 @@ func DeletePublisherByID(id int64) error {
}
// Set all publisher to 0 on all book with this publisher
_, err = x.Table("books").Where("publisher = ?", id).Update(map[string]interface{}{"publisher": 0})
_, err = x.Table("books").
Where("publisher_id = ?", id).
Update(map[string]interface{}{"publisher_id": 0})
return err
}