Atlas > Collection

This commit is contained in:
Tom Moor
2017-05-27 11:08:52 -07:00
parent 8883231f01
commit 639a0ec45c
8 changed files with 30 additions and 27 deletions

View File

@@ -152,7 +152,7 @@ router.post('auth.slack', async ctx => {
}
if (!teamExisted) {
await team.createFirstAtlas(user.id);
await team.createFirstCollection(user.id);
}
ctx.body = {

View File

@@ -5,7 +5,7 @@ import _ from 'lodash';
import auth from './middlewares/authentication';
import pagination from './middlewares/pagination';
import { presentCollection } from '../presenters';
import { Atlas } from '../models';
import { Collection } from '../models';
const router = new Router();
@@ -15,7 +15,7 @@ router.post('collections.create', auth(), async ctx => {
const user = ctx.state.user;
const atlas = await Atlas.create({
const atlas = await Collection.create({
name,
description,
type: type || 'atlas',
@@ -33,7 +33,7 @@ router.post('collections.info', auth(), async ctx => {
ctx.assertPresent(id, 'id is required');
const user = ctx.state.user;
const atlas = await Atlas.findOne({
const atlas = await Collection.findOne({
where: {
id,
teamId: user.teamId,
@@ -49,7 +49,7 @@ router.post('collections.info', auth(), async ctx => {
router.post('collections.list', auth(), pagination(), async ctx => {
const user = ctx.state.user;
const collections = await Atlas.findAll({
const collections = await Collection.findAll({
where: {
teamId: user.teamId,
},
@@ -58,7 +58,7 @@ router.post('collections.list', auth(), pagination(), async ctx => {
limit: ctx.state.pagination.limit,
});
// Atlases
// Collectiones
let data = [];
await Promise.all(
collections.map(async atlas => {
@@ -79,7 +79,7 @@ router.post('collections.updateNavigationTree', auth(), async ctx => {
ctx.assertPresent(id, 'id is required');
const user = ctx.state.user;
const atlas = await Atlas.findOne({
const atlas = await Collection.findOne({
where: {
id,
teamId: user.teamId,

View File

@@ -8,7 +8,7 @@ const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
import auth from './middlewares/authentication';
// import pagination from './middlewares/pagination';
import { presentDocument } from '../presenters';
import { Document, Atlas } from '../models';
import { Document, Collection } from '../models';
const router = new Router();
@@ -102,7 +102,7 @@ router.post('documents.create', auth(), async ctx => {
ctx.assertPresent(text, 'text is required');
const user = ctx.state.user;
const ownerCollection = await Atlas.findOne({
const ownerCollection = await Collection.findOne({
where: {
id: collection,
teamId: user.teamId,
@@ -176,7 +176,7 @@ router.post('documents.update', auth(), async ctx => {
// Update
// TODO: Add locking
const collection = await Atlas.findById(document.atlasId);
const collection = await Collection.findById(document.atlasId);
if (collection.type === 'atlas') {
await collection.updateNavigationTree();
}
@@ -195,7 +195,7 @@ router.post('documents.delete', auth(), async ctx => {
const user = ctx.state.user;
const document = await getDocumentForId(id);
const collection = await Atlas.findById(document.atlasId);
const collection = await Collection.findById(document.atlasId);
if (!document || document.teamId !== user.teamId)
throw httpErrors.BadRequest();