message: Refactor UnitController methods to non-static & private
diff: @@ -13,17 +13,6 @@ import {IUser} from '../../../shared/models/IUser';
  @UseBefore(passportJwtMiddleware)
  export class UnitController {
  - protected static async getUnitFor (unitId: string, currentUser: IUser, privilege: 'userCanViewCourse' | 'userCanEditCourse') {
  - const unit = await Unit.findById(unitId).orFail(new NotFoundError());
  -
  - const course = await Course.findById(unit._course);
  - if (!course.checkPrivileges(currentUser)[privilege]) {
  - throw new ForbiddenError();
  - }
  -
  - return unit;
  - }
  -
  /**
  * @api {get} /api/units/:id Request unit
  * @apiName GetUnit
  @@ -52,7 +41,7 @@ export class UnitController {
  */
  @Get('/:id')
  async getUnit(@Param('id') id: string, @CurrentUser() currentUser: IUser) {
  - const unit = await UnitController.getUnitFor(id, currentUser, 'userCanViewCourse');
  + const unit = await this.getUnitFor(id, currentUser, 'userCanViewCourse');
  return unit.toObject();
  }
  @@ -150,7 +139,7 @@ export class UnitController {
  @Authorized(['teacher', 'admin'])
  @Put('/:id')
  async updateUnit(@Param('id') id: string, @Body() data: any, @CurrentUser() currentUser: IUser) {
  - const oldUnit = await UnitController.getUnitFor(id, currentUser, 'userCanEditCourse');
  + const oldUnit = await this.getUnitFor(id, currentUser, 'userCanEditCourse');
  try {
  oldUnit.set(data);
  @@ -185,14 +174,28 @@ export class UnitController {
  @Authorized(['teacher', 'admin'])
  @Delete('/:id')
  async deleteUnit(@Param('id') id: string, @CurrentUser() currentUser: IUser) {
  - const unit = await UnitController.getUnitFor(id, currentUser, 'userCanEditCourse');
  + const unit = await this.getUnitFor(id, currentUser, 'userCanEditCourse');
  await Lecture.updateMany({}, {$pull: {units: id}});
  await unit.remove();
  return {};
  }
  - protected pushToLecture(lectureId: string, unit: any) {
  + private async getUnitFor (unitId: string, currentUser: IUser, privilege: 'userCanViewCourse' | 'userCanEditCourse') {
  + const unit = await Unit.findById(unitId);
  + if (!unit) {
  + throw new NotFoundError();
  + }
  +
  + const course = await Course.findById(unit._course);
  + if (!course.checkPrivileges(currentUser)[privilege]) {
  + throw new ForbiddenError();
  + }
  +
  + return unit;
  + }
  +
  + private pushToLecture(lectureId: string, unit: any) {
  return Lecture.findById(lectureId)
  .then((lecture) => {
  lecture.units.push(unit);
  @@ -209,7 +212,7 @@ export class UnitController {
  });
  }
  - protected checkPostParam(data: any) {
  + private checkPostParam(data: any) {
  if (!data.lectureId) {
  throw new BadRequestError(errorCodes.unit.postMissingLectureId.text);
  }
  