import DataType from 'sequelize';
import Model from '../sequelize';

const Unit = Model.define('unit', {
  id: {
    type: DataType.UUID,
    defaultValue: DataType.UUIDV1,
    primaryKey: true,
  },

  title: {
    type: DataType.STRING(255),
    allowNull: false,
  },

  body: {
    type: DataType.STRING,
  },

  schema: {
    type: DataType.STRING,
  },
});

export default Unit;

@@ -60,16 +60,48 @@
 uelize';
+%0Aimport * as util from './util';
 %0A%0Aconst 
@@ -389,16 +389,450 @@
 %7D,%0A%7D);%0A%0A
+Unit.prototype.canRead = async function canRead(user) %7B%0A  if (util.haveAccess(user)) return true;%0A  const courses = await this.getCourses();%0A  for (let i = 0; i %3C courses.length; i += 1) %7B%0A    // eslint-disable-next-line no-await-in-loop%0A    const role = await user.getRole(courses%5Bi%5D.id);%0A    if (!role) return false;%0A  %7D%0A  return true;%0A%7D;%0A%0AUnit.prototype.canWrite = function canWrite(user) %7B%0A  return util.haveRootAccess(user);%0A%7D;%0A%0A
 export d

add unit access rights