Replace entry with artifact and add entity
This commit is contained in:
@@ -7,7 +7,7 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/')
|
||||
.get(function(request, response, next) {
|
||||
db.Entry.findAll({
|
||||
db.Artifact.findAll({
|
||||
|
||||
}).then(entries => {
|
||||
response.display("library", {
|
||||
@@ -26,7 +26,7 @@ module.exports = function (options) {
|
||||
response.display("library-form", {
|
||||
user: request.user,
|
||||
pageTitle: "Add Library - Mantra",
|
||||
entry: {
|
||||
artifact: {
|
||||
version: "1.0"
|
||||
}
|
||||
})
|
||||
@@ -43,20 +43,21 @@ module.exports = function (options) {
|
||||
}
|
||||
}).then(dialect => {
|
||||
if (dialect) {
|
||||
return db.Entry.create({
|
||||
return db.Artifact.create({
|
||||
name: request.body.name,
|
||||
url: request.body.url,
|
||||
dialectId: dialect.id,
|
||||
licenseId: "copyright",
|
||||
entryVersions: [
|
||||
artifactVersions: [
|
||||
{
|
||||
tag: request.body.version
|
||||
}
|
||||
]
|
||||
],
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryVersions,
|
||||
association: db.Artifact.ArtifactVersions,
|
||||
|
||||
}
|
||||
]
|
||||
@@ -65,9 +66,9 @@ module.exports = function (options) {
|
||||
response.redirect("/library/add") // TODO: Show error message on missing dialect...
|
||||
}
|
||||
|
||||
}).then(entry => {
|
||||
if (entry) {
|
||||
response.redirect(`/library/${entry.id}`)
|
||||
}).then(artifact => {
|
||||
if (artifact) {
|
||||
response.redirect(`/library/${artifact.id}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
@@ -82,24 +83,24 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id')
|
||||
.get(function(request, response, next) {
|
||||
db.Entry.findByPk(request.params.id, {
|
||||
db.Artifact.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryApproval
|
||||
association: db.Artifact.ArtifactApproval
|
||||
},
|
||||
{
|
||||
association: db.Entry.EntryVersions
|
||||
association: db.Artifact.ArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(entry => {
|
||||
if (entry) {
|
||||
if (entry.entryVersions.length == 1) {
|
||||
response.redirect(`/v/${entry.entryVersions[0].id}`)
|
||||
}).then(artifact => {
|
||||
if (artifact) {
|
||||
if (artifact.artifactVersions.length == 1) {
|
||||
response.redirect(`/v/${artifact.artifactVersions[0].id}`)
|
||||
} else {
|
||||
response.display("entry", {
|
||||
response.display("artifact", {
|
||||
user: request.user,
|
||||
pageTitle: "Library - Mantra",
|
||||
entry: entry
|
||||
artifact: artifact
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user