* First pass (working) collection export to zip * Add export confirmation screen * 👕 * Refactor * Job for team export, move to tmp file, settings UI * Export all collections job * 👕 * Add specs * Clarify UI
23 lines
598 B
JavaScript
23 lines
598 B
JavaScript
// @flow
|
|
import policy from './policy';
|
|
import { Collection, User } from '../models';
|
|
import { AdminRequiredError } from '../errors';
|
|
|
|
const { allow } = policy;
|
|
|
|
allow(User, 'create', Collection);
|
|
|
|
allow(
|
|
User,
|
|
['read', 'publish', 'update', 'export'],
|
|
Collection,
|
|
(user, collection) => collection && user.teamId === collection.teamId
|
|
);
|
|
|
|
allow(User, 'delete', Collection, (user, collection) => {
|
|
if (!collection || user.teamId !== collection.teamId) return false;
|
|
if (user.id === collection.creatorId) return true;
|
|
if (user.isAdmin) return true;
|
|
throw new AdminRequiredError();
|
|
});
|