-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BC-4100 - Create Demo School Endpoint #4365
Closed
Closed
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
000aa92
implement module skeleton for school creation
uidp e519c08
implementation
hoeppner-dataport 21adc94
chore: changed test-setup-account password
hoeppner-dataport ad9d1e1
chore: adapted email-domain of demo-users
hoeppner-dataport 2e0bb36
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 209860b
chore: removed import of uncommited file
hoeppner-dataport df90d95
chore: changes to fix tests
hoeppner-dataport f8590fb
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport a44f416
chore: add tests to lesson repo
hoeppner-dataport ca9ff6e
chore: increase coverage for course.service
hoeppner-dataport d9655df
chore: added test for demo school service
hoeppner-dataport 2433464
chore: add test do demo school service
hoeppner-dataport 634f427
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 94ce4f4
chore: extended test for demo school service
hoeppner-dataport 7e29d6f
chore: add test to demo school service spec
hoeppner-dataport 1dd9aa2
chore: cleanup demo school service
hoeppner-dataport 08113f7
chore: fix test
hoeppner-dataport 0974e4a
fix: generate password and put it into creation protocol
hoeppner-dataport d20b83f
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 26898a3
fix: merge issues solved
hoeppner-dataport 77ca491
chore: use unpredictable random uuid generator
hoeppner-dataport 3957f7d
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 7008cb3
chore: adapt to name change of "School" to "SchoolEntity"
hoeppner-dataport 9ff9779
chore: fixes
hoeppner-dataport f6e095c
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 98236e1
chore: fix demoSchoolModule schoolModule usage
hoeppner-dataport 5deacb3
chore: fix lesson repo test
hoeppner-dataport b821b63
chore: remove outcommented code
hoeppner-dataport 61da413
add test for createLesson
hoeppner-dataport 73e3fe6
chore: add test for demo-school-uc
hoeppner-dataport 5420f78
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 290a85d
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 7394bc1
fix: response mapping
hoeppner-dataport dd1c93f
implement postfix generation for email-addresses
hoeppner-dataport c57610b
chore: fix - feature flag check
hoeppner-dataport 340d942
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport c0649c0
chore: fix tests
hoeppner-dataport 0734e57
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport ab6bc70
chore: fix tests
hoeppner-dataport 14fb065
chore: remove unnecessary logging
hoeppner-dataport 6a79e83
chore: fix uc test
hoeppner-dataport 51e8d3b
chore: add tests for demo-school-response
hoeppner-dataport c040616
chore: add controller test
hoeppner-dataport 7926d01
chore: remove optional mark
hoeppner-dataport ae51bf8
chore: add test for loggable
hoeppner-dataport 621fa61
chore: fix issues due to type changes
hoeppner-dataport c9bb38a
chore: fix types
hoeppner-dataport 9719f48
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 0ebc650
chore: add key property to tests
hoeppner-dataport 7b0c433
chore: add list of allowed entity types for creation protocol
hoeppner-dataport 58a477a
chore: switch entity type from sting to enum
hoeppner-dataport eb90a62
chore: use enum in response, too
hoeppner-dataport c935cc1
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport ef0c7da
chore: add info for using enum in response
hoeppner-dataport f185e38
Merge branch 'main' into BC-4100-create-demo-school
Metauriel fd0b550
chore: remove unneeded comments
hoeppner-dataport 69ebf49
Merge branch 'BC-4100-create-demo-school' of github.com:hpi-schul-clo…
hoeppner-dataport 2430549
Merge branch 'main' into BC-4100-create-demo-school
Metauriel 4a8964c
chore: trigger redeploy
hoeppner-dataport f322ab6
Merge branch 'BC-4100-create-demo-school' of github.com:hpi-schul-clo…
hoeppner-dataport 09acad6
chore: trigger redeploy
hoeppner-dataport dcce382
Merge branch 'main' into BC-4100-create-demo-school
hoeppner-dataport 655f8f3
Merge branch 'main' into BC-4100-create-demo-school
Metauriel a3dd94d
fix module imports
Metauriel 5f82aa8
Merge branch 'main' into BC-4100-create-demo-school
Metauriel f3a0296
rename feature flag
Metauriel 3f1a7f3
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 09b7397
chore: fix lint issue
hoeppner-dataport cbb2b19
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 42c0ea8
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport e372761
chore: fix imports
hoeppner-dataport 16c5417
fix: import in test on lesson service
hoeppner-dataport 17b96b7
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
hoeppner-dataport 230b4f4
Merge branch 'main' into BC-4100-create-demo-school
Metauriel 34005b4
linter fixes
Metauriel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
apps/server/src/modules/demo/controller/demo-school.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Controller, ForbiddenException, Post } from '@nestjs/common'; | ||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; | ||
import { ICurrentUser } from '@src/modules/authentication'; | ||
import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator'; | ||
import { DemoSchoolUc } from '../uc'; | ||
import { DemoSchoolResponse } from './dto'; | ||
|
||
@ApiTags('Demo School') | ||
@Authenticate('jwt') | ||
@Controller('demo-schools') | ||
export class DemoSchoolController { | ||
constructor(private readonly demoSchoolUc: DemoSchoolUc) {} | ||
|
||
@ApiOperation({ summary: 'Create a demo school.' }) | ||
@ApiResponse({ status: 200, type: DemoSchoolResponse }) | ||
@ApiResponse({ status: 403, type: ForbiddenException }) | ||
@Post() | ||
async createDemoSchool(@CurrentUser() currentUser: ICurrentUser): Promise<DemoSchoolResponse> { | ||
const school = await this.demoSchoolUc.createSchool(currentUser.userId); | ||
const response = new DemoSchoolResponse(school); | ||
|
||
return response; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/server/src/modules/demo/controller/dto/demo-school.response.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class DemoSchoolResponse { | ||
constructor({ id }: DemoSchoolResponse) { | ||
this.id = id; | ||
} | ||
|
||
@ApiProperty({ | ||
pattern: '[a-f0-9]{24}', | ||
}) | ||
id: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './demo-school.response'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { LoggerModule } from '@src/core/logger'; | ||
import { AuthorizationModule } from '..'; | ||
import { DemoSchoolController } from './controller/demo-school.controller'; | ||
import { DemoModule } from './demo.module'; | ||
import { DemoSchoolUc } from './uc'; | ||
|
||
@Module({ | ||
imports: [DemoModule, LoggerModule, AuthorizationModule], | ||
controllers: [DemoSchoolController], | ||
providers: [DemoSchoolUc], | ||
}) | ||
export class DemoApiModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { LoggerModule } from '@src/core/logger'; | ||
import { DemoSchoolRepo } from './repo/demo-school.repo'; | ||
import { DemoSchoolService } from './service/demo-school.service'; | ||
|
||
@Module({ | ||
imports: [LoggerModule], | ||
providers: [DemoSchoolService, DemoSchoolRepo], | ||
exports: [DemoSchoolService], | ||
}) | ||
export class DemoModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { EntityId } from '@shared/domain'; | ||
import { DomainObject } from '@shared/domain/domain-object'; // fix import if it is avaible | ||
|
||
export class DemoSchool extends DomainObject<DemoSchoolProps> { | ||
get createdAt(): Date { | ||
return this.props.createdAt; | ||
} | ||
|
||
get updatedAt(): Date { | ||
return this.props.updatedAt; | ||
} | ||
} | ||
|
||
export interface DemoSchoolProps { | ||
id: EntityId; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { BaseEntityWithTimestamps } from '@shared/domain'; | ||
|
||
export class DemoSchoolEntity extends BaseEntityWithTimestamps { | ||
// maybe we should even use the regular School entity | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './demo-school.do'; | ||
export * from './demo-school.entity'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './demo.module'; | ||
export * from './service/demo-school.service'; |
17 changes: 17 additions & 0 deletions
17
apps/server/src/modules/demo/loggable/demo-school-create.loggable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { EntityId } from '@shared/domain'; | ||
import { CrudOperation } from '@shared/types'; | ||
import { LogMessage, Loggable } from '@src/core/logger'; | ||
|
||
export class DemoSchoolCreateLoggable implements Loggable { | ||
constructor(private readonly userId: EntityId) {} | ||
|
||
getLogMessage(): LogMessage { | ||
return { | ||
message: 'Creating demo school', | ||
data: { | ||
operation: CrudOperation.CREATE, | ||
userId: this.userId, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './demo-school-create.loggable'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { EntityManager } from '@mikro-orm/mongodb'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { DemoSchool } from '../domain'; | ||
|
||
@Injectable() | ||
export class DemoSchoolRepo { | ||
constructor(private readonly em: EntityManager) {} | ||
|
||
async save(school: DemoSchool): Promise<void> { | ||
// TODO map to entity and actually persist | ||
return Promise.resolve(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/server/src/modules/demo/service/demo-school.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { ObjectId } from 'bson'; | ||
import { DemoSchool } from '../domain'; | ||
import { DemoSchoolRepo } from '../repo/demo-school.repo'; | ||
|
||
@Injectable() | ||
export class DemoSchoolService { | ||
constructor(private readonly repo: DemoSchoolRepo) {} | ||
|
||
async createSchool(): Promise<DemoSchool> { | ||
const school = new DemoSchool({ | ||
id: new ObjectId().toHexString(), | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}); | ||
|
||
await this.repo.save(school); | ||
|
||
return school; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { EntityId } from '@shared/domain'; | ||
import { Logger } from '@src/core/logger'; | ||
import { AuthorizationService } from '@src/modules/authorization'; | ||
import { DemoSchool } from '../domain'; | ||
import { DemoSchoolCreateLoggable } from '../loggable'; | ||
import { DemoSchoolService } from '../service/demo-school.service'; | ||
|
||
@Injectable() | ||
export class DemoSchoolUc { | ||
constructor( | ||
private readonly logger: Logger, | ||
private readonly demoSchoolService: DemoSchoolService, | ||
private readonly authorizationService: AuthorizationService | ||
) { | ||
this.logger.setContext(DemoSchoolUc.name); | ||
} | ||
|
||
async createSchool(userId: EntityId): Promise<DemoSchool> { | ||
this.logger.debug(new DemoSchoolCreateLoggable(userId)); | ||
|
||
// TODO check permission | ||
|
||
const school = await this.demoSchoolService.createSchool(); | ||
|
||
return school; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './demo-school.uc'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include a name with a DEMO_ prefix.
Because in case we want to find the demo schools later we have a easier time :)