Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
lebalz committed Jul 5, 2024
1 parent 0108f6e commit 1e5722e
Show file tree
Hide file tree
Showing 17 changed files with 270 additions and 255 deletions.
File renamed without changes.
68 changes: 35 additions & 33 deletions prisma/seed-files/document-root-permissions.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import {Prisma} from '@prisma/client';
import { Prisma } from '@prisma/client';
import {
NONE_EXAM_DOCUMENT_ID,
RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID, RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID
} from "./document-roots";
import {TEST_USER_ID} from "./users";
import {Access} from "@prisma/client";
import {CLASS_GROUP_ID, PROJECT_GROUP_ID} from "./student-groups";
NONE_EXAM_DOCUMENT_ID,
RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID
} from './document-roots';
import { TEST_USER_ID } from './users';
import { Access } from '@prisma/client';
import { CLASS_GROUP_ID, PROJECT_GROUP_ID } from './student-groups';

const rootUserPermissions: Prisma.RootUserPermissionCreateManyInput[] = [
{
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
userId: TEST_USER_ID,
access: Access.RO},
{
documentRootId: NONE_EXAM_DOCUMENT_ID,
userId: TEST_USER_ID,
access: Access.None
},
{
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
userId: TEST_USER_ID,
access: Access.RO
},
{
documentRootId: NONE_EXAM_DOCUMENT_ID,
userId: TEST_USER_ID,
access: Access.None
}
];

const rootGroupPermissions: Prisma.RootGroupPermissionCreateManyInput[] = [
{
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
studentGroupId: CLASS_GROUP_ID,
access: Access.RO
},
{
documentRootId: NONE_EXAM_DOCUMENT_ID,
studentGroupId: CLASS_GROUP_ID,
access: Access.RW
},
{
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
studentGroupId: PROJECT_GROUP_ID,
access: Access.None
},
{
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
studentGroupId: CLASS_GROUP_ID,
access: Access.RO
},
{
documentRootId: NONE_EXAM_DOCUMENT_ID,
studentGroupId: CLASS_GROUP_ID,
access: Access.RW
},
{
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
studentGroupId: PROJECT_GROUP_ID,
access: Access.None
}
];

export {rootUserPermissions, rootGroupPermissions};
export { rootUserPermissions, rootGroupPermissions };
34 changes: 17 additions & 17 deletions prisma/seed-files/document-roots.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import {Access, Prisma} from "@prisma/client";
import { Access, Prisma } from '@prisma/client';

export const RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID = 'aa5b991b-ea21-450f-870d-55f2b9f1fac8';
export const RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID = 'ff8aa31c-65df-4651-af6a-06751ccec77f';
export const NONE_EXAM_DOCUMENT_ID = 'd50cdcba-adfc-41fa-a1d1-7a026f86b12b';
export const RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID = '2b7c4da1-b909-4990-a13a-51b0ab2c1517';

const documentRoots: Prisma.DocumentRootCreateInput[] = [
{
id: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
access: Access.RW,
},
{
id: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
access: Access.RW,
},
{
id: NONE_EXAM_DOCUMENT_ID,
access: Access.None,
},
{
id: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
access: Access.RO,
},
{
id: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
access: Access.RW
},
{
id: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
access: Access.RW
},
{
id: NONE_EXAM_DOCUMENT_ID,
access: Access.None
},
{
id: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
access: Access.RO
}
];

export { documentRoots };
206 changes: 103 additions & 103 deletions prisma/seed-files/documents.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {Prisma} from '@prisma/client';
import {FOO_BAR_ID, TEST_USER_ID} from './users';
import { Prisma } from '@prisma/client';
import { FOO_BAR_ID, TEST_USER_ID } from './users';
import {
NONE_EXAM_DOCUMENT_ID,
RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID, RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID
NONE_EXAM_DOCUMENT_ID,
RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID
} from './document-roots';

} from "./document-roots";

const {USER_EMAIL, USER_ID} = process.env;
const { USER_EMAIL, USER_ID } = process.env;

export const FOO_BAR_EXERCISE_LOREM_DOCUMENT_ID = 'c5c51c3d-aa9c-4b97-a40a-4456fa0cb054';
export const TEST_USER_EXERCISE_LOREM_DOCUMENT_ID = '50ccec2b-5f68-45a5-8607-0cc199696a70';
Expand All @@ -18,104 +18,104 @@ export const FOO_BAR_VISIBILITY_WRAPPER_DOCUMENT_ID = 'bb1d0183-1640-46ef-9fa2-d
export const TEST_USER_VISIBILITY_WRAPPER_DOCUMENT_ID = 'b0b0baf9-e9ef-47c0-be59-5108915528d3';

const documents: Prisma.DocumentCreateManyInput[] = [
{
id: FOO_BAR_EXERCISE_LOREM_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Lorem exercise from foo@bar.ch. They should be able to edit this document.'
}
},
{
id: TEST_USER_EXERCISE_LOREM_DOCUMENT_ID,
authorId: TEST_USER_ID, // test@user.ch
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Lorem exercise from test@user.ch. They should be able to edit this document because their user permission is set to RO.'
}
},
{
id: FOO_BAR_EXERCISE_IMPSUM_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Ipsum exercise from foo@bar.ch. This document should be read-only for them, because their class has RO permission.'
}
},
{
id: TEST_USER_EXERCISE_IPSUM_DOCUMENT_ID,
authorId: TEST_USER_ID, // test@user.ch
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Ipsum exercise from test@user.ch. This document should be read-only for them, because their class has RO permission.'
}
},
{
id: FOO_BAR_EXAM_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: NONE_EXAM_DOCUMENT_ID,
type: 'text',
data: {
text: 'This is the exam from foo@bar.ch. They should be able to edit it, because their class has RW permission.'
}
},
{
id: FOO_BAR_VISIBILITY_WRAPPER_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is a visibility wrapper for foo@bar.ch. This document should be read-only for them, indicating that they can see the wrapped resource (but cannot change this document).'
{
id: FOO_BAR_EXERCISE_LOREM_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Lorem exercise from foo@bar.ch. They should be able to edit this document.'
}
},
{
id: TEST_USER_EXERCISE_LOREM_DOCUMENT_ID,
authorId: TEST_USER_ID, // test@user.ch
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Lorem exercise from test@user.ch. They should be able to edit this document because their user permission is set to RO.'
}
},
{
id: FOO_BAR_EXERCISE_IMPSUM_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Ipsum exercise from foo@bar.ch. This document should be read-only for them, because their class has RO permission.'
}
},
{
id: TEST_USER_EXERCISE_IPSUM_DOCUMENT_ID,
authorId: TEST_USER_ID, // test@user.ch
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is the Ipsum exercise from test@user.ch. This document should be read-only for them, because their class has RO permission.'
}
},
{
id: FOO_BAR_EXAM_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: NONE_EXAM_DOCUMENT_ID,
type: 'text',
data: {
text: 'This is the exam from foo@bar.ch. They should be able to edit it, because their class has RW permission.'
}
},
{
id: FOO_BAR_VISIBILITY_WRAPPER_DOCUMENT_ID,
authorId: FOO_BAR_ID, // foo@bar.ch
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is a visibility wrapper for foo@bar.ch. This document should be read-only for them, indicating that they can see the wrapped resource (but cannot change this document).'
}
},
{
id: TEST_USER_VISIBILITY_WRAPPER_DOCUMENT_ID,
authorId: TEST_USER_ID, // test@user.ch
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is a visibility wrapper for test@user.ch. They should not see this document, because their project group has None permission, indicating that they cannot see the wrapped resource.'
}
}
},
{
id: TEST_USER_VISIBILITY_WRAPPER_DOCUMENT_ID,
authorId: TEST_USER_ID, // test@user.ch
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: 'This is a visibility wrapper for test@user.ch. They should not see this document, because their project group has None permission, indicating that they cannot see the wrapped resource.'
}
},
];

if (USER_EMAIL && USER_ID) {
documents.push({
authorId: USER_ID,
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: `This is the Lorem exercise from ${USER_EMAIL}`
}
});
documents.push({
authorId: USER_ID,
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: `This is the Ipsum exercise from ${USER_EMAIL}`
}
});
documents.push({
authorId: USER_ID,
documentRootId: NONE_EXAM_DOCUMENT_ID,
type: 'text',
data: {
text: `This is the exam document from ${USER_EMAIL}`
}
});
documents.push({
authorId: USER_ID,
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: `This is the visibility wrapper document from ${USER_EMAIL}`
}
});
documents.push({
authorId: USER_ID,
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: `This is the Lorem exercise from ${USER_EMAIL}`
}
});
documents.push({
authorId: USER_ID,
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: `This is the Ipsum exercise from ${USER_EMAIL}`
}
});
documents.push({
authorId: USER_ID,
documentRootId: NONE_EXAM_DOCUMENT_ID,
type: 'text',
data: {
text: `This is the exam document from ${USER_EMAIL}`
}
});
documents.push({
authorId: USER_ID,
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
type: 'text',
data: {
text: `This is the visibility wrapper document from ${USER_EMAIL}`
}
});
}

export {documents};
export { documents };
38 changes: 19 additions & 19 deletions prisma/seed-files/student-groups.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import {FOO_BAR_ID, TEST_USER_ID} from "./users";
import {Prisma} from "@prisma/client";
import { FOO_BAR_ID, TEST_USER_ID } from './users';
import { Prisma } from '@prisma/client';

export const ALL_USERS_GROUP_ID = '8f60f838-940a-4ab3-bb65-405308b0db6c';
export const CLASS_GROUP_ID = '106c9621-aed4-4592-a267-0670b5fe420c';
export const PROJECT_GROUP_ID = '58b696a3-7a6c-4745-ae4b-802158af2395';

const studentGroups: Prisma.StudentGroupUncheckedCreateWithoutChildrenInput[] = [
{
name: 'All Users',
description: 'All seeded users',
id: ALL_USERS_GROUP_ID,
},
{
name: 'Test Class',
description: 'A school class consisting of all seeded test users (test@user.ch and foo@bar.ch)',
id: CLASS_GROUP_ID,
},
{
name: 'Project group A',
description: 'A project group within Test Class, including foo@bar.ch, but not test@user.ch',
id: PROJECT_GROUP_ID,
parentId: CLASS_GROUP_ID,
}
{
name: 'All Users',
description: 'All seeded users',
id: ALL_USERS_GROUP_ID
},
{
name: 'Test Class',
description: 'A school class consisting of all seeded test users (test@user.ch and foo@bar.ch)',
id: CLASS_GROUP_ID
},
{
name: 'Project group A',
description: 'A project group within Test Class, including foo@bar.ch, but not test@user.ch',
id: PROJECT_GROUP_ID,
parentId: CLASS_GROUP_ID
}
];

export {studentGroups};
export { studentGroups };
2 changes: 1 addition & 1 deletion prisma/seed-files/users.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Prisma} from '@prisma/client';
import { Prisma } from '@prisma/client';

export const FOO_BAR_ID = '96651c13-3af6-4cc0-b242-ea38d438dc41';
export const TEST_USER_ID = '4b6d8b5d-3b6c-4c8b-8d3c-6f2c3f6e2b4b';
Expand Down
Loading

0 comments on commit 1e5722e

Please sign in to comment.